简体   繁体   中英

Difference between unsigned short and unsigned char in LoRa communication

I am working on establishing a lora communication between a gateway (RPI3 + LoRa hat) and a node (RPi3 + LoRa hat). As I would like to establish the communication channel without TTN, I tried the following example to setup communication between the two: https://github.com/dragino/rpi-lora-tranceiver/blob/master/dragino_lora_app/main.c

The code works well on both as both the sender and receiver ends. That means that on the sender side, the message to be sent is being printed on the console. And on the receiver side, the received message is being displayed.

This works well for short messages. However, I would like to send a message that is 600 bytes long. In order to send this long message, I edited typedef of writeBuf() argument as follows:

static void writeBuf(byte addr, byte *value, unsigned short len) {

I made this change because byte len was limiting message to be sent to 255 (due to the range of unsugned char which is 0-255). And so I needed to extend this range so that I can send a longer message. With this change being made, no message is being printed in the console. The for loop within writeBuf() goes from 0-n and then from 99-n continuously with no send message being printed on the console. Hence, the receiver is never receiving any message. I understand the difference between unsigned short and unsigned char . However, I am not able to understand the difference between unsigned short and unsigned char in this context. Any help/guidance would be highly appreciated. I would also like to know if I am making the right changes or looking at the right direction or not.

Thank you

For the European 863-870MHz band, the application packet size varies between 51 bytes for the slowest data rate, and 222 bytes for faster rates. Cf. https://www.thethingsnetwork.org/forum/t/limitations-data-rate-packet-size-30-seconds-uplink-and-10-messages-downlink-per-day-fair-access-policy/1300

You definitively cannot have more than 255 bytes in a message including header bytes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM