rpp0 / gr-lora

GNU Radio blocks for receiving LoRa modulated radio messages using SDR
GNU General Public License v3.0
525 stars 113 forks source link

Header structure in Paper vs Code #106

Closed mustard123 closed 4 years ago

mustard123 commented 4 years ago

Thank you very much for answering my questions so far. I have another one regarding your paper.

Is my understanding correct that the header structure described in your paper and the one defined in code (loraphy.h) differs?

It seems to me that in code the order is: length 1byte crc high nibble 4 bits mac crc presence flag 1 bit coding rate 3 bits crc low nibble 4 bits reserved 4 bits

whereas in the paper the order you describe is: length 1 byte coding rate 3 bits mac crc presence 1 bit crc high nibble 4 bits crc low nibble 4 bits

Which one is correct? Much appreciated

lora_header_paper lora_phy_header lora-phy-header-figure why is this going from 7 to 0 and not in order i.e from 0 to 7?

rpp0 commented 4 years ago

Which one is correct?

Both are correct for bytes 0 and 1. They are just listed in different order in the code because of the way bit fields work in C. It does seem that in the code, "crc_lsn" and "reserved" should actually be swapped. If you want, you can make a pull request for this. Thanks for noticing!

Edit: on second thought, I think it actually does not matter which nibble "crc_lsn" is stored in since "reserved" is not really a field in the LoRa PHY header, but perhaps it is still better to store it in the MSN so that it corresponds to the figure from the paper.

why is this going from 7 to 0 and not in order i.e from 0 to 7?

Bit 0 usually refers to the LSB of a field, whereas byte 0 of a packet is usually the leftmost byte. See: https://en.wikipedia.org/wiki/Bit_field