How to set sequence number in LoRa?

I have two LoRa devices: a transmitter and a receiver. I hard-coded the user ID in both devices so that if the user uses this ID, the sequence number will increase to 1, 2, 3, etc. What I'm trying to do is reset the sequence number to start again from 1 every time I use a different ID.

How can I achieve that?

There is nothing unique about LoRa that can handle 'sequence numbers'

LoRa just sends and receives data packets up to 255 bytes long, what you do with those packets is up to you and your program.

have a look at post need-advice-on-a-home-projectwhich maintains an array of sequence numbers one for each node

byte nodeIDs[] = { 1, 2, 3 };   // list of nodeIDs to poll
byte polledOK[] = { 2, 2, 2 };  // indicate polling sucess/failure
int seqNumbers[] = { 0, 0, 0, 0 }, seqErrors = 0;

I tried it to test it on my devises and got these massages. what I'm looking for is the same idea but instead for polling the id the user is the one how will enter the id and every time the id changes the sequence numbers will start from 1

I don't know if it will make different but I'm using Arduino uno

19:49:03.297 -> 
19:49:03.297 -> LoRa slave transmitID 1
19:49:03.297 -> Lora receive RSSI -17 packet size 1 nodeID polled 3
19:49:04.875 -> ������	��[lS*��e�ȯ�8����	���l
19:46:59.581 -> ��9����9����[9�LoRa Receiver
19:47:17.566 -> ster Receiver started
19:47:19.272 -> �����EE��m���9����[9ʓ�[�������l����e���eE��m�������R8��)���R���m��,�Ȓ�R8���I����l���R���c�LoRa Receiver
19:49:37.455 -> ter Receiver started
19:49:39.144 -> ��2��E�p���9����[9

looks like your transmitter and receiver may have different data sizes
are the transmitter and receiver the same microcontroller?
if not you may have problems with different data type sizes and structure packing
In my test I used

// test packet - must match transmitter
struct __attribute__((packed)) Struct1 {
  byte NodeID;  // ID of transmitting node
  int16_t seq;  // sequence number
  int16_t distance;
  float voltage;
  char text[20];
} struct1;

where int16_t is always signed 16bit integer etc
float is generally 4 bytes
int may be 2 or 4 bytes depending on processor
doubles can be 4 bytes (UNO etc) or 8bytes (ESP32, RP2040, etc)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.