Skip to content

Commit 3540ef3

Browse files
committed
Allow to specify preamble length and select modem type from platformio ini
1 parent c203b98 commit 3540ef3

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

include/config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define CONFIG_H
33

44
// Uncomment for SX126X module usage
5-
#define USE_SX126X
5+
// #define USE_SX126X
66

77
// Check your module name at https://github.com/jgromes/RadioLib/wiki/Modules
88
#ifdef USE_SX126X
@@ -69,6 +69,7 @@
6969
#define CFG_LORA_EXPLICIT true // header mode, true - explicit, false - implicit
7070
#define CFG_LORA_SYNC 0x12 // sync word (0x12 - private used by other trackers, 0x34 - public used by LoRaWAN)
7171
#define CFG_LORA_PWR 20 // output power in dBm
72+
#define CFG_LORA_PREAMBLE 8 // preamble length from 6 to 65535
7273

7374
// WiFi client and AP options
7475
#define CFG_WIFI_ENABLE_AP false // run as wifi access point (for CFG_KISS_TCP_IP mode)

include/loraprs_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct Config
2121
int LoraSync; // lora sync word/packet id, 0x34
2222
int LoraCrc; // lora crc mode, 0 - disabled, 1 - 1 byte, 2 - 2 bytes
2323
bool LoraExplicit; // lora header mode, true - explicit, false - implicit
24+
int LoraPreamble; // lora preamble length from 6 to 65535
2425

2526
// lora hardware pinouts and isr
2627
byte LoraPinSs; // lora ss pin

platformio.ini

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[platformio]
22
description = ESP32 LoRA APRS modem
3-
default_envs = esp32dev
3+
default_envs = esp32dev_sx126x_modem
44

55
[env]
66
platform = espressif32 @ 5.2.0
@@ -19,18 +19,31 @@ check_flags =
1919
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK
2020
check_skip_packages = yes
2121

22-
[env:esp32dev]
22+
[env:esp32dev_sx126x_modem]
2323
board = esp32dev
2424
build_flags =
25-
'-D CFG_IS_CLIENT_MODE=true'
25+
-D CFG_IS_CLIENT_MODE=true
26+
-D USE_SX126X
2627

27-
[env:esp32dev_igate]
28+
[env:esp32dev_sx126x_igate]
2829
board = esp32dev
2930
board_build.f_cpu = 240000000L
3031
build_flags =
31-
'-D CFG_IS_CLIENT_MODE=false'
32+
-D CFG_IS_CLIENT_MODE=false
33+
-D USE_SX126X
3234

33-
[env:ttgo-lora32-v1]
35+
[env:esp32dev_sx127x_modem]
36+
board = esp32dev
37+
build_flags =
38+
-D CFG_IS_CLIENT_MODE=true
39+
40+
[env:esp32dev_sx127x_igate]
41+
board = esp32dev
42+
board_build.f_cpu = 240000000L
43+
build_flags =
44+
-D CFG_IS_CLIENT_MODE=false
45+
46+
[env:ttgo-lora32-v1_modem]
3447
board = ttgo-lora32-v1
3548
build_flags =
36-
'-D CFG_IS_CLIENT_MODE=true'
49+
-D CFG_IS_CLIENT_MODE=true

src/loraprs_service.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ void Service::setupRig(long loraFreq, long bw, int sf, int cr, int pwr, int sync
239239
LOG_ERROR("Radio start error:", state);
240240
}
241241
rig_->setCRC(crcBytes);
242+
rig_->setPreambleLength(config_.LoraPreamble);
242243
#ifdef USE_SX126X
243244
#pragma message("Using SX126X")
244245
LOG_INFO("Using SX126X module");

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void initializeConfig(LoraPrs::Config &cfg) {
4141
cfg.LoraCrc = CFG_LORA_CRC; // set to 0 to disable
4242
cfg.LoraExplicit = CFG_LORA_EXPLICIT;
4343
cfg.LoraPower = CFG_LORA_PWR;
44+
cfg.LoraPreamble = CFG_LORA_PREAMBLE;
4445

4546
// lora pinouts
4647
cfg.LoraPinSs = CFG_LORA_PIN_SS;

0 commit comments

Comments
 (0)