Skip to content

Commit b2b755c

Browse files
author
Scott Powell
committed
Merge branch 'dev'
2 parents 259f4ec + d7e6a36 commit b2b755c

File tree

25 files changed

+194
-104
lines changed

25 files changed

+194
-104
lines changed

examples/companion_radio/main.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ static uint32_t _atoi(const char* sp) {
8686
#define FIRMWARE_VER_CODE 3
8787

8888
#ifndef FIRMWARE_BUILD_DATE
89-
#define FIRMWARE_BUILD_DATE "30 Mar 2025"
89+
#define FIRMWARE_BUILD_DATE "7 Apr 2025"
9090
#endif
9191

9292
#ifndef FIRMWARE_VERSION
93-
#define FIRMWARE_VERSION "v1.4.2"
93+
#define FIRMWARE_VERSION "v1.4.3"
9494
#endif
9595

9696
#define CMD_APP_START 1
@@ -228,6 +228,10 @@ class MyMesh : public BaseChatMesh {
228228
void loadMainIdentity() {
229229
if (!_identity_store->load("_main", self_id)) {
230230
self_id = radio_new_identity(); // create new random identity
231+
int count = 0;
232+
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
233+
self_id = radio_new_identity(); count++;
234+
}
231235
saveMainIdentity(self_id);
232236
}
233237
}
@@ -1404,6 +1408,10 @@ class MyMesh : public BaseChatMesh {
14041408
#elif defined(BLE_PIN_CODE)
14051409
#include <helpers/esp32/SerialBLEInterface.h>
14061410
SerialBLEInterface serial_interface;
1411+
#elif defined(SERIAL_RX)
1412+
#include <helpers/ArduinoSerialInterface.h>
1413+
ArduinoSerialInterface serial_interface;
1414+
HardwareSerial companion_serial(1);
14071415
#else
14081416
#include <helpers/ArduinoSerialInterface.h>
14091417
ArduinoSerialInterface serial_interface;
@@ -1433,19 +1441,22 @@ void setup() {
14331441

14341442
board.begin();
14351443

1436-
if (!radio_init()) { halt(); }
1437-
1438-
fast_rng.begin(radio_get_rng_seed());
1439-
14401444
#ifdef HAS_UI
14411445
DisplayDriver* disp = NULL;
14421446
#ifdef DISPLAY_CLASS
14431447
if (display.begin()) {
14441448
disp = &display;
1449+
disp->startFrame();
1450+
disp->print("Please wait...");
1451+
disp->endFrame();
14451452
}
14461453
#endif
14471454
#endif
14481455

1456+
if (!radio_init()) { halt(); }
1457+
1458+
fast_rng.begin(radio_get_rng_seed());
1459+
14491460
#if defined(NRF52_PLATFORM)
14501461
InternalFS.begin();
14511462
the_mesh.begin(InternalFS,
@@ -1481,6 +1492,10 @@ void setup() {
14811492
char dev_name[32+16];
14821493
sprintf(dev_name, "%s%s", BLE_NAME_PREFIX, the_mesh.getNodeName());
14831494
serial_interface.begin(dev_name, the_mesh.getBLEPin());
1495+
#elif defined(SERIAL_RX)
1496+
companion_serial.setPins(SERIAL_RX, SERIAL_TX);
1497+
companion_serial.begin(115200);
1498+
serial_interface.begin(companion_serial);
14841499
#else
14851500
serial_interface.begin(Serial);
14861501
#endif

examples/simple_repeater/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
/* ------------------------------ Config -------------------------------- */
2121

2222
#ifndef FIRMWARE_BUILD_DATE
23-
#define FIRMWARE_BUILD_DATE "30 Mar 2025"
23+
#define FIRMWARE_BUILD_DATE "7 Apr 2025"
2424
#endif
2525

2626
#ifndef FIRMWARE_VERSION
27-
#define FIRMWARE_VERSION "v1.4.2"
27+
#define FIRMWARE_VERSION "v1.4.3"
2828
#endif
2929

3030
#ifndef LORA_FREQ
@@ -616,6 +616,14 @@ void setup() {
616616

617617
board.begin();
618618

619+
#ifdef DISPLAY_CLASS
620+
if(display.begin()){
621+
display.startFrame();
622+
display.print("Please wait...");
623+
display.endFrame();
624+
}
625+
#endif
626+
619627
if (!radio_init()) { halt(); }
620628

621629
fast_rng.begin(radio_get_rng_seed());
@@ -635,6 +643,10 @@ void setup() {
635643
if (!store.load("_main", the_mesh.self_id)) {
636644
MESH_DEBUG_PRINTLN("Generating new keypair");
637645
the_mesh.self_id = radio_new_identity(); // create new random identity
646+
int count = 0;
647+
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
648+
the_mesh.self_id = radio_new_identity(); count++;
649+
}
638650
store.save("_main", the_mesh.self_id);
639651
}
640652

@@ -646,7 +658,6 @@ void setup() {
646658
the_mesh.begin(fs);
647659

648660
#ifdef DISPLAY_CLASS
649-
display.begin();
650661
ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE);
651662
#endif
652663

examples/simple_room_server/main.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
/* ------------------------------ Config -------------------------------- */
2121

2222
#ifndef FIRMWARE_BUILD_DATE
23-
#define FIRMWARE_BUILD_DATE "30 Mar 2025"
23+
#define FIRMWARE_BUILD_DATE "7 Apr 2025"
2424
#endif
2525

2626
#ifndef FIRMWARE_VERSION
27-
#define FIRMWARE_VERSION "v1.4.2"
27+
#define FIRMWARE_VERSION "v1.4.3"
2828
#endif
2929

3030
#ifndef LORA_FREQ
@@ -62,7 +62,7 @@
6262
#endif
6363

6464
#ifndef MAX_UNSYNCED_POSTS
65-
#define MAX_UNSYNCED_POSTS 16
65+
#define MAX_UNSYNCED_POSTS 32
6666
#endif
6767

6868
#ifdef DISPLAY_CLASS
@@ -111,7 +111,7 @@ struct PostInfo {
111111

112112
#define REPLY_DELAY_MILLIS 1500
113113
#define PUSH_NOTIFY_DELAY_MILLIS 2000
114-
#define SYNC_PUSH_INTERVAL 2000
114+
#define SYNC_PUSH_INTERVAL 1200
115115

116116
#define PUSH_ACK_TIMEOUT_FLOOD 12000
117117
#define PUSH_TIMEOUT_BASE 4000
@@ -782,13 +782,15 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
782782
}
783783
// check next Round-Robin client, and sync next new post
784784
auto client = &known_clients[next_client_idx];
785+
bool did_push = false;
785786
if (client->pending_ack == 0 && client->last_activity != 0 && client->push_failures < 3) { // not already waiting for ACK, AND not evicted, AND retries not max
786787
MESH_DEBUG_PRINTLN("loop - checking for client %02X", (uint32_t) client->id.pub_key[0]);
787788
for (int k = 0, idx = next_post_idx; k < MAX_UNSYNCED_POSTS; k++) {
788789
if (posts[idx].post_timestamp > client->sync_since // is new post for this Client?
789790
&& !posts[idx].author.matches(client->id)) { // don't push posts to the author
790791
// push this post to Client, then wait for ACK
791792
pushPostToClient(client, posts[idx]);
793+
did_push = true;
792794
MESH_DEBUG_PRINTLN("loop - pushed to client %02X: %s", (uint32_t) client->id.pub_key[0], posts[idx].text);
793795
break;
794796
}
@@ -799,7 +801,12 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
799801
}
800802
next_client_idx = (next_client_idx + 1) % num_clients; // round robin polling for each client
801803

802-
next_push = futureMillis(SYNC_PUSH_INTERVAL);
804+
if (did_push) {
805+
next_push = futureMillis(SYNC_PUSH_INTERVAL);
806+
} else {
807+
// were no unsynced posts for curr client, so proccess next client much quicker! (in next loop())
808+
next_push = futureMillis(SYNC_PUSH_INTERVAL / 8);
809+
}
803810
}
804811

805812
if (next_flood_advert && millisHasNowPassed(next_flood_advert)) {
@@ -839,6 +846,14 @@ void setup() {
839846

840847
board.begin();
841848

849+
#ifdef DISPLAY_CLASS
850+
if(display.begin()){
851+
display.startFrame();
852+
display.print("Please wait...");
853+
display.endFrame();
854+
}
855+
#endif
856+
842857
if (!radio_init()) { halt(); }
843858

844859
fast_rng.begin(radio_get_rng_seed());
@@ -857,6 +872,10 @@ void setup() {
857872
#endif
858873
if (!store.load("_main", the_mesh.self_id)) {
859874
the_mesh.self_id = radio_new_identity(); // create new random identity
875+
int count = 0;
876+
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
877+
the_mesh.self_id = radio_new_identity(); count++;
878+
}
860879
store.save("_main", the_mesh.self_id);
861880
}
862881

@@ -868,7 +887,6 @@ void setup() {
868887
the_mesh.begin(fs);
869888

870889
#ifdef DISPLAY_CLASS
871-
display.begin();
872890
ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE);
873891
#endif
874892

examples/simple_secure_chat/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
300300
((StdRNG *)getRNG())->begin(millis());
301301

302302
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
303+
int count = 0;
304+
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
305+
self_id = mesh::LocalIdentity(getRNG()); count++;
306+
}
303307
store.save("_main", self_id);
304308
}
305309

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lib_deps =
2525
build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1 -DRADIOLIB_GODMODE=1
2626
-D LORA_FREQ=869.525
2727
-D LORA_BW=250
28-
-D LORA_SF=10
28+
-D LORA_SF=11
2929
build_src_filter =
3030
+<*.cpp>
3131
+<helpers/*.cpp>

src/helpers/nrf52/FaketecBoard.cpp renamed to src/helpers/nrf52/PromicroBoard.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include <Arduino.h>
2-
#include "FaketecBoard.h"
2+
#include "PromicroBoard.h"
33

44
#include <bluefruit.h>
55
#include <Wire.h>
66

77
static BLEDfu bledfu;
88

9-
void FaketecBoard::begin() {
9+
void PromicroBoard::begin() {
1010
// for future use, sub-classes SHOULD call this from their begin()
1111
startup_reason = BD_STARTUP_NORMAL;
1212
btn_prev_state = HIGH;
@@ -39,7 +39,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
3939
MESH_DEBUG_PRINTLN("BLE client disconnected");
4040
}
4141

42-
bool FaketecBoard::startOTAUpdate(const char* id, char reply[]) {
42+
bool PromicroBoard::startOTAUpdate(const char* id, char reply[]) {
4343
// Config the peripheral connection with maximum bandwidth
4444
// more SRAM required by SoftDevice
4545
// Note: All config***() function must be called before begin()
@@ -50,7 +50,7 @@ bool FaketecBoard::startOTAUpdate(const char* id, char reply[]) {
5050
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
5151
Bluefruit.setTxPower(4);
5252
// Set the BLE device name
53-
Bluefruit.setName("Faketec_OTA");
53+
Bluefruit.setName("ProMicro_OTA");
5454

5555
Bluefruit.Periph.setConnectCallback(connect_callback);
5656
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);

src/helpers/nrf52/FaketecBoard.h renamed to src/helpers/nrf52/PromicroBoard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define PIN_VBAT_READ 17
2020
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
2121

22-
class FaketecBoard : public mesh::MainBoard {
22+
class PromicroBoard : public mesh::MainBoard {
2323
protected:
2424
uint8_t startup_reason;
2525
uint8_t btn_prev_state;
@@ -43,7 +43,7 @@ class FaketecBoard : public mesh::MainBoard {
4343
}
4444

4545
const char* getManufacturerName() const override {
46-
return "Faketec DIY";
46+
return "ProMicro DIY";
4747
}
4848

4949
int buttonStateChanged() {

src/helpers/ui/DisplayDriver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class DisplayDriver {
1515
virtual bool isOn() = 0;
1616
virtual void turnOn() = 0;
1717
virtual void turnOff() = 0;
18+
virtual void clear() = 0;
1819
virtual void startFrame(Color bkg = DARK) = 0;
1920
virtual void setTextSize(int sz) = 0;
2021
virtual void setColor(Color c) = 0;

src/helpers/ui/SSD1306Display.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ void SSD1306Display::turnOff() {
2020
_isOn = false;
2121
}
2222

23+
void SSD1306Display::clear() {
24+
display.clearDisplay();
25+
display.display();
26+
}
27+
2328
void SSD1306Display::startFrame(Color bkg) {
2429
display.clearDisplay(); // TODO: apply 'bkg'
2530
_color = SSD1306_WHITE;

src/helpers/ui/SSD1306Display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SSD1306Display : public DisplayDriver {
2727
bool isOn() override { return _isOn; }
2828
void turnOn() override;
2929
void turnOff() override;
30+
void clear() override;
3031
void startFrame(Color bkg = DARK) override;
3132
void setTextSize(int sz) override;
3233
void setColor(Color c) override;

0 commit comments

Comments
 (0)