Cleanup
parent
ae47b89b53
commit
254225e917
15
Boards.h
15
Boards.h
|
@ -13,21 +13,6 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// TODO: Remove debug setup
|
|
||||||
#define PIN_PREAMBLE 7
|
|
||||||
#define PIN_HEADER 6
|
|
||||||
#define PIN_DCD 5
|
|
||||||
#define PIN_TXSIG 4
|
|
||||||
|
|
||||||
// #define PIN_DIFS 7
|
|
||||||
// #define PIN_CW 6
|
|
||||||
// #define PIN_FLUSH 5
|
|
||||||
|
|
||||||
#define PIN_DIFS 3
|
|
||||||
#define PIN_CW 3
|
|
||||||
#define PIN_FLUSH 3
|
|
||||||
///////////////////////////
|
|
||||||
|
|
||||||
#include "Modem.h"
|
#include "Modem.h"
|
||||||
|
|
||||||
#ifndef BOARDS_H
|
#ifndef BOARDS_H
|
||||||
|
|
|
@ -59,16 +59,6 @@ char sbuf[128];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// TODO: Remove debug setup
|
|
||||||
pinMode(PIN_PREAMBLE, OUTPUT);
|
|
||||||
pinMode(PIN_HEADER, OUTPUT);
|
|
||||||
pinMode(PIN_DCD, OUTPUT);
|
|
||||||
pinMode(PIN_TXSIG, OUTPUT);
|
|
||||||
pinMode(PIN_DIFS, OUTPUT);
|
|
||||||
pinMode(PIN_CW, OUTPUT);
|
|
||||||
pinMode(PIN_FLUSH, OUTPUT);
|
|
||||||
///////////////////////////
|
|
||||||
|
|
||||||
#if MCU_VARIANT == MCU_ESP32
|
#if MCU_VARIANT == MCU_ESP32
|
||||||
boot_seq();
|
boot_seq();
|
||||||
EEPROM.begin(EEPROM_SIZE);
|
EEPROM.begin(EEPROM_SIZE);
|
||||||
|
@ -524,10 +514,6 @@ bool queue_full() { return (queue_height >= CONFIG_QUEUE_MAX_LENGTH || queued_by
|
||||||
volatile bool queue_flushing = false;
|
volatile bool queue_flushing = false;
|
||||||
void flush_queue(void) {
|
void flush_queue(void) {
|
||||||
if (!queue_flushing) {
|
if (!queue_flushing) {
|
||||||
|
|
||||||
// TODO: Remove debug
|
|
||||||
digitalWrite(PIN_TXSIG, HIGH);
|
|
||||||
|
|
||||||
queue_flushing = true;
|
queue_flushing = true;
|
||||||
led_tx_on(); uint16_t processed = 0;
|
led_tx_on(); uint16_t processed = 0;
|
||||||
|
|
||||||
|
@ -1183,8 +1169,8 @@ void update_modem_status() {
|
||||||
portEXIT_CRITICAL();
|
portEXIT_CRITICAL();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (carrier_detected) { dcd = true; digitalWrite(PIN_DCD, HIGH); /* TODO: Remove debug */ }
|
if (carrier_detected) { dcd = true; }
|
||||||
else { dcd = false; digitalWrite(PIN_DCD, LOW); /* TODO: Remove debug */ }
|
else { dcd = false; }
|
||||||
|
|
||||||
dcd_led = dcd;
|
dcd_led = dcd;
|
||||||
if (dcd_led) { led_rx_on(); }
|
if (dcd_led) { led_rx_on(); }
|
||||||
|
@ -1376,13 +1362,8 @@ void tx_queue_handler() {
|
||||||
cw_wait_target = csma_cw * csma_slot_ms;
|
cw_wait_target = csma_cw * csma_slot_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove metering signallers
|
|
||||||
if (difs_wait_start == -1) { digitalWrite(PIN_DIFS, LOW); }
|
|
||||||
if (cw_wait_start == -1) { digitalWrite(PIN_CW, LOW); } else { digitalWrite(PIN_CW, HIGH); }
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
if (difs_wait_start == -1) { // DIFS wait not yet started
|
if (difs_wait_start == -1) { // DIFS wait not yet started
|
||||||
if (medium_free()) { difs_wait_start = millis(); digitalWrite(PIN_DIFS, HIGH); return; } // Set DIFS wait start time
|
if (medium_free()) { difs_wait_start = millis(); return; } // Set DIFS wait start time
|
||||||
else { return; } } // Medium not yet free, continue waiting
|
else { return; } } // Medium not yet free, continue waiting
|
||||||
|
|
||||||
else { // We are waiting for DIFS or CW to pass
|
else { // We are waiting for DIFS or CW to pass
|
||||||
|
@ -1391,7 +1372,7 @@ void tx_queue_handler() {
|
||||||
if (millis() < difs_wait_start+difs_ms) { return; } // DIFS has not yet passed, continue waiting
|
if (millis() < difs_wait_start+difs_ms) { return; } // DIFS has not yet passed, continue waiting
|
||||||
else { // DIFS has passed, and we are now in CW wait
|
else { // DIFS has passed, and we are now in CW wait
|
||||||
digitalWrite(PIN_DIFS, LOW);
|
digitalWrite(PIN_DIFS, LOW);
|
||||||
if (cw_wait_start == -1) { cw_wait_start = millis(); digitalWrite(PIN_CW, HIGH); return; } // If we haven't started counting CW wait time, do it from now
|
if (cw_wait_start == -1) { cw_wait_start = millis(); return; } // If we haven't started counting CW wait time, do it from now
|
||||||
else { // If we are already counting CW wait time, add it to the counter
|
else { // If we are already counting CW wait time, add it to the counter
|
||||||
cw_wait_passed += millis()-cw_wait_start; cw_wait_start = millis();
|
cw_wait_passed += millis()-cw_wait_start; cw_wait_start = millis();
|
||||||
if (cw_wait_passed < cw_wait_target) { return; } // Contention window wait time has not yet passed, continue waiting
|
if (cw_wait_passed < cw_wait_target) { return; } // Contention window wait time has not yet passed, continue waiting
|
||||||
|
|
11
sx126x.cpp
11
sx126x.cpp
|
@ -372,9 +372,6 @@ int sx126x::endPacket() {
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove debug
|
|
||||||
digitalWrite(PIN_TXSIG, LOW);
|
|
||||||
|
|
||||||
if (!(millis() < w_timeout)) { timed_out = true; }
|
if (!(millis() < w_timeout)) { timed_out = true; }
|
||||||
|
|
||||||
// Clear IRQs
|
// Clear IRQs
|
||||||
|
@ -402,19 +399,11 @@ bool sx126x::dcd() {
|
||||||
clearbuf[1] = IRQ_PREAMBLE_DET_MASK_6X;
|
clearbuf[1] = IRQ_PREAMBLE_DET_MASK_6X;
|
||||||
executeOpcode(OP_CLEAR_IRQ_STATUS_6X, clearbuf, 2);
|
executeOpcode(OP_CLEAR_IRQ_STATUS_6X, clearbuf, 2);
|
||||||
}
|
}
|
||||||
// TODO: Remove
|
|
||||||
digitalWrite(PIN_PREAMBLE, HIGH);
|
|
||||||
} else {
|
|
||||||
digitalWrite(PIN_PREAMBLE, LOW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buf[1] & IRQ_HEADER_DET_MASK_6X) != 0) {
|
if ((buf[1] & IRQ_HEADER_DET_MASK_6X) != 0) {
|
||||||
carrier_detected = true;
|
carrier_detected = true;
|
||||||
header_detected_at = millis();
|
header_detected_at = millis();
|
||||||
// TODO: Remove
|
|
||||||
digitalWrite(PIN_HEADER, HIGH);
|
|
||||||
} else {
|
|
||||||
digitalWrite(PIN_HEADER, LOW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return carrier_detected;
|
return carrier_detected;
|
||||||
|
|
Loading…
Reference in New Issue