Handle GC1109 LNA gain variance properly
This commit is contained in:
4
Config.h
4
Config.h
@@ -110,7 +110,9 @@
|
|||||||
#define CSMA_CW_PER_BAND_WINDOWS 15
|
#define CSMA_CW_PER_BAND_WINDOWS 15
|
||||||
#define CSMA_BAND_1_MAX_AIRTIME 7
|
#define CSMA_BAND_1_MAX_AIRTIME 7
|
||||||
#define CSMA_BAND_N_MIN_AIRTIME 85
|
#define CSMA_BAND_N_MIN_AIRTIME 85
|
||||||
#define CSMA_INFR_THRESHOLD_DB 12
|
#define CSMA_INFR_THRESHOLD_DB 6
|
||||||
|
#define CSMA_RFENV_RECAL_MS 2500
|
||||||
|
#define CSMA_RFENV_RECAL_LIMIT_DB -83
|
||||||
bool interference_detected = false;
|
bool interference_detected = false;
|
||||||
bool avoid_interference = true;
|
bool avoid_interference = true;
|
||||||
int csma_slot_ms = CSMA_SLOT_MIN_MS;
|
int csma_slot_ms = CSMA_SLOT_MIN_MS;
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -211,8 +211,8 @@ upload-heltec32_v4:
|
|||||||
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
||||||
@sleep 1
|
@sleep 1
|
||||||
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
|
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
|
||||||
@sleep 3
|
#@sleep 3
|
||||||
python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
#python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
||||||
|
|
||||||
upload-tdeck:
|
upload-tdeck:
|
||||||
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
||||||
|
|||||||
@@ -1383,6 +1383,8 @@ void update_noise_floor() {
|
|||||||
|
|
||||||
#define LED_ID_TRIG 16
|
#define LED_ID_TRIG 16
|
||||||
uint8_t led_id_filter = 0;
|
uint8_t led_id_filter = 0;
|
||||||
|
uint32_t interference_start = 0;
|
||||||
|
bool interference_persists = false;
|
||||||
void update_modem_status() {
|
void update_modem_status() {
|
||||||
#if MCU_VARIANT == MCU_ESP32
|
#if MCU_VARIANT == MCU_ESP32
|
||||||
portENTER_CRITICAL(&update_lock);
|
portENTER_CRITICAL(&update_lock);
|
||||||
@@ -1404,6 +1406,19 @@ void update_modem_status() {
|
|||||||
if (interference_detected) { if (led_id_filter < LED_ID_TRIG) { led_id_filter += 1; } }
|
if (interference_detected) { if (led_id_filter < LED_ID_TRIG) { led_id_filter += 1; } }
|
||||||
else { if (led_id_filter > 0) {led_id_filter -= 1; } }
|
else { if (led_id_filter > 0) {led_id_filter -= 1; } }
|
||||||
|
|
||||||
|
// Handle potential false interference detection due to
|
||||||
|
// LNA recalibration, antenna swap, moving into new RF
|
||||||
|
// environment or similar.
|
||||||
|
if (interference_detected && current_rssi < CSMA_RFENV_RECAL_LIMIT_DB) {
|
||||||
|
if (!interference_persists) {
|
||||||
|
interference_persists = true; interference_start = millis();
|
||||||
|
} else {
|
||||||
|
if (millis()-interference_start >= CSMA_RFENV_RECAL_MS) { noise_floor_sampled = false; interference_persists = false; }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
interference_persists = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (carrier_detected) { dcd = true; } else { dcd = false; }
|
if (carrier_detected) { dcd = true; } else { dcd = false; }
|
||||||
|
|
||||||
dcd_led = dcd;
|
dcd_led = dcd;
|
||||||
|
|||||||
20
sx126x.cpp
20
sx126x.cpp
@@ -356,8 +356,13 @@ int sx126x::begin(long frequency) {
|
|||||||
// Keep PA CPS low until actual
|
// Keep PA CPS low until actual
|
||||||
// transmit. Does it save power?
|
// transmit. Does it save power?
|
||||||
// Who knows? Will have to measure.
|
// 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);
|
pinMode(LORA_PA_CPS, OUTPUT);
|
||||||
digitalWrite(LORA_PA_CPS, LOW);
|
digitalWrite(LORA_PA_CPS, HIGH);
|
||||||
|
|
||||||
// On Heltec V4, the PA CTX pin
|
// On Heltec V4, the PA CTX pin
|
||||||
// is driven by the SX1262 DIO2
|
// is driven by the SX1262 DIO2
|
||||||
@@ -375,7 +380,10 @@ int sx126x::beginPacket(int implicitHeader) {
|
|||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
#if 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
|
||||||
|
// on permanently as long as the
|
||||||
|
// radio is powered up.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -476,7 +484,6 @@ uint8_t sx126x::packetRssiRaw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ISR_VECT sx126x::packetRssi() {
|
int ISR_VECT sx126x::packetRssi() {
|
||||||
// TODO: May need more calculations here
|
|
||||||
uint8_t buf[3] = {0};
|
uint8_t buf[3] = {0};
|
||||||
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;
|
||||||
@@ -590,7 +597,12 @@ void sx126x::receive(int size) {
|
|||||||
#if HAS_LORA_PA
|
#if HAS_LORA_PA
|
||||||
#if 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.
|
||||||
|
// 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.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user