Compare commits
11 Commits
af8647d239
...
f143109d66
| Author | SHA1 | Date | |
|---|---|---|---|
| f143109d66 | |||
| ca75017784 | |||
| 14739254e5 | |||
| 4900bd4d1e | |||
| 2997cc34dd | |||
| c49219b7bd | |||
| 1e74aff456 | |||
| 70e8561dfd | |||
| d913d7b010 | |||
| 3f05d46411 | |||
| 0e74e0cd10 |
35
Boards.h
35
Boards.h
@@ -158,10 +158,6 @@
|
||||
#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
|
||||
@@ -457,7 +453,7 @@
|
||||
#define HAS_TCXO true
|
||||
#define HAS_BUSY true
|
||||
#define DIO2_AS_RF_SWITCH true
|
||||
#define OCP_TUNED 0x28
|
||||
#define OCP_TUNED 0x18
|
||||
const int pin_busy = 32;
|
||||
const int pin_dio = 33;
|
||||
const int pin_tcxo_enable = -1;
|
||||
@@ -563,7 +559,7 @@
|
||||
#define HAS_SLEEP true
|
||||
#define PIN_WAKEUP GPIO_NUM_0
|
||||
#define WAKEUP_LEVEL 0
|
||||
#define OCP_TUNED 0x28
|
||||
#define OCP_TUNED 0x18
|
||||
|
||||
const int pin_btn_usr1 = 0;
|
||||
|
||||
@@ -605,9 +601,8 @@
|
||||
#define HAS_LORA_LNA true
|
||||
#define PIN_WAKEUP GPIO_NUM_0
|
||||
#define WAKEUP_LEVEL 0
|
||||
#define OCP_TUNED 0x28
|
||||
#define OCP_TUNED 0x38
|
||||
#define Vext GPIO_NUM_36
|
||||
#define LORA_PA_MODEL LORA_PA_UNKNOWN;
|
||||
|
||||
const int pin_btn_usr1 = 0;
|
||||
|
||||
@@ -629,17 +624,19 @@
|
||||
|
||||
#define LORA_LNA_GAIN 17
|
||||
#define LORA_LNA_GVT 12
|
||||
#define LORA_PA_GC1109 true
|
||||
#define LORA_PA_AUTO_DETECT true
|
||||
#define LORA_PA_PWR_EN 7
|
||||
#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 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};
|
||||
#define LORA_PA_CSD 2 // GC1109: PA_EN | KCT8103L: CSD (same pin, different pull resistor)
|
||||
#define LORA_PA_CTX 5 // KCT8103L: TX/LNA select (CTX=LOW=LNA, CTX=HIGH=PA)
|
||||
#define LORA_PA_CPS 46 // GC1109: TX_EN
|
||||
|
||||
#define PA_MAX_OUTPUT 28
|
||||
#define PA_GAIN_POINTS 22
|
||||
#define PA_GC1109_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 PA_KCT8103L_GAIN_VALUES 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 7
|
||||
#define PA_GAIN_VALUES PA_KCT8103L_GAIN_VALUES // compile-time fallback; runtime detection selects correct table
|
||||
|
||||
const int pin_cs = 8;
|
||||
const int pin_busy = 13;
|
||||
@@ -828,7 +825,7 @@
|
||||
#define DIO2_AS_RF_SWITCH true
|
||||
#define HAS_BUSY true
|
||||
#define HAS_TCXO true
|
||||
#define OCP_TUNED 0x28
|
||||
#define OCP_TUNED 0x18
|
||||
|
||||
#define HAS_DISPLAY true
|
||||
#define HAS_CONSOLE true
|
||||
@@ -1240,7 +1237,7 @@
|
||||
// Default OCP value if not specified
|
||||
// in board configuration
|
||||
#ifndef OCP_TUNED
|
||||
#define OCP_TUNED 0x28
|
||||
#define OCP_TUNED 0x38
|
||||
#endif
|
||||
|
||||
#ifndef NP_M
|
||||
|
||||
2
Config.h
2
Config.h
@@ -20,7 +20,7 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define MAJ_VERS 0x01
|
||||
#define MIN_VERS 0x56
|
||||
#define MIN_VERS 0x55
|
||||
|
||||
#define MODE_HOST 0x11
|
||||
#define MODE_TNC 0x12
|
||||
|
||||
@@ -4,10 +4,10 @@ import sys
|
||||
import shutil
|
||||
|
||||
packages = {
|
||||
"rns": "rns-1.1.9-py3-none-any.whl",
|
||||
"nomadnet": "nomadnet-0.9.11-py3-none-any.whl",
|
||||
"lxmf": "lxmf-0.9.6-py3-none-any.whl",
|
||||
"rnsh": "rnsh-0.1.9-py3-none-any.whl",
|
||||
"rns": "rns-1.0.3-py3-none-any.whl",
|
||||
"nomadnet": "nomadnet-0.9.1-py3-none-any.whl",
|
||||
"lxmf": "lxmf-0.9.3-py3-none-any.whl",
|
||||
"rnsh": "rnsh-0.1.5-py3-none-any.whl",
|
||||
}
|
||||
|
||||
DEFAULT_TITLE = "RNode Bootstrap Console"
|
||||
@@ -194,29 +194,8 @@ def optimise_manual(path):
|
||||
("_images/meshchat_1.webp", pm),
|
||||
("_images/radio_is5ac.png", pm),
|
||||
("_images/radio_rblhg5.png", pm),
|
||||
("_images/rbrowser.webp", pm),
|
||||
("_images/rnphone.webp", pm),
|
||||
("_images/retibbs.webp", pm),
|
||||
("_images/meshchatx.webp", pm),
|
||||
("_images/lxst_phone.webp", pm),
|
||||
("_images/columba.webp", pm),
|
||||
("_static/rns_logo_512.png", 256),
|
||||
("../images/bg_h_1.webp", pm),
|
||||
|
||||
("../../images/3_conv.webp", pm/2),
|
||||
("../../images/an1.webp", pm/2),
|
||||
("../../images/bg1ds1.webp", pm/2),
|
||||
("../../images/bg1ds2.webp", pm/2),
|
||||
("../../images/bg_h_1.webp", pm/2),
|
||||
("../../images/bg_h_2.webp", pm/2),
|
||||
("../../images/g1p.webp", pm/2),
|
||||
("../../images/g2p.webp", pm/2),
|
||||
("../../images/g3p.webp", pm/2),
|
||||
("../../images/g4p.webp", pm/2),
|
||||
("../../images/lora_rnodes.webp", pm/2),
|
||||
("../../images/nn_an.webp", pm/2),
|
||||
("../../images/nn_conv.webp", pm/2),
|
||||
("../../images/nn_init.webp", pm/2),
|
||||
]
|
||||
|
||||
import subprocess
|
||||
|
||||
@@ -1154,7 +1154,6 @@ void update_display(bool blank = false) {
|
||||
|
||||
#if BOARD_MODEL == BOARD_HELTEC_T114
|
||||
display.clear();
|
||||
digitalWrite(PIN_T114_TFT_BLGT, LOW);
|
||||
#elif BOARD_MODEL != BOARD_TDECK && BOARD_MODEL != BOARD_TECHO
|
||||
display.clearDisplay();
|
||||
#endif
|
||||
|
||||
1
Makefile
1
Makefile
@@ -30,6 +30,7 @@ prep: prep-avr prep-esp32 prep-samd
|
||||
prep-avr:
|
||||
arduino-cli core update-index --config-file arduino-cli.yaml
|
||||
arduino-cli core install arduino:avr --config-file arduino-cli.yaml
|
||||
arduino-cli core install unsignedio:avr --config-file arduino-cli.yaml
|
||||
|
||||
prep-esp32:
|
||||
arduino-cli core update-index --config-file arduino-cli.yaml
|
||||
|
||||
Binary file not shown.
30
Utilities.h
30
Utilities.h
@@ -1336,33 +1336,17 @@ 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
|
||||
#if LORA_PA_AUTO_DETECT
|
||||
static const int gc1109_tx_gain[PA_GAIN_POINTS] = {PA_GC1109_GAIN_VALUES};
|
||||
static const int kct8103l_tx_gain[PA_GAIN_POINTS] = {PA_KCT8103L_GAIN_VALUES};
|
||||
const int* tx_gain = sx126x_modem.isKCT8103L() ? kct8103l_tx_gain : gc1109_tx_gain;
|
||||
#else
|
||||
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];
|
||||
|
||||
@@ -4,3 +4,7 @@ board_manager:
|
||||
- https://raw.githubusercontent.com/RAKwireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless_index.json
|
||||
- https://github.com/HelTecAutomation/Heltec_nRF52/releases/download/1.7.0/package_heltec_nrf_index.json
|
||||
- https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
|
||||
## proMicro
|
||||
# - https://raw.githubusercontent.com/pdcook/nRFMicro-Arduino-Core/main/package_nRFMicro_index.json #can't use it bc the name has spaces, i created the file below
|
||||
- https://gist.githubusercontent.com/gargomoma/b5cffc40e5df88462f2b488492feb6ca/raw/198c5706289014dd64be31607495e02f056d52a3/nrf_cli_fix.json
|
||||
- https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
|
||||
155
sx126x.cpp
155
sx126x.cpp
@@ -96,14 +96,6 @@
|
||||
#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
|
||||
@@ -279,24 +271,9 @@ void sx126x::setPacketParams(long preamble_symbols, uint8_t headermode, uint8_t
|
||||
buf[4] = crc;
|
||||
buf[5] = 0x00; // standard IQ setting (no inversion)
|
||||
buf[6] = 0x00; // unused params
|
||||
buf[7] = 0x00;
|
||||
buf[8] = 0x00;
|
||||
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) {
|
||||
@@ -396,66 +373,30 @@ int sx126x::begin(long frequency) {
|
||||
setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode);
|
||||
|
||||
#if HAS_LORA_PA
|
||||
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.
|
||||
#if LORA_PA_AUTO_DETECT
|
||||
// Power up the FEM, then read GPIO LORA_PA_CSD as input.
|
||||
// The V4.2 (GC1109) board pulls it LOW; V4.3 (KCT8103L) pulls it HIGH.
|
||||
pinMode(LORA_PA_PWR_EN, OUTPUT);
|
||||
digitalWrite(LORA_PA_PWR_EN, HIGH);
|
||||
delay(1);
|
||||
pinMode(LORA_PA_CSD, INPUT);
|
||||
delay(1);
|
||||
_kct8103l = (digitalRead(LORA_PA_CSD) == HIGH);
|
||||
|
||||
// Enable PA LNA and TX standby
|
||||
pinMode(LORA_PA_CSD, OUTPUT);
|
||||
digitalWrite(LORA_PA_CSD, HIGH);
|
||||
|
||||
// Keep PA CPS low until actual
|
||||
// transmit. Does it save power?
|
||||
// Who knows? Will have to measure.
|
||||
// Note from the future: Nope.
|
||||
// Power consumption is the same,
|
||||
// and turning it on and off is
|
||||
// not something that it likes.
|
||||
// Keeping it high for now.
|
||||
pinMode(LORA_PA_CPS, OUTPUT);
|
||||
digitalWrite(LORA_PA_CPS, HIGH);
|
||||
|
||||
// On Heltec V4, the PA CTX pin
|
||||
// is driven by the SX1262 DIO2
|
||||
// pin directly, so we do not
|
||||
// need to manually raise this.
|
||||
|
||||
} 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.
|
||||
}
|
||||
if (_kct8103l) {
|
||||
// KCT8103L (V4.3): CSD=HIGH enables chip, CTX=LOW=LNA/RX, CTX=HIGH=PA/TX
|
||||
pinMode(LORA_PA_CSD, OUTPUT);
|
||||
digitalWrite(LORA_PA_CSD, HIGH);
|
||||
pinMode(LORA_PA_CTX, OUTPUT);
|
||||
digitalWrite(LORA_PA_CTX, LOW); // LNA enabled by default
|
||||
} else {
|
||||
// GC1109 (V4.2): PA_EN=HIGH enables chip, CPS=HIGH=full PA mode
|
||||
pinMode(LORA_PA_CSD, OUTPUT);
|
||||
digitalWrite(LORA_PA_CSD, HIGH);
|
||||
pinMode(LORA_PA_CPS, OUTPUT);
|
||||
digitalWrite(LORA_PA_CPS, HIGH);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -465,15 +406,13 @@ void sx126x::end() { sleep(); SPI.end(); _preinit_done = false; }
|
||||
|
||||
int sx126x::beginPacket(int implicitHeader) {
|
||||
#if HAS_LORA_PA
|
||||
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.
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
digitalWrite(LORA_PA_CTX, HIGH);
|
||||
}
|
||||
#if LORA_PA_AUTO_DETECT
|
||||
if (_kct8103l) {
|
||||
// CTX=HIGH: switch KCT8103L to PA/TX mode.
|
||||
digitalWrite(LORA_PA_CTX, HIGH);
|
||||
}
|
||||
// GC1109: CPS kept HIGH permanently, no action needed.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (_txen != -1) { digitalWrite(_txen, HIGH); } //Set TXen high when transmitting
|
||||
@@ -566,7 +505,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;
|
||||
}
|
||||
@@ -582,7 +521,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;
|
||||
}
|
||||
@@ -689,17 +628,13 @@ void sx126x::onReceive(void(*callback)(int)){
|
||||
|
||||
void sx126x::receive(int size) {
|
||||
#if HAS_LORA_PA
|
||||
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.
|
||||
// The LNA goes wonky if it's toggled
|
||||
// on and off too quickly. We'll keep
|
||||
// it on permanently, as long as the
|
||||
// radio is powered up.
|
||||
} else if (lora_pa_model == LORA_PA_KCT8103L) {
|
||||
digitalWrite(LORA_PA_CTX, LOW);
|
||||
}
|
||||
#if LORA_PA_AUTO_DETECT
|
||||
if (_kct8103l) {
|
||||
// CTX=LOW: switch KCT8103L to LNA/RX mode.
|
||||
digitalWrite(LORA_PA_CTX, LOW);
|
||||
}
|
||||
// GC1109: CPS kept HIGH permanently, no action needed.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (size > 0) {
|
||||
@@ -841,17 +776,7 @@ void sx126x::handleLowDataRate() {
|
||||
}
|
||||
|
||||
// TODO: Check if there's anything the sx1262 can do here
|
||||
// SX1262 errata section 15.1: Modulation quality with 500 kHz LoRa BW.
|
||||
// Register 0x0889 bit 2 must be cleared for 500 kHz, set for all other
|
||||
// bandwidths. Improves receiver sensitivity at non-500 kHz bandwidths.
|
||||
void sx126x::optimizeModemSensitivity(){
|
||||
uint8_t reg = readRegister(0x0889);
|
||||
if (getSignalBandwidth() == 500E3) {
|
||||
writeRegister(0x0889, reg & 0xFB); // clear bit 2
|
||||
} else {
|
||||
writeRegister(0x0889, reg | 0x04); // set bit 2
|
||||
}
|
||||
}
|
||||
void sx126x::optimizeModemSensitivity(){ }
|
||||
|
||||
void sx126x::setSignalBandwidth(long sbw) {
|
||||
if (sbw <= 7.8E3) { _bw = 0x00; }
|
||||
|
||||
Reference in New Issue
Block a user