tapparelj / gr-lora_sdr

This is the fully-functional GNU Radio software-defined radio (SDR) implementation of a LoRa transceiver with all the necessary receiver components to operate correctly even at very low SNRs. This work has been conducted at the Telecommunication Circuits Laboratory, EPFL.
https://www.epfl.ch/labs/tcl/
GNU General Public License v3.0
671 stars 70 forks source link

Set preamble length #34

Closed Radiomix2000 closed 1 year ago

Radiomix2000 commented 1 year ago

The LoRa has such parameter as preamble length. How to set preamble length in symbols? Does the code support preamble setting?

tapparelj commented 1 year ago

Hi @Radiomix2000 , I just pushed a new version that allow to choose the preamble length in the modulate and frame_sync blocks. You might have to use : make uninstall
make clean before building the new version to avoid conflicts of constructor definition for those two blocks. Let me know if you encounter any issue.

Radiomix2000 commented 1 year ago

Thank you a lot! By the way a question about CRC. These standard LoRa modules like SX126x, SX127x have CRC settings (CRC enabled/disabled and CRC 1 or 2, what means CRC size 1 or 2 bytes) I'm not sure, does that means header CRC and payload CRC, like CRC 1 byte means only header CRC enabled, and CRC 2 means both header and payload CRC enabled? Or this CRC 1 or 2 bytes setting is absolutely different setting? If so, is it possible to implement that 1 or 2 bytes CRC in gr-lora-sdr as well?

tapparelj commented 1 year ago

I am aware of functioning of the enable/disable payload CRC, but not of the CRC 1 or 2 that you are refering to. Could you point me toward where it is described in the datasheets?

Radiomix2000 commented 1 year ago

I found mention about 2 bytes CRC, but it's about FSK mode, not LoRa. So, it's not applicable to LoRa: image

But here I found mention about 16-bit CRC for Lora: image And again there is no apparent description, how to set it up.. Strange. I just find mention about 2 bytes CRC in different firmwares for LoRa, and this confuses me.. For example https://github.com/sh123/esp32_loraprs/blob/master/config.h

// LoRa protocol default parameters (they need to match between devices!!!)
#define CFG_LORA_FREQ_RX      433.775e6   // RX frequency in MHz
#define CFG_LORA_FREQ_TX      433.775e6   // TX frequency in MHz
#define CFG_LORA_BW           125e3       // bandwidth (from 7.8 kHz up to 500 kHz)
#define CFG_LORA_SF           12          // spreading factor (6 - 12), 6 requires implicit header mode
#define CFG_LORA_CR           7           // coding rate (5 - 8)
#define CFG_LORA_CRC          1           // 0 - disabled, 1 - 1 byte, 2 - 2 bytes
#define CFG_LORA_EXPLICIT     true        // header mode, true - explicit, false - implicit
#define CFG_LORA_SYNC         0x12        // sync word (0x12 - private used by other trackers, 0x34 - public used by LoRaWAN)
#define CFG_LORA_PWR          20          // output power in dBm
tapparelj commented 1 year ago

From what I have observed, LoRa can only enable or disable the payload CRC. The explicit header has a 5 bits checksum that cannot be disabled. The payload CRC is based on CRC-16-CCITT with a slight modification, namely the last 2 payload bytes are XORed with the CRC obtained using the standard CCITT-16 on the rest of the payload. If you want more information about how that information was found you can have a look at this reverse engineering report, section 2.5.

Radiomix2000 commented 1 year ago

Yes, thank you. I had already read your research work, it's amazing. All what I can say, that this 2 bytes CRC is somebody's misunderstanding. Really it is applicable only for FSK mode.