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", "board": "bsfrance:avr:lora32u4",
"sketch": "crossbow/crossbow.ino", "sketch": "crossbow/crossbow.ino",
"port": "COM11", "port": "COM7",
"output": "../build" "output": "../build"
} }

View File

@@ -285,7 +285,18 @@ void loop(void)
uint32_t currentMillis = millis(); 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 //Process buttons
button0.loop(); button0.loop();
@@ -314,21 +325,10 @@ void loop(void)
txInput.restart(); txInput.restart();
serialRestartMillis = currentMillis; serialRestartMillis = currentMillis;
} }
#endif
/* radioNode.handleTxDoneState(true);
* This routine handles resync of TX/RX while hoppping frequencies
*/
#ifdef DEVICE_MODE_RX
radioNode.handleChannelDwell();
#endif #endif
/*
* Detect the moment when radio module stopped transmittig and put it
* back in to receive state
*/
radioNode.handleTxDoneState();
radioNode.readAndDecode( radioNode.readAndDecode(
&qsp, &qsp,
&rxDeviceState, &rxDeviceState,
@@ -356,7 +356,7 @@ void loop(void)
qsp.protocolState == QSP_STATE_IDLE && qsp.protocolState == QSP_STATE_IDLE &&
qsp.lastTxSlotTimestamp + TX_TRANSMIT_SLOT_RATE < currentMillis qsp.lastTxSlotTimestamp + TX_TRANSMIT_SLOT_RATE < currentMillis
) { ) {
int8_t frameToSend = getFrameToTransmit(&qsp); int8_t frameToSend = getFrameToTransmit(&qsp);
#ifndef FORCE_TX_WITHOUT_INPUT #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(); uint32_t currentMillis = millis();
if ( if (
currentMillis > nextTxCheckMillis && currentMillis > nextTxCheckMillis &&
deviceState == RADIO_STATE_TX && deviceState == RADIO_STATE_TX &&
@@ -130,9 +131,9 @@ void RadioNode::handleTxDoneState(void) {
/* /*
* In case of TX module, hop right now * In case of TX module, hop right now
*/ */
#ifdef DEVICE_MODE_TX if (hop) {
hopFrequency(true, getChannel(), currentMillis); hopFrequency(true, getChannel(), currentMillis);
#endif }
LoRa.receive(); LoRa.receive();
deviceState = RADIO_STATE_RX; deviceState = RADIO_STATE_RX;

View File

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