Start with position

This commit is contained in:
Garth Vander Houwen 2022-06-21 10:15:47 -07:00
parent 0d3b6276da
commit 3e3bec380d
2 changed files with 39 additions and 3 deletions

View file

@ -955,4 +955,39 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
return false
}
public func savePositionConfig(config: Config.PositionConfig, destNum: Int64, wantResponse: Bool) -> Bool {
var adminPacket = AdminMessage()
adminPacket.setConfig.position = config
var meshPacket: MeshPacket = MeshPacket()
meshPacket.to = UInt32(connectedPeripheral.num)
meshPacket.from = 0 //UInt32(connectedPeripheral.num)
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
meshPacket.priority = MeshPacket.Priority.reliable
meshPacket.wantAck = wantResponse
meshPacket.hopLimit = 0
var dataMessage = DataMessage()
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
var toRadio: ToRadio!
toRadio = ToRadio()
toRadio.packet = meshPacket
let binaryData: Data = try! toRadio.serializedData()
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
return true
}
return false
}
}

View file

@ -112,6 +112,9 @@ struct PositionConfig: View {
@EnvironmentObject var bleManager: BLEManager
var node: NodeInfoEntity
@State private var isPresentingSaveConfirm: Bool = false
@State var initialLoad: Bool = true
@State var hasChanges = false
@State var smartPositionEnabled = true
@State var deviceGpsEnabled = true
@ -127,8 +130,6 @@ struct PositionConfig: View {
@State var includePosSpeed = false
@State var includePosHeading = false
var body: some View {
VStack {
@ -207,7 +208,7 @@ struct PositionConfig: View {
}
}
Section(header: Text("Position Flags")) {
Section(header: Text("Position Flags - Non Functional")) {
Text("Optional fields to include when assembling position messages. the more fields are included, the larger the message will be - leading to longer airtime and a higher risk of packet loss")
.font(.caption)