diff --git a/.vscode/arduino.json b/.vscode/arduino.json index 8b7bafb..bfcb771 100644 --- a/.vscode/arduino.json +++ b/.vscode/arduino.json @@ -1,6 +1,6 @@ { "board": "bsfrance:avr:lora32u4", "sketch": "crossbow.ino", - "port": "COM15", + "port": "COM19", "output": "./build" } \ No newline at end of file diff --git a/crossbow.ino b/crossbow.ino index 02c31d4..95dc25a 100644 --- a/crossbow.ino +++ b/crossbow.ino @@ -272,14 +272,14 @@ void loop(void) #ifdef DEVICE_MODE_TX if (txDeviceState.readPacket) { - int incomingByte = LoRa.read(); - if (incomingByte > -1) { + int incomingByte; + while (incomingByte = LoRa.read(), incomingByte > -1) + { qspDecodeIncomingFrame(&qsp, incomingByte, ppm, &rxDeviceState, &txDeviceState); - } else { - txDeviceState.rssi = getRadioRssi(); - txDeviceState.snr = getRadioSnr(); - txDeviceState.readPacket = false; } + txDeviceState.rssi = getRadioRssi(); + txDeviceState.snr = getRadioSnr(); + txDeviceState.readPacket = false; } #endif diff --git a/qsp.cpp b/qsp.cpp index 942210d..4db0014 100644 --- a/qsp.cpp +++ b/qsp.cpp @@ -161,7 +161,7 @@ void qspDecodeIncomingFrame( { qsp->frameDecodingStartedAt = millis(); qsp->protocolState = QSP_STATE_CHANNEL_RECEIVED; - qsp->crc ^= incomingByte; + qsp->crc = 0 ^ incomingByte; qspClearPayload(qsp); diff --git a/variables.h b/variables.h index 7c1d135..dea7656 100644 --- a/variables.h +++ b/variables.h @@ -18,7 +18,7 @@ #define CHANNEL_ID 0x01 #define QSP_PAYLOAD_LENGTH 32 -#define QSP_MAX_FRAME_DECODE_TIME 10 //max time that frame can be decoded in ms +#define QSP_MAX_FRAME_DECODE_TIME 5 //max time that frame can be decoded in ms #define QSP_FRAME_RC_DATA 0x0 #define QSP_FRAME_RX_HEALTH 0x1