Further changes to async processing
This commit is contained in:
2
.vscode/arduino.json
vendored
2
.vscode/arduino.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"board": "bsfrance:avr:lora32u4",
|
||||
"sketch": "crossbow.ino",
|
||||
"port": "COM4",
|
||||
"port": "COM3",
|
||||
"output": "../build"
|
||||
}
|
||||
16
crossbow.ino
16
crossbow.ino
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user