feat(firmware): Implement USB DFU updates for supported devices (#3901)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-12-06 06:36:54 -06:00 committed by GitHub
parent f322eb31a0
commit 499ed58311
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 860 additions and 483 deletions

View file

@ -27,6 +27,16 @@ interface RadioPrefs {
var devAddr: String?
}
fun RadioPrefs.isBle() = devAddr?.startsWith("x") == true
fun RadioPrefs.isSerial() = devAddr?.startsWith("s") == true
fun RadioPrefs.isMock() = devAddr?.startsWith("m") == true
fun RadioPrefs.isTcp() = devAddr?.startsWith("t") == true
fun RadioPrefs.isNoop() = devAddr?.startsWith("n") == true
@Singleton
class RadioPrefsImpl @Inject constructor(@RadioSharedPreferences prefs: SharedPreferences) : RadioPrefs {
override var devAddr: String? by NullableStringPrefDelegate(prefs, "devAddr2", null)

View file

@ -135,6 +135,9 @@ interface IMeshService {
/// Send FactoryReset admin packet to nodeNum
void requestFactoryReset(in int requestId, in int destNum);
/// Send reboot to DFU admin packet
void rebootToDfu();
/// Send NodedbReset admin packet to nodeNum
void requestNodedbReset(in int requestId, in int destNum, in boolean preserveFavorites);
@ -173,4 +176,4 @@ interface IMeshService {
/// Request device connection status from the radio
void getDeviceConnectionStatus(in int requestId, in int destNum);
}
}

View file

@ -49,6 +49,14 @@ class ServiceRepository @Inject constructor() {
_connectionState.value = connectionState
}
private val _connectionTransport: MutableStateFlow<String> = MutableStateFlow("Unknown")
val connectionTransport: StateFlow<String>
get() = _connectionTransport
fun setConnectionTransport(connectionTransport: String) {
_connectionTransport.value = connectionTransport
}
private val _clientNotification = MutableStateFlow<MeshProtos.ClientNotification?>(null)
val clientNotification: StateFlow<MeshProtos.ClientNotification?>
get() = _clientNotification

View file

@ -976,10 +976,10 @@
<string name="firmware_update_title">Firmware Update</string>
<string name="firmware_update_checking">Checking for updates...</string>
<string name="firmware_update_device">Device: %1$s</string>
<string name="firmware_update_currently_installed">Currently Installed: %1$s</string>
<string name="firmware_update_latest">Latest Release: %1$s</string>
<string name="firmware_update_stable">Stable</string>
<string name="firmware_update_alpha">Alpha</string>
<string name="firmware_update_button">Update Firmware</string>
<string name="firmware_update_disconnect_warning">Note: This will temporarily disconnect your device during the update.</string>
<string name="firmware_update_downloading">Downloading firmware... %1$d%</string>
<string name="firmware_update_error">Error: %1$s</string>
@ -989,7 +989,7 @@
<string name="firmware_update_starting_dfu">Starting DFU...</string>
<string name="firmware_update_updating">Updating... %1$s%</string>
<string name="firmware_update_unknown_hardware">Unknown hardware model: %1$d</string>
<string name="firmware_update_invalid_address">Connected device is not a BLE device or address is unknown (%1$s). DFU requires BLE.</string>
<string name="firmware_update_invalid_address">Connected device is not a valid BLE device or address is unknown (%1$s).</string>
<string name="firmware_update_no_device">No device connected</string>
<string name="firmware_update_not_found_in_release">Could not find firmware for %1$s in release.</string>
<string name="firmware_update_extracting">Extracting firmware...</string>
@ -1006,4 +1006,14 @@
<string name="firmware_update_disclaimer_text">You are about to flash new firmware to your device. This process carries risks.\n\n• Ensure your device is charged.\n• Keep the device close to your phone.\n• Do not close the app during the update.\n\nVerify you have selected the correct firmware for your hardware.</string>
<string name="firmware_update_disclaimer_chirpy_says">Chirpy says, "Keep your ladder handy!"</string>
<string name="chirpy">Chirpy</string>
<string name="firmware_update_rebooting">Rebooting to DFU...</string>
<string name="firmware_update_waiting_for_device">Waiting for DFU device...</string>
<string name="firmware_update_copying">Copying firmware...</string>
<string name="firmware_update_save_dfu_file">Please save the .uf2 file to your device&apos;s DFU drive.</string>
<string name="firmware_update_flashing">Flashing device, please wait...</string>
<string name="firmware_update_method_usb">USB File Transfer</string>
<string name="firmware_update_method_ble">BLE OTA</string>
<string name="firmware_update_method_detail">Update via %1$s</string>
<string name="firmware_update_usb_instruction_title">Select DFU USB Drive</string>
<string name="firmware_update_usb_instruction_text">Your device has rebooted into DFU mode and should appear as a USB drive (e.g., RAK4631).\n\nWhen the file picker opens, please select the root of that drive to save the firmware file.</string>
</resources>