Compare commits
13 Commits
a57b3bc6de
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f10ee8329 | |||
| 17a99ddd54 | |||
| eb827f5a60 | |||
| bc60028852 | |||
| 0ef379595f | |||
| 185d15cbaf | |||
| b728ca3c75 | |||
| c15afa9819 | |||
| 192a008150 | |||
| c827989f43 | |||
| 6115cd6b84 | |||
|
|
c84006da8a | ||
|
|
3157b8e4a8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@ Console/build
|
||||
build/*
|
||||
.pio/*
|
||||
.vscode/*
|
||||
Release/*.bin
|
||||
|
||||
31
Boards.h
31
Boards.h
@@ -151,6 +151,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define LORA_PA_UNKNOWN 0x00
|
||||
#define LORA_PA_GC1109 0x01
|
||||
#define LORA_PA_KCT8103L 0x02
|
||||
|
||||
#define HAS_DISPLAY false
|
||||
#define HAS_BLUETOOTH false
|
||||
#define HAS_BLE false
|
||||
@@ -363,7 +367,7 @@
|
||||
#define HAS_SLEEP true
|
||||
#define PIN_WAKEUP GPIO_NUM_0
|
||||
#define WAKEUP_LEVEL 0
|
||||
#define OCP_TUNED 0x18
|
||||
#define OCP_TUNED 0x28
|
||||
|
||||
const int pin_btn_usr1 = 0;
|
||||
|
||||
@@ -411,8 +415,9 @@
|
||||
#define HAS_LORA_LNA true
|
||||
#define PIN_WAKEUP GPIO_NUM_0
|
||||
#define WAKEUP_LEVEL 0
|
||||
#define OCP_TUNED 0x18
|
||||
#define OCP_TUNED 0x28
|
||||
#define Vext GPIO_NUM_36
|
||||
#define LORA_PA_MODEL LORA_PA_UNKNOWN;
|
||||
|
||||
const int pin_btn_usr1 = 0;
|
||||
|
||||
@@ -434,14 +439,17 @@
|
||||
|
||||
#define LORA_LNA_GAIN 17
|
||||
#define LORA_LNA_GVT 12
|
||||
#define LORA_PA_GC1109 true
|
||||
#define LORA_PA_PWR_EN 7
|
||||
#define LORA_PA_CSD 2
|
||||
#define LORA_PA_CPS 46
|
||||
#define LORA_PA_CSD 2 // Same pin on GC1109
|
||||
#define LORA_PA_CPS 46 // Same pin on GC1109
|
||||
#define LORA_PA_CTX 5 // Only used on KCT8103
|
||||
|
||||
#define PA_MAX_OUTPUT 28
|
||||
#define PA_GAIN_POINTS 22
|
||||
#define PA_GAIN_VALUES 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7
|
||||
|
||||
#define LORA_LNA_KCT8103L_GAIN 21
|
||||
const int PA_GC1109_VALUES[PA_GAIN_POINTS] = {11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7};
|
||||
const int PA_KCT8103L_VALUES[PA_GAIN_POINTS] = {13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 7};
|
||||
|
||||
const int pin_cs = 8;
|
||||
const int pin_busy = 13;
|
||||
@@ -529,13 +537,10 @@
|
||||
const int pin_np = 12;
|
||||
const int pin_dac = 25;
|
||||
const int pin_adc = 34;
|
||||
// CBA already defined by framework
|
||||
//const int SD_MISO = 2;
|
||||
// CBA already defined by framework
|
||||
//const int SD_MOSI = 15;
|
||||
const int SD_MISO = 2;
|
||||
const int SD_MOSI = 15;
|
||||
const int SD_CLK = 14;
|
||||
// CBA already defined by framework
|
||||
//const int SD_CS = 13;
|
||||
const int SD_CS = 13;
|
||||
#if HAS_NP == false
|
||||
#if defined(EXTERNAL_LEDS)
|
||||
const int pin_led_rx = 12;
|
||||
@@ -980,7 +985,7 @@
|
||||
// Default OCP value if not specified
|
||||
// in board configuration
|
||||
#ifndef OCP_TUNED
|
||||
#define OCP_TUNED 0x18
|
||||
#define OCP_TUNED 0x28
|
||||
#endif
|
||||
|
||||
#ifndef PA_MAX_OUTPUT
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
#include <WebServer.h>
|
||||
#include <DNSServer.h>
|
||||
|
||||
// ─── Node hash (cached in RTC by normal boot, read here without starting RNS) ─
|
||||
#define NODE_HASH_RTC_MAGIC 0x504B4841UL
|
||||
extern uint32_t rtc_node_hash_magic;
|
||||
extern char rtc_node_hash_hex[33];
|
||||
|
||||
// ─── Config Portal State ─────────────────────────────────────────────────────
|
||||
static bool config_portal_active = false;
|
||||
static WebServer* config_server = nullptr;
|
||||
@@ -126,12 +131,25 @@ static void config_send_html() {
|
||||
"button:hover{background:#c73e54;}"
|
||||
".ok{background:#16213e;padding:20px;border-radius:8px;text-align:center;}"
|
||||
".ok h1{color:#0f0;}"
|
||||
".node-hash{background:#0f1a30;border:1px solid #0f3460;border-radius:6px;"
|
||||
"padding:10px 14px;margin:0 0 16px;}"
|
||||
".node-hash .nh-label{display:block;font-size:0.75em;color:#888;margin-bottom:4px;}"
|
||||
".node-hash code{font-family:monospace;font-size:0.95em;color:#7ecfff;"
|
||||
"word-break:break-all;letter-spacing:0.05em;}"
|
||||
"</style></head><body>"
|
||||
"<h1>📡 RNode Boundary Node</h1>"
|
||||
"<form method='POST' action='/save'>"
|
||||
);
|
||||
|
||||
// ── WiFi STA Section ──
|
||||
// ── Node public hash ──
|
||||
html += F("<div class='node-hash'><span class='nh-label'>🔑 Node Hash (Reticulum destination)</span><code>");
|
||||
if (rtc_node_hash_magic == NODE_HASH_RTC_MAGIC && rtc_node_hash_hex[0] != '\0') {
|
||||
html += String(rtc_node_hash_hex);
|
||||
} else {
|
||||
html += F("<span style='color:#888;font-style:italic;'>Not yet assigned — will be set on first normal boot</span>");
|
||||
}
|
||||
html += F("</code></div>");
|
||||
|
||||
html += F("<form method='POST' action='/save'>");
|
||||
html += F(
|
||||
"<h2>📶 WiFi Network</h2>"
|
||||
"<label>WiFi</label>"
|
||||
|
||||
2
Config.h
2
Config.h
@@ -20,7 +20,7 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define MAJ_VERS 0x01
|
||||
#define MIN_VERS 0x55
|
||||
#define MIN_VERS 0x56
|
||||
|
||||
#define MODE_HOST 0x11
|
||||
#define MODE_TNC 0x12
|
||||
|
||||
@@ -100,7 +100,7 @@ extern BoundaryState boundary_state;
|
||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
||||
#define DISP_RST -1
|
||||
#define DISP_ADDR 0x3C
|
||||
#define SCL_OLED 44
|
||||
#define SCL_OLED 0
|
||||
#define SDA_OLED 42
|
||||
#elif BOARD_MODEL == BOARD_RAK4631
|
||||
// RAK1921/SSD1306
|
||||
|
||||
@@ -259,6 +259,13 @@ RTC_NOINIT_ATTR uint32_t boundary_skip_config;
|
||||
RTC_NOINIT_ATTR uint32_t bootloop_magic;
|
||||
RTC_NOINIT_ATTR uint32_t bootloop_count;
|
||||
RTC_NOINIT_ATTR uint32_t bootloop_first_boot_ms;
|
||||
|
||||
// Node public hash — cached in RTC so the config portal can display it without
|
||||
// needing to start RNS. Populated after the transport destination is created
|
||||
// on a normal boot; survives software reboots into the captive portal.
|
||||
#define NODE_HASH_RTC_MAGIC 0x504B4841UL // "PKHA"
|
||||
RTC_NOINIT_ATTR uint32_t rtc_node_hash_magic;
|
||||
RTC_NOINIT_ATTR char rtc_node_hash_hex[33]; // 32 hex chars + NUL
|
||||
#endif
|
||||
|
||||
#endif // HAS_RNS
|
||||
@@ -404,7 +411,7 @@ void setup() {
|
||||
#if MODEM == SX1276 || MODEM == SX1278
|
||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy);
|
||||
#elif MODEM == SX1262
|
||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen);
|
||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen, pin_txen);
|
||||
#elif MODEM == SX1280
|
||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen, pin_txen);
|
||||
#endif
|
||||
@@ -927,6 +934,17 @@ void setup() {
|
||||
*/
|
||||
RNS::Destination destination(RNS::Transport::identity(), RNS::Type::Destination::IN, RNS::Type::Destination::SINGLE, "rnstransport", "local");
|
||||
|
||||
// Cache this node's destination hash in RTC memory so the captive-portal
|
||||
// config page can show it without needing RNS to be running.
|
||||
{
|
||||
std::string h = destination.hash().toHex();
|
||||
size_t len = h.length();
|
||||
if (len > 32) len = 32;
|
||||
memcpy(rtc_node_hash_hex, h.c_str(), len);
|
||||
rtc_node_hash_hex[len] = '\0';
|
||||
rtc_node_hash_magic = NODE_HASH_RTC_MAGIC;
|
||||
}
|
||||
|
||||
HEAD("RNS is READY!", RNS::LOG_TRACE);
|
||||
#ifdef BOUNDARY_MODE
|
||||
HEAD("*** BOUNDARY MODE ACTIVE ***", RNS::LOG_TRACE);
|
||||
@@ -1568,7 +1586,7 @@ void serial_callback(uint8_t sbyte) {
|
||||
if (txp > 13) txp = 13;
|
||||
#endif
|
||||
#else
|
||||
if (txp > 17) txp = 17;
|
||||
if (txp > 20) txp = 20;
|
||||
#endif
|
||||
|
||||
lora_txp = txp;
|
||||
@@ -2630,7 +2648,13 @@ void sleep_now() {
|
||||
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
||||
headless_led_off();
|
||||
headless_led_detach_pwm();
|
||||
digitalWrite(LORA_PA_CPS, LOW);
|
||||
#if LORA_PA_AUTO_DETECT
|
||||
if (sx126x_modem.isKCT8103L()) {
|
||||
digitalWrite(LORA_PA_CTX, LOW);
|
||||
} else {
|
||||
digitalWrite(LORA_PA_CPS, LOW);
|
||||
}
|
||||
#endif
|
||||
digitalWrite(LORA_PA_CSD, LOW);
|
||||
digitalWrite(LORA_PA_PWR_EN, LOW);
|
||||
digitalWrite(Vext, HIGH);
|
||||
|
||||
Binary file not shown.
22
Utilities.h
22
Utilities.h
@@ -1383,11 +1383,33 @@ int getTxPower() {
|
||||
}
|
||||
|
||||
#if HAS_LORA_PA
|
||||
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
||||
bool pa_values_determined = false;
|
||||
int tx_gain[PA_GAIN_POINTS] = {100};
|
||||
#else
|
||||
bool pa_values_determined = true;
|
||||
const int tx_gain[PA_GAIN_POINTS] = {PA_GAIN_VALUES};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern uint8_t lora_pa_model;
|
||||
void determine_pa_values() {
|
||||
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
||||
if (lora_pa_model == LORA_PA_GC1109) {
|
||||
for (int i=0; i < PA_GAIN_POINTS; i++) { tx_gain[i] = PA_GC1109_VALUES[i]; }
|
||||
pa_values_determined = true;
|
||||
for (int i=0; i < PA_GAIN_POINTS; i++) { Serial.print(" "); Serial.printf("%d", tx_gain[i]); }
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
for (int i=0; i < PA_GAIN_POINTS; i++) { tx_gain[i] = PA_KCT8103L_VALUES[i]; }
|
||||
pa_values_determined = true;
|
||||
for (int i=0; i < PA_GAIN_POINTS; i++) { Serial.print(" "); Serial.printf("%d", tx_gain[i]); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int map_target_power_to_modem_output(int target_tx_power) {
|
||||
#if HAS_LORA_PA
|
||||
if (!pa_values_determined) { determine_pa_values(); }
|
||||
int modem_output_dbm = -9;
|
||||
for (int i = 0; i < PA_GAIN_POINTS; i++) {
|
||||
int gain = tx_gain[i];
|
||||
|
||||
0
lib/microReticulum/library.properties
Normal file → Executable file
0
lib/microReticulum/library.properties
Normal file → Executable file
@@ -34,7 +34,7 @@ build_src_filter = +<*> -<variants/>
|
||||
extra_scripts = pre:extra_script.py
|
||||
|
||||
[env:rnode-ng-20]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v2
|
||||
custom_variant = ng20
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -48,7 +48,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:rnode-ng-21]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v21
|
||||
custom_variant = ng21
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -62,7 +62,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-t-beam]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-t-beam
|
||||
custom_variant = tbeam
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -76,7 +76,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-t-beam-sx1262]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-t-beam
|
||||
custom_variant = tbeam_sx1262
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -91,7 +91,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-t-beam-supreme]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-t-beam
|
||||
custom_variant = tbeam_supreme
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -108,7 +108,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:lilygo-t3-s3]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = lilygo-t3-s3
|
||||
custom_variant = t3s3
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -123,7 +123,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:lilygo-t3-s3-sx127x]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = lilygo-t3-s3
|
||||
custom_variant = t3s3_sx127x
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -138,7 +138,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:lilygo-t3-s3-sx1280-pa]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = lilygo-t3-s3
|
||||
custom_variant = t3s3_sx1280_pa
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -153,7 +153,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:lilygo-t-deck]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = tdeck
|
||||
board_build.filesystem = littlefs
|
||||
@@ -176,7 +176,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v1]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v1
|
||||
custom_variant = lora32v10
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -190,7 +190,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v2]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v2
|
||||
custom_variant = lora32v20
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -204,7 +204,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v2-extled]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v2
|
||||
custom_variant = lora32v20_extled
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -219,7 +219,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v21]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v21
|
||||
custom_variant = lora32v21
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -233,7 +233,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v21-extled]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v21
|
||||
custom_variant = lora32v21_extled
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -248,7 +248,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-lora32-v21-tcxo]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v21
|
||||
custom_variant = lora32v21_extled
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -263,7 +263,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:heltec_wifi_lora_32_V2]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = heltec_wifi_lora_32_V2
|
||||
custom_variant = heltec32v2
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -277,7 +277,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:heltec_wifi_lora_32_V2-extled]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = heltec_wifi_lora_32_V2
|
||||
custom_variant = heltec32v2_extled
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -292,7 +292,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:heltec_wifi_lora_32_V3]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = heltec_wifi_lora_32_V3
|
||||
custom_variant = heltec32v3
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -306,7 +306,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:heltec_V3_boundary]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = heltec_wifi_lora_32_V3
|
||||
custom_variant = heltec32v3
|
||||
board_build.filesystem = littlefs
|
||||
@@ -333,7 +333,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:heltec_wifi_lora_32_V4]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = heltec32v4
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -348,7 +348,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:meshadventurer_S3_boundary]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = meshadventurer_s3_boundary
|
||||
board_build.filesystem = littlefs
|
||||
@@ -376,7 +376,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:heltec_V4_boundary]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = heltec32v4_boundary
|
||||
board_build.filesystem = littlefs
|
||||
@@ -404,7 +404,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:heltec_V4_boundary-local]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = heltec32v4_boundary_local
|
||||
board_build.filesystem = littlefs
|
||||
@@ -429,7 +429,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:featheresp32]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = featheresp32
|
||||
custom_variant = featheresp32
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -443,7 +443,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:seeed_xiao_esp32s3]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = seeed_xiao_esp32s3
|
||||
custom_variant = xiao_esp32s3
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -457,7 +457,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:generic-esp32]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32dev
|
||||
custom_variant = esp32_generic
|
||||
board_build.partitions = no_ota.csv
|
||||
@@ -489,7 +489,7 @@ lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.15.4
|
||||
|
||||
[env:ttgo-t-beam-local]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-t-beam
|
||||
upload_speed = 460800
|
||||
custom_variant = tbeam_local
|
||||
@@ -507,7 +507,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:ttgo-lora32-v21-local]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = ttgo-lora32-v21
|
||||
upload_speed = 460800
|
||||
custom_variant = lora32v21_local
|
||||
@@ -523,7 +523,7 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
[env:heltec_wifi_lora_32_V4-local]
|
||||
platform = espressif32
|
||||
platform = espressif32@6.12.0
|
||||
board = esp32-s3-devkitc-1
|
||||
custom_variant = heltec32v4_local
|
||||
board_build.partitions = no_ota.csv
|
||||
|
||||
2841
rnodethv3.log
2841
rnodethv3.log
File diff suppressed because it is too large
Load Diff
121
sx126x.cpp
121
sx126x.cpp
@@ -96,13 +96,21 @@
|
||||
#define SPI spiModem
|
||||
#endif
|
||||
|
||||
#if HAS_LORA_PA
|
||||
uint8_t lora_pa_model = LORA_PA_MODEL;
|
||||
#endif
|
||||
|
||||
#if HAS_LORA_LNA
|
||||
int lora_lna_gain = LORA_LNA_GAIN;
|
||||
#endif
|
||||
|
||||
extern SPIClass SPI;
|
||||
|
||||
#define MAX_PKT_LENGTH 255
|
||||
|
||||
sx126x::sx126x() :
|
||||
_spiSettings(16E6, MSBFIRST, SPI_MODE0),
|
||||
_ss(LORA_DEFAULT_SS_PIN), _reset(LORA_DEFAULT_RESET_PIN), _dio0(LORA_DEFAULT_DIO0_PIN), _busy(LORA_DEFAULT_BUSY_PIN), _rxen(LORA_DEFAULT_RXEN_PIN),
|
||||
_ss(LORA_DEFAULT_SS_PIN), _reset(LORA_DEFAULT_RESET_PIN), _dio0(LORA_DEFAULT_DIO0_PIN), _busy(LORA_DEFAULT_BUSY_PIN), _rxen(LORA_DEFAULT_RXEN_PIN), _txen(LORA_DEFAULT_TXEN_PIN),
|
||||
_frequency(0),
|
||||
_txp(0),
|
||||
_sf(0x07),
|
||||
@@ -184,6 +192,7 @@ uint8_t ISR_VECT sx126x::singleTransfer(uint8_t opcode, uint16_t address, uint8_
|
||||
|
||||
void sx126x::rxAntEnable() {
|
||||
if (_rxen != -1) { digitalWrite(_rxen, HIGH); }
|
||||
if (_txen != -1) { digitalWrite(_txen, LOW); }
|
||||
}
|
||||
|
||||
void sx126x::loraMode() {
|
||||
@@ -274,6 +283,21 @@ void sx126x::setPacketParams(long preamble_symbols, uint8_t headermode, uint8_t
|
||||
buf[7] = 0x00;
|
||||
buf[8] = 0x00;
|
||||
executeOpcode(OP_PACKET_PARAMS_6X, buf, 9);
|
||||
|
||||
// SX1262 errata section 15.4: IQ polarity is inverted compared to
|
||||
// SX1276. The SetPacketParams command resets register 0x0736 to an
|
||||
// incorrect default. For standard IQ (no inversion), bit 2 must be
|
||||
// SET after every SetPacketParams call. For inverted IQ, bit 2 must
|
||||
// be CLEARED. Without this fix, LoRa RX demodulation fails silently
|
||||
// while TX continues to work.
|
||||
uint8_t iqreg = readRegister(0x0736);
|
||||
if (buf[5] == 0x00) {
|
||||
// Standard IQ: set bit 2
|
||||
writeRegister(0x0736, iqreg | 0x04);
|
||||
} else {
|
||||
// Inverted IQ: clear bit 2
|
||||
writeRegister(0x0736, iqreg & ~0x04);
|
||||
}
|
||||
}
|
||||
|
||||
void sx126x::reset(void) {
|
||||
@@ -286,6 +310,22 @@ void sx126x::reset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void sx126x::setDCDCRegulator(void) {
|
||||
// Documentation
|
||||
// 5. Power Distribution -> 5.1 Selecting DC-DC Converter or LDO Regulation
|
||||
// 13.1.11 SetRegulatorMode
|
||||
|
||||
uint8_t mode_byte = MODE_STDBY_RC_6X;
|
||||
executeOpcode(OP_STANDBY_6X, &mode_byte, 1);
|
||||
|
||||
// Enable DC-DC regulator for high power operation
|
||||
uint8_t reg_mode = 0x01; // 0x00 = LDO, 0x01 = DC-DC
|
||||
executeOpcode(OP_REGULATOR_MODE_6X, ®_mode, 1);
|
||||
|
||||
delay(5);
|
||||
waitOnBusy();
|
||||
}
|
||||
|
||||
void sx126x::calibrate(void) {
|
||||
// Put in STDBY_RC mode before calibration
|
||||
uint8_t mode_byte = MODE_STDBY_RC_6X;
|
||||
@@ -316,10 +356,21 @@ int sx126x::begin(long frequency) {
|
||||
if (_busy != -1) { pinMode(_busy, INPUT); }
|
||||
if (!_preinit_done) { if (!preInit()) { return false; } }
|
||||
if (_rxen != -1) { pinMode(_rxen, OUTPUT); }
|
||||
if (_txen != -1) { pinMode(_txen, OUTPUT); }
|
||||
|
||||
//TODO: if it works, make it optional
|
||||
//#ifdef SX1262_USE_DCDC_REGULATOR
|
||||
setDCDCRegulator();
|
||||
//#endif
|
||||
|
||||
calibrate();
|
||||
calibrate_image(frequency);
|
||||
enableTCXO();
|
||||
#if HAS_TCXO
|
||||
enableTCXO();
|
||||
//13.1.15 SetRxTxFallbackMode to STDBY_XOSC
|
||||
uint8_t fallback_mode = 0x30; // STDBY_XOSC after TX/RX
|
||||
executeOpcode(OP_RX_TX_FALLBACK_MODE_6X, &fallback_mode, 1);
|
||||
#endif
|
||||
loraMode();
|
||||
standby();
|
||||
|
||||
@@ -336,7 +387,9 @@ int sx126x::begin(long frequency) {
|
||||
setFrequency(frequency);
|
||||
setTxPower(2);
|
||||
enableCrc();
|
||||
writeRegister(REG_LNA_6X, 0x96); // Set LNA boost
|
||||
writeRegister(REG_LNA_6X, 0x96); // Set LNA boosted gain mode
|
||||
// Undocumented SX1262 register patch recommended by Heltec/Semtech for improved RX sensitivity.
|
||||
writeRegister(0x08B5, readRegister(0x08B5) | 0x01);
|
||||
uint8_t basebuf[2] = {0}; // Set base addresses
|
||||
executeOpcode(OP_BUFFER_BASE_ADDR_6X, basebuf, 2);
|
||||
|
||||
@@ -344,7 +397,22 @@ int sx126x::begin(long frequency) {
|
||||
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
||||
|
||||
#if HAS_LORA_PA
|
||||
#if LORA_PA_GC1109
|
||||
if (lora_pa_model == LORA_PA_UNKNOWN) {
|
||||
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
||||
|
||||
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
||||
pinMode(LORA_PA_CSD, INPUT);
|
||||
digitalWrite(LORA_PA_PWR_EN, HIGH); delay(5);
|
||||
if (digitalRead(LORA_PA_CSD) == HIGH) {
|
||||
lora_pa_model = LORA_PA_KCT8103L;
|
||||
lora_lna_gain = LORA_LNA_KCT8103L_GAIN;
|
||||
} else {
|
||||
lora_pa_model = LORA_PA_GC1109;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (lora_pa_model == LORA_PA_GC1109) {
|
||||
// Enable Vfem_ctl for supply to
|
||||
// PA power net.
|
||||
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
||||
@@ -369,7 +437,26 @@ int sx126x::begin(long frequency) {
|
||||
// is driven by the SX1262 DIO2
|
||||
// pin directly, so we do not
|
||||
// need to manually raise this.
|
||||
#endif
|
||||
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
// Enable Vfem_ctl for supply to
|
||||
// PA power net.
|
||||
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
||||
digitalWrite(LORA_PA_PWR_EN, HIGH);
|
||||
|
||||
// Enable KCT8103L chip
|
||||
pinMode(LORA_PA_CSD, OUTPUT);
|
||||
digitalWrite(LORA_PA_CSD, HIGH);
|
||||
|
||||
// Enable receive LNA
|
||||
pinMode(LORA_PA_CTX, OUTPUT);
|
||||
digitalWrite(LORA_PA_CTX, LOW);
|
||||
|
||||
// On Heltec V4.3, the PA CPS pin
|
||||
// is driven by the SX1262 DIO2
|
||||
// pin directly, so we do not
|
||||
// need to manually raise this.
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -379,15 +466,19 @@ void sx126x::end() { sleep(); SPI.end(); _preinit_done = false; }
|
||||
|
||||
int sx126x::beginPacket(int implicitHeader) {
|
||||
#if HAS_LORA_PA
|
||||
#if LORA_PA_GC1109
|
||||
if (lora_pa_model == LORA_PA_GC1109) {
|
||||
// Enable PA CPS for transmit
|
||||
// digitalWrite(LORA_PA_CPS, HIGH);
|
||||
// Disabled since we're keeping it
|
||||
// on permanently as long as the
|
||||
// radio is powered up.
|
||||
#endif
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
digitalWrite(LORA_PA_CTX, HIGH);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_txen != -1) { digitalWrite(_txen, HIGH); } //Set TXen high when transmitting
|
||||
|
||||
standby();
|
||||
if (implicitHeader) { implicitHeaderMode(); }
|
||||
else { explicitHeaderMode(); }
|
||||
@@ -401,6 +492,9 @@ int sx126x::beginPacket(int implicitHeader) {
|
||||
|
||||
int sx126x::endPacket() {
|
||||
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
||||
|
||||
if (_rxen != -1) { digitalWrite(_rxen, LOW); } //Set RXen low when transmitting
|
||||
|
||||
uint8_t timeout[3] = {0}; // Put in single TX mode
|
||||
executeOpcode(OP_TX_6X, timeout, 3);
|
||||
|
||||
@@ -473,7 +567,7 @@ int ISR_VECT sx126x::currentRssi() {
|
||||
executeOpcodeRead(OP_CURRENT_RSSI_6X, &byte, 1);
|
||||
int rssi = -(int(byte)) / 2;
|
||||
#if HAS_LORA_LNA
|
||||
rssi -= LORA_LNA_GAIN;
|
||||
rssi -= lora_lna_gain;
|
||||
#endif
|
||||
return rssi;
|
||||
}
|
||||
@@ -489,7 +583,7 @@ int ISR_VECT sx126x::packetRssi() {
|
||||
executeOpcodeRead(OP_PACKET_STATUS_6X, buf, 3);
|
||||
int pkt_rssi = -buf[0] / 2;
|
||||
#if HAS_LORA_LNA
|
||||
pkt_rssi -= LORA_LNA_GAIN;
|
||||
pkt_rssi -= lora_lna_gain;
|
||||
#endif
|
||||
return pkt_rssi;
|
||||
}
|
||||
@@ -596,7 +690,7 @@ void sx126x::onReceive(void(*callback)(int)){
|
||||
|
||||
void sx126x::receive(int size) {
|
||||
#if HAS_LORA_PA
|
||||
#if LORA_PA_GC1109
|
||||
if (lora_pa_model == LORA_PA_GC1109) {
|
||||
// Disable PA CPS for receive
|
||||
// digitalWrite(LORA_PA_CPS, LOW);
|
||||
// That turned out to be a bad idea.
|
||||
@@ -604,7 +698,9 @@ void sx126x::receive(int size) {
|
||||
// on and off too quickly. We'll keep
|
||||
// it on permanently, as long as the
|
||||
// radio is powered up.
|
||||
#endif
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
digitalWrite(LORA_PA_CTX, LOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (size > 0) {
|
||||
@@ -772,12 +868,13 @@ void sx126x::setSyncWord(uint16_t sw) {
|
||||
writeRegister(REG_SYNC_WORD_LSB_6X, 0x24);
|
||||
}
|
||||
|
||||
void sx126x::setPins(int ss, int reset, int dio0, int busy, int rxen) {
|
||||
void sx126x::setPins(int ss, int reset, int dio0, int busy, int rxen, int txen) {
|
||||
_ss = ss;
|
||||
_reset = reset;
|
||||
_dio0 = dio0;
|
||||
_busy = busy;
|
||||
_rxen = rxen;
|
||||
_txen = txen;
|
||||
}
|
||||
|
||||
void sx126x::dumpRegisters(Stream& out) {
|
||||
|
||||
10
sx126x.h
10
sx126x.h
@@ -74,6 +74,7 @@ public:
|
||||
void disableCrc();
|
||||
void enableTCXO();
|
||||
void disableTCXO();
|
||||
void setDCDCRegulator();
|
||||
|
||||
void rxAntEnable();
|
||||
void loraMode();
|
||||
@@ -92,11 +93,13 @@ public:
|
||||
|
||||
byte random();
|
||||
|
||||
void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN, int busy = LORA_DEFAULT_BUSY_PIN, int rxen = LORA_DEFAULT_RXEN_PIN);
|
||||
void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN, int busy = LORA_DEFAULT_BUSY_PIN, int rxen = LORA_DEFAULT_RXEN_PIN, int txen = LORA_DEFAULT_TXEN_PIN);
|
||||
void setSPIFrequency(uint32_t frequency);
|
||||
|
||||
void dumpRegisters(Stream& out);
|
||||
|
||||
bool isKCT8103L() { return _kct8103l; }
|
||||
|
||||
private:
|
||||
void explicitHeaderMode();
|
||||
void implicitHeaderMode();
|
||||
@@ -107,7 +110,8 @@ public:
|
||||
// Poll for deferred DIO0 interrupt (call from main loop)
|
||||
void pollDio0();
|
||||
|
||||
private: uint8_t readRegister(uint16_t address);
|
||||
private:
|
||||
uint8_t readRegister(uint16_t address);
|
||||
void writeRegister(uint16_t address, uint8_t value);
|
||||
uint8_t singleTransfer(uint8_t opcode, uint16_t address, uint8_t value);
|
||||
|
||||
@@ -125,6 +129,7 @@ private:
|
||||
int _reset;
|
||||
int _dio0;
|
||||
int _rxen;
|
||||
int _txen;
|
||||
int _busy;
|
||||
long _frequency;
|
||||
int _txp;
|
||||
@@ -141,6 +146,7 @@ private:
|
||||
int _fifo_rx_addr_ptr;
|
||||
uint8_t _packet[255];
|
||||
bool _preinit_done;
|
||||
bool _kct8103l;
|
||||
volatile bool _dio0_risen;
|
||||
void (*_onReceive)(int);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user