Further changes to async processing

This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-01-02 21:14:11 +01:00
parent 8dfc41759e
commit cb3c510815
3 changed files with 11 additions and 8 deletions

View File

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

View File

@@ -1,10 +1,10 @@
// #define DEVICE_MODE_TX
#define DEVICE_MODE_RX
#define DEVICE_MODE_TX
// #define DEVICE_MODE_RX
// #define FEATURE_TX_OLED
// #define FORCE_TX_WITHOUT_INPUT
// #define DEBUG_SERIAL
#define DEBUG_SERIAL
// #define DEBUG_PING_PONG
// #define DEBUG_LED
@@ -276,9 +276,14 @@ void loop(void)
* Detect the moment when radio module stopped transmittig and put it
* back in to receive state
*/
if (radioState.deviceState == RADIO_STATE_TX && !LoRa.isTransmitting()) {
if (
currentMillis > radioState.nextTxCheckMillis &&
radioState.deviceState == RADIO_STATE_TX &&
!LoRa.isTransmitting()
) {
LoRa.receive();
radioState.deviceState = RADIO_STATE_RX;
radioState.nextTxCheckMillis = currentMillis + 1; //We check of TX done every 1ms
}
if (radioState.bytesToRead != NO_DATA_TO_READ) {
@@ -516,9 +521,6 @@ void loop(void)
void onReceive(int packetSize)
{
if (packetSize == 0)
return;
/*
* We can start reading only when radio is not reading.
* If not reading, then we might start

View File

@@ -87,6 +87,7 @@ struct RadioState_t {
uint8_t rssi = 0;
uint8_t snr = 0;
uint8_t deviceState = RADIO_STATE_RX;
uint32_t nextTxCheckMillis = 0;
};
struct TxDeviceState_t {