Outgoing bind frame

This commit is contained in:
Pawel Spychalski
2018-05-23 15:21:11 +02:00
parent 831c97b219
commit 95ecb7c4f9
5 changed files with 35 additions and 2 deletions

View File

@@ -263,6 +263,11 @@ int8_t getFrameToTransmit(QspConfiguration_t *qsp) {
#ifdef DEVICE_MODE_TX
int8_t getFrameToTransmit(QspConfiguration_t *qsp) {
if (platformNode.isBindMode) {
return QSP_FRAME_BIND;
}
int8_t retVal = txSendSequence[currentSequenceIndex];
currentSequenceIndex++;
@@ -380,6 +385,10 @@ void loop(void)
case QSP_FRAME_RC_DATA:
encodeRcDataPayload(&qsp, PLATFORM_CHANNEL_COUNT);
break;
case QSP_FRAME_BIND:
encodeBindPayload(&qsp, platformNode.bindKey);
break;
}
transmitPayload = true;

View File

@@ -237,4 +237,13 @@ void encodePingPayload(QspConfiguration_t *qsp, uint32_t currentMicros) {
qsp->payload[3] = (currentMicros >> 24) & 255;
qsp->payloadLength = qspFrameLengths[QSP_FRAME_PING];
}
void encodeBindPayload(QspConfiguration_t *qsp, uint8_t bindKey[]) {
for (uint8_t i = 0; i < qspFrameLengths[QSP_FRAME_PING]; i++) {
qsp->payload[i] = bindKey[i];
}
qsp->payloadLength = qspFrameLengths[QSP_FRAME_PING];
}

View File

@@ -19,4 +19,5 @@ void qspDecodeIncomingFrame(
void qspClearPayload(QspConfiguration_t *qsp);
void qspEncodeFrame(QspConfiguration_t *qsp, uint8_t buffer[], uint8_t *size, uint8_t radioChannel, uint8_t bindKey[]);
void encodePingPayload(QspConfiguration_t *qsp, uint32_t currentMicros);
void encodePingPayload(QspConfiguration_t *qsp, uint32_t currentMicros);
void encodeBindPayload(QspConfiguration_t *qsp, uint8_t bindKey[]);

View File

@@ -22,6 +22,13 @@ void TxOled::loop() {
//Second button has notthing to do over here
break;
case TX_PAGE_BIND:
if (button1.getState() == TACTILE_STATE_LONG_PRESS) {
platformNode.isBindMode = !platformNode.isBindMode;
update = true;
}
break;
case TX_PAGE_STATS:
//Second button refreshes this page
if (button1.getState() == TACTILE_STATE_SHORT_PRESS) {
@@ -93,7 +100,12 @@ void TxOled::renderPageBind() {
_display.clear();
_display.draw1x2String(0, 0, "Bind");
snprintf(buf, OLED_COL_COUNT, "Bind?");
if (platformNode.isBindMode) {
snprintf(buf, OLED_COL_COUNT, "Binding!!");
} else {
snprintf(buf, OLED_COL_COUNT, "Bind?");
}
_display.draw1x2String(0, 4, buf);
}

View File

@@ -8,8 +8,10 @@
#include "variables.h"
#include "tactile.h"
#include "radio_node.h"
#include "platform_node.h"
extern RadioNode radioNode;
extern PlatformNode platformNode;
extern RxDeviceState_t rxDeviceState;
extern TxDeviceState_t txDeviceState;
extern Tactile button0;