Compare commits

..

21 Commits

Author SHA1 Message Date
Matthias Wientapper
14c00ace72 Integration of upstrem PR #1297 2026-01-14 11:09:17 +01:00
Matthias Wientapper
e81ce6158e Integration of upstrem PR #1199 2026-01-14 11:07:25 +01:00
Matthias Wientapper
c9d6927d26 Add cli config flood.advert.base
0 = forwarding flood adverts off
1 = forwarding flood adverts on (unrestricted)
0.308 (default) = prob. forwarding according to #1338
2026-01-14 10:53:09 +01:00
Matthias Wientapper
0b947f9d1b Limit flood advert packet forwarding for roomservers as well 2026-01-14 10:51:04 +01:00
Matthias Wientapper
1798e44f01 Limit flood advert packet forwarding, implements #1223 2026-01-14 10:51:04 +01:00
Matthias Wientapper
4fd7aa6ce8 Merge branch 'dev' into meshcore-evo 2026-01-13 23:21:57 +01:00
Liam Cottle
4643f4d3a3 Merge pull request #1378 from recrof/ikoka-cleanup
cleanup ikoka variants and add all supported sensors
2026-01-13 17:21:24 +13:00
Liam Cottle
77257a376b Merge pull request #1377 from recrof/t3s3-sx1276-fix
FIX: remove serial debug logging from t3s3 sx1276 companion usb
2026-01-13 10:34:45 +13:00
Rastislav Vysoky
324eab9394 cleanup ikoka variants and add all supported sensors 2026-01-12 19:29:32 +01:00
Rastislav Vysoky
266e4893fd remove serial debug logging from t3s3 sx1276 companion usb 2026-01-12 19:19:23 +01:00
Scott Powell
bafbfaf2b5 Merge branch 'regions-request' into dev 2026-01-12 17:48:19 +11:00
Scott Powell
69a71d0e25 * repeater login response, FIRMWARE_VER_LEVEL now bumped to 2 2026-01-12 17:47:51 +11:00
Scott Powell
b6110eee38 * new req/resp (after login): REQ_TYPE_GET_OWNER_INFO (includes firmware-ver)
* ANON_REQ_TYPE_OWNER, firmware-ver removed (security exploit)
* ANON_REQ_TYPE_BASIC, formware-ver removed, just remote clock + some 'feature' bits
* CTL_TYPE_NODE_DISCOVER_REQ now ingored if 'repeat off' has been set
2026-01-12 16:58:35 +11:00
Scott Powell
4e4f6d92a0 * ANON_REQ_TYPE_VER_OWNER now delimited by newline chars 2026-01-09 16:32:08 +11:00
Scott Powell
65796c8f20 * CommonCLI: added "set name ..." validation
* ANON_REQ_TYPE_VER_OWNER, now removes commas from node_name
2026-01-09 16:28:08 +11:00
Scott Powell
fd69acb421 * new ANON_REQ_TYPE_VER (for just simple clock + ver info) 2026-01-09 13:54:18 +11:00
Scott Powell
2a035ad816 * ANON_REQ_TYPE_VER_OWNER, now includes node_name 2026-01-09 13:20:20 +11:00
Scott Powell
5475043083 * new ANON_REQ_TYPE_VER_OWNER
* CommonCLI: new "get/set owner.info ..."
2026-01-09 11:07:31 +11:00
Scott Powell
5cc44dd802 * ANON_REQ_TYPE_REGIONS now direct only, with reply_path encoded in request 2026-01-08 13:20:52 +11:00
Scott Powell
8d51126956 Merge branch 'dev' into regions-request 2026-01-08 00:21:08 +11:00
Scott Powell
3af25495bb * Repeater: new anon request sub-type: ANON_REQ_TYPE_REGIONS (rate limited to max 4 every 3 mins)
* Companion: new CMD_SEND_ANON_REQ command (reply with existing RESP_CODE_SENT frame)
2026-01-03 12:02:15 +11:00
21 changed files with 402 additions and 316 deletions

View File

@@ -103,7 +103,9 @@ Request type
| `0x02` | keepalive | (deprecated) |
| `0x03` | get telemetry data | TODO |
| `0x04` | get min,max,avg data | sensor nodes - get min, max, average for given time span |
| `0x05` | get access list | get node's approved access list |
| `0x05` | get access list | get node's approved access list |
| `0x06` | get neighbors | get repeater node's neighbors |
| `0x07` | get owner info | get repeater firmware-ver/name/owner info |
### Get stats
@@ -132,6 +134,27 @@ Gets information about the node, possibly including the following:
Request data about sensors on the node, including battery level.
### Get Telemetry
TODO
### Get Min/Max/Ave (Sensor nodes)
TODO
### Get Access List
TODO
### Get Neighors
TODO
### Get Owner Info
TODO
## Response
| Field | Size (bytes) | Description |
@@ -179,6 +202,34 @@ txt_type
| timestamp | 4 | sender time (unix timestamp) |
| password | rest of message | password for repeater/sensor |
## Repeater - Regions request
| Field | Size (bytes) | Description |
|----------------|-----------------|-------------------------------------------------------------------------------|
| timestamp | 4 | sender time (unix timestamp) |
| req type | 1 | 0x01 (request sub type) |
| reply path len | 1 | path len for reply |
| reply path | (variable) | reply path |
## Repeater - Owner info request
| Field | Size (bytes) | Description |
|----------------|-----------------|-------------------------------------------------------------------------------|
| timestamp | 4 | sender time (unix timestamp) |
| req type | 1 | 0x02 (request sub type) |
| reply path len | 1 | path len for reply |
| reply path | (variable) | reply path |
## Repeater - Clock and status request
| Field | Size (bytes) | Description |
|----------------|-----------------|-------------------------------------------------------------------------------|
| timestamp | 4 | sender time (unix timestamp) |
| req type | 1 | 0x03 (request sub type) |
| reply path len | 1 | path len for reply |
| reply path | (variable) | reply path |
# Group text message / datagram
| Field | Size (bytes) | Description |

View File

@@ -53,6 +53,7 @@
#define CMD_SET_FLOOD_SCOPE 54 // v8+
#define CMD_SEND_CONTROL_DATA 55 // v8+
#define CMD_GET_STATS 56 // v8+, second byte is stats type
#define CMD_SEND_ANON_REQ 57
// Stats sub-types for CMD_GET_STATS
#define STATS_TYPE_CORE 0
@@ -732,7 +733,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0;
_prefs.airtime_factor = 1.0; // one half
strcpy(_prefs.node_name, "NONAME");
_prefs.freq = LORA_FREQ;
_prefs.sf = LORA_SF;
@@ -1286,6 +1287,27 @@ void MyMesh::handleCmdFrame(size_t len) {
} else {
writeErrFrame(ERR_CODE_NOT_FOUND); // contact not found
}
} else if (cmd_frame[0] == CMD_SEND_ANON_REQ && len > 1 + PUB_KEY_SIZE) {
uint8_t *pub_key = &cmd_frame[1];
ContactInfo *recipient = lookupContactByPubKey(pub_key, PUB_KEY_SIZE);
uint8_t *data = &cmd_frame[1 + PUB_KEY_SIZE];
if (recipient) {
uint32_t tag, est_timeout;
int result = sendAnonReq(*recipient, data, len - (1 + PUB_KEY_SIZE), tag, est_timeout);
if (result == MSG_SEND_FAILED) {
writeErrFrame(ERR_CODE_TABLE_FULL);
} else {
clearPendingReqs();
pending_req = tag; // match this to onContactResponse()
out_frame[0] = RESP_CODE_SENT;
out_frame[1] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0;
memcpy(&out_frame[2], &tag, 4);
memcpy(&out_frame[6], &est_timeout, 4);
_serial->writeFrame(out_frame, 10);
}
} else {
writeErrFrame(ERR_CODE_NOT_FOUND); // contact not found
}
} else if (cmd_frame[0] == CMD_SEND_STATUS_REQ && len >= 1 + PUB_KEY_SIZE) {
uint8_t *pub_key = &cmd_frame[1];
ContactInfo *recipient = lookupContactByPubKey(pub_key, PUB_KEY_SIZE);

View File

@@ -41,16 +41,21 @@
#define TXT_ACK_DELAY 200
#endif
#define FIRMWARE_VER_LEVEL 1
#define FIRMWARE_VER_LEVEL 2
#define REQ_TYPE_GET_STATUS 0x01 // same as _GET_STATS
#define REQ_TYPE_KEEP_ALIVE 0x02
#define REQ_TYPE_GET_TELEMETRY_DATA 0x03
#define REQ_TYPE_GET_ACCESS_LIST 0x05
#define REQ_TYPE_GET_NEIGHBOURS 0x06
#define REQ_TYPE_GET_OWNER_INFO 0x07 // FIRMWARE_VER_LEVEL >= 2
#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
#define ANON_REQ_TYPE_REGIONS 0x01
#define ANON_REQ_TYPE_OWNER 0x02
#define ANON_REQ_TYPE_BASIC 0x03 // just remote clock
#define CLI_REPLY_DELAY_MILLIS 600
#define LAZY_CONTACTS_WRITE_DELAY 5000
@@ -139,6 +144,64 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
return 13; // reply length
}
uint8_t MyMesh::handleAnonRegionsReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
// request data has: {reply-path-len}{reply-path}
reply_path_len = *data++ & 0x3F;
memcpy(reply_path, data, reply_path_len);
// data += reply_path_len;
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
uint32_t now = getRTCClock()->getCurrentTime();
memcpy(&reply_data[4], &now, 4); // include our clock (for easy clock sync, and packet hash uniqueness)
return 8 + region_map.exportNamesTo((char *) &reply_data[8], sizeof(reply_data) - 12, REGION_DENY_FLOOD); // reply length
}
return 0;
}
uint8_t MyMesh::handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
// request data has: {reply-path-len}{reply-path}
reply_path_len = *data++ & 0x3F;
memcpy(reply_path, data, reply_path_len);
// data += reply_path_len;
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
uint32_t now = getRTCClock()->getCurrentTime();
memcpy(&reply_data[4], &now, 4); // include our clock (for easy clock sync, and packet hash uniqueness)
sprintf((char *) &reply_data[8], "%s\n%s", _prefs.node_name, _prefs.owner_info);
return 8 + strlen((char *) &reply_data[8]); // reply length
}
return 0;
}
uint8_t MyMesh::handleAnonClockReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data) {
if (anon_limiter.allow(rtc_clock.getCurrentTime())) {
// request data has: {reply-path-len}{reply-path}
reply_path_len = *data++ & 0x3F;
memcpy(reply_path, data, reply_path_len);
// data += reply_path_len;
memcpy(reply_data, &sender_timestamp, 4); // prefix with sender_timestamp, like a tag
uint32_t now = getRTCClock()->getCurrentTime();
memcpy(&reply_data[4], &now, 4); // include our clock (for easy clock sync, and packet hash uniqueness)
reply_data[8] = 0; // features
#ifdef WITH_RS232_BRIDGE
reply_data[8] |= 0x01; // is bridge, type UART
#elif WITH_ESPNOW_BRIDGE
reply_data[8] |= 0x03; // is bridge, type ESP-NOW
#endif
if (_prefs.disable_fwd) { // is this repeater currently disabled
reply_data[8] |= 0x80; // is disabled
}
// TODO: add some kind of moving-window utilisation metric, so can query 'how busy' is this repeater
return 9; // reply length
}
return 0;
}
int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t *payload, size_t payload_len) {
// uint32_t now = getRTCClock()->getCurrentTimeUnique();
// memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
@@ -296,6 +359,9 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
return reply_offset;
}
} else if (payload[0] == REQ_TYPE_GET_OWNER_INFO) {
sprintf((char *) &reply_data[4], "%s\n%s\n%s", FIRMWARE_VERSION, _prefs.node_name, _prefs.owner_info);
return 4 + strlen((char *) &reply_data[4]);
}
return 0; // unknown command
}
@@ -327,7 +393,7 @@ bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
// Limit flood advert paket forwarding using a probabilistic reduction defined by P(h) = 0.308^(hops-1)
// https://github.com/meshcore-dev/MeshCore/issues/1223
double_t roll_dice = (double)rand() / RAND_MAX;
double_t forw_prob = pow(0.308, packet->path_len - 1);
double_t forw_prob = pow(_prefs.flood_advert_base, packet->path_len - 1);
if (packet->getPayloadType() == PAYLOAD_TYPE_ADVERT && packet->isRouteFlood() && roll_dice > forw_prob)
return false;
@@ -456,12 +522,18 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
data[len] = 0; // ensure null terminator
uint8_t reply_len;
reply_path_len = -1;
if (data[4] == 0 || data[4] >= ' ') { // is password, ie. a login request
reply_len = handleLoginReq(sender, secret, timestamp, &data[4], packet->isRouteFlood());
//} else if (data[4] == ANON_REQ_TYPE_*) { // future type codes
// TODO
} else if (data[4] == ANON_REQ_TYPE_REGIONS && packet->isRouteDirect()) {
reply_len = handleAnonRegionsReq(sender, timestamp, &data[5]);
} else if (data[4] == ANON_REQ_TYPE_OWNER && packet->isRouteDirect()) {
reply_len = handleAnonOwnerReq(sender, timestamp, &data[5]);
} else if (data[4] == ANON_REQ_TYPE_BASIC && packet->isRouteDirect()) {
reply_len = handleAnonClockReq(sender, timestamp, &data[5]);
} else {
reply_len = 0; // unknown request type
reply_len = 0; // unknown/invalid request type
}
if (reply_len == 0) return; // invalid request
@@ -471,9 +543,12 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
mesh::Packet* path = createPathReturn(sender, secret, packet->path, packet->path_len,
PAYLOAD_TYPE_RESPONSE, reply_data, reply_len);
if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
} else {
} else if (reply_path_len < 0) {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, secret, reply_data, reply_len);
if (reply) sendFlood(reply, SERVER_RESPONSE_DELAY);
} else {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, secret, reply_data, reply_len);
if (reply) sendDirect(reply, reply_path, reply_path_len, SERVER_RESPONSE_DELAY);
}
}
}
@@ -651,7 +726,9 @@ void MyMesh::onControlDataRecv(mesh::Packet* packet) {
#if !defined(STEALTH_MODE)
uint8_t type = packet->payload[0] & 0xF0; // just test upper 4 bits
if (type == CTL_TYPE_NODE_DISCOVER_REQ && packet->payload_len >= 6 && discover_limiter.allow(rtc_clock.getCurrentTime())) {
if (type == CTL_TYPE_NODE_DISCOVER_REQ && packet->payload_len >= 6
&& !_prefs.disable_fwd && discover_limiter.allow(rtc_clock.getCurrentTime())
) {
int i = 1;
uint8_t filter = packet->payload[i++];
uint32_t tag;
@@ -683,7 +760,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
mesh::RTCClock &rtc, mesh::MeshTables &tables)
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4), region_map(key_store), temp_map(key_store),
discover_limiter(4, 120) // max 4 every 2 minutes
discover_limiter(4, 120), // max 4 every 2 minutes
anon_limiter(4, 180) // max 4 every 3 minutes
#if defined(WITH_RS232_BRIDGE)
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
#endif
@@ -705,7 +783,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0;
_prefs.airtime_factor = 1.0; // one half
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
_prefs.tx_delay_factor = 0.5f; // was 0.25f
_prefs.direct_tx_delay_factor = 0.2f; // was zero
@@ -720,6 +798,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.tx_power_dbm = LORA_TX_POWER;
_prefs.advert_interval = DEF_LOCAL_ADVERT_INTERVAL;
_prefs.flood_advert_interval = DEF_FLOOD_ADVERT_INTERVAL;
_prefs.flood_advert_base = 0.308f;
_prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled

View File

@@ -88,12 +88,14 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
NodePrefs _prefs;
CommonCLI _cli;
uint8_t reply_data[MAX_PACKET_PAYLOAD];
uint8_t reply_path[MAX_PATH_SIZE];
int8_t reply_path_len;
ClientACL acl;
TransportKeyStore key_store;
RegionMap region_map, temp_map;
RegionEntry* load_stack[8];
RegionEntry* recv_pkt_region;
RateLimiter discover_limiter;
RateLimiter discover_limiter, anon_limiter;
bool region_load_active;
unsigned long dirty_contacts_expiry;
#if MAX_NEIGHBOURS
@@ -114,6 +116,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
void putNeighbour(const mesh::Identity& id, uint32_t timestamp, float snr);
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood);
uint8_t handleAnonRegionsReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
uint8_t handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
uint8_t handleAnonClockReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
int handleRequest(ClientInfo* sender, uint32_t sender_timestamp, uint8_t* payload, size_t payload_len);
mesh::Packet* createSelfAdvert();

View File

@@ -279,7 +279,7 @@ bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
// Limit flood advert paket forwarding using a probabilistic reduction defined by P(h) = 0.308^(hops-1)
// https://github.com/meshcore-dev/MeshCore/issues/1223
double_t roll_dice = (double)rand() / RAND_MAX;
double_t forw_prob = pow(0.308, packet->path_len - 1);
double_t forw_prob = pow(_prefs.flood_advert_base, packet->path_len - 1);
if (packet->getPayloadType() == PAYLOAD_TYPE_ADVERT && packet->isRouteFlood() && roll_dice > forw_prob)
return false;
@@ -606,7 +606,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0;
_prefs.airtime_factor = 1.0; // one half
_prefs.rx_delay_base = 0.0f; // off by default, was 10.0
_prefs.tx_delay_factor = 0.5f; // was 0.25f;
_prefs.direct_tx_delay_factor = 0.2f; // was zero
@@ -622,6 +622,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.disable_fwd = 1;
_prefs.advert_interval = DEF_LOCAL_ADVERT_INTERVAL;
_prefs.flood_advert_interval = DEF_FLOOD_ADVERT_INTERVAL;
_prefs.flood_advert_base = 0.308f;
_prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled
#ifdef ROOM_PASSWORD

View File

@@ -280,7 +280,7 @@ public:
{
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0;
_prefs.airtime_factor = 2.0; // one third
strcpy(_prefs.node_name, "NONAME");
_prefs.freq = LORA_FREQ;
_prefs.tx_power_dbm = LORA_TX_POWER;

View File

@@ -705,7 +705,7 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
// defaults
memset(&_prefs, 0, sizeof(_prefs));
_prefs.airtime_factor = 1.0;
_prefs.airtime_factor = 1.0; // one half
_prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0;
_prefs.tx_delay_factor = 0.5f; // was 0.25f
_prefs.direct_tx_delay_factor = 0.2f; // was zero

View File

@@ -24,10 +24,9 @@ lib_deps =
melopero/Melopero RV3028 @ ^1.1.0
electroniccats/CayenneLPP @ 1.6.1
build_flags = -w -DNDEBUG
-D LORA_FREQ=869.618
-D LORA_BW=62.5
-D LORA_SF=8
-D LORA_CR=8
-D LORA_FREQ=869.525
-D LORA_BW=250
-D LORA_SF=11
;
-D ENABLE_PRIVATE_KEY_IMPORT=1 ; NOTE: comment these out for more secure firmware
-D ENABLE_PRIVATE_KEY_EXPORT=1
@@ -50,11 +49,11 @@ build_flags = -w -DNDEBUG
-D RADIOLIB_EXCLUDE_SSTV=1
;
-D MIN_LOCAL_ADVERT_INTERVAL=60
-D MAX_LOCAL_ADVERT_INTERVAL=10080 ;1 week
-D DEF_LOCAL_ADVERT_INTERVAL=2 ; default to 2 minutes for NEW installs
-D MIN_FLOOD_ADVERT_INTERVAL=48
-D MAX_FLOOD_ADVERT_INTERVAL=672 ; 4 weeks
-D DEF_FLOOD_ADVERT_INTERVAL=48 ; default to 12 hours for NEW installs
-D MAX_LOCAL_ADVERT_INTERVAL=240
-D DEF_LOCAL_ADVERT_INTERVAL=1 ; default to 2 minutes for NEW installs
-D MIN_FLOOD_ADVERT_INTERVAL=3
-D MAX_FLOOD_ADVERT_INTERVAL=48
-D DEF_FLOOD_ADVERT_INTERVAL=12 ; default to 12 hours for NEW installs
; -D NO_BOOT_ADVERT=1 ; disable boot advertisement
; -D STEALTH_MODE=1 ; disable all advertisements and DISCOVER_REQ
build_src_filter =

View File

@@ -20,34 +20,12 @@ void Dispatcher::begin() {
_err_flags = 0;
radio_nonrx_start = _ms->getMillis();
duty_cycle_window_ms = getDutyCycleWindowMs();
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
tx_budget_ms = (unsigned long)(duty_cycle_window_ms * duty_cycle);
last_budget_update = _ms->getMillis();
_radio->begin();
prev_isrecv_mode = _radio->isInRecvMode();
}
float Dispatcher::getAirtimeBudgetFactor() const {
return 1.0;
}
void Dispatcher::updateTxBudget() {
unsigned long now = _ms->getMillis();
unsigned long elapsed = now - last_budget_update;
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
unsigned long max_budget = (unsigned long)(getDutyCycleWindowMs() * duty_cycle);
unsigned long refill = (unsigned long)(elapsed * duty_cycle);
tx_budget_ms += refill;
if (tx_budget_ms > max_budget) {
tx_budget_ms = max_budget;
}
last_budget_update = now;
return 2.0; // default, 33.3% (1/3rd)
}
int Dispatcher::calcRxDelay(float score, uint32_t air_time) const {
@@ -83,24 +61,11 @@ void Dispatcher::loop() {
if (outbound) { // waiting for outbound send to be completed
if (_radio->isSendComplete()) {
long t = _ms->getMillis() - outbound_start;
total_air_time += t;
total_air_time += t; // keep track of how much air time we are using
//Serial.print(" airtime="); Serial.println(t);
updateTxBudget();
if (t > tx_budget_ms) {
tx_budget_ms = 0;
} else {
tx_budget_ms -= t;
}
if (tx_budget_ms < 100) {
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
unsigned long needed = 100 - tx_budget_ms;
next_tx_time = futureMillis((unsigned long)(needed / duty_cycle));
} else {
next_tx_time = _ms->getMillis();
}
// will need radio silence up to next_tx_time
next_tx_time = futureMillis(t * getAirtimeBudgetFactor());
_radio->onSendFinished();
logTx(outbound, 2 + outbound->path_len + outbound->payload_len);
@@ -259,20 +224,9 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
}
void Dispatcher::checkSend() {
if (_mgr->getOutboundCount(_ms->getMillis()) == 0) return;
updateTxBudget();
uint32_t est_airtime = _radio->getEstAirtimeFor(MAX_TRANS_UNIT);
if (tx_budget_ms < est_airtime / 2) {
float duty_cycle = 1.0f / (1.0f + getAirtimeBudgetFactor());
unsigned long needed = est_airtime / 2 - tx_budget_ms;
next_tx_time = futureMillis((unsigned long)(needed / duty_cycle));
return;
}
if (!millisHasNowPassed(next_tx_time)) return;
if (_radio->isReceiving()) {
if (_mgr->getOutboundCount(_ms->getMillis()) == 0) return; // nothing waiting to send
if (!millisHasNowPassed(next_tx_time)) return; // still in 'radio silence' phase (from airtime budget setting)
if (_radio->isReceiving()) { // LBT - check if radio is currently mid-receive, or if channel activity
if (cad_busy_start == 0) {
cad_busy_start = _ms->getMillis(); // record when CAD busy state started
}

View File

@@ -122,12 +122,8 @@ class Dispatcher {
bool prev_isrecv_mode;
uint32_t n_sent_flood, n_sent_direct;
uint32_t n_recv_flood, n_recv_direct;
unsigned long tx_budget_ms;
unsigned long last_budget_update;
unsigned long duty_cycle_window_ms;
void processRecvPacket(Packet* pkt);
void updateTxBudget();
protected:
PacketManager* _mgr;
@@ -146,9 +142,6 @@ protected:
_err_flags = 0;
radio_nonrx_start = 0;
prev_isrecv_mode = true;
tx_budget_ms = 0;
last_budget_update = 0;
duty_cycle_window_ms = 3600000;
}
virtual DispatcherAction onRecvPacket(Packet* pkt) = 0;
@@ -166,7 +159,6 @@ protected:
virtual uint32_t getCADFailMaxDuration() const;
virtual int getInterferenceThreshold() const { return 0; } // disabled by default
virtual int getAGCResetInterval() const { return 0; } // disabled by default
virtual unsigned long getDutyCycleWindowMs() const { return 3600000; }
public:
void begin();
@@ -176,9 +168,8 @@ public:
void releasePacket(Packet* packet);
void sendPacket(Packet* packet, uint8_t priority, uint32_t delay_millis=0);
unsigned long getTotalAirTime() const { return total_air_time; }
unsigned long getTotalAirTime() const { return total_air_time; } // in milliseconds
unsigned long getReceiveAirTime() const {return rx_air_time; }
unsigned long getRemainingTxBudget() const { return tx_budget_ms; }
uint32_t getNumSentFlood() const { return n_sent_flood; }
uint32_t getNumSentDirect() const { return n_sent_direct; }
uint32_t getNumRecvFlood() const { return n_recv_flood; }

View File

@@ -477,6 +477,31 @@ int BaseChatMesh::sendLogin(const ContactInfo& recipient, const char* password,
return MSG_SEND_FAILED;
}
int BaseChatMesh::sendAnonReq(const ContactInfo& recipient, const uint8_t* data, uint8_t len, uint32_t& tag, uint32_t& est_timeout) {
mesh::Packet* pkt;
{
uint8_t temp[MAX_PACKET_PAYLOAD];
tag = getRTCClock()->getCurrentTimeUnique();
memcpy(temp, &tag, 4); // tag to match later (also extra blob to help make packet_hash unique)
memcpy(&temp[4], data, len);
pkt = createAnonDatagram(PAYLOAD_TYPE_ANON_REQ, self_id, recipient.id, recipient.getSharedSecret(self_id), temp, 4 + len);
}
if (pkt) {
uint32_t t = _radio->getEstAirtimeFor(pkt->getRawLength());
if (recipient.out_path_len < 0) {
sendFloodScoped(recipient, pkt);
est_timeout = calcFloodTimeoutMillisFor(t);
return MSG_SEND_SENT_FLOOD;
} else {
sendDirect(pkt, recipient.out_path, recipient.out_path_len);
est_timeout = calcDirectTimeoutMillisFor(t, recipient.out_path_len);
return MSG_SEND_SENT_DIRECT;
}
}
return MSG_SEND_FAILED;
}
int BaseChatMesh::sendRequest(const ContactInfo& recipient, const uint8_t* req_data, uint8_t data_len, uint32_t& tag, uint32_t& est_timeout) {
if (data_len > MAX_PACKET_PAYLOAD - 16) return MSG_SEND_FAILED;

View File

@@ -141,6 +141,7 @@ public:
int sendCommandData(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& est_timeout);
bool sendGroupMessage(uint32_t timestamp, mesh::GroupChannel& channel, const char* sender_name, const char* text, int text_len);
int sendLogin(const ContactInfo& recipient, const char* password, uint32_t& est_timeout);
int sendAnonReq(const ContactInfo& recipient, const uint8_t* data, uint8_t len, uint32_t& tag, uint32_t& est_timeout);
int sendRequest(const ContactInfo& recipient, uint8_t req_type, uint32_t& tag, uint32_t& est_timeout);
int sendRequest(const ContactInfo& recipient, const uint8_t* req_data, uint8_t data_len, uint32_t& tag, uint32_t& est_timeout);
bool shareContactZeroHop(const ContactInfo& contact);

View File

@@ -14,6 +14,14 @@ static uint32_t _atoi(const char* sp) {
return n;
}
static bool isValidName(const char *n) {
while (*n) {
if (*n == '[' || *n == ']' || *n == '/' || *n == '\\' || *n == ':' || *n == ',' || *n == '?' || *n == '*') return false;
n++;
}
return true;
}
void CommonCLI::loadPrefs(FILESYSTEM* fs) {
if (fs->exists("/com_prefs")) {
loadPrefsInt(fs, "/com_prefs"); // new filename
@@ -72,7 +80,10 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
file.read((uint8_t *)&_prefs->advert_loc_policy, sizeof (_prefs->advert_loc_policy)); // 161
file.read((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
file.read((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
// 170
file.read((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170
file.read((uint8_t *)&_prefs->flood_advert_base, sizeof(_prefs->flood_advert_base)); // 290
// 294
// sanitise bad pref values
_prefs->rx_delay_base = constrain(_prefs->rx_delay_base, 0, 20.0f);
@@ -99,6 +110,8 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
_prefs->gps_enabled = constrain(_prefs->gps_enabled, 0, 1);
_prefs->advert_loc_policy = constrain(_prefs->advert_loc_policy, 0, 2);
_prefs->flood_advert_base = constrain(_prefs->flood_advert_base, 0, 1);
file.close();
}
}
@@ -155,7 +168,10 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
file.write((uint8_t *)&_prefs->advert_loc_policy, sizeof(_prefs->advert_loc_policy)); // 161
file.write((uint8_t *)&_prefs->discovery_mod_timestamp, sizeof(_prefs->discovery_mod_timestamp)); // 162
file.write((uint8_t *)&_prefs->adc_multiplier, sizeof(_prefs->adc_multiplier)); // 166
// 170
file.write((uint8_t *)_prefs->owner_info, sizeof(_prefs->owner_info)); // 170
file.write((uint8_t *)&_prefs->flood_advert_base, sizeof(_prefs->flood_advert_base)); // 290
// 294
file.close();
}
@@ -300,6 +316,15 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
sprintf(reply, "> %d", (uint32_t)_prefs->flood_max);
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
} else if (memcmp(config, "owner.info", 10) == 0) {
*reply++ = '>';
*reply++ = ' ';
const char* sp = _prefs->owner_info;
while (*sp) {
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
sp++;
}
*reply = 0; // set null terminator
} else if (memcmp(config, "tx", 2) == 0 && (config[2] == 0 || config[2] == ' ')) {
sprintf(reply, "> %d", (uint32_t) _prefs->tx_power_dbm);
} else if (memcmp(config, "freq", 4) == 0) {
@@ -344,6 +369,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
} else {
sprintf(reply, "> %.3f", adc_mult);
}
} else if (memcmp(config, "flood.advert.base", 17) == 0) {
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->flood_advert_base));
} else {
sprintf(reply, "??: %s", config);
}
@@ -411,9 +438,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
strcpy(reply, "Error, invalid key");
}
} else if (memcmp(config, "name ", 5) == 0) {
StrHelper::strncpy(_prefs->node_name, &config[5], sizeof(_prefs->node_name));
savePrefs();
strcpy(reply, "OK");
if (isValidName(&config[5])) {
StrHelper::strncpy(_prefs->node_name, &config[5], sizeof(_prefs->node_name));
savePrefs();
strcpy(reply, "OK");
} else {
strcpy(reply, "Error, bad chars");
}
} else if (memcmp(config, "repeat ", 7) == 0) {
_prefs->disable_fwd = memcmp(&config[7], "off", 3) == 0;
savePrefs();
@@ -480,6 +511,16 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
} else {
strcpy(reply, "Error, cannot be negative");
}
} else if (memcmp(config, "owner.info ", 11) == 0) {
config += 11;
char *dp = _prefs->owner_info;
while (*config && dp - _prefs->owner_info < sizeof(_prefs->owner_info)-1) {
*dp++ = (*config == '|') ? '\n' : *config; // translate '|' to newline chars
config++;
}
*dp = 0;
savePrefs();
strcpy(reply, "OK");
} else if (memcmp(config, "tx ", 3) == 0) {
_prefs->tx_power_dbm = atoi(&config[3]);
savePrefs();
@@ -551,6 +592,15 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
_prefs->adc_multiplier = 0.0f;
strcpy(reply, "Error: unsupported by this board");
};
} else if (memcmp(config, "flood.advert.base ", 18) == 0) {
float f = atof(&config[18]);
if((f > 0) || (f<1)) {
_prefs->flood_advert_base = f;
savePrefs();
strcpy(reply, "OK");
} else {
strcpy(reply, "Error: base must be between 0 and 1");
}
} else {
sprintf(reply, "unknown config: %s", config);
}

View File

@@ -35,6 +35,7 @@ struct NodePrefs { // persisted to file
uint8_t flood_max;
uint8_t interference_threshold;
uint8_t agc_reset_interval; // secs / 4
float flood_advert_base;
// Bridge settings
uint8_t bridge_enabled; // boolean
uint16_t bridge_delay; // milliseconds (default 500 ms)
@@ -50,6 +51,7 @@ struct NodePrefs { // persisted to file
uint8_t advert_loc_policy;
uint32_t discovery_mod_timestamp;
float adc_multiplier;
char owner_info[120];
};
class CommonCLICallbacks {

View File

@@ -9,8 +9,9 @@ RegionMap::RegionMap(TransportKeyStore& store) : _store(&store) {
strcpy(wildcard.name, "*");
}
bool RegionMap::is_name_char(char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-' || c == '.' || c == '_' || c == '#';
bool RegionMap::is_name_char(uint8_t c) {
// accept all alpha-num or accented characters, but exclude most punctuation chars
return c == '-' || c == '#' || (c >= '0' && c <= '9') || c >= 'A';
}
static File openWrite(FILESYSTEM* _fs, const char* filename) {
@@ -24,12 +25,12 @@ static File openWrite(FILESYSTEM* _fs, const char* filename) {
#endif
}
bool RegionMap::load(FILESYSTEM* _fs) {
if (_fs->exists("/regions2")) {
bool RegionMap::load(FILESYSTEM* _fs, const char* path) {
if (_fs->exists(path ? path : "/regions2")) {
#if defined(RP2040_PLATFORM)
File file = _fs->open("/regions2", "r");
File file = _fs->open(path ? path : "/regions2", "r");
#else
File file = _fs->open("/regions2");
File file = _fs->open(path ? path : "/regions2");
#endif
if (file) {
@@ -67,8 +68,8 @@ bool RegionMap::load(FILESYSTEM* _fs) {
return false; // failed
}
bool RegionMap::save(FILESYSTEM* _fs) {
File file = openWrite(_fs, "/regions2");
bool RegionMap::save(FILESYSTEM* _fs, const char* path) {
File file = openWrite(_fs, path ? path : "/regions2");
if (file) {
uint8_t pad[128];
memset(pad, 0, sizeof(pad));
@@ -235,3 +236,27 @@ void RegionMap::printChildRegions(int indent, const RegionEntry* parent, Stream&
void RegionMap::exportTo(Stream& out) const {
printChildRegions(0, &wildcard, out); // recursive
}
int RegionMap::exportNamesTo(char *dest, int max_len, uint8_t mask) {
char *dp = dest;
if ((wildcard.flags & mask) == 0) {
*dp++ = '*';
*dp++ = ',';
}
for (int i = 0; i < num_regions; i++) {
auto region = &regions[i];
if ((region->flags & mask) == 0) { // region allowed? (per 'mask' param)
int len = strlen(region->name);
if ((dp - dest) + len + 2 < max_len) { // only append if name will fit
memcpy(dp, region->name, len);
dp += len;
*dp++ = ',';
}
}
}
if (dp > dest) { dp--; } // don't include trailing comma
*dp = 0; // set null terminator
return dp - dest; // return length
}

View File

@@ -30,10 +30,10 @@ class RegionMap {
public:
RegionMap(TransportKeyStore& store);
static bool is_name_char(char c);
static bool is_name_char(uint8_t c);
bool load(FILESYSTEM* _fs);
bool save(FILESYSTEM* _fs);
bool load(FILESYSTEM* _fs, const char* path=NULL);
bool save(FILESYSTEM* _fs, const char* path=NULL);
RegionEntry* putRegion(const char* name, uint16_t parent_id, uint16_t id = 0);
RegionEntry* findMatch(mesh::Packet* packet, uint8_t mask);
@@ -47,6 +47,9 @@ public:
bool clear();
void resetFrom(const RegionMap& src) { num_regions = 0; next_id = src.next_id; }
int getCount() const { return num_regions; }
const RegionEntry* getByIdx(int i) const { return &regions[i]; }
const RegionEntry* getRoot() const { return &wildcard; }
int exportNamesTo(char *dest, int max_len, uint8_t mask);
void exportTo(Stream& out) const;
};

View File

@@ -1,64 +0,0 @@
#!/bin/bash # Note: switched to bash for process substitution support
export PATH="$HOME/.platformio/penv/bin:$PATH"
LOGFILE="$PWD/meshcore-evo-fw.log"
FIRMWARE_VERSION="v1.11_evo"
FIRMWARE_BUILD_DATE=$(date '+%d-%b-%Y')
collect_bin_files(){
DEST_DIR="./firmwares"
mkdir -p "$DEST_DIR"
BUILD_DIR=".pio/build"
if [ ! -d "$BUILD_DIR" ]; then
echo "Error: $BUILD_DIR not found. Did you run the build process?"
exit 1
fi
echo "Copying firmware files to $DEST_DIR..."
for target_path in "$BUILD_DIR"/*/; do
echo $target_path
target_name=$(basename "$target_path")
# if ls "$target_path"*.bin >/dev/null 2>&1; then
for bin_file in "$target_path"*firmware*.{uf2,bin,zip}; do
filename=$(basename "$bin_file")
new_filename="${target_name}_${FIRMWARE_VERSION}_${FIRMWARE_BUILD_DATE}_${filename}"
cp "$bin_file" "$DEST_DIR/$new_filename"
echo "Done: $new_filename"
done
# fi
done
}
# Everything after this line goes to BOTH console and logfile
exec > >(tee -a "$LOGFILE") 2>&1
echo "-------------------- Build start ----------------"
date
echo "-------------------------------------------------"
# apply patches
# ./tools/maint/apply_patches.sh 1199 1338 1297
# build all repeater firmwares, the will be in .out
FIRMWARE_VERSION="v1.11_evo" ./build.sh build-repeater-firmwares
# build single firmwares
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware ProMicro_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware RAK_4631_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware heltec_v4_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware Heltec_v3_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware Xiao_nrf52_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware LilyGo_T3S3_sx1262_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware Heltec_t114_without_display_repeater
#FIRMWARE_VERSION=$FIRMWARE_VERSION FIRMWARE_BUILD_DATE=$FIRMWARE_BUILD_DATE ./build.sh build-firmware Heltec_t114_repeater
#collect_bin_files
echo "-------------------- Build end ------------------"
date
echo "-------------------------------------------------"
#grep -E " SUCCESS | FAILED " hansemesh_fw.log

View File

@@ -1,8 +1,5 @@
[ikoka_nrf52]
extends = Xiao_nrf52
lib_deps = ${nrf52_base.lib_deps}
${sensor_base.lib_deps}
densaugeo/base64 @ ~1.4.0
[ikoka_handheld_nrf]
extends = nrf52_base
build_flags = ${nrf52_base.build_flags}
${sensor_base.build_flags}
-I lib/nrf52/s140_nrf52_7.3.0_API/include
@@ -26,12 +23,15 @@ build_flags = ${nrf52_base.build_flags}
build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/ikoka_handheld_nrf>
+<helpers/sensors>
lib_deps = ${nrf52_base.lib_deps}
${sensor_base.lib_deps}
densaugeo/base64 @ ~1.4.0
# larger screen has a different driver, this is for the 0.96 inch
[ikoka_nrf52_ssd1306_companion]
lib_deps = ${ikoka_nrf52.lib_deps}
[ikoka_handheld_nrf_ssd1306_companion]
lib_deps = ${ikoka_handheld_nrf.lib_deps}
adafruit/Adafruit SSD1306 @ ^2.5.13
build_flags = ${ikoka_nrf52.build_flags}
build_flags = ${ikoka_handheld_nrf.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_ROTATION=0
-D PIN_WIRE_SCL=D6
@@ -42,62 +42,62 @@ build_flags = ${ikoka_nrf52.build_flags}
-D OFFLINE_QUEUE_SIZE=256
-D QSPIFLASH=1
-I examples/companion_radio/ui-new
build_src_filter = ${ikoka_nrf52.build_src_filter}
build_src_filter = ${ikoka_handheld_nrf.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/companion_radio/ui-new/UITask.cpp>
+<../examples/companion_radio/*.cpp>
[env:ikoka_handheld_nrf_e22_30dbm_096_companion_radio_ble]
extends = ikoka_nrf52
build_flags = ${ikoka_nrf52_ssd1306_companion.build_flags}
build_flags = ${ikoka_handheld_nrf_ssd1306_companion.build_flags}
-D BLE_PIN_CODE=123456
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_nrf52_ssd1306_companion.build_src_filter}
build_src_filter = ${ikoka_handheld_nrf_ssd1306_companion.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
[env:ikoka_handheld_nrf_e22_30dbm_096_rotated_companion_radio_ble]
extends = ikoka_nrf52
build_flags = ${ikoka_nrf52_ssd1306_companion.build_flags}
build_flags = ${ikoka_handheld_nrf_ssd1306_companion.build_flags}
-D BLE_PIN_CODE=123456
-D LORA_TX_POWER=20
-D DISPLAY_ROTATION=2
build_src_filter = ${ikoka_nrf52_ssd1306_companion.build_src_filter}
-D DISPLAY_ROTATION=2
build_src_filter = ${ikoka_handheld_nrf_ssd1306_companion.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
[env:ikoka_handheld_nrf_e22_30dbm_096_companion_radio_usb]
extends = ikoka_nrf52
build_flags = ${ikoka_nrf52_ssd1306_companion.build_flags}
build_flags = ${ikoka_handheld_nrf_ssd1306_companion.build_flags}
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_nrf52_ssd1306_companion.build_src_filter}
build_src_filter = ${ikoka_handheld_nrf_ssd1306_companion.build_src_filter}
[env:ikoka_handheld_nrf_e22_30dbm_096_rotated_companion_radio_usb]
extends = ikoka_nrf52
build_flags = ${ikoka_nrf52_ssd1306_companion.build_flags}
build_flags = ${ikoka_handheld_nrf_ssd1306_companion.build_flags}
-D LORA_TX_POWER=20
-D DISPLAY_ROTATION=2
build_src_filter = ${ikoka_nrf52_ssd1306_companion.build_src_filter}
build_src_filter = ${ikoka_handheld_nrf_ssd1306_companion.build_src_filter}
[env:ikoka_handheld_nrf_e22_30dbm_repeater]
extends = ikoka_nrf52
build_flags =
${ikoka_nrf52.build_flags}
${ikoka_handheld_nrf.build_flags}
-D ADVERT_NAME='"ikoka_handheld Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_nrf52.build_src_filter}
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_handheld_nrf.build_src_filter}
+<../examples/simple_repeater/*.cpp>
[env:ikoka_handheld_nrf_e22_30dbm_room_server]
extends = ikoka_nrf52
build_flags =
${ikoka_nrf52.build_flags}
${ikoka_handheld_nrf.build_flags}
-D ADVERT_NAME='"ikoka_handheld Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_nrf52.build_src_filter}
-D LORA_TX_POWER=20
build_src_filter = ${ikoka_handheld_nrf.build_src_filter}
+<../examples/simple_room_server/*.cpp>

View File

@@ -1,151 +1,124 @@
[nrf52840_xiao]
[ikoka_nano_nrf]
extends = nrf52_base
platform_packages =
toolchain-gccarmnoneeabi@~1.100301.0
framework-arduinoadafruitnrf52
board = seeed-xiao-afruitnrf52-nrf52840
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52_base.build_flags}
${sensor_base.build_flags}
-D NRF52_PLATFORM -D XIAO_NRF52
-I lib/nrf52/s140_nrf52_7.3.0_API/include
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
lib_ignore =
BluetoothOTA
lvgl
lib5b4
lib_deps =
${nrf52_base.lib_deps}
rweather/Crypto @ ^0.4.0
adafruit/Adafruit INA3221 Library @ ^1.0.1
adafruit/Adafruit INA219 @ ^1.2.3
adafruit/Adafruit AHTX0 @ ^2.0.5
adafruit/Adafruit BME280 Library @ ^2.3.0
adafruit/Adafruit SSD1306 @ ^2.5.13
[ikoka_nano_nrf_baseboard]
extends = nrf52840_xiao
;board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52840_xiao.build_flags}
-D P_LORA_TX_LED=11
-I variants/ikoka_nano_nrf
-I src/helpers/nrf52
-D P_LORA_TX_LED=11
-D DISPLAY_CLASS=NullDisplayDriver
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_DIO_1=D1
; -D P_LORA_BUSY=D3
-D P_LORA_BUSY=D2 ; specific to ikoka nano variant.
; -D P_LORA_RESET=D2
-D P_LORA_RESET=D3 ; specific to ikoka nano variant.
; -D P_LORA_NSS=D4
-D P_LORA_NSS=D0 ; specific to ikoka nano variant.
; -D SX126X_RXEN=D5
-D P_LORA_BUSY=D2
-D P_LORA_RESET=D3
-D P_LORA_NSS=D0
-D SX126X_RXEN=D7
-D SX126X_TXEN=RADIOLIB_NC
-D SX126X_DIO2_AS_RF_SWITCH=1
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_WIRE_SCL=5 ; specific to ikoka nano variant.
-D PIN_WIRE_SDA=4 ; specific to ikoka nano variant.
-D ENV_INCLUDE_AHTX0=1
-D ENV_INCLUDE_BME280=1
-D ENV_INCLUDE_INA3221=1
-D ENV_INCLUDE_INA219=1
-D PIN_WIRE_SCL=5
-D PIN_WIRE_SDA=4
-UENV_INCLUDE_GPS
debug_tool = jlink
upload_protocol = nrfutil
;;; abstracted hardware variants
lib_deps = ${nrf52_base.lib_deps}
${sensor_base.lib_deps}
[ikoka_nano_nrf_e22_22dbm]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
; No PA in this model, full 22dBm
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Nano-E22-22dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=22
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/NullDisplayDriver.cpp>
+<../variants/ikoka_nano_nrf>
[ikoka_nano_nrf_e22_30dbm]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
; limit txpower to 20dBm on E22-900M30S. Anything higher will
; cause distortion in the PA output. 20dBm in -> 30dBm out
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Nano-E22-30dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=20
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/NullDisplayDriver.cpp>
+<../variants/ikoka_nano_nrf>
[ikoka_nano_nrf_e22_33dbm]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
; limit txpower to 9dBm on E22-900M33S to avoid hardware damage
; to the rf amplifier frontend. 9dBm in -> 33dBm out
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Nano-E22-33dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=9
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/NullDisplayDriver.cpp>
+<../variants/ikoka_nano_nrf>
;;; abstracted firmware roles
[ikoka_nano_nrf_companion_radio_ble]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-I examples/companion_radio/ui-new
-D QSPIFLASH=1
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_nano_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ikoka_nano_nrf_baseboard.lib_deps}
${ikoka_nano_nrf.lib_deps}
densaugeo/base64 @ ~1.4.0
[ikoka_nano_nrf_companion_radio_usb]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-I examples/companion_radio/ui-new
-D QSPIFLASH=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_nano_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ikoka_nano_nrf_baseboard.lib_deps}
${ikoka_nano_nrf.lib_deps}
densaugeo/base64 @ ~1.4.0
[ikoka_nano_nrf_repeater]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D ADVERT_NAME='"Ikoka Nano Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -153,26 +126,23 @@ build_flags =
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_nano_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<../examples/simple_repeater/*.cpp>
[ikoka_nano_nrf_room_server]
extends = ikoka_nano_nrf_baseboard
extends = ikoka_nano_nrf
build_flags =
${ikoka_nano_nrf_baseboard.build_flags}
${ikoka_nano_nrf.build_flags}
-D ADVERT_NAME='"Ikoka Nano Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_nano_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_nano_nrf.build_src_filter}
+<../examples/simple_room_server/*.cpp>
;;; hardware + firmware variants
;;; 22dBm EBYTE E22-900M22 variants
[env:ikoka_nano_nrf_22dbm_companion_radio_usb]
extends =
ikoka_nano_nrf_e22_22dbm
@@ -219,7 +189,6 @@ build_src_filter =
;;; 30dBm EBYTE E22-900M30 variants
[env:ikoka_nano_nrf_30dbm_companion_radio_usb]
extends =
ikoka_nano_nrf_e22_30dbm
@@ -266,7 +235,6 @@ build_src_filter =
;;; 33dBm EBYTE E22-900M33 variants
[env:ikoka_nano_nrf_33dbm_companion_radio_usb]
extends =
ikoka_nano_nrf_e22_33dbm

View File

@@ -1,34 +1,15 @@
[nrf52840_xiao]
[ikoka_stick_nrf]
extends = nrf52_base
platform_packages =
toolchain-gccarmnoneeabi@~1.100301.0
framework-arduinoadafruitnrf52
board = seeed-xiao-afruitnrf52-nrf52840
board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52_base.build_flags}
${sensor_base.build_flags}
-D NRF52_PLATFORM -D XIAO_NRF52
-I lib/nrf52/s140_nrf52_7.3.0_API/include
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
lib_ignore =
BluetoothOTA
lvgl
lib5b4
lib_deps =
${nrf52_base.lib_deps}
rweather/Crypto @ ^0.4.0
adafruit/Adafruit INA3221 Library @ ^1.0.1
adafruit/Adafruit INA219 @ ^1.2.3
adafruit/Adafruit AHTX0 @ ^2.0.5
adafruit/Adafruit BME280 Library @ ^2.3.0
adafruit/Adafruit SSD1306 @ ^2.5.13
[ikoka_stick_nrf_baseboard]
extends = nrf52840_xiao
;board_build.ldscript = boards/nrf52840_s140_v7.ld
build_flags = ${nrf52840_xiao.build_flags}
-D P_LORA_TX_LED=11
-I variants/ikoka_stick_nrf
-I src/helpers/nrf52
-D P_LORA_TX_LED=11
-D DISPLAY_CLASS=SSD1306Display
-D DISPLAY_ROTATION=2
-D RADIO_CLASS=CustomSX1262
@@ -46,24 +27,17 @@ build_flags = ${nrf52840_xiao.build_flags}
-D PIN_USER_BTN=0
-D PIN_WIRE_SCL=7
-D PIN_WIRE_SDA=6
-D ENV_INCLUDE_AHTX0=1
-D ENV_INCLUDE_BME280=1
-D ENV_INCLUDE_INA3221=1
-D ENV_INCLUDE_INA219=1
debug_tool = jlink
upload_protocol = nrfutil
;;; abstracted hardware variants
lib_deps = ${nrf52_base.lib_deps}
${sensor_base.lib_deps}
[ikoka_stick_nrf_e22_22dbm]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
; No PA in this model, full 22dBm
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Stick-E22-22dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=22
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/MomentaryButton.cpp>
@@ -71,14 +45,14 @@ build_src_filter = ${nrf52840_xiao.build_src_filter}
+<../variants/ikoka_stick_nrf>
[ikoka_stick_nrf_e22_30dbm]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
; limit txpower to 20dBm on E22-900M30S. Anything higher will
; cause distortion in the PA output. 20dBm in -> 30dBm out
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Stick-E22-30dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=20
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/MomentaryButton.cpp>
@@ -86,14 +60,14 @@ build_src_filter = ${nrf52840_xiao.build_src_filter}
+<../variants/ikoka_stick_nrf>
[ikoka_stick_nrf_e22_33dbm]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
; limit txpower to 9dBm on E22-900M33S to avoid hardware damage
; to the rf amplifier frontend. 9dBm in -> 33dBm out
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D MANUFACTURER_STRING='"Ikoka Stick-E22-33dBm (Xiao_nrf52)"'
-D LORA_TX_POWER=9
build_src_filter = ${nrf52840_xiao.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
+<helpers/ui/MomentaryButton.cpp>
@@ -103,50 +77,52 @@ build_src_filter = ${nrf52840_xiao.build_src_filter}
;;; abstracted firmware roles
[ikoka_stick_nrf_companion_radio_ble]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-I examples/companion_radio/ui-new
-D QSPIFLASH=1
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_stick_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ikoka_stick_nrf_baseboard.lib_deps}
${ikoka_stick_nrf.lib_deps}
densaugeo/base64 @ ~1.4.0
[ikoka_stick_nrf_companion_radio_usb]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
board_upload.maximum_size = 708608
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-I examples/companion_radio/ui-new
-D QSPIFLASH=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_stick_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ikoka_stick_nrf_baseboard.lib_deps}
${ikoka_stick_nrf.lib_deps}
densaugeo/base64 @ ~1.4.0
[ikoka_stick_nrf_repeater]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D ADVERT_NAME='"Ikoka Stick Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
@@ -154,21 +130,21 @@ build_flags =
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_stick_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_repeater/*.cpp>
[ikoka_stick_nrf_room_server]
extends = ikoka_stick_nrf_baseboard
extends = ikoka_stick_nrf
build_flags =
${ikoka_stick_nrf_baseboard.build_flags}
${ikoka_stick_nrf.build_flags}
-D ADVERT_NAME='"Ikoka Stick Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${ikoka_stick_nrf_baseboard.build_src_filter}
build_src_filter = ${ikoka_stick_nrf.build_src_filter}
+<../examples/simple_room_server/*.cpp>
;;; hardware + firmware variants

View File

@@ -138,8 +138,6 @@ build_flags =
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>