V 1.25.1 Save Position packet SNR and lastHeard

This commit is contained in:
Garth Vander Houwen 2021-10-07 12:50:40 -07:00
parent 2214e01666
commit c023856d47
3 changed files with 38 additions and 19 deletions

View file

@ -659,7 +659,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.24;
MARKETING_VERSION = 1.25.1;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = NO;
@ -686,7 +686,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.24;
MARKETING_VERSION = 1.25.1;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = NO;

View file

@ -315,7 +315,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
if decodedInfo.myInfo.myNodeNum != 0
{
print("Save myInfo for \(decodedInfo.myInfo.myNodeNum)")
do {
// Create a MyInfoModel
@ -332,9 +332,13 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
// Save it to the connected node
connectedNode = meshData.nodes.first(where: {$0.num == myInfoModel.id})
// Since the data is from the device itself we save all myInfo objects since they are always the most update
if connectedNode != nil {
if connectedNode != nil && connectedNode.myInfo == nil {
connectedNode.myInfo = myInfoModel
connectedNode.update(from: connectedNode.data)
let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.myInfo.myNodeNum })
meshData.nodes.remove(at: nodeIndex!)
meshData.nodes.append(connectedNode)
meshData.save()
print("Saved a myInfo for \(decodedInfo.myInfo.myNodeNum)") // connectedNode.update(from: connectedNode.data)
}
meshData.save()
@ -440,19 +444,34 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
else if decodedInfo.packet.decoded.portnum == PortNum.nodeinfoApp {
var updatedNode = meshData.nodes.first(where: {$0.id == decodedInfo.packet.from })
updatedNode!.snr = decodedInfo.packet.rxSnr
updatedNode!.lastHeard = decodedInfo.packet.rxTime
// updatedNode!.user.longName = "Node Info updated longname"
updatedNode!.update(from: updatedNode!.data)
//let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.packet.from })
//meshData.nodes.remove(at: nodeIndex!)
//meshData.nodes.append(updatedNode!)
meshData.save()
print("Updated NodeInfo SNR and Time from Packet For: \(updatedNode!.user.longName)")
if updatedNode != nil {
updatedNode!.snr = decodedInfo.packet.rxSnr
updatedNode!.lastHeard = decodedInfo.packet.rxTime
//updatedNode!.update(from: updatedNode!.data)
let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.packet.from })
meshData.nodes.remove(at: nodeIndex!)
meshData.nodes.append(updatedNode!)
meshData.save()
//meshData.load()
print("Updated NodeInfo SNR and Time from Packet For: \(updatedNode!.user.longName)")
}
}
else if decodedInfo.packet.decoded.portnum == PortNum.positionApp {
var updatedNode = meshData.nodes.first(where: {$0.id == decodedInfo.packet.from })
if updatedNode != nil {
updatedNode!.snr = decodedInfo.packet.rxSnr
updatedNode!.lastHeard = decodedInfo.packet.rxTime
//updatedNode!.update(from: updatedNode!.data)
let nodeIndex = meshData.nodes.firstIndex(where: { $0.id == decodedInfo.packet.from })
meshData.nodes.remove(at: nodeIndex!)
meshData.nodes.append(updatedNode!)
meshData.save()
print("Updated Position SNR and Time from Packet For: \(updatedNode!.user.longName)")
}
print("Postion Payload")
print(try decodedInfo.packet.jsonString())
}

View file

@ -20,7 +20,6 @@ class LocalNotificationManager {
func schedule()
{
UNUserNotificationCenter.current().getNotificationSettings { settings in
switch settings.authorizationStatus {
case .notDetermined:
self.requestAuthorization()
@ -37,10 +36,11 @@ class LocalNotificationManager {
{
for notification in notifications
{
let content = UNMutableNotificationContent()
content.title = notification.title
content.body = notification.content
content.sound = .default
let content = UNMutableNotificationContent()
content.title = notification.title
content.body = notification.content
content.sound = .default
content.interruptionLevel = .timeSensitive
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: notification.id, content: content, trigger: trigger)