Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.8 #954

Merged
merged 11 commits into from
Oct 6, 2024
Merged

2.5.8 #954

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -11481,9 +11481,6 @@
},
"Map Tile Data" : {

},
"Map Type" : {

},
"map.centering" : {
"extractionState" : "manual",
Expand Down Expand Up @@ -18948,9 +18945,6 @@
},
"Select a Trace Route" : {

},
"Select something to view" : {

},
"select.contact" : {
"extractionState" : "manual",
Expand Down Expand Up @@ -19139,6 +19133,9 @@
},
"Send a message to a certain meshtastic channel" : {

},
"Send a position on the primary channel when the user button is triple clicked." : {

},
"Send a shutdown to the node you are connected to" : {

Expand Down Expand Up @@ -21895,6 +21892,9 @@
},
"Treat double tap on supported accelerometers as a user button press." : {

},
"Triple Click Ad Hoc Ping" : {

},
"Try Again" : {

Expand Down
8 changes: 3 additions & 5 deletions Meshtastic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1540;
LastUpgradeCheck = 1540;
LastUpgradeCheck = 1600;
TargetAttributes = {
25F5D5C62C4375A8008036E3 = {
CreatedOnToolsVersion = 15.4;
Expand Down Expand Up @@ -1680,7 +1680,6 @@
DDC2E17F26CE248F0042C5E4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
Expand All @@ -1695,7 +1694,7 @@
INFOPLIST_FILE = Meshtastic/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Meshtastic;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -1715,7 +1714,6 @@
DDC2E18026CE248F0042C5E4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
Expand All @@ -1730,7 +1728,7 @@
INFOPLIST_FILE = Meshtastic/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Meshtastic;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
LastUpgradeVersion = "1600"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Meshtastic/AppIntents/AppIntentErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppIntentErrors {

var localizedStringResource: LocalizedStringResource {
switch self {
case let .message(message):
case let .message(message):
Logger.services.error("App Intent: \(message)")
return "Error: \(message)"
case .notConnected:
Expand Down
6 changes: 3 additions & 3 deletions Meshtastic/AppIntents/FactoryResetNodeIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import AppIntents
struct FactoryResetNodeIntent: AppIntent {
static var title: LocalizedStringResource = "Factory Reset"
static var description: IntentDescription = "Perform a factory reset on the node you are connected to"

func perform() async throws -> some IntentResult {
// Request user confirmation before performing the factory reset
try await requestConfirmation(result: .result(dialog: "Are you sure you want to factory reset the node?"),confirmationActionName: ConfirmationActionName
try await requestConfirmation(result: .result(dialog: "Are you sure you want to factory reset the node?"), confirmationActionName: ConfirmationActionName
.custom(acceptLabel: "Factory Reset", acceptAlternatives: [], denyLabel: "Cancel", denyAlternatives: [], destructive: true))

// Ensure the node is connected
Expand All @@ -27,7 +27,7 @@ struct FactoryResetNodeIntent: AppIntent {
let connectedNode = getNodeInfo(id: connectedPeripheralNum, context: PersistenceController.shared.container.viewContext),
let fromUser = connectedNode.user,
let toUser = connectedNode.user {

// Attempt to send a factory reset command, throw an error if it fails
if !BLEManager.shared.sendFactoryReset(fromUser: fromUser, toUser: toUser) {
throw AppIntentErrors.AppIntentError.message("Failed to perform factory reset")
Expand Down
21 changes: 10 additions & 11 deletions Meshtastic/AppIntents/MessageChannelIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,36 @@ struct MessageChannelIntent: AppIntent {

@Parameter(title: "Message")
var messageContent: String
@Parameter(title: "Channel",controlStyle: .stepper, inclusiveRange: (lowerBound: 0, upperBound: 7))

@Parameter(title: "Channel", controlStyle: .stepper, inclusiveRange: (lowerBound: 0, upperBound: 7))
var channelNumber: Int



static var parameterSummary: some ParameterSummary {
Summary("Send \(\.$messageContent) to \(\.$channelNumber)")
}
func perform() async throws -> some IntentResult {
if (!BLEManager.shared.isConnected){
if !BLEManager.shared.isConnected {
throw AppIntentErrors.AppIntentError.notConnected
}

// Check if channel number is between 1 and 7
guard (0...7).contains(channelNumber) else {
throw $channelNumber.needsValueError("Channel number must be between 0 and 7.")
}

// Convert messageContent to data and check its length
guard let messageData = messageContent.data(using: .utf8) else {
throw AppIntentErrors.AppIntentError.message("Failed to encode message content")
}

if messageData.count > 200 {
throw $messageContent.needsValueError("Message content exceeds 200 bytes.")
}

if(!BLEManager.shared.sendMessage(message: messageContent, toUserNum: 0, channel: Int32(channelNumber), isEmoji: false, replyID: 0)){
if !BLEManager.shared.sendMessage(message: messageContent, toUserNum: 0, channel: Int32(channelNumber), isEmoji: false, replyID: 0) {
throw AppIntentErrors.AppIntentError.message("Failed to send message")
}
return .result()

return .result()
}
}
56 changes: 25 additions & 31 deletions Meshtastic/AppIntents/NodePositionIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,38 @@ struct NodePositionIntent: AppIntent {

@Parameter(title: "Node Number")
var nodeNum: Int

static var title: LocalizedStringResource = "Get Node Position"
static var description: IntentDescription = "Fetch the latest position of a cetain node"



func perform() async throws -> some IntentResult & ReturnsValue<CLPlacemark> {
if (!BLEManager.shared.isConnected) {
if !BLEManager.shared.isConnected {
throw AppIntentErrors.AppIntentError.notConnected
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "NodeInfoEntity")
fetchNodeInfoRequest.predicate = NSPredicate(format: "num == %lld", Int64(nodeNum))
do {
guard let fetchedNode = try PersistenceController.shared.container.viewContext.fetch(fetchNodeInfoRequest) as? [NodeInfoEntity], fetchedNode.count == 1 else {
throw $nodeNum.needsValueError("Could not find node")
}

let nodeInfo = fetchedNode[0]
nodeInfo.latestEnvironmentMetrics?.batteryLevel
if let latitude = nodeInfo.latestPosition?.coordinate.latitude,
let longitude = nodeInfo.latestPosition?.coordinate.longitude {
let nodeLocation = CLLocation(latitude: latitude, longitude: longitude)

// Reverse geocode the CLLocation to get a CLPlacemark
let geocoder = CLGeocoder()
let placemarks = try await geocoder.reverseGeocodeLocation(nodeLocation)

if let placemark = placemarks.first {
return .result(value: placemark)
} else {
throw AppIntentErrors.AppIntentError.message("Error Reverse Geocoding Location")
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "NodeInfoEntity")
fetchNodeInfoRequest.predicate = NSPredicate(format: "num == %lld", Int64(nodeNum))
do {
guard let fetchedNode = try PersistenceController.shared.container.viewContext.fetch(fetchNodeInfoRequest) as? [NodeInfoEntity], fetchedNode.count == 1 else {
throw $nodeNum.needsValueError("Could not find node")
}
let nodeInfo = fetchedNode[0]
if let latitude = nodeInfo.latestPosition?.coordinate.latitude,
let longitude = nodeInfo.latestPosition?.coordinate.longitude {
let nodeLocation = CLLocation(latitude: latitude, longitude: longitude)
// Reverse geocode the CLLocation to get a CLPlacemark
let geocoder = CLGeocoder()
let placemarks = try await geocoder.reverseGeocodeLocation(nodeLocation)

if let placemark = placemarks.first {
return .result(value: placemark)
} else {
throw AppIntentErrors.AppIntentError.message("Node does not have positions")
throw AppIntentErrors.AppIntentError.message("Error Reverse Geocoding Location")
}
} catch {
throw AppIntentErrors.AppIntentError.message("Fetch Failure")
} else {
throw AppIntentErrors.AppIntentError.message("Node does not have positions")
}
} catch {
throw AppIntentErrors.AppIntentError.message("Fetch Failure")
}

}
}

16 changes: 6 additions & 10 deletions Meshtastic/AppIntents/SendWaypointIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ struct SendWaypointIntent: AppIntent {

@Parameter(title: "Name", default: "Dropped Pin")
var nameParameter: String?

@Parameter(title: "Description", default: "")
var descriptionParameter: String?

@Parameter(title: "Emoji", default: "📍")
var emojiParameter: String?

@Parameter(title: "Location")
var locationParameter: CLPlacemark

func perform() async throws -> some IntentResult {
if (!BLEManager.shared.isConnected){
if !BLEManager.shared.isConnected {
throw AppIntentErrors.AppIntentError.notConnected
}
// Provide default values if parameters are nil
let name = nameParameter ?? "Dropped Pin"
let description = descriptionParameter ?? ""
let emoji = emojiParameter ?? "📍"

// Validate name length
if name.utf8.count > 30 {
throw $nameParameter.needsValueError("Name must be less than 30 bytes")
}

// Validate description length
if description.utf8.count > 100 {
throw $descriptionParameter.needsValueError("Description must be less than 100 bytes")
Expand All @@ -60,7 +60,6 @@ struct SendWaypointIntent: AppIntent {
newWaypoint.longitudeI = Int32(longitude * 10_000_000)
}


newWaypoint.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
// Unicode scalar value for the icon emoji string
let unicodeScalers = emoji.unicodeScalars
Expand All @@ -69,12 +68,9 @@ struct SendWaypointIntent: AppIntent {
newWaypoint.icon = unicode
newWaypoint.name = name
newWaypoint.description_p = description
if(!BLEManager.shared.sendWaypoint(waypoint: newWaypoint)){
if !BLEManager.shared.sendWaypoint(waypoint: newWaypoint) {
throw AppIntentErrors.AppIntentError.message("Failed to Send Waypoint")
}



return .result()
}

Expand Down
1 change: 0 additions & 1 deletion Meshtastic/Enums/TelemetryEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ enum Iaq: Int, CaseIterable, Identifiable {
}
}


// Default of 0 is Client
enum MetricsTypes: Int, CaseIterable, Identifiable {

Expand Down
Loading