Allow sending positions over all channels

This commit is contained in:
Garth Vander Houwen 2024-01-13 09:35:38 -08:00
parent 84f301c7e3
commit 6595fdfe3c
4 changed files with 9 additions and 12 deletions

View file

@ -958,7 +958,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
return success
}
public func sendPosition(destNum: Int64, wantResponse: Bool) -> Bool {
public func sendPosition(channel: Int32, destNum: Int64, wantResponse: Bool) -> Bool {
var success = false
let fromNodeNum = connectedPeripheral.num
var positionPacket = Position()
@ -1011,11 +1011,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
}
var meshPacket = MeshPacket()
if destNum < 9 {
meshPacket.to = emptyNodeNum
} else {
meshPacket.to = UInt32(destNum)
}
meshPacket.to = UInt32(destNum)
meshPacket.channel = UInt32(channel)
meshPacket.from = UInt32(fromNodeNum)
var dataMessage = DataMessage()
dataMessage.payload = try! positionPacket.serializedData()
@ -1040,7 +1037,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
if connectedPeripheral != nil {
// Send a position out to the mesh if "share location with the mesh" is enabled in settings
if UserDefaults.provideLocation {
let _ = sendPosition(destNum: connectedPeripheral.num, wantResponse: false)
let _ = sendPosition(channel: 0, destNum: connectedPeripheral.num, wantResponse: false)
}
}
}

View file

@ -373,7 +373,7 @@ struct ChannelMessageList: View {
focusedField = nil
replyMessageId = 0
if sendPositionWithMessage {
if bleManager.sendPosition(destNum: Int64(channel.index), wantResponse: false) {
if bleManager.sendPosition(channel: Int32(channel.index), destNum: Int64(bleManager.emptyNodeNum), wantResponse: false) {
print("Location Sent")
}
}
@ -390,7 +390,7 @@ struct ChannelMessageList: View {
focusedField = nil
replyMessageId = 0
if sendPositionWithMessage {
if bleManager.sendPosition(destNum: Int64(channel.index), wantResponse: false) {
if bleManager.sendPosition(channel: Int32(channel.index), destNum: Int64(bleManager.emptyNodeNum), wantResponse: false) {
print("Location Sent")
}
}

View file

@ -325,7 +325,7 @@ struct UserMessageList: View {
focusedField = nil
replyMessageId = 0
if sendPositionWithMessage {
if bleManager.sendPosition(destNum: user.num, wantResponse: true) {
if bleManager.sendPosition(channel: 0, destNum: user.num, wantResponse: true) {
print("Location Sent")
}
}
@ -342,7 +342,7 @@ struct UserMessageList: View {
focusedField = nil
replyMessageId = 0
if sendPositionWithMessage {
if bleManager.sendPosition(destNum: user.num, wantResponse: true) {
if bleManager.sendPosition(channel: 0, destNum: user.num, wantResponse: true) {
print("Location Sent")
}
}

View file

@ -276,7 +276,7 @@ struct PositionConfig: View {
Button(buttonText) {
if fixedPosition {
_ = bleManager.sendPosition(destNum: node!.num, wantResponse: true)
_ = bleManager.sendPosition(channel: 0, destNum: node?.num ?? 0, wantResponse: true)
}
let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context)