mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2025-05-02 06:36:11 -04:00
Revert radiolib work and fix SX127X issues #39
This commit is contained in:
parent
734727ebc6
commit
46a46b4069
6 changed files with 120 additions and 184 deletions
|
@ -349,12 +349,15 @@ void lora_receive(RadioInterface* radio) {
|
|||
}
|
||||
|
||||
inline void kiss_write_packet(int index) {
|
||||
// We need to convert the interface index to the command byte representation
|
||||
uint8_t cmd_byte = getInterfaceCommandByte(index);
|
||||
|
||||
// Print index of interface the packet came from
|
||||
serial_write(FEND);
|
||||
serial_write(CMD_SEL_INT);
|
||||
serial_write(index);
|
||||
serial_write(FEND);
|
||||
|
||||
serial_write(FEND);
|
||||
// Add index of interface the packet came from
|
||||
serial_write(cmd_byte);
|
||||
serial_write(CMD_DATA);
|
||||
|
||||
for (uint16_t i = 0; i < read_len[index]; i++) {
|
||||
#if MCU_VARIANT == MCU_NRF52
|
||||
|
@ -689,39 +692,27 @@ void transmit(RadioInterface* radio, uint16_t size) {
|
|||
|
||||
void serialCallback(uint8_t sbyte) {
|
||||
if (IN_FRAME && sbyte == FEND &&
|
||||
(command == CMD_INT0_DATA
|
||||
|| command == CMD_INT1_DATA
|
||||
|| command == CMD_INT2_DATA
|
||||
|| command == CMD_INT3_DATA
|
||||
|| command == CMD_INT4_DATA
|
||||
|| command == CMD_INT5_DATA
|
||||
|| command == CMD_INT6_DATA
|
||||
|| command == CMD_INT7_DATA
|
||||
|| command == CMD_INT8_DATA
|
||||
|| command == CMD_INT9_DATA
|
||||
|| command == CMD_INT10_DATA
|
||||
|| command == CMD_INT11_DATA)) {
|
||||
command == CMD_DATA) {
|
||||
IN_FRAME = false;
|
||||
|
||||
if (getInterfaceIndex(command) < INTERFACE_COUNT) {
|
||||
uint8_t index = getInterfaceIndex(command);
|
||||
if (!fifo16_isfull(&packet_starts[index]) && (queued_bytes[index] < (getQueueSize(index)))) {
|
||||
uint16_t s = current_packet_start[index];
|
||||
int32_t e = queue_cursor[index]-1; if (e == -1) e = (getQueueSize(index))-1;
|
||||
if (interface < INTERFACE_COUNT) {
|
||||
if (!fifo16_isfull(&packet_starts[interface]) && (queued_bytes[interface] < (getQueueSize(interface)))) {
|
||||
uint16_t s = current_packet_start[interface];
|
||||
int32_t e = queue_cursor[interface]-1; if (e == -1) e = (getQueueSize(interface))-1;
|
||||
uint16_t l;
|
||||
|
||||
if (s != e) {
|
||||
l = (s < e) ? e - s + 1: (getQueueSize(index)) - s + e + 1;
|
||||
l = (s < e) ? e - s + 1: (getQueueSize(interface)) - s + e + 1;
|
||||
} else {
|
||||
l = 1;
|
||||
}
|
||||
|
||||
if (l >= MIN_L) {
|
||||
queue_height[index]++;
|
||||
queue_height[interface]++;
|
||||
|
||||
fifo16_push(&packet_starts[index], s);
|
||||
fifo16_push(&packet_lengths[index], l);
|
||||
current_packet_start[index] = queue_cursor[index];
|
||||
fifo16_push(&packet_starts[interface], s);
|
||||
fifo16_push(&packet_lengths[interface], l);
|
||||
current_packet_start[interface] = queue_cursor[interface];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -735,33 +726,10 @@ void serialCallback(uint8_t sbyte) {
|
|||
// Have a look at the command byte first
|
||||
if (frame_len == 0 && command == CMD_UNKNOWN) {
|
||||
command = sbyte;
|
||||
if (command == CMD_SEL_INT0
|
||||
|| command == CMD_SEL_INT1
|
||||
|| command == CMD_SEL_INT2
|
||||
|| command == CMD_SEL_INT3
|
||||
|| command == CMD_SEL_INT4
|
||||
|| command == CMD_SEL_INT5
|
||||
|| command == CMD_SEL_INT6
|
||||
|| command == CMD_SEL_INT7
|
||||
|| command == CMD_SEL_INT8
|
||||
|| command == CMD_SEL_INT9
|
||||
|| command == CMD_SEL_INT10
|
||||
|| command == CMD_SEL_INT11) {
|
||||
interface = getInterfaceIndex(command);
|
||||
}
|
||||
|
||||
} else if (command == CMD_INT0_DATA
|
||||
|| command == CMD_INT1_DATA
|
||||
|| command == CMD_INT2_DATA
|
||||
|| command == CMD_INT3_DATA
|
||||
|| command == CMD_INT4_DATA
|
||||
|| command == CMD_INT5_DATA
|
||||
|| command == CMD_INT6_DATA
|
||||
|| command == CMD_INT7_DATA
|
||||
|| command == CMD_INT8_DATA
|
||||
|| command == CMD_INT9_DATA
|
||||
|| command == CMD_INT10_DATA
|
||||
|| command == CMD_INT11_DATA) {
|
||||
} else if (command == CMD_SEL_INT) {
|
||||
interface = sbyte;
|
||||
} else if (command == CMD_DATA) {
|
||||
if (bt_state != BT_STATE_CONNECTED) cable_state = CABLE_STATE_CONNECTED;
|
||||
if (sbyte == FESC) {
|
||||
ESCAPE = true;
|
||||
|
@ -772,12 +740,11 @@ void serialCallback(uint8_t sbyte) {
|
|||
ESCAPE = false;
|
||||
}
|
||||
|
||||
if (getInterfaceIndex(command) < INTERFACE_COUNT) {
|
||||
uint8_t index = getInterfaceIndex(command);
|
||||
if (queue_height[index] < CONFIG_QUEUE_MAX_LENGTH && queued_bytes[index] < (getQueueSize(index))) {
|
||||
queued_bytes[index]++;
|
||||
packet_queue[index][queue_cursor[index]++] = sbyte;
|
||||
if (queue_cursor[index] == (getQueueSize(index))) queue_cursor[index] = 0;
|
||||
if (interface < INTERFACE_COUNT) {
|
||||
if (queue_height[interface] < CONFIG_QUEUE_MAX_LENGTH && queued_bytes[interface] < (getQueueSize(interface))) {
|
||||
queued_bytes[interface]++;
|
||||
packet_queue[interface][queue_cursor[interface]++] = sbyte;
|
||||
if (queue_cursor[interface] == (getQueueSize(interface))) queue_cursor[interface] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -962,7 +929,7 @@ void serialCallback(uint8_t sbyte) {
|
|||
} else if (command == CMD_STAT_TX) {
|
||||
kiss_indicate_stat_tx();
|
||||
} else if (command == CMD_STAT_RSSI) {
|
||||
kiss_indicate_stat_rssi();
|
||||
kiss_indicate_stat_rssi(interface_obj[interface]);
|
||||
} else if (command == CMD_RADIO_LOCK) {
|
||||
selected_radio = interface_obj[interface];
|
||||
update_radio_lock(selected_radio);
|
||||
|
@ -1320,7 +1287,7 @@ void loop() {
|
|||
#if MCU_VARIANT == MCU_ESP32
|
||||
modem_packet_t *modem_packet = NULL;
|
||||
if(modem_packet_queue && xQueueReceive(modem_packet_queue, &modem_packet, 0) == pdTRUE && modem_packet) {
|
||||
packet_interface = modem_packet->interface;
|
||||
uint8_t packet_interface = modem_packet->interface;
|
||||
read_len[packet_interface] = modem_packet->len;
|
||||
last_rssi = modem_packet->rssi;
|
||||
last_snr_raw = modem_packet->snr_raw;
|
||||
|
@ -1328,15 +1295,15 @@ void loop() {
|
|||
free(modem_packet);
|
||||
modem_packet = NULL;
|
||||
|
||||
kiss_indicate_stat_rssi();
|
||||
kiss_indicate_stat_snr();
|
||||
kiss_indicate_stat_rssi(interface_obj[packet_interface]);
|
||||
kiss_indicate_stat_snr(interface_obj[packet_interface]);
|
||||
kiss_write_packet(packet_interface);
|
||||
}
|
||||
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
modem_packet_t *modem_packet = NULL;
|
||||
if(modem_packet_queue && xQueueReceive(modem_packet_queue, &modem_packet, 0) == pdTRUE && modem_packet) {
|
||||
packet_interface = modem_packet->interface;
|
||||
uint8_t packet_interface = modem_packet->interface;
|
||||
read_len[packet_interface] = modem_packet->len;
|
||||
last_rssi = modem_packet->rssi;
|
||||
last_snr_raw = modem_packet->snr_raw;
|
||||
|
@ -1344,8 +1311,8 @@ void loop() {
|
|||
free(modem_packet);
|
||||
modem_packet = NULL;
|
||||
|
||||
kiss_indicate_stat_rssi();
|
||||
kiss_indicate_stat_snr();
|
||||
kiss_indicate_stat_rssi(packet_interface);
|
||||
kiss_indicate_stat_snr(packet_interface);
|
||||
kiss_write_packet(packet_interface);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue