mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Look up channel to get its precision bits when sending a position to the device.
This commit is contained in:
parent
cce30cd9f7
commit
96f3fd84cd
5 changed files with 135 additions and 31 deletions
|
|
@ -974,49 +974,65 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
var success = false
|
||||
let fromNodeNum = connectedPeripheral.num
|
||||
var positionPacket = Position()
|
||||
|
||||
let fetchChannelRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "ChannelEntity")
|
||||
fetchChannelRequest.predicate = NSPredicate(format: "index == %lld", channel)
|
||||
|
||||
if #available(iOS 17.0, macOS 14.0, *) {
|
||||
|
||||
if let lastLocation = LocationsHandler.shared.locationsArray.last {
|
||||
do {
|
||||
guard let fetchedChannel = try context!.fetch(fetchChannelRequest) as? [ChannelEntity] else {
|
||||
return false
|
||||
}
|
||||
if #available(iOS 17.0, macOS 14.0, *) {
|
||||
|
||||
positionPacket.latitudeI = Int32(lastLocation.coordinate.latitude * 1e7)
|
||||
positionPacket.longitudeI = Int32(lastLocation.coordinate.longitude * 1e7)
|
||||
let timestamp = lastLocation.timestamp
|
||||
if let lastLocation = LocationsHandler.shared.locationsArray.last {
|
||||
|
||||
positionPacket.latitudeI = Int32(lastLocation.coordinate.latitude * 1e7)
|
||||
positionPacket.longitudeI = Int32(lastLocation.coordinate.longitude * 1e7)
|
||||
let timestamp = lastLocation.timestamp
|
||||
positionPacket.time = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.timestamp = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(lastLocation.altitude)
|
||||
positionPacket.satsInView = UInt32(LocationsHandler.satsInView)
|
||||
positionPacket.precisionBits = UInt32(fetchedChannel[0].positionPrecision)
|
||||
let currentSpeed = lastLocation.speed
|
||||
if currentSpeed > 0 && (!currentSpeed.isNaN || !currentSpeed.isInfinite) {
|
||||
positionPacket.groundSpeed = UInt32(currentSpeed * 3.6)
|
||||
}
|
||||
let currentHeading = lastLocation.course
|
||||
if currentHeading > 0 && (!currentHeading.isNaN || !currentHeading.isInfinite) {
|
||||
positionPacket.groundTrack = UInt32(currentHeading)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if fromNodeNum <= 0 || LocationHelper.currentLocation.distance(from: LocationHelper.DefaultLocation) == 0.0 {
|
||||
return false
|
||||
}
|
||||
positionPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7)
|
||||
positionPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7)
|
||||
let timestamp = LocationHelper.shared.locationManager.location?.timestamp ?? Date()
|
||||
positionPacket.time = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.timestamp = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(lastLocation.altitude)
|
||||
positionPacket.satsInView = UInt32(LocationsHandler.satsInView)
|
||||
let currentSpeed = lastLocation.speed
|
||||
positionPacket.altitude = Int32(LocationHelper.shared.locationManager.location?.altitude ?? 0)
|
||||
positionPacket.satsInView = UInt32(LocationHelper.satsInView)
|
||||
positionPacket.precisionBits = UInt32(fetchedChannel[0].positionPrecision)
|
||||
let currentSpeed = LocationHelper.shared.locationManager.location?.speed ?? 0
|
||||
if currentSpeed > 0 && (!currentSpeed.isNaN || !currentSpeed.isInfinite) {
|
||||
positionPacket.groundSpeed = UInt32(currentSpeed * 3.6)
|
||||
}
|
||||
let currentHeading = lastLocation.course
|
||||
let currentHeading = LocationHelper.shared.locationManager.location?.course ?? 0
|
||||
if currentHeading > 0 && (!currentHeading.isNaN || !currentHeading.isInfinite) {
|
||||
positionPacket.groundTrack = UInt32(currentHeading)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if fromNodeNum <= 0 || LocationHelper.currentLocation.distance(from: LocationHelper.DefaultLocation) == 0.0 {
|
||||
return false
|
||||
}
|
||||
positionPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7)
|
||||
positionPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7)
|
||||
let timestamp = LocationHelper.shared.locationManager.location?.timestamp ?? Date()
|
||||
positionPacket.time = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.timestamp = UInt32(timestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(LocationHelper.shared.locationManager.location?.altitude ?? 0)
|
||||
positionPacket.satsInView = UInt32(LocationHelper.satsInView)
|
||||
let currentSpeed = LocationHelper.shared.locationManager.location?.speed ?? 0
|
||||
if currentSpeed > 0 && (!currentSpeed.isNaN || !currentSpeed.isInfinite) {
|
||||
positionPacket.groundSpeed = UInt32(currentSpeed * 3.6)
|
||||
}
|
||||
let currentHeading = LocationHelper.shared.locationManager.location?.course ?? 0
|
||||
if currentHeading > 0 && (!currentHeading.isNaN || !currentHeading.isInfinite) {
|
||||
positionPacket.groundTrack = UInt32(currentHeading)
|
||||
}
|
||||
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
|
||||
|
||||
|
||||
var meshPacket = MeshPacket()
|
||||
meshPacket.to = UInt32(destNum)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,28 @@
|
|||
"clear.app.data"="App Daten löschen";
|
||||
"clear.log"="Log löschen";
|
||||
"close"="Schließen";
|
||||
"config.power.settings"="Power";
|
||||
"config.power.title"="Power Config";
|
||||
"config.power.section.battery"="Battery";
|
||||
"config.power.section.sleep"="Sleep";
|
||||
"config.power.adc.override"="ADC Override";
|
||||
"config.power.adc.multiplier"="Multiplier";
|
||||
"config.power.ls.secs"="Light Sleep Interval";
|
||||
"config.power.min.wake.secs"="Minimum Wake Interval";
|
||||
"config.power.saving"="Power Saving";
|
||||
"config.power.saving.description"="Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. Don't use this setting if you want to use your device with the phone apps or are using a device without a user button.";
|
||||
"config.power.shutdown.on.power.loss"="Shutdown on Power Loss";
|
||||
"config.power.shutdown.after.secs"="After";
|
||||
"config.power.wait.bluetooth.secs"="Bluetooth Off After";
|
||||
"config.ringtone"="RTTTL Ringtone";
|
||||
"config.ringtone.title"="Ringtone Config";
|
||||
"config.ringtone.label"="Ringtone Transfer Language";
|
||||
"config.ringtone.description"="Ringtone Transfer Language(RTTTL) Ringtone String used by supported buzzers in external notifications.";
|
||||
"config.module.paxcounter.settings"="PAX Counter";
|
||||
"config.module.paxcounter.title"="PAX Counter Config";
|
||||
"config.module.paxcounter.enabled.description"="When enabled the PAX Counter module counts the number of people passing by using WiFi and Bluetooth. Both WiFI and Bluetooth must be enabled for PAX counter to work.";
|
||||
"config.module.paxcounter.updateinterval"="Update Interval";
|
||||
"config.module.paxcounter.updateinterval.description"="How often we can send a message to the mesh when people are detected.";
|
||||
"config.save.confirm"="Nach dem ändern der Einstellungen wird das Gerät neu starten.";
|
||||
"connected.radio"="Verbundenes Gerät";
|
||||
"communicating"="Verbinde mit Gerät...";
|
||||
|
|
|
|||
|
|
@ -51,6 +51,28 @@
|
|||
"clear.app.data"="אפס הגדרות אפליקציה";
|
||||
"clear.log"="נקה";
|
||||
"close"="סגור";
|
||||
"config.power.settings"="Power";
|
||||
"config.power.title"="Power Config";
|
||||
"config.power.section.battery"="Battery";
|
||||
"config.power.section.sleep"="Sleep";
|
||||
"config.power.adc.override"="ADC Override";
|
||||
"config.power.adc.multiplier"="Multiplier";
|
||||
"config.power.ls.secs"="Light Sleep Interval";
|
||||
"config.power.min.wake.secs"="Minimum Wake Interval";
|
||||
"config.power.saving"="Power Saving";
|
||||
"config.power.saving.description"="Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. Don't use this setting if you want to use your device with the phone apps or are using a device without a user button.";
|
||||
"config.power.shutdown.on.power.loss"="Shutdown on Power Loss";
|
||||
"config.power.shutdown.after.secs"="After";
|
||||
"config.power.wait.bluetooth.secs"="Bluetooth Off After";
|
||||
"config.ringtone"="RTTTL Ringtone";
|
||||
"config.ringtone.title"="Ringtone Config";
|
||||
"config.ringtone.label"="Ringtone Transfer Language";
|
||||
"config.ringtone.description"="Ringtone Transfer Language(RTTTL) Ringtone String used by supported buzzers in external notifications.";
|
||||
"config.module.paxcounter.settings"="PAX Counter";
|
||||
"config.module.paxcounter.title"="PAX Counter Config";
|
||||
"config.module.paxcounter.enabled.description"="When enabled the PAX Counter module counts the number of people passing by using WiFi and Bluetooth. Both WiFI and Bluetooth must be enabled for PAX counter to work.";
|
||||
"config.module.paxcounter.updateinterval"="Update Interval";
|
||||
"config.module.paxcounter.updateinterval.description"="How often we can send a message to the mesh when people are detected.";
|
||||
"config.save.confirm"="לאחר שמירת הגדרות המכשיר יתחיל מחדש.";
|
||||
"communicating"="מתקשר עם מכשיר. .";
|
||||
"connected.radio"="מכשיר מחובר";
|
||||
|
|
|
|||
|
|
@ -53,6 +53,28 @@
|
|||
"clear.app.data"="Wyczyść dane aplikacji";
|
||||
"clear.log"="Wyczyść";
|
||||
"close"="Zamknij";
|
||||
"config.power.settings"="Power";
|
||||
"config.power.title"="Power Config";
|
||||
"config.power.section.battery"="Battery";
|
||||
"config.power.section.sleep"="Sleep";
|
||||
"config.power.adc.override"="ADC Override";
|
||||
"config.power.adc.multiplier"="Multiplier";
|
||||
"config.power.ls.secs"="Light Sleep Interval";
|
||||
"config.power.min.wake.secs"="Minimum Wake Interval";
|
||||
"config.power.saving"="Power Saving";
|
||||
"config.power.saving.description"="Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. Don't use this setting if you want to use your device with the phone apps or are using a device without a user button.";
|
||||
"config.power.shutdown.on.power.loss"="Shutdown on Power Loss";
|
||||
"config.power.shutdown.after.secs"="After";
|
||||
"config.power.wait.bluetooth.secs"="Bluetooth Off After";
|
||||
"config.ringtone"="RTTTL Ringtone";
|
||||
"config.ringtone.title"="Ringtone Config";
|
||||
"config.ringtone.label"="Ringtone Transfer Language";
|
||||
"config.ringtone.description"="Ringtone Transfer Language(RTTTL) Ringtone String used by supported buzzers in external notifications.";
|
||||
"config.module.paxcounter.settings"="PAX Counter";
|
||||
"config.module.paxcounter.title"="PAX Counter Config";
|
||||
"config.module.paxcounter.enabled.description"="When enabled the PAX Counter module counts the number of people passing by using WiFi and Bluetooth. Both WiFI and Bluetooth must be enabled for PAX counter to work.";
|
||||
"config.module.paxcounter.updateinterval"="Update Interval";
|
||||
"config.module.paxcounter.updateinterval.description"="How often we can send a message to the mesh when people are detected.";
|
||||
"config.save.confirm"="Po zapisaniu wartości konfiguracji węzeł zostanie zrestartowany.";
|
||||
"communicating"="Komunikowanie z urządzeniem. .";
|
||||
"connected.radio"="Podłączone radio";
|
||||
|
|
|
|||
|
|
@ -51,6 +51,28 @@
|
|||
"clear.app.data"="清除 App 数据";
|
||||
"clear.log"="清除日志";
|
||||
"close"="关闭";
|
||||
"config.power.settings"="Power";
|
||||
"config.power.title"="Power Config";
|
||||
"config.power.section.battery"="Battery";
|
||||
"config.power.section.sleep"="Sleep";
|
||||
"config.power.adc.override"="ADC Override";
|
||||
"config.power.adc.multiplier"="Multiplier";
|
||||
"config.power.ls.secs"="Light Sleep Interval";
|
||||
"config.power.min.wake.secs"="Minimum Wake Interval";
|
||||
"config.power.saving"="Power Saving";
|
||||
"config.power.saving.description"="Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. Don't use this setting if you want to use your device with the phone apps or are using a device without a user button.";
|
||||
"config.power.shutdown.on.power.loss"="Shutdown on Power Loss";
|
||||
"config.power.shutdown.after.secs"="After";
|
||||
"config.power.wait.bluetooth.secs"="Bluetooth Off After";
|
||||
"config.ringtone"="RTTTL Ringtone";
|
||||
"config.ringtone.title"="Ringtone Config";
|
||||
"config.ringtone.label"="Ringtone Transfer Language";
|
||||
"config.ringtone.description"="Ringtone Transfer Language(RTTTL) Ringtone String used by supported buzzers in external notifications.";
|
||||
"config.module.paxcounter.settings"="PAX Counter";
|
||||
"config.module.paxcounter.title"="PAX Counter Config";
|
||||
"config.module.paxcounter.enabled.description"="When enabled the PAX Counter module counts the number of people passing by using WiFi and Bluetooth. Both WiFI and Bluetooth must be enabled for PAX counter to work.";
|
||||
"config.module.paxcounter.updateinterval"="Update Interval";
|
||||
"config.module.paxcounter.updateinterval.description"="How often we can send a message to the mesh when people are detected.";
|
||||
"config.save.confirm"="电台将会在配置保存后重启。";
|
||||
"connected.radio"="已连接的电台";
|
||||
"communicating"="与电台进行通讯中...";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue