mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2024-12-29 01:16:17 -05:00
Revert to ISR handling packets and cap SX1280 data rate
This commit is contained in:
parent
c3b5a6f47f
commit
51afd310a5
1
Config.h
1
Config.h
@ -78,6 +78,7 @@
|
||||
bool pmu_ready = false;
|
||||
bool promisc = false;
|
||||
bool implicit = false;
|
||||
volatile bool packet_ready = false;
|
||||
uint8_t implicit_l = 0;
|
||||
|
||||
uint8_t op_mode = MODE_HOST;
|
||||
|
@ -320,6 +320,7 @@ inline void kiss_write_packet(int index) {
|
||||
}
|
||||
serial_write(FEND);
|
||||
read_len = 0;
|
||||
packet_ready = false;
|
||||
}
|
||||
|
||||
inline void getPacketData(RadioInterface* radio, uint16_t len) {
|
||||
@ -358,7 +359,7 @@ void receive_callback(uint8_t index, int packet_size) {
|
||||
getPacketData(selected_radio, packet_size);
|
||||
|
||||
seq = SEQ_UNSET;
|
||||
ready = true;
|
||||
packet_ready = true;
|
||||
|
||||
} else if (isSplitPacket(header) && seq != sequence) {
|
||||
// This split packet does not carry the
|
||||
@ -383,7 +384,7 @@ void receive_callback(uint8_t index, int packet_size) {
|
||||
}
|
||||
|
||||
getPacketData(selected_radio, packet_size);
|
||||
ready = true;
|
||||
packet_ready = true;
|
||||
}
|
||||
} else {
|
||||
// In promiscuous mode, raw packets are
|
||||
@ -391,26 +392,9 @@ void receive_callback(uint8_t index, int packet_size) {
|
||||
read_len = 0;
|
||||
|
||||
getPacketData(selected_radio, packet_size);
|
||||
ready = true;
|
||||
packet_ready = true;
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portENTER_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portENTER_CRITICAL();
|
||||
#endif
|
||||
last_rssi = selected_radio->packetRssi();
|
||||
last_snr_raw = selected_radio->packetSnrRaw();
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portEXIT_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portEXIT_CRITICAL();
|
||||
#endif
|
||||
kiss_indicate_stat_rssi();
|
||||
kiss_indicate_stat_snr();
|
||||
kiss_write_packet(index);
|
||||
}
|
||||
last_rx = millis();
|
||||
}
|
||||
|
||||
@ -1168,7 +1152,23 @@ void validate_status() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
packet_poll();
|
||||
if (packet_ready) {
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portENTER_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portENTER_CRITICAL();
|
||||
#endif
|
||||
last_rssi = selected_radio->packetRssi();
|
||||
last_snr_raw = selected_radio->packetSnrRaw();
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portEXIT_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portEXIT_CRITICAL();
|
||||
#endif
|
||||
kiss_indicate_stat_rssi();
|
||||
kiss_indicate_stat_snr();
|
||||
kiss_write_packet(1);
|
||||
}
|
||||
|
||||
bool ready = false;
|
||||
for (int i = 0; i < INTERFACE_COUNT; i++) {
|
||||
@ -1313,25 +1313,6 @@ void poll_buffers() {
|
||||
process_serial();
|
||||
}
|
||||
|
||||
void packet_poll() {
|
||||
// If we have received a packet on an interface which needs to be processed
|
||||
while (!fifo_isempty(&packet_rdy_interfaces)) {
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portENTER_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portENTER_CRITICAL();
|
||||
#endif
|
||||
uint8_t packet_int = fifo_pop(&packet_rdy_interfaces);
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
portEXIT_CRITICAL(&update_lock);
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
portEXIT_CRITICAL();
|
||||
#endif
|
||||
selected_radio = interface_obj[packet_int];
|
||||
selected_radio->handleDio0Rise();
|
||||
}
|
||||
}
|
||||
|
||||
volatile bool serial_polling = false;
|
||||
void serial_poll() {
|
||||
serial_polling = true;
|
||||
|
12
Radio.cpp
12
Radio.cpp
@ -96,10 +96,11 @@ extern RadioInterface* interface_obj[];
|
||||
// which one is high. We can then use the index of this pin in the 2D array to
|
||||
// signal the correct interface to the main loop
|
||||
void ISR_VECT onDio0Rise() {
|
||||
BaseType_t int_status = taskENTER_CRITICAL_FROM_ISR();
|
||||
for (int i = 0; i < INTERFACE_COUNT; i++) {
|
||||
if (digitalRead(interface_pins[i][5]) == HIGH) {
|
||||
if (interface_obj[i]->getPacketValidity()) {
|
||||
fifo_push(&packet_rdy_interfaces, i);
|
||||
interface_obj[i]->handleDio0Rise();
|
||||
}
|
||||
if (interfaces[i] == SX128X) {
|
||||
// On the SX1280, there is a bug which can cause the busy line
|
||||
@ -111,6 +112,7 @@ void ISR_VECT onDio0Rise() {
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL_FROM_ISR(int_status);
|
||||
}
|
||||
|
||||
sx126x::sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen) :
|
||||
@ -2622,11 +2624,11 @@ void sx128x::updateBitrate() {
|
||||
_csma_slot_ms = 10;
|
||||
|
||||
float target_preamble_symbols;
|
||||
if (_bitrate <= LORA_FAST_BITRATE_THRESHOLD) {
|
||||
//if (_bitrate <= LORA_FAST_BITRATE_THRESHOLD) {
|
||||
target_preamble_symbols = (LORA_PREAMBLE_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
|
||||
} else {
|
||||
target_preamble_symbols = (LORA_PREAMBLE_FAST_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
|
||||
}
|
||||
//} else {
|
||||
/*target_preamble_symbols = (LORA_PREAMBLE_FAST_TARGET_MS/_lora_symbol_time_ms)-LORA_PREAMBLE_SYMBOLS_HW;
|
||||
}*/
|
||||
if (target_preamble_symbols < LORA_PREAMBLE_SYMBOLS_MIN) {
|
||||
target_preamble_symbols = LORA_PREAMBLE_SYMBOLS_MIN;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user