Merge branch 'master' into tx-sbus
This commit is contained in:
12
crossbow.ino
12
crossbow.ino
@@ -62,6 +62,8 @@ RxDeviceState_t rxDeviceState = {};
|
||||
TxDeviceState_t txDeviceState = {};
|
||||
volatile RadioState_t radioState;
|
||||
|
||||
uint8_t tmpBuffer[MAX_PACKET_SIZE];
|
||||
|
||||
uint8_t getRadioRssi(void)
|
||||
{
|
||||
return 164 - constrain(LoRa.packetRssi() * -1, 0, 164);
|
||||
@@ -265,10 +267,12 @@ void loop(void)
|
||||
{
|
||||
|
||||
if (radioState.bytesToRead != NO_DATA_TO_READ) {
|
||||
LoRa.read(tmpBuffer, radioState.bytesToRead);
|
||||
|
||||
for (int i = 0; i < radioState.bytesToRead; i++) {
|
||||
qspDecodeIncomingFrame(&qsp, LoRa.fastRead(), &rxDeviceState, &txDeviceState, &radioState);
|
||||
qspDecodeIncomingFrame(&qsp, tmpBuffer[i], &rxDeviceState, &txDeviceState, &radioState);
|
||||
}
|
||||
|
||||
radioState.rssi = getRadioRssi();
|
||||
radioState.snr = getRadioSnr();
|
||||
|
||||
@@ -397,8 +401,12 @@ void loop(void)
|
||||
|
||||
if (qsp.canTransmit && transmitPayload)
|
||||
{
|
||||
uint8_t size;
|
||||
LoRa.beginPacket();
|
||||
qspEncodeFrame(&qsp);
|
||||
//Prepare packet
|
||||
qspEncodeFrame(&qsp, tmpBuffer, &size);
|
||||
//Sent it to radio in one SPI transaction
|
||||
LoRa.write(tmpBuffer, size);
|
||||
LoRa.endPacket();
|
||||
//After ending packet, put device into receive mode again
|
||||
LoRa.receive();
|
||||
|
||||
Reference in New Issue
Block a user