Merge remote-tracking branch 'upstream/dev' into feat/kiss-agc-fem-control

This commit is contained in:
agessaman committed 2026-11-06 20:38:01 -08:00
commit c0ccb9c7ff
123 files changed
+2095 -396

No files matched your search

+140 -5
View File
@@ -758,8 +758,21 @@ void MyMesh::onContactResponse(const ContactInfo &contact, const uint8_t *data,
memcpy(&out_frame[i], &data[4], len - 4);
i += (len - 4);
_serial->writeFrame(out_frame, i);
} else if (_listener && len > 4) {
_listener->onUnhandledResponse(contact, tag, &data[4], len - 4);
} else {
bool handled;
if (_listener && len > 4) {
handled = _listener->onUnhandledResponse(contact, tag, &data[4], len - 4);
} else {
handled = false;
}
if (!handled) { // let the app know about unknown/unhandled responses (eg. push telemetry packets)
int i = 0;
out_frame[i++] = PUSH_CODE_BINARY_RESPONSE;
out_frame[i++] = 0; // reserved
memcpy(&out_frame[i], data, len);
i += len;
_serial->writeFrame(out_frame, i);
}
}
}
@@ -1162,7 +1175,9 @@ void MyMesh::handleCmdFrame(size_t len) {
? ERR_CODE_NOT_FOUND
: ERR_CODE_UNSUPPORTED_CMD); // unknown recipient, or unsupported TXT_TYPE_*
}
} else if (cmd_frame[0] == CMD_SEND_CHANNEL_TXT_MSG) { // send GroupChannel text msg
} else if (cmd_frame[0] == CMD_SEND_CHANNEL_TXT_MSG && len >= 7) { // send GroupChannel text msg
// 7 = code, txt_type, channel_idx and the 4 byte timestamp; the text may be empty.
// Without this the text length below is computed as len - 7 and turns negative.
int i = 1;
uint8_t txt_type = cmd_frame[i++]; // should be TXT_TYPE_PLAIN
uint8_t channel_idx = cmd_frame[i++];
@@ -2109,6 +2124,23 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
return true;
}
#ifdef PIN_BUZZER
if (strcmp(command, "get buzzer") == 0) {
sprintf(reply, "> %s", _prefs.buzzer_quiet ? "off" : "on");
return true;
}
if (memcmp(command, "set buzzer ", 11) == 0) {
if (strcmp(&command[11], "on") == 0 || strcmp(&command[11], "off") == 0) {
_prefs.buzzer_quiet = strcmp(&command[11], "off") == 0;
savePrefs();
strcpy(reply, "OK");
} else {
strcpy(reply, "Error: state must be on or off");
}
return true;
}
#endif
if (memcmp(command, "set pin ", 8) == 0) {
_prefs.ble_pin = atoi(&command[8]);
savePrefs();
@@ -2179,11 +2211,12 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
}
if (strcmp(command, "get tz.offset") == 0) {
sprintf(reply, "> %d", _prefs.tz_offset);
float q = _prefs.tz_offset * 4;
sprintf(reply, (q == (int)q && ((int)q & 1)) ? "> %.2f" : "> %.1f", _prefs.tz_offset);
return true;
}
if (memcmp(command, "set tz.offset ", 14) == 0) {
int8_t tz = atof(&command[14]);
float tz = atof(&command[14]);
if (tz < -12 || tz > 14) {
strcpy(reply, "Error, must be from -12 to +14");
} else {
@@ -2193,6 +2226,108 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
}
return true;
}
#ifdef DISPLAY_CLASS
if (memcmp(command, "set ui.show_clock", 17) == 0) {
_prefs.ui_show_clock = atoi(&command[17]) ? 1 : 0;
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_show_clock);
return true;
}
if (memcmp(command, "set ui.auto_off_delay", 21) == 0) {
_prefs.ui_auto_off_delay = atoi(&command[21]);
savePrefs();
sprintf(reply, "> now %d seconds", _prefs.ui_auto_off_delay);
return true;
}
if (memcmp(command, "set ui.backlight_delay", 22) == 0) {
_prefs.ui_backlight_delay = atoi(&command[22]);
savePrefs();
if (_prefs.ui_backlight_delay >= 0)
sprintf(reply, "> now %d seconds", _prefs.ui_backlight_delay);
else if (_prefs.ui_backlight_delay == -1)
sprintf(reply, "> now always on (-1)");
else
sprintf(reply, "> now disabled (<-1)");
return true;
}
if (memcmp(command, "set ui.backlight_on_keys", 24) == 0) {
_prefs.ui_backlight_on_keys = atoi(&command[24]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_backlight_on_keys);
return true;
}
if (memcmp(command, "set ui.backlight_on_msgs", 24) == 0) {
_prefs.ui_backlight_on_msgs = atoi(&command[24]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_backlight_on_msgs);
return true;
}
if (memcmp(command, "set ui.auto_off_blank", 21) == 0) {
_prefs.ui_auto_off_blank = atoi(&command[21]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_auto_off_blank);
return true;
}
if (memcmp(command, "set ui.auto_off_keep_msgs", 25) == 0) {
_prefs.ui_auto_off_keep_msgs = atoi(&command[25]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_auto_off_keep_msgs);
return true;
}
if (memcmp(command, "set ui.max_partial", 18) == 0) {
_prefs.ui_max_partial = atoi(&command[18]);
savePrefs();
sprintf(reply, "> now %d (applied at next screen wakeup)", _prefs.ui_max_partial);
return true;
}
if (memcmp(command, "set ui.nd_name", 14) == 0) {
_prefs.ui_nd_name = atoi(&command[14]);
savePrefs();
sprintf(reply, "> ui.nd_name is now %d", _prefs.ui_nd_name);
return true;
}
if (memcmp(command, "get ui.show_clock", 17) == 0) {
sprintf(reply, "> %d", _prefs.ui_show_clock);
return true;
}
if (memcmp(command, "get ui.auto_off_delay", 21) == 0) {
sprintf(reply, "> %d seconds", _prefs.ui_auto_off_delay);
return true;
}
if (memcmp(command, "get ui.backlight_delay", 22) == 0) {
if (_prefs.ui_backlight_delay >= 0)
sprintf(reply, "> %d seconds", _prefs.ui_backlight_delay);
else if (_prefs.ui_backlight_delay == -1)
sprintf(reply, "> always on (-1)");
else
sprintf(reply, "> disabled (<-1)");
return true;
}
if (memcmp(command, "get ui.backlight_on_keys", 24) == 0) {
sprintf(reply, "> %d", _prefs.ui_backlight_on_keys);
return true;
}
if (memcmp(command, "get ui.backlight_on_msgs", 24) == 0) {
sprintf(reply, "> %d", _prefs.ui_backlight_on_msgs);
return true;
}
if (memcmp(command, "get ui.auto_off_blank", 21) == 0) {
sprintf(reply, "> %d", _prefs.ui_auto_off_blank);
return true;
}
if (memcmp(command, "get ui.auto_off_keep_msgs", 25) == 0) {
sprintf(reply, "> %d", _prefs.ui_auto_off_keep_msgs);
return true;
}
if (memcmp(command, "get ui.max_partial", 18) == 0) {
sprintf(reply, "> %d", _prefs.ui_max_partial);
return true;
}
if (memcmp(command, "get ui.nd_name", 14) == 0) {
sprintf(reply, "> %d", _prefs.ui_nd_name);
return true;
}
#endif
return false; // not handled
}
+3 -3
View File
@@ -7,11 +7,11 @@
#define FIRMWARE_VER_CODE 14
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "14 Aug 2026"
#define FIRMWARE_BUILD_DATE "15 Oct 2026"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.17.1"
#define FIRMWARE_VERSION "v1.18.0"
#endif
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
@@ -101,7 +101,7 @@ public:
virtual void onACKRecv(uint32_t ack_crc) { }
virtual uint8_t onUnhandledRequest(const ContactInfo &contact, uint32_t sender_timestamp, const uint8_t *data,
uint8_t len, uint8_t *reply) { return 0; /* unknown request type */ }
virtual void onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { }
virtual bool onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { return false; /* not handled */ }
virtual void onTraceRecv(mesh::Packet *pkt, uint32_t tag, uint32_t auth_code, uint8_t flags,
const uint8_t *path_snrs, const uint8_t *path_hashes, uint8_t path_len) { }
virtual void onRawDataRecv(mesh::Packet *pkt) { }
+58 -3
View File
@@ -47,7 +47,7 @@ public:
uint8_t agc_reset_interval = 0; // secs / 4
char default_scope_name[31];
uint8_t default_scope_key[16];
int8_t tz_offset = 0;
float tz_offset = 0;
#ifdef ENABLE_WIFI_INTERFACE
#ifndef WIFI_SSID
#define WIFI_SSID ""
@@ -58,6 +58,34 @@ public:
// use ssid from prefs, or fallback to ssid from build flags
const char* getWifiSSID() const { return wifi_ssid[0] ? wifi_ssid : WIFI_SSID; }
#endif
#ifdef DISPLAY_CLASS
#ifndef UI_SHOW_CLOCK
#define UI_SHOW_CLOCK 0
#endif
#ifndef AUTO_OFF_MILLIS
#define AUTO_OFF_MILLIS 15000
#endif
#ifndef EINK_MAX_PARTIAL_REFRESH
#define EINK_MAX_PARTIAL_REFRESH 0
#endif
uint8_t ui_show_clock = UI_SHOW_CLOCK;
uint32_t ui_auto_off_delay = AUTO_OFF_MILLIS / 1000;
int32_t ui_backlight_delay = 5;
#if defined(BACKLIGHT_BTN)
uint8_t ui_backlight_on_keys = 0;
#else
uint8_t ui_backlight_on_keys = 1;
#endif
uint8_t ui_backlight_on_msgs = 0;
#ifdef UI_SCREENOFF_BLANK
uint8_t ui_auto_off_blank = 1;
#else
uint8_t ui_auto_off_blank = 0;
#endif
uint8_t ui_auto_off_keep_msgs = 1;
uint8_t ui_max_partial = EINK_MAX_PARTIAL_REFRESH;
uint8_t ui_nd_name = 1;
#endif
private:
class RadioPrefs : public CommonRadioPrefs {
@@ -102,8 +130,8 @@ private:
void setIntThresh(uint8_t t) override { _parent->interference_threshold = t; markDirty(); }
uint8_t getRxGain() const override { return _parent->rx_boosted_gain; }
void setRxGain(uint8_t g) override { _parent->rx_boosted_gain = g; markDirty(); }
uint8_t getTxPower() const override { return _parent->tx_power_dbm; }
void setTxPower(uint8_t dbm) override { _parent->tx_power_dbm = dbm; markDirty(); }
int8_t getTxPower() const override { return _parent->tx_power_dbm; }
void setTxPower(int8_t dbm) override { _parent->tx_power_dbm = dbm; markDirty(); }
float getRxDelay() const override { return _parent->rx_delay_base; }
void setRxDelay(float d) override { _parent->rx_delay_base = d; markDirty(); }
uint16_t getAgcResetInt() const override { return _parent->agc_reset_interval * 4; }
@@ -189,6 +217,27 @@ private:
WiFiPrefs wifi;
#endif
#ifdef DISPLAY_CLASS
class UI_Prefs : public ConfigSerializer {
NodePrefs* _parent;
protected:
void structure() override {
def("show_clock", _parent->ui_show_clock);
def("auto_off", _parent->ui_auto_off_delay);
def("bl_dly", _parent->ui_backlight_delay);
def("bl_keys", _parent->ui_backlight_on_keys);
def("bl_msgs", _parent->ui_backlight_on_msgs);
def("max_partial", _parent->ui_max_partial);
def("off_blank", _parent->ui_auto_off_blank);
def("off_keep_msgs", _parent->ui_auto_off_keep_msgs);
def("nd_name", _parent->ui_nd_name);
}
public:
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
};
UI_Prefs ui;
#endif
protected:
void structure() override {
def("name", node_name, sizeof(node_name));
@@ -203,12 +252,18 @@ protected:
def("custom", custom);
#ifdef ENABLE_WIFI_INTERFACE
def("wifi", wifi);
#endif
#ifdef DISPLAY_CLASS
def("ui", ui);
#endif
}
public:
NodePrefs() : radio(this), gps(this), companion(this), custom(&radio)
#ifdef ENABLE_WIFI_INTERFACE
, wifi(this)
#endif
#ifdef DISPLAY_CLASS
, ui(this)
#endif
{
node_name[0] = 0;
+127 -72
View File
@@ -91,7 +91,9 @@ class HomeScreen : public UIScreen {
FIRST,
RECENT,
RADIO,
#ifdef BLE_PIN_CODE
BLUETOOTH,
#endif
ADVERT,
#if ENV_INCLUDE_GPS == 1
GPS,
@@ -120,7 +122,6 @@ class HomeScreen : public UIScreen {
uint32_t disc_node_req_tag = 0;
uint32_t disc_nodes_count = 0;
uint32_t discovery_req_time = 0;
bool discovery_disp_names = true; // by default desplay names if available (removes SNR_O)
#endif
void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) {
@@ -195,11 +196,10 @@ class HomeScreen : public UIScreen {
sensors_nb ++;
}
sensors_scroll = sensors_nb > UI_RECENT_LIST_SIZE;
#if AUTO_OFF_MILLIS > 0
next_sensors_refresh = millis() + 5000; // refresh sensor values every 5 sec
#else
next_sensors_refresh = millis() + 60000; // refresh sensor values every 1 min
#endif
if (display.isEink()) // preserve eink displays
next_sensors_refresh = millis() + 60000; // refresh sensor values every 1 min
else
next_sensors_refresh = millis() + 5000; // refresh sensor values every 5 sec
}
}
@@ -281,45 +281,51 @@ public:
if (_page == HomePage::FIRST) {
display.setColor(UIColor::primary_txt);
#ifdef ENABLE_WIFI_INTERFACE
// smaller unread message ui for wifi variants
display.setTextSize(1);
sprintf(tmp, "Unread Msg: %d", _task->getMsgCount());
display.drawTextCentered(display.width() / 2, 22, tmp);
#else
// larger unread message ui for non wifi variants
display.setTextSize(2);
sprintf(tmp, "MSG: %d", _task->getMsgCount());
display.drawTextCentered(display.width() / 2, 22, tmp);
#ifdef UI_SHOW_CLOCK
display.setTextSize(3);
uint32_t now = _rtc->getCurrentTime();
now += (int32_t)_node_prefs->tz_offset * 3600;
DateTime dt (now);
sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute());
display.drawTextCentered(display.width() / 2, 60, tmp);
display.setTextSize(1);
sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
display.drawTextCentered(display.width() / 2, 80, tmp);
#endif
if (_node_prefs->ui_show_clock) {
display.setTextSize(3);
uint32_t now = _rtc->getCurrentTime();
now += (int32_t)(_node_prefs->tz_offset * 3600);
DateTime dt (now);
sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute());
display.drawTextCentered(display.width() / 2, 60, tmp);
display.setTextSize(1);
sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
display.drawTextCentered(display.width() / 2, 80, tmp);
}
#ifdef ENABLE_WIFI_INTERFACE
IPAddress ip = WiFi.localIP();
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 54, tmp);
display.drawTextCentered(display.width() / 2, 32, tmp);
#endif
if (_task->hasConnection()) {
display.setColor(UIColor::warning_txt);
display.setTextSize(1);
#ifdef UI_SHOW_CLOCK
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
#else
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
#endif
if (_node_prefs->ui_show_clock)
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
else
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
} else if (the_mesh.getBLEPin() != 0) { // BT pin
display.setColor(UIColor::warning_txt);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());
#ifdef UI_SHOW_CLOCK
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 110, tmp);
#else
display.setTextSize(2);
display.drawTextCentered(display.width() / 2, 43, tmp);
#endif
if (_node_prefs->ui_show_clock) {
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 110, tmp);
} else {
display.setTextSize(2);
display.drawTextCentered(display.width() / 2, 43, tmp);
}
}
} else if (_page == HomePage::RECENT) {
the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE);
@@ -365,6 +371,7 @@ public:
display.setCursor(0, 53);
sprintf(tmp, "Noise floor: %d", radio_driver.getNoiseFloor());
display.print(tmp);
#ifdef BLE_PIN_CODE
} else if (_page == HomePage::BLUETOOTH) {
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 18,
@@ -373,6 +380,7 @@ public:
display.setColor(UIColor::secondary_txt);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 64 - 11, "toggle: " PRESS_LABEL);
#endif
} else if (_page == HomePage::ADVERT) {
display.setColor(UIColor::corp_blue);
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
@@ -508,7 +516,7 @@ public:
for (int i = 0; i < count; i++, y += 11) {
char name[32];
auto a = &discovered[i];
if ((a->name[0] == 0) || !discovery_disp_names) {
if ((a->name[0] == 0) || !_node_prefs->ui_nd_name) {
mesh::Utils::toHex(name, a->pubkey_prefix, 4);
} else {
strncpy(name, a->name, 32);
@@ -568,6 +576,7 @@ public:
#endif
return true;
}
#ifdef BLE_PIN_CODE
if (c == KEY_ENTER && _page == HomePage::BLUETOOTH) {
if (_task->isBluetoothEnabled()) { // toggle Bluetooth on/off
_task->disableBluetooth();
@@ -576,6 +585,7 @@ public:
}
return true;
}
#endif
if (c == KEY_ENTER && _page == HomePage::ADVERT) {
_task->notify(UIEventType::ack);
if (the_mesh.advert()) {
@@ -606,7 +616,7 @@ public:
return true;
}
if (c == KEY_SELECT && _page == HomePage::DISCOVERY) {
discovery_disp_names = !discovery_disp_names;
_node_prefs->ui_nd_name = !_node_prefs->ui_nd_name;
return true;
}
#endif
@@ -690,11 +700,7 @@ public:
display.translateUTF8ToBlocks(filtered_msg, p->msg, sizeof(filtered_msg));
display.printWordWrap(filtered_msg, display.width());
#if AUTO_OFF_MILLIS==0 // probably e-ink
return 10000; // 10 s
#else
return 1000; // next render after 1000 ms
#endif
return display.isEink() ? 10000 : 1000; // 10 s for eink
}
bool handleInput(char c) override {
@@ -718,7 +724,6 @@ public:
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
_display = display;
_sensors = sensors;
_auto_off = millis() + AUTO_OFF_MILLIS;
#if defined(PIN_USER_BTN)
user_btn.begin();
@@ -726,11 +731,16 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
#if defined(PIN_USER_BTN_ANA)
analog_btn.begin();
#endif
#if defined(BACKLIGHT_BTN)
backlight_btn.begin();
#endif
_node_prefs = node_prefs;
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000;
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
if (_display != NULL) {
_display->turnOn();
_display->turnOn(_node_prefs->ui_max_partial);
}
#ifdef PIN_BUZZER
@@ -796,11 +806,14 @@ void UITask::onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t t
if (_display != NULL) {
if (!_display->isOn() && !hasConnection()) {
_display->turnOn();
_display->turnOn(_node_prefs->ui_max_partial);
}
if (_display->isOn()) {
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
_next_refresh = 100; // trigger refresh
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend the auto-off timer
_next_refresh = 100; // trigger refresh
if (_node_prefs->ui_backlight_on_msgs) {
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
}
}
}
@@ -816,10 +829,10 @@ void UITask::onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_det
if (_display != NULL) {
if (!_display->isOn() && !hasConnection()) {
_display->turnOn();
_display->turnOn(_node_prefs->ui_max_partial);
}
if (_display->isOn()) {
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend the auto-off timer
_next_refresh = 100; // trigger refresh
}
}
@@ -897,9 +910,9 @@ void UITask::shutdown(bool restart){
if (restart) {
_board->reboot();
} else {
display.forceFullRefresh();
display.clear();
display.endFrame();
if (_display->isEink()) {
_display->turnOff(true);
}
// Power off board including radio, display, GPS and components
_board->powerOff();
}
@@ -944,7 +957,7 @@ void UITask::loop() {
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_ENTER);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
display.turnOff();
display.turnOff(true);
} else if (ev == BUTTON_EVENT_DOUBLE_CLICK) {
c = handleDoubleClick(KEY_SELECT);
} else if (ev == BUTTON_EVENT_TRIPLE_CLICK) {
@@ -964,11 +977,11 @@ void UITask::loop() {
#endif
#if defined(UI_HAS_ROTARY_INPUT)
RotaryInputEvent rotaryEv = rotary_input.poll();
if (c == 0 && _display != NULL && _display->isOn()) {
if (c == 0 && _display != NULL) {
if (rotaryEv == RotaryInputEvent::Next) {
c = KEY_NEXT;
c = checkDisplayOn(KEY_NEXT);
} else if (rotaryEv == RotaryInputEvent::Prev) {
c = KEY_PREV;
c = checkDisplayOn(KEY_PREV);
}
}
#endif
@@ -987,27 +1000,59 @@ void UITask::loop() {
_analogue_pin_read_millis = millis();
}
#endif
#if defined(DISP_BACKLIGHT) || defined(EXP_PIN_BACKLIGHT)
#if defined(BACKLIGHT_BTN)
if (millis() > next_backlight_btn_check) {
bool touch_state = digitalRead(PIN_BUTTON2);
#if defined(DISP_BACKLIGHT)
digitalWrite(DISP_BACKLIGHT, !touch_state);
#elif defined(EXP_PIN_BACKLIGHT)
expander.digitalWrite(EXP_PIN_BACKLIGHT, !touch_state);
#endif
next_backlight_btn_check = millis() + 300;
if (backlight_btn.isPressed()) {
if (!_display->isOn()) {
_display->turnOn(_node_prefs->ui_max_partial);
_next_refresh = 0;
}
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000; // extend auto_off for backlight
}
next_backlight_btn_check = millis() + 100;
}
int bev = backlight_btn.check();
if (bev == BUTTON_EVENT_DOUBLE_CLICK) {
_display->forceFullRefresh();
} else if (bev == BUTTON_EVENT_TRIPLE_CLICK) {
_display->turnOff(true);
_backlight_off = 0;
}
#endif
bool backlight_state;
if (_node_prefs->ui_backlight_delay == -1) {
backlight_state = true;
} else if (_node_prefs->ui_backlight_delay < -1) {
backlight_state = false;
} else if (_node_prefs->ui_backlight_delay == 0) {
backlight_state = false;
#ifdef BACKLIGHT_BTN
backlight_state = backlight_btn.isPressed();
#endif
} else {
backlight_state = (millis() < _backlight_off);
}
#if defined(DISP_BACKLIGHT)
digitalWrite(DISP_BACKLIGHT, backlight_state);
#elif defined(EXP_PIN_BACKLIGHT)
expander.digitalWrite(EXP_PIN_BACKLIGHT, backlight_state);
#endif
#endif
if (c != 0 && curr) {
curr->handleInput(c);
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
_next_refresh = 100; // trigger refresh
}
userLedHandler();
#ifdef PIN_BUZZER
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
if (buzzer.isPlaying()) buzzer.loop();
#endif
@@ -1032,20 +1077,27 @@ void UITask::loop() {
}
_display->endFrame();
}
#if AUTO_OFF_MILLIS > 0
if (_node_prefs->ui_auto_off_delay > 0) {
#ifdef KEEP_DISPLAY_ON_USB
// Opt-in: refresh the auto-off deadline while externally powered, so the
// timer counts from the moment external power is removed. Off by default
// because OLED panels burn in quickly; only enable for LCD targets or
// where the display is replaceable.
if (board.isExternalPowered()) {
_auto_off = millis() + AUTO_OFF_MILLIS;
}
// Opt-in: refresh the auto-off deadline while externally powered, so the
// timer counts from the moment external power is removed. Off by default
// because OLED panels burn in quickly; only enable for LCD targets or
// where the display is replaceable.
if (board.isExternalPowered()) {
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000;
}
#endif
if (millis() > _auto_off) {
_display->turnOff();
if (millis() > _auto_off) {
if (_node_prefs->ui_auto_off_blank &&
!(_node_prefs->ui_auto_off_keep_msgs
&& curr == msg_preview)) {
// don't blank if messages are waiting
_display->turnOff(true);
} else {
_display->turnOff();
}
}
}
#endif
}
#ifdef PIN_VIBRATION
@@ -1077,10 +1129,13 @@ void UITask::loop() {
char UITask::checkDisplayOn(char c) {
if (_display != NULL) {
if (!_display->isOn()) {
_display->turnOn(); // turn display on and consume event
_display->turnOn(_node_prefs->ui_max_partial); // turn display on and consume event
c = 0;
}
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
_auto_off = millis() + _node_prefs->ui_auto_off_delay * 1000; // extend auto-off timer
if (_node_prefs->ui_backlight_on_keys) {
_backlight_off = millis() + _node_prefs->ui_backlight_delay * 1000;
}
_next_refresh = 0; // trigger refresh
}
return c;
+2 -1
View File
@@ -61,7 +61,8 @@ class UITask : public AbstractUITask {
unsigned long _alert_expiry;
int _msgcount;
unsigned long ui_started_at, next_batt_chck;
int next_backlight_btn_check = 0;
unsigned long next_backlight_btn_check = 0;
unsigned long _backlight_off = 0;
#ifdef PIN_STATUS_LED
int led_state = 0;
int next_led_change = 0;
@@ -485,6 +485,7 @@ void UITask::loop() {
userLedHandler();
#ifdef PIN_BUZZER
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
if (buzzer.isPlaying()) buzzer.loop();
#endif
@@ -691,6 +691,7 @@ void UITask::loop() {
userLedHandler();
#ifdef PIN_BUZZER
if (buzzer.isQuiet() != (bool)_node_prefs->buzzer_quiet) buzzer.quiet(_node_prefs->buzzer_quiet);
if (buzzer.isPlaying()) buzzer.loop();
#endif
+3 -2
View File
@@ -229,8 +229,8 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
stats.n_recv_direct = getNumRecvDirect();
stats.err_events = _err_flags;
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
stats.n_direct_dups = std::min<uint32_t>(((SimpleMeshTables *)getTables())->getNumDirectDups(), 0xFFFF);
stats.n_flood_dups = std::min<uint32_t>(((SimpleMeshTables *)getTables())->getNumFloodDups(), 0xFFFF);
stats.total_rx_air_time_secs = getReceiveAirTime() / 1000;
stats.n_recv_errors = radio_driver.getPacketsRecvErrors();
memcpy(&reply_data[4], &stats, sizeof(stats));
@@ -790,6 +790,7 @@ void MyMesh::onControlDataRecv(mesh::Packet* packet) {
uint8_t type = packet->payload[0] & 0xF0; // just test upper 4 bits
if (type == CTL_TYPE_NODE_DISCOVER_REQ && packet->payload_len >= 6
&& !_prefs.disable_fwd && discover_limiter.allow(rtc_clock.getCurrentTime())
&& !isHiddenNode() // this node wishes to NOT be discoverable
) {
int i = 1;
uint8_t filter = packet->payload[i++];
+5 -2
View File
@@ -67,11 +67,11 @@ struct NeighbourInfo {
};
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "14 Aug 2026"
#define FIRMWARE_BUILD_DATE "15 Oct 2026"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.17.1"
#define FIRMWARE_VERSION "v1.18.0"
#endif
#define FIRMWARE_ROLE "repeater"
@@ -187,6 +187,9 @@ public:
NodePrefs* getNodePrefs() {
return &_prefs;
}
bool isHiddenNode() const {
return _prefs.advert_interval == 0 && _prefs.flood_advert_interval == 0;
}
void savePrefs() override {
_cli.savePrefs(_fs);
+5 -2
View File
@@ -1,4 +1,5 @@
#include "MyMesh.h"
#include <algorithm>
#define REPLY_DELAY_MILLIS 1500
#define PUSH_NOTIFY_DELAY_MILLIS 2000
@@ -170,8 +171,8 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
stats.n_recv_direct = getNumRecvDirect();
stats.err_events = _err_flags;
stats.last_snr = (int16_t)(radio_driver.getLastSNR() * 4);
stats.n_direct_dups = ((SimpleMeshTables *)getTables())->getNumDirectDups();
stats.n_flood_dups = ((SimpleMeshTables *)getTables())->getNumFloodDups();
stats.n_direct_dups = std::min<uint32_t>(((SimpleMeshTables *)getTables())->getNumDirectDups(), 0xFFFF);
stats.n_flood_dups = std::min<uint32_t>(((SimpleMeshTables *)getTables())->getNumFloodDups(), 0xFFFF);
stats.n_posted = _num_posted;
stats.n_post_push = _num_post_pushes;
@@ -983,6 +984,8 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
addSystemPost(msg);
snprintf(reply, MAX_POST_TEXT_LEN, "OK");
}
} else if (memcmp(command, "set repeat on", 13) == 0) {
strcpy(reply, "ERR - repeat now deprecated");
} else{
_cli.handleCommand(sender_timestamp, command, reply); // common CLI commands
}
+2 -2
View File
@@ -28,11 +28,11 @@
/* ------------------------------ Config -------------------------------- */
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "14 Aug 2026"
#define FIRMWARE_BUILD_DATE "15 Oct 2026"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.17.1"
#define FIRMWARE_VERSION "v1.18.0"
#endif
#ifndef LORA_FREQ
+3 -3
View File
@@ -34,16 +34,16 @@
#define PERM_RECV_ALERTS_HI (1 << 7) // high priority alerts
#ifndef FIRMWARE_BUILD_DATE
#define FIRMWARE_BUILD_DATE "14 Aug 2026"
#define FIRMWARE_BUILD_DATE "15 Oct 2026"
#endif
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "v1.17.1"
#define FIRMWARE_VERSION "v1.18.0"
#endif
#define FIRMWARE_ROLE "sensor"
#define MAX_SEARCH_RESULTS 8
#define MAX_SEARCH_RESULTS 24
#define MAX_CONCURRENT_ALERTS 4
class SensorMesh : public mesh::Mesh, public CommonCLICallbacks {