Bump to version 3 to get rssi et al

This commit is contained in:
Scott Penrose
2026-06-10 11:29:28 +10:00
parent 493826bef5
commit 1444edba0c
3 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ public:
/* ---- commands (fire-and-forget; replies arrive via callbacks) ---- */
void appStart(const char *name = "esp32");
void deviceQuery(uint8_t appTargetVer = 1);
void deviceQuery(uint8_t appTargetVer = 3); /* 3 = request V3 frames (SNR+RSSI) */
void getDeviceTime();
void setDeviceTime(uint32_t epochSecs);
void sendSelfAdvert(bool flood = true);
+3 -1
View File
@@ -46,6 +46,7 @@ static int parse_channel_text(const uint8_t *b, size_t n, int v3, mc_channel_msg
m->txt_type = q[2];
m->sender_ts = get_u32(q + 3);
m->snr_q4 = v3 ? (int8_t)b[0] : MC_SNR_NONE;
m->rssi = v3 ? (int8_t)b[1] : MC_RSSI_NONE; /* V3 lead: [snr][rssi][?] */
copy_rest_string(m->text, sizeof(m->text), q, 7, qn);
return 1;
}
@@ -63,6 +64,7 @@ static int parse_contact_text(const uint8_t *b, size_t n, int v3, mc_contact_msg
m->txt_type = q[7];
m->sender_ts = get_u32(q + 8);
m->snr_q4 = v3 ? (int8_t)b[0] : MC_SNR_NONE;
m->rssi = v3 ? (int8_t)b[1] : MC_RSSI_NONE; /* V3 lead: [snr][rssi][?] */
size_t toff = 12;
if (m->txt_type == MC_TXT_SIGNED_PLAIN && qn >= toff + 4) {
memcpy(m->signature, q + toff, 4);
@@ -148,7 +150,7 @@ size_t mc_cmd_app_start(uint8_t *out, size_t cap, const char *app_name) {
if (cap < total) return 0;
size_t i = 0;
out[i++] = MC_CMD_APP_START;
out[i++] = 1; /* app version */
out[i++] = 3; /* app version (3 = accept V3 frames with SNR+RSSI) */
memset(out + i, 0, 6); i += 6; /* reserved */
memcpy(out + i, app_name, nlen); i += nlen;
return i;
+4
View File
@@ -154,6 +154,8 @@ enum { MC_ADVERT_ZERO_HOP = 0, MC_ADVERT_FLOOD = 1 };
#define MC_SNR_DB(q4) ((float)(q4) / 4.0f)
/* snr_q4 sentinel for non-V3 messages that carry no SNR. */
#define MC_SNR_NONE ((int8_t)-128)
/* rssi sentinel for non-V3 messages that carry no RSSI (0 dBm never occurs). */
#define MC_RSSI_NONE ((int8_t)0)
/* ======================================================================== *
* Receive side: streaming frame assembler
@@ -262,6 +264,7 @@ typedef struct {
uint8_t txt_type;
uint32_t sender_ts;
int8_t snr_q4; /* V3 only (code 17); MC_SNR_NONE otherwise */
int8_t rssi; /* dBm; V3 only (code 17); MC_RSSI_NONE otherwise */
char text[MC_MAX_TEXT]; /* for channel msgs this is "Name: body" */
} mc_channel_msg_t;
@@ -280,6 +283,7 @@ typedef struct {
uint8_t txt_type;
uint32_t sender_ts;
int8_t snr_q4; /* V3 only (code 16); MC_SNR_NONE otherwise */
int8_t rssi; /* dBm; V3 only (code 16); MC_RSSI_NONE otherwise */
uint8_t signature[4]; /* present when txt_type==MC_TXT_SIGNED_PLAIN */
int has_signature;
char text[MC_MAX_TEXT];