This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-05-16 17:06:03 +02:00
parent 1c2bd0055e
commit 35053daa90
4 changed files with 21 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
{
"board": "bsfrance:avr:lora32u4",
"sketch": "crossbow/crossbow.ino",
"port": "COM11",
"port": "COM7",
"output": "../build"
}

View File

@@ -285,7 +285,18 @@ void loop(void)
uint32_t currentMillis = millis();
#ifdef DEVICE_MODE_TX
#ifdef DEVICE_MODE_RX
/*
* This routine handles resync of TX/RX while hoppping frequencies
*/
radioNode.handleChannelDwell();
/*
* Detect the moment when radio module stopped transmittig and put it
* back in to receive state
*/
radioNode.handleTxDoneState(false);
#else
//Process buttons
button0.loop();
@@ -314,21 +325,10 @@ void loop(void)
txInput.restart();
serialRestartMillis = currentMillis;
}
#endif
/*
* This routine handles resync of TX/RX while hoppping frequencies
*/
#ifdef DEVICE_MODE_RX
radioNode.handleChannelDwell();
radioNode.handleTxDoneState(true);
#endif
/*
* Detect the moment when radio module stopped transmittig and put it
* back in to receive state
*/
radioNode.handleTxDoneState();
radioNode.readAndDecode(
&qsp,
&rxDeviceState,
@@ -356,7 +356,7 @@ void loop(void)
qsp.protocolState == QSP_STATE_IDLE &&
qsp.lastTxSlotTimestamp + TX_TRANSMIT_SLOT_RATE < currentMillis
) {
int8_t frameToSend = getFrameToTransmit(&qsp);
#ifndef FORCE_TX_WITHOUT_INPUT

View File

@@ -119,8 +119,9 @@ void RadioNode::handleChannelDwell(void) {
}
}
void RadioNode::handleTxDoneState(void) {
void RadioNode::handleTxDoneState(bool hop) {
uint32_t currentMillis = millis();
if (
currentMillis > nextTxCheckMillis &&
deviceState == RADIO_STATE_TX &&
@@ -130,9 +131,9 @@ void RadioNode::handleTxDoneState(void) {
/*
* In case of TX module, hop right now
*/
#ifdef DEVICE_MODE_TX
hopFrequency(true, getChannel(), currentMillis);
#endif
if (hop) {
hopFrequency(true, getChannel(), currentMillis);
}
LoRa.receive();
deviceState = RADIO_STATE_RX;

View File

@@ -33,7 +33,7 @@ class RadioNode {
uint8_t getChannel(void);
uint32_t getChannelEntryMillis(void);
void handleChannelDwell(void);
void handleTxDoneState();
void handleTxDoneState(bool hop);
void handleTx(QspConfiguration_t *qsp);
volatile int8_t bytesToRead = -1;
volatile uint8_t deviceState = RADIO_STATE_RX;