protocol preamble removed as not required for LoRa packet processing
This commit is contained in:
@@ -10,11 +10,10 @@ Development, ready for testing
|
|||||||
|
|
||||||
| Byte | Description | Notes |
|
| Byte | Description | Notes |
|
||||||
| ---- | ---- | ---- |
|
| ---- | ---- | ---- |
|
||||||
| 1 | Preamble | "Q" 0x51 |
|
| 1 | Channel ID | channel used for comunication between TX and RX |
|
||||||
| 2 | Channel ID | channel used for comunication between TX and RX |
|
| 2 | Frame type & Length | bits 7-5 defines frame, bits 4-0 payload length |
|
||||||
| 3 | Frame type & Length | bits 7-5 defines frame, bits 4-0 payload length |
|
| 3 - 34 | Payload | 32 bytes max |
|
||||||
| 5 - 36 | Payload | 32 bytes max |
|
| payload length + 3 | CRC | XOR of all previous bytes |
|
||||||
| payload length + 4 | CRC | XOR of all previous bytes |
|
|
||||||
|
|
||||||
## Frame types
|
## Frame types
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// #define DEVICE_MODE_TX
|
#define DEVICE_MODE_TX
|
||||||
#define DEVICE_MODE_RX
|
// #define DEVICE_MODE_RX
|
||||||
|
|
||||||
#define FEATURE_TX_OLED
|
#define FEATURE_TX_OLED
|
||||||
|
|
||||||
|
|||||||
12
qsp.cpp
12
qsp.cpp
@@ -154,18 +154,12 @@ void qspDecodeIncomingFrame(
|
|||||||
static uint8_t payloadLength;
|
static uint8_t payloadLength;
|
||||||
static uint8_t receivedPayload;
|
static uint8_t receivedPayload;
|
||||||
|
|
||||||
if (qsp->protocolState == QSP_STATE_IDLE && incomingByte == QSP_PREAMBLE)
|
if (qsp->protocolState == QSP_STATE_IDLE)
|
||||||
{
|
|
||||||
//If in IDLE and correct preamble comes, start to decode frame
|
|
||||||
qsp->protocolState = QSP_STATE_PREAMBLE_RECEIVED;
|
|
||||||
qsp->crc = 0 ^ incomingByte;
|
|
||||||
qsp->frameDecodingStartedAt = millis();
|
|
||||||
}
|
|
||||||
else if (qsp->protocolState == QSP_STATE_PREAMBLE_RECEIVED)
|
|
||||||
{
|
{
|
||||||
// Check if incomming channel ID is the same as receiver
|
// Check if incomming channel ID is the same as receiver
|
||||||
if (incomingByte == CHANNEL_ID)
|
if (incomingByte == CHANNEL_ID)
|
||||||
{
|
{
|
||||||
|
qsp->frameDecodingStartedAt = millis();
|
||||||
qsp->protocolState = QSP_STATE_CHANNEL_RECEIVED;
|
qsp->protocolState = QSP_STATE_CHANNEL_RECEIVED;
|
||||||
qsp->crc ^= incomingByte;
|
qsp->crc ^= incomingByte;
|
||||||
|
|
||||||
@@ -269,8 +263,6 @@ void qspEncodeFrame(QspConfiguration_t *qsp) {
|
|||||||
//Zero CRC
|
//Zero CRC
|
||||||
qsp->crc = 0;
|
qsp->crc = 0;
|
||||||
|
|
||||||
//Write preamble
|
|
||||||
qsp->hardwareWriteFunction(QSP_PREAMBLE, qsp);
|
|
||||||
//Write CHANNEL_ID
|
//Write CHANNEL_ID
|
||||||
qsp->hardwareWriteFunction(CHANNEL_ID, qsp);
|
qsp->hardwareWriteFunction(CHANNEL_ID, qsp);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#define TX_FAILSAFE_DELAY (RX_FAILSAFE_DELAY * 4)
|
#define TX_FAILSAFE_DELAY (RX_FAILSAFE_DELAY * 4)
|
||||||
|
|
||||||
#define CHANNEL_ID 0x01
|
#define CHANNEL_ID 0x01
|
||||||
#define QSP_PREAMBLE 0x51
|
|
||||||
#define QSP_PAYLOAD_LENGTH 32
|
#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 10 //max time that frame can be decoded in ms
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
|
|
||||||
enum dataStates {
|
enum dataStates {
|
||||||
QSP_STATE_IDLE,
|
QSP_STATE_IDLE,
|
||||||
QSP_STATE_PREAMBLE_RECEIVED,
|
|
||||||
QSP_STATE_CHANNEL_RECEIVED,
|
QSP_STATE_CHANNEL_RECEIVED,
|
||||||
QSP_STATE_FRAME_TYPE_RECEIVED,
|
QSP_STATE_FRAME_TYPE_RECEIVED,
|
||||||
QSP_STATE_PAYLOAD_RECEIVED,
|
QSP_STATE_PAYLOAD_RECEIVED,
|
||||||
|
|||||||
Reference in New Issue
Block a user