Skip to content

Commit 0b987cf

Browse files
committed
Improve remote command processing, add more serial debugging
1 parent 142e2a4 commit 0b987cf

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Firmware/LoRaSerial/States.ino

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,14 @@ void updateRadioState()
721721
triggerEvent(TRIGGER_RX_DATA);
722722

723723
//Place the data in the serial output buffer
724+
if (settings.debugSerial)
725+
{
726+
systemPrint("Moving ");
727+
systemPrint(rxDataBytes);
728+
systemPrintln(" from incomingBuffer to serialTransmitBuffer");
729+
dumpBuffer(rxData, length);
730+
outputSerialData(true);
731+
}
724732
serialBufferOutput(rxData, rxDataBytes);
725733

726734
//Transmit ACK
@@ -750,6 +758,16 @@ void updateRadioState()
750758
case DATAGRAM_REMOTE_COMMAND:
751759
triggerEvent(TRIGGER_RX_COMMAND);
752760

761+
//Debug the remote command operation
762+
if (settings.debugSerial)
763+
{
764+
systemPrint("Moving ");
765+
systemPrint(rxDataBytes);
766+
systemPrintln(" from incomingBuffer to commandRXBuffer");
767+
dumpBuffer(rxData, length);
768+
outputSerialData(true);
769+
}
770+
753771
//Determine the number of bytes received
754772
length = 0;
755773
if ((commandRXHead + rxDataBytes) > sizeof(commandRXBuffer))
@@ -772,9 +790,16 @@ void updateRadioState()
772790
case DATAGRAM_REMOTE_COMMAND_RESPONSE:
773791
triggerEvent(TRIGGER_RX_COMMAND_RESPONSE);
774792

775-
//Print received data. This is blocking but we do not use the serialTransmitBuffer because we're in command mode (and it's not much data to print).
776-
for (int x = 0 ; x < rxDataBytes ; x++)
777-
Serial.write(rxData[x]);
793+
//Print received data.
794+
if (settings.debugSerial)
795+
{
796+
systemPrint("Moving ");
797+
systemPrint(rxDataBytes);
798+
systemPrintln(" from incomingBuffer to serialTransmitBuffer");
799+
dumpBuffer(rxData, length);
800+
outputSerialData(true);
801+
}
802+
serialBufferOutput(rxData, rxDataBytes);
778803

779804
//Transmit ACK
780805
P2P_SEND_ACK(TRIGGER_TX_ACK);

0 commit comments

Comments
 (0)