JP_STRICT: adjust MAX_TEXT_LEN based on LORA_CR setting

MAX_TEXT_LEN is automatically selected based on the LORA_CR build flag
defined in platformio.ini (e.g. -D LORA_CR=5).

CR4/5: 48 bytes (~16 JP chars, TX ~3808ms)
CR4/6: 32 bytes (~10 JP chars)
CR4/7: 24 bytes (~8 JP chars)
CR4/8: 16 bytes (~5 JP chars, default)

To enable CR4/5 for Japan, add -D LORA_CR=5 to your board's
build_flags in platformio.ini. Set LORA_CR=5 for WioTrackerL1 and RAK WisMesh Tag.
This commit is contained in:
jirogit 2026-03-25 19:39:46 -07:00
parent f4519b19c8
commit eb58523775
3 changed files with 18 additions and 4 deletions

View file

@ -6,12 +6,24 @@
#include <helpers/TxtDataHelpers.h>
// JP_STRICT: limit MAX_TEXT_LEN to keep TX time under 4s (ARIB STD-T108)
// SF12/BW125/CR4-8: 60 bytes total packet = ~3809ms, overhead ~44 bytes
// leaving 16 bytes (1*CIPHER_BLOCK_SIZE) for text payload
// SF12/BW125, packet overhead ~44 bytes
// CR4/5: 100 bytes total = ~3808ms → 56 bytes text → ~18 JP chars
// CR4/6: 80 bytes total = ~3530ms → 36 bytes text → ~12 JP chars
// CR4/7: 70 bytes total = ~3530ms → 26 bytes text → ~8 JP chars
// CR4/8: 60 bytes total = ~3809ms → 16 bytes text → ~5 JP chars
#ifdef JP_STRICT
#define MAX_TEXT_LEN (1*CIPHER_BLOCK_SIZE) // ~16 chars, TX <= 4s for JP
#if defined(LORA_CR) && (LORA_CR == 5)
#define MAX_TEXT_LEN (3*CIPHER_BLOCK_SIZE) // 48 bytes ~18 JP chars
#elif defined(LORA_CR) && (LORA_CR == 6)
#define MAX_TEXT_LEN (2*CIPHER_BLOCK_SIZE) // 32 bytes ~10 JP chars
#elif defined(LORA_CR) && (LORA_CR == 7)
#define MAX_TEXT_LEN (1*CIPHER_BLOCK_SIZE+8) // 24 bytes ~8 JP chars
#else
#define MAX_TEXT_LEN (1*CIPHER_BLOCK_SIZE) // 16 bytes ~5 JP chars
#endif
#else
#define MAX_TEXT_LEN (10*CIPHER_BLOCK_SIZE) // must be LESS than (MAX_PACKET_PAYLOAD - 4 - CIPHER_MAC_SIZE - 1)
#define MAX_TEXT_LEN (10*CIPHER_BLOCK_SIZE)
// must be LESS than (MAX_PACKET_PAYLOAD - 4 - CIPHER_MAC_SIZE - 1)
#endif
#include "ContactInfo.h"

View file

@ -26,6 +26,7 @@ build_flags = ${nrf52_base.build_flags}
-D PIN_BOARD_SDA=PIN_WIRE_SDA
-D PIN_BOARD_SCL=PIN_WIRE_SCL
-D JP_STRICT
-D LORA_CR=5
build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/rak_wismesh_tag>
+<helpers/ui/MomentaryButton.cpp>

View file

@ -17,6 +17,7 @@ build_flags = ${nrf52_base.build_flags}
-D PIN_OLED_RESET=-1
-D GPS_BAUD_RATE=9600
-D JP_STRICT
-D LORA_CR=5
build_src_filter = ${nrf52_base.build_src_filter}
+<WioTrackerL1Board.cpp>
+<../variants/wio-tracker-l1>