Merge remote-tracking branch 'origin/dev'

This commit is contained in:
tth committed 2026-10-28 20:29:38 +01:00
commit 790cf23466
25 files changed
+293 -93

No files matched your search

+2 -2
View File
@@ -102,8 +102,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; }
+2 -2
View File
@@ -493,8 +493,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();
stats.n_tx_start_fail = getNumTxStartFail(); // CUSTOM (TeTeHacko)
+3 -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;
+1 -2
View File
@@ -42,8 +42,7 @@ monitor_speed = 115200
lib_deps =
SPI
Wire
;jgromes/RadioLib @ ^7.7.1
https://github.com/jgromes/RadioLib.git#6d8934836678d8894e3d556550475b37dce3e2b6
jgromes/RadioLib @ 7.8.1
rweather/Crypto @ ^0.4.0
adafruit/RTClib @ ^2.1.3
melopero/Melopero RV3028 @ ^1.1.0
+9 -1
View File
@@ -133,6 +133,7 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
ContactInfo* from = NULL;
for (int i = 0; i < num_contacts; i++) {
if (contacts[i].isEmptySlot()) continue;
if (id.matches(contacts[i].id)) { // is from one of our contacts
from = &contacts[i];
if (timestamp <= from->last_advert_timestamp) { // check for replay attacks!!
@@ -208,6 +209,11 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
int BaseChatMesh::searchPeersByHash(const uint8_t* hash) {
int n = 0;
for (int i = 0; i < num_contacts && n < MAX_SEARCH_RESULTS; i++) {
// Skip empty/unconfigured anon slots. An empty slot has an all-zero pub_key
// (an order-4 Edwards25519 point whose clamped X25519 key exchange yields an
// all-zero shared secret for any private key) and would otherwise match
// src_hash == 0x00 as a null-key peer sink while consuming search slots.
if (contacts[i].isEmptySlot()) continue;
if (contacts[i].id.isHashMatch(hash)) {
matching_peer_indexes[n++] = i; // store the INDEXES of matching contacts (for subsequent 'peer' methods)
}
@@ -876,6 +882,7 @@ ContactInfo* BaseChatMesh::searchContactsByPrefix(const char* name_prefix) {
int len = strlen(name_prefix);
for (int i = 0; i < num_contacts; i++) {
auto c = &contacts[i];
if (c->isEmptySlot() || c->name[0] == 0) continue;
if (memcmp(c->name, name_prefix, len) == 0) return c;
}
return NULL; // not found
@@ -884,6 +891,7 @@ ContactInfo* BaseChatMesh::searchContactsByPrefix(const char* name_prefix) {
ContactInfo* BaseChatMesh::lookupContactByPubKey(const uint8_t* pub_key, int prefix_len) {
for (int i = 0; i < num_contacts; i++) {
auto c = &contacts[i];
if (c->isEmptySlot()) continue;
if (memcmp(c->id.pub_key, pub_key, prefix_len) == 0) return c;
}
return NULL; // not found
@@ -901,7 +909,7 @@ bool BaseChatMesh::addContact(const ContactInfo& contact) {
bool BaseChatMesh::removeContact(ContactInfo& contact) {
int idx = 0;
while (idx < num_contacts && !contacts[idx].id.matches(contact.id)) {
while (idx < num_contacts && (contacts[idx].isEmptySlot() || !contacts[idx].id.matches(contact.id))) {
idx++;
}
if (idx >= num_contacts) return false; // not found
+2 -2
View File
@@ -132,8 +132,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; }
+2 -2
View File
@@ -35,8 +35,8 @@ public:
virtual uint8_t getRxGain() const = 0;
virtual void setRxGain(uint8_t g) = 0;
virtual uint8_t getTxPower() const = 0;
virtual void setTxPower(uint8_t dbm) = 0;
virtual int8_t getTxPower() const = 0;
virtual void setTxPower(int8_t dbm) = 0;
virtual float getRxDelay() const = 0;
virtual void setRxDelay(float d) = 0;
+6
View File
@@ -31,6 +31,12 @@ struct ContactInfo {
bool isTelemLocAllowed() const { return flags & 0x04; }
bool isTelemEnvAllowed() const { return flags & 0x08; }
bool isRemoteCLIAllowed() const { return flags & 0x10; }
bool isEmptySlot() const {
for (int i = 0; i < PUB_KEY_SIZE; i++) {
if (id.pub_key[i] != 0) return false;
}
return true;
}
private:
mutable uint8_t shared_secret[PUB_KEY_SIZE];
+4
View File
@@ -3,6 +3,10 @@
#include "ESP32Board.h"
#include <target.h>
// The RTC backup of ESP32RTCClock, declared in ESP32Board.h.
RTC_NOINIT_ATTR uint32_t _rtc_backup_time;
RTC_NOINIT_ATTR uint32_t _rtc_backup_magic;
#if defined(ADMIN_PASSWORD) && !defined(DISABLE_WIFI_OTA) // Repeater or Room Server only
#include <WiFi.h>
#include <AsyncTCP.h>
+5 -2
View File
@@ -200,8 +200,11 @@ public:
}
};
static RTC_NOINIT_ATTR uint32_t _rtc_backup_time;
static RTC_NOINIT_ATTR uint32_t _rtc_backup_magic;
// The time ESP32RTCClock restores after a reset, in RTC memory that a reset does
// not clear. Defined once, in ESP32Board.cpp: the inline members below run in
// every translation unit that uses them and must all see the same backup.
extern uint32_t _rtc_backup_time;
extern uint32_t _rtc_backup_magic;
#define RTC_BACKUP_MAGIC 0xAA55CC33
#define RTC_TIME_MIN 1772323200 // 1 Mar 2026
+15 -7
View File
@@ -16,15 +16,23 @@ public:
CustomLR2021Wrapper(CustomLR2021& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
((CustomLR2021 *)_radio)->setFrequency(freq);
((CustomLR2021 *)_radio)->setSpreadingFactor(sf);
((CustomLR2021 *)_radio)->setBandwidth(bw);
((CustomLR2021 *)_radio)->setCodingRate(cr);
auto r = (CustomLR2021 *)_radio;
// LR2021 only accepts RF/modulation config commands while in STANDBY mode.
// Re-configuring while in continuous RX gets silently rejected (-706),
// which broke hot frequency changes over BLE.
int16_t status = r->standby();
if (status != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: standby() -> %d", status); }
if ((status = r->setFrequency(freq)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setFrequency() -> %d", status); }
if ((status = r->setSpreadingFactor(sf)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setSpreadingFactor() -> %d", status); }
if ((status = r->setBandwidth(bw)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setBandwidth() -> %d", status); }
if ((status = r->setCodingRate(cr)) != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: setCodingRate() -> %d", status); }
updatePreamble(sf);
applySideDetectorConfig();
// internal idle() sets STATE_IDLE, which triggers a startReceive() on the next loop
status = applySideDetectorConfig();
if (status != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("CustomLR2021Wrapper: applySideDetectorConfig() -> %d", status); }
PacketMillis pm = calcMaxPacketMillis(sf, bw, cr, preambleLengthForSF(sf));
((CustomLR2021 *)_radio)->setPreambleMillis(pm.preambleMillis);
((CustomLR2021 *)_radio)->setMaxPayloadMillis(pm.payloadMillis);
r->setPreambleMillis(pm.preambleMillis); // pure in-memory setters, no standby needed
r->setMaxPayloadMillis(pm.payloadMillis);
}
@@ -0,0 +1,230 @@
#include <gtest/gtest.h>
#include <cstring>
#include <ed_25519.h>
#include "Dispatcher.cpp"
#include "Mesh.cpp"
#include "helpers/AdvertDataHelpers.cpp"
#include "helpers/BaseChatMesh.cpp"
void StrHelper::strncpy(char* dest, const char* src, size_t buf_sz) {
if (buf_sz == 0) return;
std::strncpy(dest, src, buf_sz - 1);
dest[buf_sz - 1] = 0;
}
namespace mesh {
Identity::Identity() {
memset(pub_key, 0, sizeof(pub_key));
}
bool Identity::verify(const uint8_t*, const uint8_t*, int) const {
return true;
}
LocalIdentity::LocalIdentity() : Identity() {
memset(prv_key, 0, sizeof(prv_key));
}
void LocalIdentity::sign(uint8_t* sig, const uint8_t*, int) const {
memset(sig, 0, SIGNATURE_SIZE);
}
void LocalIdentity::calcSharedSecret(uint8_t* secret, const uint8_t* other_pub_key) const {
ed25519_key_exchange(secret, other_pub_key, prv_key);
}
} // namespace mesh
namespace {
class DummyRadio : public mesh::Radio {
public:
int recvRaw(uint8_t*, int) override { return 0; }
uint32_t getEstAirtimeFor(int) override { return 10; }
float packetScore(float, int) override { return 1.0f; }
bool startSendRaw(const uint8_t*, int) override { return true; }
bool isSendComplete() override { return true; }
void onSendFinished() override {}
bool isInRecvMode() const override { return true; }
};
class DummyMillisecondClock : public mesh::MillisecondClock {
public:
unsigned long getMillis() override { return 1000; }
};
class DummyRNG : public mesh::RNG {
public:
void random(uint8_t* dest, size_t len) override { memset(dest, 0x42, len); }
};
class DummyRTCClock : public mesh::RTCClock {
uint32_t _now = 1700000000;
public:
uint32_t getCurrentTime() override { return _now; }
void setCurrentTime(uint32_t time) override { _now = time; }
};
class DummyPacketManager : public mesh::PacketManager {
public:
mesh::Packet* allocNew() override { return nullptr; }
void free(mesh::Packet*) override {}
void queueOutbound(mesh::Packet*, uint8_t, uint32_t) override {}
mesh::Packet* getNextOutbound(uint32_t) override { return nullptr; }
int getOutboundCount(uint32_t) const override { return 0; }
int getOutboundTotal() const override { return 0; }
int getFreeCount() const override { return 16; }
mesh::Packet* getOutboundByIdx(int) override { return nullptr; }
mesh::Packet* removeOutboundByIdx(int) override { return nullptr; }
void queueInbound(mesh::Packet*, uint32_t) override {}
mesh::Packet* getNextInbound(uint32_t) override { return nullptr; }
};
class DummyMeshTables : public mesh::MeshTables {
public:
bool wasSeen(const mesh::Packet*) override { return false; }
void markSeen(const mesh::Packet*) override {}
void clear(const mesh::Packet*) override {}
};
class TestChatMesh : public BaseChatMesh {
public:
int messages_received = 0;
TestChatMesh(mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng,
mesh::RTCClock& rtc, mesh::PacketManager& mgr, mesh::MeshTables& tables)
: BaseChatMesh(radio, ms, rng, rtc, mgr, tables) {}
void onDiscoveredContact(ContactInfo&, bool, uint8_t, const uint8_t*) override {}
ContactInfo* processAck(const uint8_t*) override { return nullptr; }
void onContactPathUpdated(const ContactInfo&) override {}
void onMessageRecv(const ContactInfo&, mesh::Packet*, uint32_t, const char*) override {
messages_received++;
}
void onCommandDataRecv(const ContactInfo&, mesh::Packet*, uint32_t, const char*) override {}
void onCLICommandRecv(const ContactInfo&, mesh::Packet*, uint32_t, const char*, char*) override {}
void onSignedMessageRecv(const ContactInfo&, mesh::Packet*, uint32_t, const uint8_t*, const char*) override {}
void onChannelMessageRecv(const mesh::GroupChannel&, mesh::Packet*, uint32_t, const char*) override {}
uint8_t onContactRequest(const ContactInfo&, uint32_t, const uint8_t*, uint8_t, uint8_t*) override { return 0; }
void onContactResponse(const ContactInfo&, const uint8_t*, uint8_t) override {}
uint32_t calcFloodTimeoutMillisFor(uint32_t) const override { return 1000; }
uint32_t calcDirectTimeoutMillisFor(uint32_t, uint8_t) const override { return 1000; }
void onSendTimeout() override {}
using BaseChatMesh::resetContacts;
using BaseChatMesh::searchPeersByHash;
using BaseChatMesh::getPeerSharedSecret;
using mesh::Mesh::onRecvPacket;
};
struct MeshFixture {
DummyRadio radio;
DummyMillisecondClock ms;
DummyRNG rng;
DummyRTCClock rtc;
DummyPacketManager mgr;
DummyMeshTables tables;
TestChatMesh chat{radio, ms, rng, rtc, mgr, tables};
};
} // namespace
TEST(EmptyContactSlots, ZeroPubKeyProducesAllZeroSharedSecretForAnyPrivateKey) {
ContactInfo empty_slot;
memset(&empty_slot, 0, sizeof(empty_slot));
EXPECT_TRUE(empty_slot.isEmptySlot());
uint8_t raw_prv[PRV_KEY_SIZE];
for (int i = 0; i < PRV_KEY_SIZE; i++) {
raw_prv[i] = static_cast<uint8_t>(0xA5 ^ (i * 13 + 7));
}
uint8_t secret[PUB_KEY_SIZE];
ed25519_key_exchange(secret, empty_slot.id.pub_key, raw_prv);
uint8_t expected_zeroes[PUB_KEY_SIZE] = { 0 };
EXPECT_EQ(0, memcmp(secret, expected_zeroes, PUB_KEY_SIZE));
}
TEST(EmptyContactSlots, NullKeyPeerPacketIsRejectedWhenAnonSlotsAreEmpty) {
MeshFixture fx;
fx.chat.self_id.pub_key[0] = 0x42;
// Craft a PAYLOAD_TYPE_TXT_MSG addressed to self_id (dest_hash=0x42) with src_hash=0x00,
// encrypted and MAC'd under the all-zero 32-byte key that an empty ContactInfo slot derives.
uint8_t zero_secret[PUB_KEY_SIZE] = { 0 };
uint8_t plaintext[16] = { 0 };
uint32_t ts = 1700000001;
memcpy(plaintext, &ts, 4);
plaintext[4] = (TXT_TYPE_PLAIN << 2);
strcpy(reinterpret_cast<char*>(&plaintext[5]), "forged");
mesh::Packet pkt;
pkt.header = ROUTE_TYPE_FLOOD | (PAYLOAD_TYPE_TXT_MSG << PH_TYPE_SHIFT);
pkt.path_len = 0;
pkt.payload[0] = 0x42; // dest_hash (matches fx.chat.self_id)
pkt.payload[1] = 0x00; // src_hash (matches all-zero pub_key if empty slots are not skipped)
int enc_len = mesh::Utils::encryptThenMAC(zero_secret, &pkt.payload[2], plaintext, 12);
pkt.payload_len = static_cast<uint8_t>(2 + enc_len);
fx.chat.onRecvPacket(&pkt);
EXPECT_EQ(0, fx.chat.messages_received);
}
TEST(EmptyContactSlots, SearchPeersByHashSkipsEmptyAnonSlotsAndFindsRealZeroPrefixPeer) {
MeshFixture fx;
const uint8_t zero_hash = 0x00;
// Freshly reset contacts has MAX_ANON_CONTACTS (8) zeroed transient slots.
EXPECT_EQ(0, fx.chat.searchPeersByHash(&zero_hash));
// Add a legitimate permanent contact whose public key starts with 0x00.
ContactInfo peer;
memset(&peer, 0, sizeof(peer));
peer.type = ADV_TYPE_CHAT;
peer.lastmod = 1700000100;
strcpy(peer.name, "Alice");
peer.id.pub_key[0] = 0x00;
for (int i = 1; i < PUB_KEY_SIZE; i++) {
peer.id.pub_key[i] = static_cast<uint8_t>(i);
}
ASSERT_TRUE(fx.chat.addContact(peer));
// Only the populated contact at index MAX_ANON_CONTACTS should match.
EXPECT_EQ(1, fx.chat.searchPeersByHash(&zero_hash));
// Lookup by pubkey and name prefix must also skip the empty transient slots.
uint8_t zero_prefix[6] = { 0 };
EXPECT_EQ(nullptr, fx.chat.lookupContactByPubKey(zero_prefix, sizeof(zero_prefix)));
ContactInfo* found = fx.chat.lookupContactByPubKey(peer.id.pub_key, 6);
ASSERT_NE(nullptr, found);
EXPECT_STREQ("Alice", found->name);
ContactInfo* by_name = fx.chat.searchContactsByPrefix("");
ASSERT_NE(nullptr, by_name);
EXPECT_STREQ("Alice", by_name->name);
}
TEST(EmptyContactSlots, PopulatedTransientAnonSlotStillMatchesEvenWhenLastmodIsZero) {
MeshFixture fx;
const uint8_t zero_hash = 0x00;
ContactInfo anon;
memset(&anon, 0, sizeof(anon));
anon.type = ADV_TYPE_NONE;
anon.lastmod = 0; // e.g. RTC not yet initialised on nRF52
anon.id.pub_key[0] = 0x00;
anon.id.pub_key[1] = 0x7F;
ASSERT_TRUE(fx.chat.addContact(anon));
EXPECT_FALSE(anon.isEmptySlot());
EXPECT_EQ(1, fx.chat.searchPeersByHash(&zero_hash));
EXPECT_NE(nullptr, fx.chat.lookupContactByPubKey(anon.id.pub_key, PUB_KEY_SIZE));
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+5
View File
@@ -32,6 +32,11 @@ build_flags = ${nrf52_base.build_flags}
-D PIN_GPS_RESET_ACTIVE=LOW
-D TELEM_BME280_ADDRESS=0x77
-D DISPLAY_CLASS=GxEPDDisplay
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
-D EINK_SCALE_X=1.5625f
-D EINK_SCALE_Y=1.5625f
-D EINK_X_OFFSET=0
-D EINK_Y_OFFSET=10
-D EINK_SCREENOFF_BLANK
-D UI_RECENT_LIST_SIZE=9
-D UI_MSG_PREVIEW_SIZE=165
+6
View File
@@ -131,6 +131,12 @@ extern const int SCK;
#define DISP_BUSY (3)
#define DISP_BACKLIGHT (43)
// used by GxEPDDisplay when EINK_DISPLAY_MODEL is set
#define PIN_DISPLAY_CS DISP_CS
#define PIN_DISPLAY_DC DISP_DC
#define PIN_DISPLAY_RST DISP_RST
#define PIN_DISPLAY_BUSY DISP_BUSY
////////////////////////////////////////////////////////////////////////////////
// GPS
@@ -5,7 +5,6 @@
void MeshTrackerX1Board::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = LOW; // button is active HIGH
#ifdef BUTTON_PIN
pinMode(BATTERY_PIN, INPUT);
@@ -5,9 +5,6 @@
#include <helpers/NRF52Board.h>
class MeshTrackerX1Board : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
MeshTrackerX1Board() : NRF52Board("X1_OTA") {}
void begin();
@@ -35,17 +32,6 @@ public:
return "Seeed SenseCAP MeshTracker X1";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
-1
View File
@@ -5,7 +5,6 @@
void PromicroBoard::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
pinMode(PIN_VBAT_READ, INPUT);
-12
View File
@@ -9,7 +9,6 @@
class PromicroBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
float adc_mult = ADC_MULTIPLIER;
public:
@@ -48,15 +47,4 @@ public:
const char* getManufacturerName() const override {
return "ProMicro DIY";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
};
-1
View File
@@ -5,7 +5,6 @@
void T1000eBoard::begin() {
NRF52BoardDCDC::begin();
btn_prev_state = HIGH;
#ifdef BUTTON_PIN
pinMode(BATTERY_PIN, INPUT);
-14
View File
@@ -5,9 +5,6 @@
#include <helpers/NRF52Board.h>
class T1000eBoard : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
T1000eBoard() : NRF52Board("T1000E_OTA") {}
void begin();
@@ -38,17 +35,6 @@ public:
return "Seeed Tracker T1000-E";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
#ifdef HAS_GPS
digitalWrite(GPS_VRTC_EN, LOW);
@@ -6,7 +6,6 @@
void ThinkNodeM3Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
-12
View File
@@ -11,7 +11,6 @@ protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
public:
ThinkNodeM3Board() : NRF52Board("THINKNODE_M3_OTA") {}
@@ -31,17 +30,6 @@ public:
return "Elecrow ThinkNode M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
// turn off all leds, sd_power_system_off will not do this for us
digitalWrite(PIN_LED_BLUE, !LED_STATE_ON);
@@ -6,7 +6,6 @@
void ThinkNodeM4Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
battery_serial->begin(4800);
-12
View File
@@ -9,7 +9,6 @@ protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
HardwareSerial * battery_serial;
uint16_t bat_level_mv = 0;
uint8_t bat_level_percent =0;
@@ -32,17 +31,6 @@ public:
return "Elecrow ThinkNode M4";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == USER_BTN_PRESSED) ? 1 : -1;
}
#endif
return 0;
}
void shutdownPeripherals() override {
// shutdown common peripherals
NRF52Board::shutdownPeripherals();
+1 -2
View File
@@ -44,6 +44,7 @@ build_flags = ${nrf52_base.build_flags}
-D LORA_TX_POWER=22
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<ThinkNodeM8Board.cpp>
+<../variants/thinknode_m8>
lib_deps =
@@ -111,7 +112,6 @@ build_src_filter = ${ThinkNode_M8.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/RotaryInputGPIO.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
@@ -143,7 +143,6 @@ build_src_filter = ${ThinkNode_M8.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/ui/RotaryInputGPIO.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =