Compare commits
1 Commits
main
...
a57b3bc6de
| Author | SHA1 | Date | |
|---|---|---|---|
| a57b3bc6de |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,4 +16,3 @@ Console/build
|
|||||||
build/*
|
build/*
|
||||||
.pio/*
|
.pio/*
|
||||||
.vscode/*
|
.vscode/*
|
||||||
Release/*.bin
|
|
||||||
|
|||||||
31
Boards.h
31
Boards.h
@@ -151,10 +151,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LORA_PA_UNKNOWN 0x00
|
|
||||||
#define LORA_PA_GC1109 0x01
|
|
||||||
#define LORA_PA_KCT8103L 0x02
|
|
||||||
|
|
||||||
#define HAS_DISPLAY false
|
#define HAS_DISPLAY false
|
||||||
#define HAS_BLUETOOTH false
|
#define HAS_BLUETOOTH false
|
||||||
#define HAS_BLE false
|
#define HAS_BLE false
|
||||||
@@ -367,7 +363,7 @@
|
|||||||
#define HAS_SLEEP true
|
#define HAS_SLEEP true
|
||||||
#define PIN_WAKEUP GPIO_NUM_0
|
#define PIN_WAKEUP GPIO_NUM_0
|
||||||
#define WAKEUP_LEVEL 0
|
#define WAKEUP_LEVEL 0
|
||||||
#define OCP_TUNED 0x28
|
#define OCP_TUNED 0x18
|
||||||
|
|
||||||
const int pin_btn_usr1 = 0;
|
const int pin_btn_usr1 = 0;
|
||||||
|
|
||||||
@@ -415,9 +411,8 @@
|
|||||||
#define HAS_LORA_LNA true
|
#define HAS_LORA_LNA true
|
||||||
#define PIN_WAKEUP GPIO_NUM_0
|
#define PIN_WAKEUP GPIO_NUM_0
|
||||||
#define WAKEUP_LEVEL 0
|
#define WAKEUP_LEVEL 0
|
||||||
#define OCP_TUNED 0x28
|
#define OCP_TUNED 0x18
|
||||||
#define Vext GPIO_NUM_36
|
#define Vext GPIO_NUM_36
|
||||||
#define LORA_PA_MODEL LORA_PA_UNKNOWN;
|
|
||||||
|
|
||||||
const int pin_btn_usr1 = 0;
|
const int pin_btn_usr1 = 0;
|
||||||
|
|
||||||
@@ -439,17 +434,14 @@
|
|||||||
|
|
||||||
#define LORA_LNA_GAIN 17
|
#define LORA_LNA_GAIN 17
|
||||||
#define LORA_LNA_GVT 12
|
#define LORA_LNA_GVT 12
|
||||||
|
#define LORA_PA_GC1109 true
|
||||||
#define LORA_PA_PWR_EN 7
|
#define LORA_PA_PWR_EN 7
|
||||||
#define LORA_PA_CSD 2 // Same pin on GC1109
|
#define LORA_PA_CSD 2
|
||||||
#define LORA_PA_CPS 46 // Same pin on GC1109
|
#define LORA_PA_CPS 46
|
||||||
#define LORA_PA_CTX 5 // Only used on KCT8103
|
|
||||||
|
|
||||||
#define PA_MAX_OUTPUT 28
|
#define PA_MAX_OUTPUT 28
|
||||||
#define PA_GAIN_POINTS 22
|
#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_cs = 8;
|
||||||
const int pin_busy = 13;
|
const int pin_busy = 13;
|
||||||
@@ -537,10 +529,13 @@
|
|||||||
const int pin_np = 12;
|
const int pin_np = 12;
|
||||||
const int pin_dac = 25;
|
const int pin_dac = 25;
|
||||||
const int pin_adc = 34;
|
const int pin_adc = 34;
|
||||||
const int SD_MISO = 2;
|
// CBA already defined by framework
|
||||||
const int SD_MOSI = 15;
|
//const int SD_MISO = 2;
|
||||||
|
// CBA already defined by framework
|
||||||
|
//const int SD_MOSI = 15;
|
||||||
const int SD_CLK = 14;
|
const int SD_CLK = 14;
|
||||||
const int SD_CS = 13;
|
// CBA already defined by framework
|
||||||
|
//const int SD_CS = 13;
|
||||||
#if HAS_NP == false
|
#if HAS_NP == false
|
||||||
#if defined(EXTERNAL_LEDS)
|
#if defined(EXTERNAL_LEDS)
|
||||||
const int pin_led_rx = 12;
|
const int pin_led_rx = 12;
|
||||||
@@ -985,7 +980,7 @@
|
|||||||
// Default OCP value if not specified
|
// Default OCP value if not specified
|
||||||
// in board configuration
|
// in board configuration
|
||||||
#ifndef OCP_TUNED
|
#ifndef OCP_TUNED
|
||||||
#define OCP_TUNED 0x28
|
#define OCP_TUNED 0x18
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PA_MAX_OUTPUT
|
#ifndef PA_MAX_OUTPUT
|
||||||
|
|||||||
@@ -24,11 +24,6 @@
|
|||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <DNSServer.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 ─────────────────────────────────────────────────────
|
// ─── Config Portal State ─────────────────────────────────────────────────────
|
||||||
static bool config_portal_active = false;
|
static bool config_portal_active = false;
|
||||||
static WebServer* config_server = nullptr;
|
static WebServer* config_server = nullptr;
|
||||||
@@ -131,25 +126,12 @@ static void config_send_html() {
|
|||||||
"button:hover{background:#c73e54;}"
|
"button:hover{background:#c73e54;}"
|
||||||
".ok{background:#16213e;padding:20px;border-radius:8px;text-align:center;}"
|
".ok{background:#16213e;padding:20px;border-radius:8px;text-align:center;}"
|
||||||
".ok h1{color:#0f0;}"
|
".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>"
|
"</style></head><body>"
|
||||||
"<h1>📡 RNode Boundary Node</h1>"
|
"<h1>📡 RNode Boundary Node</h1>"
|
||||||
|
"<form method='POST' action='/save'>"
|
||||||
);
|
);
|
||||||
|
|
||||||
// ── Node public hash ──
|
// ── WiFi STA Section ──
|
||||||
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(
|
html += F(
|
||||||
"<h2>📶 WiFi Network</h2>"
|
"<h2>📶 WiFi Network</h2>"
|
||||||
"<label>WiFi</label>"
|
"<label>WiFi</label>"
|
||||||
|
|||||||
2
Config.h
2
Config.h
@@ -20,7 +20,7 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MAJ_VERS 0x01
|
#define MAJ_VERS 0x01
|
||||||
#define MIN_VERS 0x56
|
#define MIN_VERS 0x55
|
||||||
|
|
||||||
#define MODE_HOST 0x11
|
#define MODE_HOST 0x11
|
||||||
#define MODE_TNC 0x12
|
#define MODE_TNC 0x12
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ extern BoundaryState boundary_state;
|
|||||||
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
#elif BOARD_MODEL == BOARD_MESHADVENTURER_S3
|
||||||
#define DISP_RST -1
|
#define DISP_RST -1
|
||||||
#define DISP_ADDR 0x3C
|
#define DISP_ADDR 0x3C
|
||||||
#define SCL_OLED 0
|
#define SCL_OLED 44
|
||||||
#define SDA_OLED 42
|
#define SDA_OLED 42
|
||||||
#elif BOARD_MODEL == BOARD_RAK4631
|
#elif BOARD_MODEL == BOARD_RAK4631
|
||||||
// RAK1921/SSD1306
|
// RAK1921/SSD1306
|
||||||
|
|||||||
@@ -259,13 +259,6 @@ RTC_NOINIT_ATTR uint32_t boundary_skip_config;
|
|||||||
RTC_NOINIT_ATTR uint32_t bootloop_magic;
|
RTC_NOINIT_ATTR uint32_t bootloop_magic;
|
||||||
RTC_NOINIT_ATTR uint32_t bootloop_count;
|
RTC_NOINIT_ATTR uint32_t bootloop_count;
|
||||||
RTC_NOINIT_ATTR uint32_t bootloop_first_boot_ms;
|
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
|
||||||
|
|
||||||
#endif // HAS_RNS
|
#endif // HAS_RNS
|
||||||
@@ -411,7 +404,7 @@ void setup() {
|
|||||||
#if MODEM == SX1276 || MODEM == SX1278
|
#if MODEM == SX1276 || MODEM == SX1278
|
||||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy);
|
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy);
|
||||||
#elif MODEM == SX1262
|
#elif MODEM == SX1262
|
||||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen, pin_txen);
|
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen);
|
||||||
#elif MODEM == SX1280
|
#elif MODEM == SX1280
|
||||||
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen, pin_txen);
|
LoRa->setPins(pin_cs, pin_reset, pin_dio, pin_busy, pin_rxen, pin_txen);
|
||||||
#endif
|
#endif
|
||||||
@@ -934,17 +927,6 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
RNS::Destination destination(RNS::Transport::identity(), RNS::Type::Destination::IN, RNS::Type::Destination::SINGLE, "rnstransport", "local");
|
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);
|
HEAD("RNS is READY!", RNS::LOG_TRACE);
|
||||||
#ifdef BOUNDARY_MODE
|
#ifdef BOUNDARY_MODE
|
||||||
HEAD("*** BOUNDARY MODE ACTIVE ***", RNS::LOG_TRACE);
|
HEAD("*** BOUNDARY MODE ACTIVE ***", RNS::LOG_TRACE);
|
||||||
@@ -1586,7 +1568,7 @@ void serial_callback(uint8_t sbyte) {
|
|||||||
if (txp > 13) txp = 13;
|
if (txp > 13) txp = 13;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
if (txp > 20) txp = 20;
|
if (txp > 17) txp = 17;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lora_txp = txp;
|
lora_txp = txp;
|
||||||
@@ -2648,13 +2630,7 @@ void sleep_now() {
|
|||||||
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
#if BOARD_MODEL == BOARD_HELTEC32_V4
|
||||||
headless_led_off();
|
headless_led_off();
|
||||||
headless_led_detach_pwm();
|
headless_led_detach_pwm();
|
||||||
#if LORA_PA_AUTO_DETECT
|
digitalWrite(LORA_PA_CPS, LOW);
|
||||||
if (sx126x_modem.isKCT8103L()) {
|
|
||||||
digitalWrite(LORA_PA_CTX, LOW);
|
|
||||||
} else {
|
|
||||||
digitalWrite(LORA_PA_CPS, LOW);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
digitalWrite(LORA_PA_CSD, LOW);
|
digitalWrite(LORA_PA_CSD, LOW);
|
||||||
digitalWrite(LORA_PA_PWR_EN, LOW);
|
digitalWrite(LORA_PA_PWR_EN, LOW);
|
||||||
digitalWrite(Vext, HIGH);
|
digitalWrite(Vext, HIGH);
|
||||||
|
|||||||
BIN
Release/rnode_firmware_heltec32v3.bin
Executable file
BIN
Release/rnode_firmware_heltec32v3.bin
Executable file
Binary file not shown.
22
Utilities.h
22
Utilities.h
@@ -1383,33 +1383,11 @@ int getTxPower() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_LORA_PA
|
#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};
|
const int tx_gain[PA_GAIN_POINTS] = {PA_GAIN_VALUES};
|
||||||
#endif
|
|
||||||
#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) {
|
int map_target_power_to_modem_output(int target_tx_power) {
|
||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
if (!pa_values_determined) { determine_pa_values(); }
|
|
||||||
int modem_output_dbm = -9;
|
int modem_output_dbm = -9;
|
||||||
for (int i = 0; i < PA_GAIN_POINTS; i++) {
|
for (int i = 0; i < PA_GAIN_POINTS; i++) {
|
||||||
int gain = tx_gain[i];
|
int gain = tx_gain[i];
|
||||||
|
|||||||
0
lib/microReticulum/library.properties
Executable file → Normal file
0
lib/microReticulum/library.properties
Executable file → Normal file
@@ -34,7 +34,7 @@ build_src_filter = +<*> -<variants/>
|
|||||||
extra_scripts = pre:extra_script.py
|
extra_scripts = pre:extra_script.py
|
||||||
|
|
||||||
[env:rnode-ng-20]
|
[env:rnode-ng-20]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v2
|
board = ttgo-lora32-v2
|
||||||
custom_variant = ng20
|
custom_variant = ng20
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -48,7 +48,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:rnode-ng-21]
|
[env:rnode-ng-21]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
custom_variant = ng21
|
custom_variant = ng21
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -62,7 +62,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-t-beam]
|
[env:ttgo-t-beam]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
custom_variant = tbeam
|
custom_variant = tbeam
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -76,7 +76,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-t-beam-sx1262]
|
[env:ttgo-t-beam-sx1262]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
custom_variant = tbeam_sx1262
|
custom_variant = tbeam_sx1262
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -91,7 +91,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-t-beam-supreme]
|
[env:ttgo-t-beam-supreme]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
custom_variant = tbeam_supreme
|
custom_variant = tbeam_supreme
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -108,7 +108,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:lilygo-t3-s3]
|
[env:lilygo-t3-s3]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = lilygo-t3-s3
|
board = lilygo-t3-s3
|
||||||
custom_variant = t3s3
|
custom_variant = t3s3
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -123,7 +123,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:lilygo-t3-s3-sx127x]
|
[env:lilygo-t3-s3-sx127x]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = lilygo-t3-s3
|
board = lilygo-t3-s3
|
||||||
custom_variant = t3s3_sx127x
|
custom_variant = t3s3_sx127x
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -138,7 +138,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:lilygo-t3-s3-sx1280-pa]
|
[env:lilygo-t3-s3-sx1280-pa]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = lilygo-t3-s3
|
board = lilygo-t3-s3
|
||||||
custom_variant = t3s3_sx1280_pa
|
custom_variant = t3s3_sx1280_pa
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -153,7 +153,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:lilygo-t-deck]
|
[env:lilygo-t-deck]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = tdeck
|
custom_variant = tdeck
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -176,7 +176,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v1]
|
[env:ttgo-lora32-v1]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v1
|
board = ttgo-lora32-v1
|
||||||
custom_variant = lora32v10
|
custom_variant = lora32v10
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -190,7 +190,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v2]
|
[env:ttgo-lora32-v2]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v2
|
board = ttgo-lora32-v2
|
||||||
custom_variant = lora32v20
|
custom_variant = lora32v20
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -204,7 +204,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v2-extled]
|
[env:ttgo-lora32-v2-extled]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v2
|
board = ttgo-lora32-v2
|
||||||
custom_variant = lora32v20_extled
|
custom_variant = lora32v20_extled
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -219,7 +219,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v21]
|
[env:ttgo-lora32-v21]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
custom_variant = lora32v21
|
custom_variant = lora32v21
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -233,7 +233,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v21-extled]
|
[env:ttgo-lora32-v21-extled]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
custom_variant = lora32v21_extled
|
custom_variant = lora32v21_extled
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -248,7 +248,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-lora32-v21-tcxo]
|
[env:ttgo-lora32-v21-tcxo]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
custom_variant = lora32v21_extled
|
custom_variant = lora32v21_extled
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -263,7 +263,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32_V2]
|
[env:heltec_wifi_lora_32_V2]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = heltec_wifi_lora_32_V2
|
board = heltec_wifi_lora_32_V2
|
||||||
custom_variant = heltec32v2
|
custom_variant = heltec32v2
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -277,7 +277,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32_V2-extled]
|
[env:heltec_wifi_lora_32_V2-extled]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = heltec_wifi_lora_32_V2
|
board = heltec_wifi_lora_32_V2
|
||||||
custom_variant = heltec32v2_extled
|
custom_variant = heltec32v2_extled
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -292,7 +292,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32_V3]
|
[env:heltec_wifi_lora_32_V3]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = heltec_wifi_lora_32_V3
|
board = heltec_wifi_lora_32_V3
|
||||||
custom_variant = heltec32v3
|
custom_variant = heltec32v3
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -306,7 +306,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:heltec_V3_boundary]
|
[env:heltec_V3_boundary]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = heltec_wifi_lora_32_V3
|
board = heltec_wifi_lora_32_V3
|
||||||
custom_variant = heltec32v3
|
custom_variant = heltec32v3
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -333,7 +333,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32_V4]
|
[env:heltec_wifi_lora_32_V4]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = heltec32v4
|
custom_variant = heltec32v4
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -348,7 +348,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:meshadventurer_S3_boundary]
|
[env:meshadventurer_S3_boundary]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = meshadventurer_s3_boundary
|
custom_variant = meshadventurer_s3_boundary
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -376,7 +376,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:heltec_V4_boundary]
|
[env:heltec_V4_boundary]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = heltec32v4_boundary
|
custom_variant = heltec32v4_boundary
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -404,7 +404,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:heltec_V4_boundary-local]
|
[env:heltec_V4_boundary-local]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = heltec32v4_boundary_local
|
custom_variant = heltec32v4_boundary_local
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -429,7 +429,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:featheresp32]
|
[env:featheresp32]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = featheresp32
|
board = featheresp32
|
||||||
custom_variant = featheresp32
|
custom_variant = featheresp32
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -443,7 +443,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:seeed_xiao_esp32s3]
|
[env:seeed_xiao_esp32s3]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = seeed_xiao_esp32s3
|
board = seeed_xiao_esp32s3
|
||||||
custom_variant = xiao_esp32s3
|
custom_variant = xiao_esp32s3
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -457,7 +457,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:generic-esp32]
|
[env:generic-esp32]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
custom_variant = esp32_generic
|
custom_variant = esp32_generic
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
@@ -489,7 +489,7 @@ lib_deps =
|
|||||||
adafruit/Adafruit NeoPixel@^1.15.4
|
adafruit/Adafruit NeoPixel@^1.15.4
|
||||||
|
|
||||||
[env:ttgo-t-beam-local]
|
[env:ttgo-t-beam-local]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
upload_speed = 460800
|
upload_speed = 460800
|
||||||
custom_variant = tbeam_local
|
custom_variant = tbeam_local
|
||||||
@@ -507,7 +507,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:ttgo-lora32-v21-local]
|
[env:ttgo-lora32-v21-local]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = ttgo-lora32-v21
|
board = ttgo-lora32-v21
|
||||||
upload_speed = 460800
|
upload_speed = 460800
|
||||||
custom_variant = lora32v21_local
|
custom_variant = lora32v21_local
|
||||||
@@ -523,7 +523,7 @@ lib_deps =
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
|
|
||||||
[env:heltec_wifi_lora_32_V4-local]
|
[env:heltec_wifi_lora_32_V4-local]
|
||||||
platform = espressif32@6.12.0
|
platform = espressif32
|
||||||
board = esp32-s3-devkitc-1
|
board = esp32-s3-devkitc-1
|
||||||
custom_variant = heltec32v4_local
|
custom_variant = heltec32v4_local
|
||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
|
|||||||
2841
rnodethv3.log
Normal file
2841
rnodethv3.log
Normal file
File diff suppressed because it is too large
Load Diff
121
sx126x.cpp
121
sx126x.cpp
@@ -96,21 +96,13 @@
|
|||||||
#define SPI spiModem
|
#define SPI spiModem
|
||||||
#endif
|
#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;
|
extern SPIClass SPI;
|
||||||
|
|
||||||
#define MAX_PKT_LENGTH 255
|
#define MAX_PKT_LENGTH 255
|
||||||
|
|
||||||
sx126x::sx126x() :
|
sx126x::sx126x() :
|
||||||
_spiSettings(16E6, MSBFIRST, SPI_MODE0),
|
_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), _txen(LORA_DEFAULT_TXEN_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),
|
||||||
_frequency(0),
|
_frequency(0),
|
||||||
_txp(0),
|
_txp(0),
|
||||||
_sf(0x07),
|
_sf(0x07),
|
||||||
@@ -192,7 +184,6 @@ uint8_t ISR_VECT sx126x::singleTransfer(uint8_t opcode, uint16_t address, uint8_
|
|||||||
|
|
||||||
void sx126x::rxAntEnable() {
|
void sx126x::rxAntEnable() {
|
||||||
if (_rxen != -1) { digitalWrite(_rxen, HIGH); }
|
if (_rxen != -1) { digitalWrite(_rxen, HIGH); }
|
||||||
if (_txen != -1) { digitalWrite(_txen, LOW); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sx126x::loraMode() {
|
void sx126x::loraMode() {
|
||||||
@@ -283,21 +274,6 @@ void sx126x::setPacketParams(long preamble_symbols, uint8_t headermode, uint8_t
|
|||||||
buf[7] = 0x00;
|
buf[7] = 0x00;
|
||||||
buf[8] = 0x00;
|
buf[8] = 0x00;
|
||||||
executeOpcode(OP_PACKET_PARAMS_6X, buf, 9);
|
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) {
|
void sx126x::reset(void) {
|
||||||
@@ -310,22 +286,6 @@ 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) {
|
void sx126x::calibrate(void) {
|
||||||
// Put in STDBY_RC mode before calibration
|
// Put in STDBY_RC mode before calibration
|
||||||
uint8_t mode_byte = MODE_STDBY_RC_6X;
|
uint8_t mode_byte = MODE_STDBY_RC_6X;
|
||||||
@@ -356,21 +316,10 @@ int sx126x::begin(long frequency) {
|
|||||||
if (_busy != -1) { pinMode(_busy, INPUT); }
|
if (_busy != -1) { pinMode(_busy, INPUT); }
|
||||||
if (!_preinit_done) { if (!preInit()) { return false; } }
|
if (!_preinit_done) { if (!preInit()) { return false; } }
|
||||||
if (_rxen != -1) { pinMode(_rxen, OUTPUT); }
|
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();
|
||||||
calibrate_image(frequency);
|
calibrate_image(frequency);
|
||||||
#if HAS_TCXO
|
enableTCXO();
|
||||||
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();
|
loraMode();
|
||||||
standby();
|
standby();
|
||||||
|
|
||||||
@@ -387,9 +336,7 @@ int sx126x::begin(long frequency) {
|
|||||||
setFrequency(frequency);
|
setFrequency(frequency);
|
||||||
setTxPower(2);
|
setTxPower(2);
|
||||||
enableCrc();
|
enableCrc();
|
||||||
writeRegister(REG_LNA_6X, 0x96); // Set LNA boosted gain mode
|
writeRegister(REG_LNA_6X, 0x96); // Set LNA boost
|
||||||
// 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
|
uint8_t basebuf[2] = {0}; // Set base addresses
|
||||||
executeOpcode(OP_BUFFER_BASE_ADDR_6X, basebuf, 2);
|
executeOpcode(OP_BUFFER_BASE_ADDR_6X, basebuf, 2);
|
||||||
|
|
||||||
@@ -397,22 +344,7 @@ int sx126x::begin(long frequency) {
|
|||||||
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
||||||
|
|
||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
if (lora_pa_model == LORA_PA_UNKNOWN) {
|
#if LORA_PA_GC1109
|
||||||
#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
|
// Enable Vfem_ctl for supply to
|
||||||
// PA power net.
|
// PA power net.
|
||||||
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
||||||
@@ -437,26 +369,7 @@ int sx126x::begin(long frequency) {
|
|||||||
// is driven by the SX1262 DIO2
|
// is driven by the SX1262 DIO2
|
||||||
// pin directly, so we do not
|
// pin directly, so we do not
|
||||||
// need to manually raise this.
|
// 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
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -466,19 +379,15 @@ void sx126x::end() { sleep(); SPI.end(); _preinit_done = false; }
|
|||||||
|
|
||||||
int sx126x::beginPacket(int implicitHeader) {
|
int sx126x::beginPacket(int implicitHeader) {
|
||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
if (lora_pa_model == LORA_PA_GC1109) {
|
#if LORA_PA_GC1109
|
||||||
// Enable PA CPS for transmit
|
// Enable PA CPS for transmit
|
||||||
// digitalWrite(LORA_PA_CPS, HIGH);
|
// digitalWrite(LORA_PA_CPS, HIGH);
|
||||||
// Disabled since we're keeping it
|
// Disabled since we're keeping it
|
||||||
// on permanently as long as the
|
// on permanently as long as the
|
||||||
// radio is powered up.
|
// radio is powered up.
|
||||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
#endif
|
||||||
digitalWrite(LORA_PA_CTX, HIGH);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_txen != -1) { digitalWrite(_txen, HIGH); } //Set TXen high when transmitting
|
|
||||||
|
|
||||||
standby();
|
standby();
|
||||||
if (implicitHeader) { implicitHeaderMode(); }
|
if (implicitHeader) { implicitHeaderMode(); }
|
||||||
else { explicitHeaderMode(); }
|
else { explicitHeaderMode(); }
|
||||||
@@ -492,9 +401,6 @@ int sx126x::beginPacket(int implicitHeader) {
|
|||||||
|
|
||||||
int sx126x::endPacket() {
|
int sx126x::endPacket() {
|
||||||
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
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
|
uint8_t timeout[3] = {0}; // Put in single TX mode
|
||||||
executeOpcode(OP_TX_6X, timeout, 3);
|
executeOpcode(OP_TX_6X, timeout, 3);
|
||||||
|
|
||||||
@@ -567,7 +473,7 @@ int ISR_VECT sx126x::currentRssi() {
|
|||||||
executeOpcodeRead(OP_CURRENT_RSSI_6X, &byte, 1);
|
executeOpcodeRead(OP_CURRENT_RSSI_6X, &byte, 1);
|
||||||
int rssi = -(int(byte)) / 2;
|
int rssi = -(int(byte)) / 2;
|
||||||
#if HAS_LORA_LNA
|
#if HAS_LORA_LNA
|
||||||
rssi -= lora_lna_gain;
|
rssi -= LORA_LNA_GAIN;
|
||||||
#endif
|
#endif
|
||||||
return rssi;
|
return rssi;
|
||||||
}
|
}
|
||||||
@@ -583,7 +489,7 @@ int ISR_VECT sx126x::packetRssi() {
|
|||||||
executeOpcodeRead(OP_PACKET_STATUS_6X, buf, 3);
|
executeOpcodeRead(OP_PACKET_STATUS_6X, buf, 3);
|
||||||
int pkt_rssi = -buf[0] / 2;
|
int pkt_rssi = -buf[0] / 2;
|
||||||
#if HAS_LORA_LNA
|
#if HAS_LORA_LNA
|
||||||
pkt_rssi -= lora_lna_gain;
|
pkt_rssi -= LORA_LNA_GAIN;
|
||||||
#endif
|
#endif
|
||||||
return pkt_rssi;
|
return pkt_rssi;
|
||||||
}
|
}
|
||||||
@@ -690,7 +596,7 @@ void sx126x::onReceive(void(*callback)(int)){
|
|||||||
|
|
||||||
void sx126x::receive(int size) {
|
void sx126x::receive(int size) {
|
||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
if (lora_pa_model == LORA_PA_GC1109) {
|
#if LORA_PA_GC1109
|
||||||
// Disable PA CPS for receive
|
// Disable PA CPS for receive
|
||||||
// digitalWrite(LORA_PA_CPS, LOW);
|
// digitalWrite(LORA_PA_CPS, LOW);
|
||||||
// That turned out to be a bad idea.
|
// That turned out to be a bad idea.
|
||||||
@@ -698,9 +604,7 @@ void sx126x::receive(int size) {
|
|||||||
// on and off too quickly. We'll keep
|
// on and off too quickly. We'll keep
|
||||||
// it on permanently, as long as the
|
// it on permanently, as long as the
|
||||||
// radio is powered up.
|
// radio is powered up.
|
||||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
#endif
|
||||||
digitalWrite(LORA_PA_CTX, LOW);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
@@ -868,13 +772,12 @@ void sx126x::setSyncWord(uint16_t sw) {
|
|||||||
writeRegister(REG_SYNC_WORD_LSB_6X, 0x24);
|
writeRegister(REG_SYNC_WORD_LSB_6X, 0x24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sx126x::setPins(int ss, int reset, int dio0, int busy, int rxen, int txen) {
|
void sx126x::setPins(int ss, int reset, int dio0, int busy, int rxen) {
|
||||||
_ss = ss;
|
_ss = ss;
|
||||||
_reset = reset;
|
_reset = reset;
|
||||||
_dio0 = dio0;
|
_dio0 = dio0;
|
||||||
_busy = busy;
|
_busy = busy;
|
||||||
_rxen = rxen;
|
_rxen = rxen;
|
||||||
_txen = txen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sx126x::dumpRegisters(Stream& out) {
|
void sx126x::dumpRegisters(Stream& out) {
|
||||||
|
|||||||
10
sx126x.h
10
sx126x.h
@@ -74,7 +74,6 @@ public:
|
|||||||
void disableCrc();
|
void disableCrc();
|
||||||
void enableTCXO();
|
void enableTCXO();
|
||||||
void disableTCXO();
|
void disableTCXO();
|
||||||
void setDCDCRegulator();
|
|
||||||
|
|
||||||
void rxAntEnable();
|
void rxAntEnable();
|
||||||
void loraMode();
|
void loraMode();
|
||||||
@@ -93,13 +92,11 @@ public:
|
|||||||
|
|
||||||
byte random();
|
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, int txen = LORA_DEFAULT_TXEN_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);
|
||||||
void setSPIFrequency(uint32_t frequency);
|
void setSPIFrequency(uint32_t frequency);
|
||||||
|
|
||||||
void dumpRegisters(Stream& out);
|
void dumpRegisters(Stream& out);
|
||||||
|
|
||||||
bool isKCT8103L() { return _kct8103l; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void explicitHeaderMode();
|
void explicitHeaderMode();
|
||||||
void implicitHeaderMode();
|
void implicitHeaderMode();
|
||||||
@@ -110,8 +107,7 @@ public:
|
|||||||
// Poll for deferred DIO0 interrupt (call from main loop)
|
// Poll for deferred DIO0 interrupt (call from main loop)
|
||||||
void pollDio0();
|
void pollDio0();
|
||||||
|
|
||||||
private:
|
private: uint8_t readRegister(uint16_t address);
|
||||||
uint8_t readRegister(uint16_t address);
|
|
||||||
void writeRegister(uint16_t address, uint8_t value);
|
void writeRegister(uint16_t address, uint8_t value);
|
||||||
uint8_t singleTransfer(uint8_t opcode, uint16_t address, uint8_t value);
|
uint8_t singleTransfer(uint8_t opcode, uint16_t address, uint8_t value);
|
||||||
|
|
||||||
@@ -129,7 +125,6 @@ private:
|
|||||||
int _reset;
|
int _reset;
|
||||||
int _dio0;
|
int _dio0;
|
||||||
int _rxen;
|
int _rxen;
|
||||||
int _txen;
|
|
||||||
int _busy;
|
int _busy;
|
||||||
long _frequency;
|
long _frequency;
|
||||||
int _txp;
|
int _txp;
|
||||||
@@ -146,7 +141,6 @@ private:
|
|||||||
int _fifo_rx_addr_ptr;
|
int _fifo_rx_addr_ptr;
|
||||||
uint8_t _packet[255];
|
uint8_t _packet[255];
|
||||||
bool _preinit_done;
|
bool _preinit_done;
|
||||||
bool _kct8103l;
|
|
||||||
volatile bool _dio0_risen;
|
volatile bool _dio0_risen;
|
||||||
void (*_onReceive)(int);
|
void (*_onReceive)(int);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user