Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/NRF52Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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()
Expand Down
12 changes: 3 additions & 9 deletions src/helpers/NRF52Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
class NRF52Board : public mesh::MainBoard {
protected:
uint8_t startup_reason;
char *ota_name;

public:
NRF52Board(char *otaname) : ota_name(name) {}
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;
};

/*
Expand All @@ -27,13 +30,4 @@ class NRF52BoardDCDC : virtual public NRF52Board {
public:
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
4 changes: 2 additions & 2 deletions variants/heltec_mesh_solar/MeshSolarBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions variants/heltec_t114/T114Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#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 {
public:
T114Board() : NRF52BoardOTA("T114_OTA") {}
T114Board() : NRF52Board("T114_OTA") {}
void begin();

#if defined(P_LORA_TX_LED)
Expand Down
4 changes: 2 additions & 2 deletions variants/ikoka_handheld_nrf/IkokaNrf52Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions variants/ikoka_nano_nrf/IkokaNanoNRFBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions variants/ikoka_stick_nrf/IkokaStickNRFBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions variants/keepteen_lt1/KeepteenLT1Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions variants/lilygo_techo/TechoBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions variants/lilygo_techo_lite/TechoBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions variants/mesh_pocket/MeshPocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions variants/minewsemi_me25ls01/MinewsemiME25LS01Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 0 additions & 61 deletions variants/nano_g2_ultra/nano-g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion variants/nano_g2_ultra/nano-g2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }

Expand Down
4 changes: 2 additions & 2 deletions variants/promicro/PromicroBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions variants/rak4631/RAK4631Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#define PIN_VBAT_READ 5
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)

class RAK4631Board : public NRF52BoardDCDC, public NRF52BoardOTA {
class RAK4631Board : public NRF52BoardDCDC {
public:
RAK4631Board() : NRF52BoardOTA("RAK4631_OTA") {}
RAK4631Board() : NRF52Board("RAK4631_OTA") {}
void begin();

#define BATTERY_SAMPLES 8
Expand Down
4 changes: 2 additions & 2 deletions variants/rak_wismesh_tag/RAKWismeshTagBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions variants/sensecap_solar/SenseCapSolarBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions variants/t1000-e/T1000eBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class T1000eBoard : public NRF52BoardDCDC {
uint8_t btn_prev_state;

public:
T1000eBoard() : NRF52Board("T1000E_OTA") {}
void begin();

uint16_t getBattMilliVolts() override {
Expand Down Expand Up @@ -89,6 +90,4 @@ class T1000eBoard : public NRF52BoardDCDC {

sd_power_system_off();
}

// bool startOTAUpdate(const char* id, char reply[]) override;
};
4 changes: 2 additions & 2 deletions variants/thinknode_m1/ThinkNodeM1Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading