diff --git a/sx126x.cpp b/sx126x.cpp index 4c06862..c890c62 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -389,12 +389,30 @@ int sx126x::endPacket() { if (timed_out) { return 0; } else { return 1; } } +///////////////////////////////////////// +// #define PIN_PREAMBLE 46 +// #define PIN_HEADER 45 +// #define PIN_FALSE 48 +// #define PIN_DCD 47 +// bool ps = false; +///////////////////////////////////////// + unsigned long preamble_detected_at = 0; extern long lora_preamble_time_ms; extern long lora_header_time_ms; bool false_preamble_detected = false; bool sx126x::dcd() { + ///////////////////////////////////////// + // if (!ps) { + // pinMode(PIN_PREAMBLE, OUTPUT); + // pinMode(PIN_HEADER, OUTPUT); + // pinMode(PIN_FALSE, OUTPUT); + // pinMode(PIN_DCD, OUTPUT); + // ps = true; + // } + ///////////////////////////////////////// + uint8_t buf[2] = {0}; executeOpcodeRead(OP_GET_IRQ_STATUS_6X, buf, 2); uint32_t now = millis(); @@ -416,6 +434,11 @@ bool sx126x::dcd() { } } + // if (preamble_detected_at != 0) { digitalWrite(PIN_PREAMBLE, HIGH); } else { digitalWrite(PIN_PREAMBLE, LOW); } + // if (header_detected) { digitalWrite(PIN_HEADER, HIGH); } else { digitalWrite(PIN_HEADER, LOW); } + // if (false_preamble_detected) { digitalWrite(PIN_FALSE, HIGH); } else { digitalWrite(PIN_FALSE, LOW); } + // if (carrier_detected) { digitalWrite(PIN_DCD, HIGH); } else { digitalWrite(PIN_DCD, LOW); } + // TODO: Maybe there's a way of unlatching the RSSI // status without re-activating receive mode? if (false_preamble_detected) { sx126x_modem.receive(); false_preamble_detected = false; }