Просмотр исходного кода

Merge pull request #1246 from fschrempf/nrf-dcdc

NRF52 boards: Enable internal DC/DC regulator to reduce power consumption and enable OTA support for all boards
fdlamotte 6 месяцев назад
Родитель
Сommit
ac79b38fa6

+ 1 - 1
src/helpers/NRF52Board.cpp

@@ -271,7 +271,7 @@ float NRF52Board::getMCUTemperature() {
   return temp * 0.25f; // Convert to *C
 }
 
-bool NRF52BoardOTA::startOTAUpdate(const char *id, char reply[]) {
+bool NRF52Board::startOTAUpdate(const char *id, char reply[]) {
   // Config the peripheral connection with maximum bandwidth
   // more SRAM required by SoftDevice
   // Note: All config***() function must be called before begin()

+ 4 - 9
src/helpers/NRF52Board.h

@@ -31,6 +31,7 @@ class NRF52Board : public mesh::MainBoard {
 
 protected:
   uint8_t startup_reason;
+  char *ota_name;
 
 #ifdef NRF52_POWER_MANAGEMENT
   uint32_t reset_reason;              // RESETREAS register value
@@ -44,10 +45,12 @@ protected:
 #endif
 
 public:
+  NRF52Board(char *otaname) : ota_name(otaname) {}
   virtual void begin();
   virtual uint8_t getStartupReason() const override { return startup_reason; }
   virtual float getMCUTemperature() override;
   virtual void reboot() override { NVIC_SystemReset(); }
+  virtual bool startOTAUpdate(const char *id, char reply[]) override;
 
 #ifdef NRF52_POWER_MANAGEMENT
   bool isExternalPowered() override;
@@ -68,15 +71,7 @@ public:
  */
 class NRF52BoardDCDC : virtual public NRF52Board {
 public:
+  NRF52BoardDCDC() {}
   virtual void begin() override;
 };
-
-class NRF52BoardOTA : virtual public NRF52Board {
-private:
-  char *ota_name;
-
-public:
-  NRF52BoardOTA(char *name) : ota_name(name) {}
-  virtual bool startOTAUpdate(const char *id, char reply[]) override;
-};
 #endif

+ 2 - 2
variants/heltec_mesh_solar/MeshSolarBoard.h

@@ -20,9 +20,9 @@
 #define SX126X_DIO2_AS_RF_SWITCH  true
 #define SX126X_DIO3_TCXO_VOLTAGE   1.8
 
-class MeshSolarBoard : public NRF52BoardOTA {
+class MeshSolarBoard : public NRF52BoardDCDC {
 public:
-  MeshSolarBoard() : NRF52BoardOTA("MESH_SOLAR_OTA") {}
+  MeshSolarBoard() : NRF52Board("MESH_SOLAR_OTA") {}
   void begin();
 
   uint16_t getBattMilliVolts() override {

+ 2 - 2
variants/heltec_t114/T114Board.h

@@ -9,14 +9,14 @@
 #define  PIN_BAT_CTL      6
 #define  MV_LSB   (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
 
-class T114Board : public NRF52BoardOTA {
+class T114Board : public NRF52BoardDCDC {
 protected:
 #ifdef NRF52_POWER_MANAGEMENT
   void initiateShutdown(uint8_t reason) override;
 #endif
 
 public:
-    T114Board() : NRF52BoardOTA("T114_OTA") {}
+  T114Board() : NRF52Board("T114_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 2 - 2
variants/ikoka_handheld_nrf/IkokaNrf52Board.h

@@ -6,9 +6,9 @@
 
 #ifdef IKOKA_NRF52
 
-class IkokaNrf52Board : public NRF52BoardOTA {
+class IkokaNrf52Board : public NRF52BoardDCDC {
 public:
-  IkokaNrf52Board() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
+  IkokaNrf52Board() : NRF52Board("XIAO_NRF52_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 2 - 2
variants/ikoka_nano_nrf/IkokaNanoNRFBoard.h

@@ -6,9 +6,9 @@
 
 #ifdef XIAO_NRF52
 
-class IkokaNanoNRFBoard : public NRF52BoardOTA {
+class IkokaNanoNRFBoard : public NRF52BoardDCDC {
 public:
-  IkokaNanoNRFBoard() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
+  IkokaNanoNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 2 - 2
variants/ikoka_stick_nrf/IkokaStickNRFBoard.h

@@ -6,9 +6,9 @@
 
 #ifdef XIAO_NRF52
 
-class IkokaStickNRFBoard : public NRF52BoardOTA {
+class IkokaStickNRFBoard : public NRF52BoardDCDC {
 public:
-  IkokaStickNRFBoard() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
+  IkokaStickNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 2 - 2
variants/keepteen_lt1/KeepteenLT1Board.h

@@ -4,12 +4,12 @@
 #include <Arduino.h>
 #include <helpers/NRF52Board.h>
 
-class KeepteenLT1Board : public NRF52BoardOTA {
+class KeepteenLT1Board : public NRF52Board {
 protected:
   uint8_t btn_prev_state;
 
 public:
-  KeepteenLT1Board() : NRF52BoardOTA("KeepteenLT1_OTA") {}
+  KeepteenLT1Board() : NRF52Board("KeepteenLT1_OTA") {}
   void begin();
 
   #define BATTERY_SAMPLES 8

+ 2 - 2
variants/lilygo_techo/TechoBoard.h

@@ -13,9 +13,9 @@
 #define PIN_VBAT_READ     (4)
 #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
 
-class TechoBoard : public NRF52BoardOTA {
+class TechoBoard : public NRF52BoardDCDC {
 public:
-  TechoBoard() : NRF52BoardOTA("TECHO_OTA") {}
+  TechoBoard() : NRF52Board("TECHO_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
 

+ 2 - 2
variants/lilygo_techo_lite/TechoBoard.h

@@ -13,9 +13,9 @@
 #define PIN_VBAT_READ     (4)
 #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
 
-class TechoBoard : public NRF52BoardOTA {
+class TechoBoard : public NRF52BoardDCDC {
 public:
-  TechoBoard() : NRF52BoardOTA("TECHO_OTA") {}
+  TechoBoard() : NRF52Board("TECHO_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
 

+ 2 - 2
variants/mesh_pocket/MeshPocket.h

@@ -9,9 +9,9 @@
 #define  PIN_BAT_CTL      34
 #define  MV_LSB   (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
 
-class HeltecMeshPocket : public NRF52BoardOTA {
+class HeltecMeshPocket : public NRF52BoardDCDC {
 public:
-  HeltecMeshPocket() : NRF52BoardOTA("MESH_POCKET_OTA") {}
+  HeltecMeshPocket() : NRF52Board("MESH_POCKET_OTA") {}
   void begin();
 
   uint16_t getBattMilliVolts() override {

+ 2 - 2
variants/minewsemi_me25ls01/MinewsemiME25LS01Board.h

@@ -20,12 +20,12 @@
 #define  PIN_VBAT_READ BATTERY_PIN
 #define  ADC_MULTIPLIER   (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
 
-class MinewsemiME25LS01Board : public NRF52BoardOTA {
+class MinewsemiME25LS01Board : public NRF52BoardDCDC {
 protected:
   uint8_t btn_prev_state;
 
 public:
-  MinewsemiME25LS01Board() : NRF52BoardOTA("Minewsemi_OTA") {}
+  MinewsemiME25LS01Board() : NRF52Board("Minewsemi_OTA") {}
   void begin();
 
 #define BATTERY_SAMPLES 8

+ 0 - 61
variants/nano_g2_ultra/nano-g2.cpp

@@ -3,25 +3,8 @@
 
 #ifdef NANO_G2_ULTRA
 
-#include <bluefruit.h>
 #include <Wire.h>
 
-static BLEDfu bledfu;
-
-static void connect_callback(uint16_t conn_handle)
-{
-  (void)conn_handle;
-  MESH_DEBUG_PRINTLN("BLE client connected");
-}
-
-static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
-{
-  (void)conn_handle;
-  (void)reason;
-
-  MESH_DEBUG_PRINTLN("BLE client disconnected");
-}
-
 void NanoG2Ultra::begin()
 {
   NRF52Board::begin();
@@ -56,48 +39,4 @@ uint16_t NanoG2Ultra::getBattMilliVolts()
   // divider into account (providing the actual LIPO voltage)
   return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
 }
-
-bool NanoG2Ultra::startOTAUpdate(const char *id, char reply[])
-{
-  // Config the peripheral connection with maximum bandwidth
-  // more SRAM required by SoftDevice
-  // Note: All config***() function must be called before begin()
-  Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
-  Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
-
-  Bluefruit.begin(1, 0);
-  // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
-  Bluefruit.setTxPower(4);
-  // Set the BLE device name
-  Bluefruit.setName("NANO_G2_OTA");
-
-  Bluefruit.Periph.setConnectCallback(connect_callback);
-  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
-
-  // To be consistent OTA DFU should be added first if it exists
-  bledfu.begin();
-
-  // Set up and start advertising
-  // Advertising packet
-  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
-  Bluefruit.Advertising.addTxPower();
-  Bluefruit.Advertising.addName();
-
-  /* Start Advertising
-    - Enable auto advertising if disconnected
-    - Interval:  fast mode = 20 ms, slow mode = 152.5 ms
-    - Timeout for fast mode is 30 seconds
-    - Start(timeout) with timeout = 0 will advertise forever (until connected)
-
-    For recommended advertising interval
-    https://developer.apple.com/library/content/qa/qa1931/_index.html
-  */
-  Bluefruit.Advertising.restartOnDisconnect(true);
-  Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
-  Bluefruit.Advertising.setFastTimeout(30);   // number of seconds in fast mode
-  Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
-
-  strcpy(reply, "OK - started");
-  return true;
-}
 #endif

+ 1 - 1
variants/nano_g2_ultra/nano-g2.h

@@ -37,9 +37,9 @@
 
 class NanoG2Ultra : public NRF52Board {
 public:
+  NanoG2Ultra() : NRF52Board("NANO_G2_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
-  bool startOTAUpdate(const char *id, char reply[]) override;
 
   const char *getManufacturerName() const override { return "Nano G2 Ultra"; }
 

+ 2 - 2
variants/promicro/PromicroBoard.h

@@ -20,13 +20,13 @@
 #define  PIN_VBAT_READ 17
 #define  ADC_MULTIPLIER   (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
 
-class PromicroBoard : public NRF52BoardOTA {
+class PromicroBoard : public NRF52BoardDCDC {
 protected:
   uint8_t btn_prev_state;
   float adc_mult = ADC_MULTIPLIER;
 
 public:
-  PromicroBoard() : NRF52BoardOTA("ProMicro_OTA") {}
+  PromicroBoard() : NRF52Board("ProMicro_OTA") {}
   void begin();
 
   #define BATTERY_SAMPLES 8

+ 2 - 2
variants/rak4631/RAK4631Board.h

@@ -29,14 +29,14 @@
 #define  PIN_VBAT_READ    5
 #define  ADC_MULTIPLIER   (3 * 1.73 * 1.187 * 1000)
 
-class RAK4631Board : public NRF52BoardDCDC, public NRF52BoardOTA {
+class RAK4631Board : public NRF52BoardDCDC {
 protected:
 #ifdef NRF52_POWER_MANAGEMENT
   void initiateShutdown(uint8_t reason) override;
 #endif
 
 public:
-  RAK4631Board() : NRF52BoardOTA("RAK4631_OTA") {}
+  RAK4631Board() : NRF52Board("RAK4631_OTA") {}
   void begin();
 
   #define BATTERY_SAMPLES 8

+ 2 - 2
variants/rak_wismesh_tag/RAKWismeshTagBoard.h

@@ -8,9 +8,9 @@
 #define  PIN_VBAT_READ    5
 #define  ADC_MULTIPLIER   (3 * 1.73 * 1.187 * 1000)
 
-class RAKWismeshTagBoard : public NRF52BoardDCDC, public NRF52BoardOTA {
+class RAKWismeshTagBoard : public NRF52BoardDCDC {
 public:
-  RAKWismeshTagBoard() : NRF52BoardOTA("WISMESHTAG_OTA") {}
+  RAKWismeshTagBoard() : NRF52Board("WISMESHTAG_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED) && defined(LED_STATE_ON)

+ 2 - 2
variants/sensecap_solar/SenseCapSolarBoard.h

@@ -4,9 +4,9 @@
 #include <Arduino.h>
 #include <helpers/NRF52Board.h>
 
-class SenseCapSolarBoard : public NRF52BoardOTA {
+class SenseCapSolarBoard : public NRF52BoardDCDC {
 public:
-  SenseCapSolarBoard() : NRF52BoardOTA("SENSECAP_SOLAR_OTA") {}
+  SenseCapSolarBoard() : NRF52Board("SENSECAP_SOLAR_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 1 - 2
variants/t1000-e/T1000eBoard.h

@@ -9,6 +9,7 @@ protected:
   uint8_t btn_prev_state;
 
 public:
+  T1000eBoard() : NRF52Board("T1000E_OTA") {}
   void begin();
 
   uint16_t getBattMilliVolts() override {
@@ -89,6 +90,4 @@ public:
 
     sd_power_system_off();
   }
-
-//  bool startOTAUpdate(const char* id, char reply[]) override;
 };

+ 2 - 2
variants/thinknode_m1/ThinkNodeM1Board.h

@@ -13,9 +13,9 @@
 #define PIN_VBAT_READ     (4)
 #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
 
-class ThinkNodeM1Board : public NRF52BoardOTA {
+class ThinkNodeM1Board : public NRF52Board {
 public:
-  ThinkNodeM1Board() : NRF52BoardOTA("THINKNODE_M1_OTA") {}
+  ThinkNodeM1Board() : NRF52Board("THINKNODE_M1_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
 

+ 2 - 68
variants/thinknode_m3/ThinknodeM3Board.cpp

@@ -5,76 +5,10 @@
 #include <bluefruit.h>
 
 void ThinknodeM3Board::begin() {
-  // for future use, sub-classes SHOULD call this from their begin()
-  startup_reason = BD_STARTUP_NORMAL;
+  Nrf52BoardDCDC::begin();
   btn_prev_state = HIGH;
 
-  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
-
-  // Enable DC/DC converter for improved power efficiency
-  NRF_POWER->DCDCEN = 1;
-
   Wire.begin();
 
   delay(10);   // give sx1262 some time to power up
-}
-
-#if 0
-static BLEDfu bledfu;
-
-static void connect_callback(uint16_t conn_handle) {
-  (void)conn_handle;
-  MESH_DEBUG_PRINTLN("BLE client connected");
-}
-
-static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
-  (void)conn_handle;
-  (void)reason;
-
-  MESH_DEBUG_PRINTLN("BLE client disconnected");
-}
-
-
-bool TrackerThinknodeM3Board::startOTAUpdate(const char* id, char reply[]) {
-  // Config the peripheral connection with maximum bandwidth
-  // more SRAM required by SoftDevice
-  // Note: All config***() function must be called before begin()
-  Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
-  Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
-
-  Bluefruit.begin(1, 0);
-  // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
-  Bluefruit.setTxPower(4);
-  // Set the BLE device name
-  Bluefruit.setName("T1000E_OTA");
-
-  Bluefruit.Periph.setConnectCallback(connect_callback);
-  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
-
-  // To be consistent OTA DFU should be added first if it exists
-  bledfu.begin();
-
-  // Set up and start advertising
-  // Advertising packet
-  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
-  Bluefruit.Advertising.addTxPower();
-  Bluefruit.Advertising.addName();
-
-  /* Start Advertising
-    - Enable auto advertising if disconnected
-    - Interval:  fast mode = 20 ms, slow mode = 152.5 ms
-    - Timeout for fast mode is 30 seconds
-    - Start(timeout) with timeout = 0 will advertise forever (until connected)
-
-    For recommended advertising interval
-    https://developer.apple.com/library/content/qa/qa1931/_index.html
-  */
-  Bluefruit.Advertising.restartOnDisconnect(true);
-  Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
-  Bluefruit.Advertising.setFastTimeout(30);   // number of seconds in fast mode
-  Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
-
-  strcpy(reply, "OK - started");
-  return true;
-}
-#endif
+}

+ 8 - 18
variants/thinknode_m3/ThinknodeM3Board.h

@@ -1,13 +1,13 @@
 #pragma once
 
-#include <MeshCore.h>
 #include <Arduino.h>
+#include <MeshCore.h>
+#include <helpers/NRF52Board.h>
 
 #define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
 
-class ThinknodeM3Board : public mesh::MainBoard {
+class ThinknodeM3Board : public Nrf52BoardDCDC {
 protected:
-  uint8_t startup_reason;
   uint8_t btn_prev_state;
 
 public:
@@ -27,12 +27,10 @@ public:
     return (uint16_t)((float)adcvalue * ADC_FACTOR);
   }
 
-  uint8_t getStartupReason() const override { return startup_reason; }
-
-  #if defined(P_LORA_TX_LED)
-  #if !defined(P_LORA_TX_LED_ON)
-    #define P_LORA_TX_LED_ON HIGH
-  #endif
+#if defined(P_LORA_TX_LED)
+#if !defined(P_LORA_TX_LED_ON)
+#define P_LORA_TX_LED_ON HIGH
+#endif
   void onBeforeTransmit() override {
     digitalWrite(P_LORA_TX_LED, P_LORA_TX_LED_ON);   // turn TX LED on
   }
@@ -56,13 +54,5 @@ public:
     return 0;
   }
 
-  void powerOff() override {
-    sd_power_system_off();
-  }
-
-  void reboot() override {
-    NVIC_SystemReset();
-  }
-
-//  bool startOTAUpdate(const char* id, char reply[]) override;
+  void powerOff() override { sd_power_system_off(); }
 };

+ 1 - 60
variants/thinknode_m6/ThinkNodeM6Board.cpp

@@ -4,25 +4,9 @@
 #ifdef THINKNODE_M6
 
 #include <Wire.h>
-#include <bluefruit.h>
-
-static BLEDfu bledfu;
-
-static void connect_callback(uint16_t conn_handle) {
-  (void)conn_handle;
-  MESH_DEBUG_PRINTLN("BLE client connected");
-}
-
-static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
-  (void)conn_handle;
-  (void)reason;
-
-  MESH_DEBUG_PRINTLN("BLE client disconnected");
-}
 
 void ThinkNodeM6Board::begin() {
-  // for future use, sub-classes SHOULD call this from their begin()
-  startup_reason = BD_STARTUP_NORMAL;
+  NRF52Board::begin();
 
   Wire.begin();
 
@@ -49,47 +33,4 @@ uint16_t ThinkNodeM6Board::getBattMilliVolts() {
   // divider into account (providing the actual LIPO voltage)
   return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
 }
-
-bool ThinkNodeM6Board::startOTAUpdate(const char *id, char reply[]) {
-  // Config the peripheral connection with maximum bandwidth
-  // more SRAM required by SoftDevice
-  // Note: All config***() function must be called before begin()
-  Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
-  Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
-
-  Bluefruit.begin(1, 0);
-  // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
-  Bluefruit.setTxPower(4);
-  // Set the BLE device name
-  Bluefruit.setName("THINKNODE_M1_OTA");
-
-  Bluefruit.Periph.setConnectCallback(connect_callback);
-  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
-
-  // To be consistent OTA DFU should be added first if it exists
-  bledfu.begin();
-
-  // Set up and start advertising
-  // Advertising packet
-  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
-  Bluefruit.Advertising.addTxPower();
-  Bluefruit.Advertising.addName();
-
-  /* Start Advertising
-    - Enable auto advertising if disconnected
-    - Interval:  fast mode = 20 ms, slow mode = 152.5 ms
-    - Timeout for fast mode is 30 seconds
-    - Start(timeout) with timeout = 0 will advertise forever (until connected)
-
-    For recommended advertising interval
-    https://developer.apple.com/library/content/qa/qa1931/_index.html
-  */
-  Bluefruit.Advertising.restartOnDisconnect(true);
-  Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
-  Bluefruit.Advertising.setFastTimeout(30);   // number of seconds in fast mode
-  Bluefruit.Advertising.start(0);             // 0 = Don't stop advertising after n seconds
-
-  strcpy(reply, "OK - started");
-  return true;
-}
 #endif

+ 5 - 17
variants/thinknode_m6/ThinkNodeM6Board.h

@@ -1,7 +1,8 @@
 #pragma once
 
-#include <MeshCore.h>
 #include <Arduino.h>
+#include <MeshCore.h>
+#include <helpers/NRF52Board.h>
 
 // built-ins
 #define VBAT_MV_PER_LSB   (0.73242188F)   // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
@@ -11,21 +12,13 @@
 #define PIN_VBAT_READ     BATTERY_PIN
 #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
 
-class ThinkNodeM6Board : public mesh::MainBoard {
-protected:
-  uint8_t startup_reason;
-
+class ThinkNodeM6Board : public Nrf52BoardOTA {
 public:
-
+  ThinkNodeM6Board() : NRF52BoardOTA("THINKNODE_M1_OTA") {}
   void begin();
   uint16_t getBattMilliVolts() override;
-  bool startOTAUpdate(const char* id, char reply[]) override;
 
-  uint8_t getStartupReason() const override {
-    return startup_reason;
-  }
-
-  #if defined(P_LORA_TX_LED)
+#if defined(P_LORA_TX_LED)
   void onBeforeTransmit() override {
     digitalWrite(P_LORA_TX_LED, HIGH);   // turn TX LED on
   }
@@ -38,10 +31,6 @@ public:
     return "Elecrow ThinkNode-M6";
   }
 
-  void reboot() override {
-    NVIC_SystemReset();
-  }
-
   void powerOff() override {
 
     // turn off all leds, sd_power_system_off will not do this for us
@@ -51,6 +40,5 @@ public:
 
     // power off board
     sd_power_system_off();
-
   }
 };

+ 2 - 2
variants/wio-tracker-l1/WioTrackerL1Board.h

@@ -4,12 +4,12 @@
 #include <Arduino.h>
 #include <helpers/NRF52Board.h>
 
-class WioTrackerL1Board : public NRF52BoardDCDC, public NRF52BoardOTA {
+class WioTrackerL1Board : public NRF52BoardDCDC {
 protected:
   uint8_t btn_prev_state;
 
 public:
-  WioTrackerL1Board() : NRF52BoardOTA("WioTrackerL1 OTA") {}
+  WioTrackerL1Board() : NRF52Board("WioTrackerL1 OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)

+ 2 - 43
variants/wio_wm1110/WioWM1110Board.cpp

@@ -1,24 +1,9 @@
 #ifdef WIO_WM1110
 
-#include <Arduino.h>
-#include <Wire.h>
-#include <bluefruit.h>
-
 #include "WioWM1110Board.h"
 
-static BLEDfu bledfu;
-
-static void connect_callback(uint16_t conn_handle) {
-  (void)conn_handle;
-  MESH_DEBUG_PRINTLN("BLE client connected");
-}
-
-static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
-  (void)conn_handle;
-  (void)reason;
-
-  MESH_DEBUG_PRINTLN("BLE client disconnected");
-}
+#include <Arduino.h>
+#include <Wire.h>
 
 void WioWM1110Board::begin() {
   NRF52BoardDCDC::begin();
@@ -42,31 +27,5 @@ void WioWM1110Board::begin() {
 
   delay(10);
 }
-
-bool WioWM1110Board::startOTAUpdate(const char *id, char reply[]) {
-  Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
-  Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
-
-  Bluefruit.begin(1, 0);
-  Bluefruit.setTxPower(4);
-  Bluefruit.setName("WM1110_OTA");
-
-  Bluefruit.Periph.setConnectCallback(connect_callback);
-  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
-
-  bledfu.begin();
-
-  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
-  Bluefruit.Advertising.addTxPower();
-  Bluefruit.Advertising.addName();
-  Bluefruit.Advertising.restartOnDisconnect(true);
-  Bluefruit.Advertising.setInterval(32, 244);
-  Bluefruit.Advertising.setFastTimeout(30);
-  Bluefruit.Advertising.start(0);
-
-  strcpy(reply, "OK - started");
-  return true;
-}
-
 #endif
 

+ 1 - 2
variants/wio_wm1110/WioWM1110Board.h

@@ -13,6 +13,7 @@
 
 class WioWM1110Board : public NRF52BoardDCDC {
 public:
+  WioWM1110Board() : NRF52Board("WM1110_OTA") {}
   void begin();
 
 #if defined(LED_GREEN)
@@ -37,8 +38,6 @@ public:
     return "Seeed Wio WM1110";
   }
 
-  bool startOTAUpdate(const char* id, char reply[]) override;
-
   void enableSensorPower(bool enable) {
     digitalWrite(SENSOR_POWER_PIN, enable ? HIGH : LOW);
     if (enable) {

+ 2 - 2
variants/xiao_nrf52/XiaoNrf52Board.h

@@ -6,14 +6,14 @@
 
 #ifdef XIAO_NRF52
 
-class XiaoNrf52Board : public NRF52BoardDCDC, public NRF52BoardOTA { 
+class XiaoNrf52Board : public NRF52BoardDCDC {
 protected:
 #if NRF52_POWER_MANAGEMENT
   void initiateShutdown(uint8_t reason) override;
 #endif
 
 public:
-  XiaoNrf52Board() : NRF52BoardOTA("XIAO_NRF52_OTA") {}
+  XiaoNrf52Board() : NRF52Board("XIAO_NRF52_OTA") {}
   void begin();
 
 #if defined(P_LORA_TX_LED)