mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-10-23 06:42:24 +00:00
sync to vanilla 1.16
This commit is contained in:
1 parent
4353936328
commit
ffe9ea652d
15 files changed
+105
-24
No files matched your search
@@ -552,8 +552,9 @@ bool CompanionMesh::continueContactIteration()
|
||||
if (_contact_iter_idx < getNumContacts()) {
|
||||
ContactInfo c;
|
||||
if (getContactByIdx(_contact_iter_idx, c)) {
|
||||
// Skip transient/anon contacts (ADV_TYPE_NONE) — never synced to the app.
|
||||
// Apply 'since' filter - only send contacts modified after the timestamp
|
||||
if (c.lastmod > _contact_iter_since) {
|
||||
if (c.type != ADV_TYPE_NONE && c.lastmod > _contact_iter_since) {
|
||||
if (c.lastmod > _contact_iter_lastmod) {
|
||||
_contact_iter_lastmod = c.lastmod;
|
||||
}
|
||||
@@ -2226,6 +2227,9 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
#define FIRMWARE_BUILD_DATE __DATE__
|
||||
#endif
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v0.0.0-dev" // real value injected by CMakeLists.txt
|
||||
#endif
|
||||
/* Wire format reserves 40 bytes for the board name. Require room
|
||||
* for a null terminator within those 40 bytes so a phone parsing
|
||||
* it as a C-string never reads past the field. */
|
||||
@@ -2233,10 +2237,10 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
|
||||
"CONFIG_ZEPHCORE_BOARD_NAME must fit in 40 bytes including null terminator");
|
||||
static const uint8_t fw_build[12] = FIRMWARE_BUILD_DATE;
|
||||
static const uint8_t model[40] = CONFIG_ZEPHCORE_BOARD_NAME;
|
||||
static const uint8_t version[20] = "v1.15.9-zephyr";
|
||||
static const uint8_t version[20] = FIRMWARE_VERSION; // injected by CMakeLists.txt
|
||||
uint8_t rsp[82];
|
||||
rsp[0] = PACKET_DEVICE_INFO;
|
||||
rsp[1] = 12; // FIRMWARE_VER_CODE - v12 = CMD_SET_FLOOD_SCOPE_KEY [0x36, 0x01] unscoped variant
|
||||
rsp[1] = 13; // FIRMWARE_VER_CODE - v13 = CMD_SEND_ANON_REQ to non-contact pubkey (transient anon contacts)
|
||||
rsp[2] = (MAX_CONTACTS / 2 > 255) ? 255 : (MAX_CONTACTS / 2); // protocol byte, app multiplies by 2
|
||||
rsp[3] = MAX_GROUP_CHANNELS;
|
||||
put_le32(&rsp[4], prefs.ble_pin ? prefs.ble_pin : 123456); // BLE PIN
|
||||
@@ -2952,6 +2956,19 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
|
||||
case CMD_SEND_ANON_REQ:
|
||||
if (len >= 1 + PUB_KEY_SIZE + 1) {
|
||||
ContactInfo *contact = lookupContactByPubKey(&data[1], PUB_KEY_SIZE);
|
||||
if (contact == nullptr) {
|
||||
/* FIRMWARE_VER_CODE 13+: allow requests to a non-contact pubkey by
|
||||
* creating a transient "anon" contact (ADV_TYPE_NONE). These are never
|
||||
* persisted or synced to the app; re-lookup to get the stable slot. */
|
||||
ContactInfo anon;
|
||||
memset(&anon, 0, sizeof(anon));
|
||||
memcpy(anon.id.pub_key, &data[1], PUB_KEY_SIZE);
|
||||
anon.out_path_len = 0; // zero-hop direct by default
|
||||
anon.type = ADV_TYPE_NONE; // transient/unknown
|
||||
if (addContact(anon)) {
|
||||
contact = lookupContactByPubKey(&data[1], PUB_KEY_SIZE);
|
||||
}
|
||||
}
|
||||
if (contact) {
|
||||
uint32_t tag, est_timeout;
|
||||
int result = sendAnonReq(*contact, &data[1 + PUB_KEY_SIZE], len - 1 - PUB_KEY_SIZE, tag, est_timeout);
|
||||
@@ -2963,7 +2980,7 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
|
||||
sendPacketError(ERR_BAD_STATE);
|
||||
}
|
||||
} else {
|
||||
sendPacketError(ERR_NOT_FOUND);
|
||||
sendPacketError(ERR_TABLE_FULL);
|
||||
}
|
||||
} else {
|
||||
sendPacketError(ERR_ILLEGAL_ARG);
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#include "observer_creds.h"
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.15.9-zephyr"
|
||||
// Real version injected by CMakeLists.txt (-DFIRMWARE_VERSION); this fallback
|
||||
// only applies to builds that bypass that injection and should never surface.
|
||||
#define FIRMWARE_VERSION "v0.0.0-dev"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
|
||||
@@ -195,6 +195,10 @@ bool RepeaterDataStore::loadPrefs(NodePrefs& prefs) {
|
||||
fs_read(&file, &prefs.rx_duty_cycle, sizeof(prefs.rx_duty_cycle));
|
||||
fs_read(&file, &prefs.apc_enabled, sizeof(prefs.apc_enabled));
|
||||
fs_read(&file, &prefs.apc_margin, sizeof(prefs.apc_margin));
|
||||
/* Flood hop-ceiling extensions (absent in <296-byte files; the no-op EOF
|
||||
* read leaves the constructor defaults flood_max_unscoped=64, flood_max_advert=8). */
|
||||
fs_read(&file, &prefs.flood_max_unscoped, sizeof(prefs.flood_max_unscoped));
|
||||
fs_read(&file, &prefs.flood_max_advert, sizeof(prefs.flood_max_advert));
|
||||
|
||||
fs_close(&file);
|
||||
|
||||
@@ -234,7 +238,7 @@ bool RepeaterDataStore::loadPrefs(NodePrefs& prefs) {
|
||||
prefs.path_hash_mode = 1;
|
||||
prefs.loop_detect = LOOP_DETECT_MODERATE;
|
||||
savePrefs(prefs);
|
||||
LOG_INF("loadPrefs: upgraded prefs format (%d -> 294 bytes)", (int)entry.size);
|
||||
LOG_INF("loadPrefs: upgraded prefs format (%d -> 296 bytes)", (int)entry.size);
|
||||
}
|
||||
|
||||
/* One-time migration: disable RX duty cycle if it was previously enabled. */
|
||||
@@ -313,6 +317,9 @@ bool RepeaterDataStore::savePrefs(const NodePrefs& prefs) {
|
||||
fs_write(&file, &prefs.rx_duty_cycle, sizeof(prefs.rx_duty_cycle));
|
||||
fs_write(&file, &prefs.apc_enabled, sizeof(prefs.apc_enabled));
|
||||
fs_write(&file, &prefs.apc_margin, sizeof(prefs.apc_margin));
|
||||
/* Flood hop-ceiling extensions (extend the format past 294 bytes) */
|
||||
fs_write(&file, &prefs.flood_max_unscoped, sizeof(prefs.flood_max_unscoped));
|
||||
fs_write(&file, &prefs.flood_max_advert, sizeof(prefs.flood_max_advert));
|
||||
|
||||
ret = fs_sync(&file);
|
||||
fs_close(&file);
|
||||
|
||||
@@ -532,6 +532,8 @@ bool RepeaterMesh::allowPacketForward(const mesh::Packet* packet) {
|
||||
if (packet->getPathHashCount() >= _prefs.flood_max) return false;
|
||||
// un-scoped floods can be clamped to a lower hop limit than scoped (transport) floods
|
||||
if (packet->getRouteType() == ROUTE_TYPE_FLOOD && packet->getPathHashCount() >= _prefs.flood_max_unscoped) return false;
|
||||
// ADVERT floods get their own (typically tighter) hop ceiling to curb advert churn
|
||||
if (packet->getPayloadType() == PAYLOAD_TYPE_ADVERT && packet->getPathHashCount() >= _prefs.flood_max_advert) return false;
|
||||
}
|
||||
if (packet->isRouteFlood() && recv_pkt_region == nullptr) return false;
|
||||
if (packet->isRouteFlood() && _prefs.loop_detect != LOOP_DETECT_OFF) {
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.15.9-zephyr"
|
||||
// Real version injected by CMakeLists.txt (-DFIRMWARE_VERSION); this fallback
|
||||
// only applies to builds that bypass that injection and should never surface.
|
||||
#define FIRMWARE_VERSION "v0.0.0-dev"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#include "RepeaterDataStore.h"
|
||||
|
||||
#ifndef FIRMWARE_VERSION
|
||||
#define FIRMWARE_VERSION "v1.15.9-zephyr"
|
||||
// Real version injected by CMakeLists.txt (-DFIRMWARE_VERSION); this fallback
|
||||
// only applies to builds that bypass that injection and should never surface.
|
||||
#define FIRMWARE_VERSION "v0.0.0-dev"
|
||||
#endif
|
||||
|
||||
#ifndef FIRMWARE_BUILD_DATE
|
||||
|
||||
Reference in new issue
Block a user