mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add option to reset keys and ble bonds to factory reset
This commit is contained in:
parent
c16ef7f118
commit
25ca292c55
3 changed files with 29 additions and 116 deletions
|
|
@ -2809,34 +2809,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"All device and app data will be deleted." : {
|
||||
"localizations" : {
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Tutti i dati del dispositivo e delle app verranno eliminati."
|
||||
}
|
||||
},
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Сви подаци о уређају и апликацији ће бити избрисани."
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "所有设备以及 App 数据都会被删除。"
|
||||
}
|
||||
},
|
||||
"zh-Hant-TW" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "全部的設備及App資料將會被刪除。"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Allow incoming device control over the insecure legacy admin channel." : {
|
||||
"localizations" : {
|
||||
"de" : {
|
||||
|
|
@ -8139,6 +8111,12 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Delete all config, keys and BLE bonds? " : {
|
||||
|
||||
},
|
||||
"Delete all config? " : {
|
||||
|
||||
},
|
||||
"Delete all device metrics?" : {
|
||||
"localizations" : {
|
||||
|
|
@ -10719,64 +10697,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Enabling Ethernet will disable the bluetooth connection to the app." : {
|
||||
"localizations" : {
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Abilitando l'Ethernet si disabilita la connessione bluetooth all'applicazione."
|
||||
}
|
||||
},
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Омогућавање етернета ће онемогућити блутут везу са апликацијом."
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "启用以太网将禁用应用程序的蓝牙连接。"
|
||||
}
|
||||
},
|
||||
"zh-Hant-TW" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "啟用乙太網路後,將會停用與應用程式的藍牙連線。"
|
||||
}
|
||||
}
|
||||
}
|
||||
"Enabling Ethernet will disable the bluetooth connection to the app. TCP node connections are not available on Apple devices." : {
|
||||
|
||||
},
|
||||
"Enabling WiFi will disable the bluetooth connection to the app." : {
|
||||
"extractionState" : "stale",
|
||||
"localizations" : {
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "L'attivazione del WiFi disabilita la connessione bluetooth all'applicazione."
|
||||
}
|
||||
},
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Омогућавање ВајФаја ће онемогућити блутут везу са апликацијом."
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "启用 WiFi 将禁用应用程序的蓝牙连接。"
|
||||
}
|
||||
},
|
||||
"zh-Hant-TW" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "啟用 Wi-Fi 後,將會停用與應用程式的藍牙連線。"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Enabling WiFi will disable the bluetooth connection to the app. TCP node connections are not available on apple devices." : {
|
||||
"Enabling WiFi will disable the bluetooth connection to the app. TCP node connections are not available on Apple devices." : {
|
||||
|
||||
},
|
||||
"Encoder Press Event" : {
|
||||
|
|
@ -11677,33 +11601,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Factory reset your device and app? " : {
|
||||
"localizations" : {
|
||||
"de" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Gerät und App auf Werkseinstellungen zurücksetzen?"
|
||||
}
|
||||
},
|
||||
"it" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Resettare il dispositivo e l'applicazione? "
|
||||
}
|
||||
},
|
||||
"sr" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Вратите уређај и апликацију на фабричка подешавања?"
|
||||
}
|
||||
},
|
||||
"zh-Hant-TW" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "要將您的裝置與應用程式恢復原廠設定嗎?"
|
||||
}
|
||||
}
|
||||
}
|
||||
"Factory reset will delete device and app data." : {
|
||||
|
||||
},
|
||||
"Failed to encode message content" : {
|
||||
"localizations" : {
|
||||
|
|
|
|||
|
|
@ -1532,9 +1532,13 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
return false
|
||||
}
|
||||
|
||||
public func sendFactoryReset(fromUser: UserEntity, toUser: UserEntity) -> Bool {
|
||||
public func sendFactoryReset(fromUser: UserEntity, toUser: UserEntity, resetDevice: Bool = false) -> Bool {
|
||||
var adminPacket = AdminMessage()
|
||||
adminPacket.factoryResetConfig = 5
|
||||
if resetDevice {
|
||||
adminPacket.factoryResetDevice = 5
|
||||
} else {
|
||||
adminPacket.factoryResetConfig = 5
|
||||
}
|
||||
if fromUser != toUser {
|
||||
adminPacket.sessionPasskey = toUser.userNode?.sessionPasskey ?? Data()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,11 +204,11 @@ struct DeviceConfig: View {
|
|||
.controlSize(.regular)
|
||||
.padding(.trailing)
|
||||
.confirmationDialog(
|
||||
"All device and app data will be deleted.",
|
||||
"Factory reset will delete device and app data.",
|
||||
isPresented: $isPresentingFactoryResetConfirm,
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Factory reset your device and app? ", role: .destructive) {
|
||||
Button("Delete all config? ", role: .destructive) {
|
||||
if bleManager.sendFactoryReset(fromUser: node!.user!, toUser: node!.user!) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
bleManager.disconnectPeripheral()
|
||||
|
|
@ -218,6 +218,16 @@ struct DeviceConfig: View {
|
|||
Logger.mesh.error("Factory Reset Failed")
|
||||
}
|
||||
}
|
||||
Button("Delete all config, keys and BLE bonds? ", role: .destructive) {
|
||||
if bleManager.sendFactoryReset(fromUser: node!.user!, toUser: node!.user!, resetDevice: true) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
bleManager.disconnectPeripheral()
|
||||
clearCoreDataDatabase(context: context, includeRoutes: false)
|
||||
}
|
||||
} else {
|
||||
Logger.mesh.error("Factory Reset Failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue