Skip to content

Commit

Permalink
add additional logging to diagnose position exchange errors
Browse files Browse the repository at this point in the history
  • Loading branch information
72A12F4E committed Jul 14, 2024
1 parent 29afebc commit c7ed3ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Meshtastic/Helpers/BLEManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,9 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}

public func sendPosition(channel: Int32, destNum: Int64, wantResponse: Bool) -> Bool {
var success = false
let fromNodeNum = connectedPeripheral.num
guard let positionPacket = getPositionFromPhoneGPS(destNum: destNum) else {
Logger.services.error("Unable to get position data from device GPS to send to node")
return false
}

Expand All @@ -1234,22 +1234,27 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
dataMessage.wantResponse = wantResponse
meshPacket.decoded = dataMessage
} else {
Logger.services.error("Failed to serialize position packet data")
return false
}

var toRadio: ToRadio!
toRadio = ToRadio()
toRadio.packet = meshPacket
guard let binaryData: Data = try? toRadio.serializedData() else {
Logger.services.error("Failed to serialize position packet")
return false
}
if connectedPeripheral?.peripheral.state ?? CBPeripheralState.disconnected == CBPeripheralState.connected {
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
success = true

let logString = String.localizedStringWithFormat("mesh.log.sharelocation %@".localized, String(fromNodeNum))
Logger.services.debug("📍 \(logString)")
return true
} else {
Logger.services.error("Device no longer connected. Unable to send position information.")
return false
}
return success
}
@objc func positionTimerFired(timer: Timer) {
// Check for connected node
Expand Down
2 changes: 1 addition & 1 deletion protobufs

0 comments on commit c7ed3ef

Please sign in to comment.