Skip to content

Commit c8628b6

Browse files
committed
JP: update MAX_TEXT_LEN limits based on measured airtimes, add getMaxGroupTextLen()
Measured actual TimeOnAir via RadioLib getTimeOnAir() on RAK WisMesh Tag (SF12/BW125, CR4/5-8) to verify ARIB STD-T108 4-second TX limit compliance. DM limits (getMaxTextLen): CR4/5: 64 bytes (3874ms) CR4/6: 48 bytes (3874ms) CR4/7: 32 bytes (3678ms) CR4/8: 24 bytes (3547ms) Channel message limits (getMaxGroupTextLen): CR4/5: 64 bytes (3710ms) CR4/6: 48 bytes (3678ms) CR4/7: 39 bytes (3907ms) CR4/8: 29 bytes (3809ms) DM and channel packets differ by 1 byte overhead, warranting separate limits for CR4/7 and CR4/8. Non-JP returns default 160 bytes unchanged. Also apply dynamic limit to sendCommandData() and sendGroupMessage() via getMaxTextLen()/getMaxGroupTextLen() instead of hardcoded MAX_TEXT_LEN.
1 parent 52f1d69 commit c8628b6

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/Dispatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Radio {
3939
virtual float packetScore(float snr, int packet_len) = 0;
4040

4141
virtual int getMaxTextLen() const { return 10 * 16; } // default: non-JP
42+
virtual int getMaxGroupTextLen() const { return 10 * 16; } // default: non-JP
4243

4344
/**
4445
* \brief starts the raw packet send. (no wait)

src/helpers/BaseChatMesh.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ int BaseChatMesh::sendMessage(const ContactInfo& recipient, uint32_t timestamp,
436436

437437
int BaseChatMesh::sendCommandData(const ContactInfo& recipient, uint32_t timestamp, uint8_t attempt, const char* text, uint32_t& est_timeout) {
438438
int text_len = strlen(text);
439-
if (text_len > MAX_TEXT_LEN) return MSG_SEND_FAILED;
439+
int max_len = _radio->getMaxTextLen();
440+
if (text_len > max_len) return MSG_SEND_FAILED;
440441

441442
uint8_t temp[5+MAX_TEXT_LEN+1];
442443
memcpy(temp, &timestamp, 4); // mostly an extra blob to help make packet_hash unique
@@ -469,7 +470,9 @@ bool BaseChatMesh::sendGroupMessage(uint32_t timestamp, mesh::GroupChannel& chan
469470
char *ep = strchr((char *) &temp[5], 0);
470471
int prefix_len = ep - (char *) &temp[5];
471472

472-
if (text_len + prefix_len > MAX_TEXT_LEN) text_len = MAX_TEXT_LEN - prefix_len;
473+
int max_len = _radio->getMaxGroupTextLen();
474+
if (text_len + prefix_len > max_len) text_len = max_len - prefix_len;
475+
473476
memcpy(ep, text, text_len);
474477
ep[text_len] = 0; // null terminator
475478

src/helpers/radiolib/RadioLibWrappers.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,21 @@ class RadioLibWrapper : public mesh::Radio {
5454
}
5555

5656
int getMaxTextLen() const {
57-
if (!isJapanMode()) return 10 * 16; // default
57+
if (!isJapanMode()) return 10 * 16; // default 160 bytes
5858
uint8_t cr = getCodingRate();
59-
if (cr <= 5) return 3 * 16; // 48 bytes ~16 JP chars
60-
if (cr == 6) return 2 * 16; // 32 bytes ~10 JP chars
61-
if (cr == 7) return 1 * 16 + 8; // 24 bytes ~8 JP chars
62-
return 1 * 16; // 16 bytes ~5 JP chars
59+
if (cr <= 5) return 64; // 3874ms @ SF12/BW125/CR4-5
60+
if (cr == 6) return 48; // 3874ms @ SF12/BW125/CR4-6
61+
if (cr == 7) return 32; // 3678ms @ SF12/BW125/CR4-7
62+
return 24; // 3547ms @ SF12/BW125/CR4-8
63+
}
64+
65+
int getMaxGroupTextLen() const {
66+
if (!isJapanMode()) return 10 * 16; // default 160 bytes
67+
uint8_t cr = getCodingRate();
68+
if (cr <= 5) return 64; // 3710ms @ SF12/BW125/CR4-5
69+
if (cr == 6) return 48; // 3678ms @ SF12/BW125/CR4-6
70+
if (cr == 7) return 39; // 3907ms @ SF12/BW125/CR4-7
71+
return 29; // 3809ms @ SF12/BW125/CR4-8
6372
}
6473

6574
virtual int16_t performChannelScan();

0 commit comments

Comments
 (0)