diff --git a/README.md b/README.md index 1f6d2c5..28d5bab 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,14 @@ Total length of `RC_DATA` payload is 9 bytes | 3 | RX supply volatage, sent in 0,1V | | 4 | RX analog input 1 sent in 0,1V | | 5 | RX analog input 2 sent in 0,1V | +| 6 | Flags | + +#### Flags + +| Bit | Meaning | +| ---- | ---- | +| 00000001 | Device in Failsafe mode | + ### `PING` and `PONG` frames diff --git a/crossbow.ino b/crossbow.ino index de56112..bf29680 100644 --- a/crossbow.ino +++ b/crossbow.ino @@ -1,7 +1,7 @@ #define LORA_HARDWARE_SPI -// #define DEVICE_MODE_TX -#define DEVICE_MODE_RX +#define DEVICE_MODE_TX +// #define DEVICE_MODE_RX #define FEATURE_TX_OLED diff --git a/qsp.cpp b/qsp.cpp index 5fb14e1..8f37fae 100644 --- a/qsp.cpp +++ b/qsp.cpp @@ -61,6 +61,14 @@ void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta qsp->payload[3] = rxDeviceState->a1Voltage; qsp->payload[4] = rxDeviceState->a2Voltage; + uint8_t flags = 0; + + if (qsp->deviceState == DEVICE_STATE_FAILSAFE) { + flags |= 0x01 << 0; + } + + qsp->payload[5] = flags; + qsp->payloadLength = 6; } @@ -70,6 +78,7 @@ void decodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta rxDeviceState->rxVoltage = qsp->payload[2]; rxDeviceState->a1Voltage = qsp->payload[3]; rxDeviceState->a2Voltage = qsp->payload[4]; + rxDeviceState->flags = qsp->payload[5]; } /** diff --git a/variables.h b/variables.h index 174776d..993fc67 100644 --- a/variables.h +++ b/variables.h @@ -89,4 +89,5 @@ struct RxDeviceState_t { uint8_t a1Voltage = 0; uint8_t a2Voltage = 0; uint32_t roundtrip = 0; + uint8_t flags = 0; }; \ No newline at end of file