Skip to content

Commit

Permalink
Implemented enter (Uf2 usb) DFU mode admin message on NRF52 (#3045)
Browse files Browse the repository at this point in the history
* Added enter DFU mode admin message

* Trunk
  • Loading branch information
thebentern authored Dec 27, 2023
1 parent 2b7eb1e commit dbac2b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion protobufs
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extern int heltec_version;
// This will suppress the current delay and instead try to run ASAP.
extern bool runASAP;

void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds();
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds(), enterDfuMode();

meshtastic_DeviceMetadata getDeviceMetadata();

Expand Down
2 changes: 1 addition & 1 deletion src/mesh/generated/meshtastic/admin.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ typedef struct _meshtastic_AdminMessage {
bool get_node_remote_hardware_pins_request;
/* Respond with the mesh's nodes with their available gpio pins for RemoteHardware module use */
meshtastic_NodeRemoteHardwarePinsResponse get_node_remote_hardware_pins_response;
/* Enter (serial) DFU mode
/* Enter (UF2) DFU mode
Only implemented on NRF52 currently */
bool enter_dfu_mode_request;
/* Set the owner for this node */
Expand Down
7 changes: 7 additions & 0 deletions src/modules/AdminModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
reboot(DEFAULT_REBOOT_SECONDS);
break;
}
case meshtastic_AdminMessage_enter_dfu_mode_request_tag: {
LOG_INFO("Client is requesting to enter DFU mode.\n");
#ifdef ARCH_NRF52
enterDfuMode();
#endif
break;
}
#ifdef ARCH_PORTDUINO
case meshtastic_AdminMessage_exit_simulator_tag:
LOG_INFO("Exiting simulator\n");
Expand Down
6 changes: 6 additions & 0 deletions src/platform/nrf52/main-nrf52.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "configuration.h"
#include <Adafruit_TinyUSB.h>
#include <Adafruit_nRFCrypto.h>
#include <SPI.h>
#include <Wire.h>
Expand Down Expand Up @@ -214,4 +215,9 @@ void clearBonds()
nrf52Bluetooth->setup();
}
nrf52Bluetooth->clearBonds();
}

void enterDfuMode()
{
enterUf2Dfu();
}

0 comments on commit dbac2b1

Please sign in to comment.