Skip to content

Fixed promiscuous mode. #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions RNode_Firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,15 @@ void ISR_VECT receive_callback(int packet_size) {
BaseType_t int_mask;
#endif

if (!promisc) {
bool ready = false;
if (!promisc) { // Not in promiscuous mode
// The standard operating mode allows large
// packets with a payload up to 500 bytes,
// by combining two raw LoRa packets.
// We read the 1-byte header and extract
// packet sequence number and split flags
uint8_t header = LoRa->read(); packet_size--;
uint8_t sequence = packetSequence(header);
bool ready = false;

if (isSplitPacket(header) && seq == SEQ_UNSET) {
// This is the first part of a split
Expand Down Expand Up @@ -442,40 +442,7 @@ void ISR_VECT receive_callback(int packet_size) {
getPacketData(packet_size);
ready = true;
}

if (ready) {
#if MCU_VARIANT != MCU_ESP32 && MCU_VARIANT != MCU_NRF52
// We first signal the RSSI of the
// recieved packet to the host.
kiss_indicate_stat_rssi();
kiss_indicate_stat_snr();

// And then write the entire packet
kiss_write_packet();

#else
// Allocate packet struct, but abort if there
// is not enough memory available.
modem_packet_t *modem_packet = (modem_packet_t*)malloc(sizeof(modem_packet_t) + read_len);
if(!modem_packet) { memory_low = true; return; }

// Get packet RSSI and SNR
#if MCU_VARIANT == MCU_ESP32
modem_packet->snr_raw = LoRa->packetSnrRaw();
modem_packet->rssi = LoRa->packetRssi(modem_packet->snr_raw);
#endif

// Send packet to event queue, but free the
// allocated memory again if the queue is
// unable to receive the packet.
modem_packet->len = read_len;
memcpy(modem_packet->data, pbuf, read_len);
if (!modem_packet_queue || xQueueSendFromISR(modem_packet_queue, &modem_packet, NULL) != pdPASS) {
free(modem_packet);
}
#endif
}
} else {
} else { // In promiscuous mode
// In promiscuous mode, raw packets are
// output directly to the host
read_len = 0;
Expand All @@ -495,7 +462,40 @@ void ISR_VECT receive_callback(int packet_size) {

#else
getPacketData(packet_size);
packet_ready = true;
ready = true;
#endif
}

if (ready) {
#if MCU_VARIANT != MCU_ESP32 && MCU_VARIANT != MCU_NRF52
// We first signal the RSSI of the
// recieved packet to the host.
kiss_indicate_stat_rssi();
kiss_indicate_stat_snr();

// And then write the entire packet
kiss_write_packet();

#else
// Allocate packet struct, but abort if there
// is not enough memory available.
modem_packet_t *modem_packet = (modem_packet_t*)malloc(sizeof(modem_packet_t) + read_len);
if(!modem_packet) { memory_low = true; return; }

// Get packet RSSI and SNR
#if MCU_VARIANT == MCU_ESP32
modem_packet->snr_raw = LoRa->packetSnrRaw();
modem_packet->rssi = LoRa->packetRssi(modem_packet->snr_raw);
#endif

// Send packet to event queue, but free the
// allocated memory again if the queue is
// unable to receive the packet.
modem_packet->len = read_len;
memcpy(modem_packet->data, pbuf, read_len);
if (!modem_packet_queue || xQueueSendFromISR(modem_packet_queue, &modem_packet, NULL) != pdPASS) {
free(modem_packet);
}
#endif
}
}
Expand Down