Skip to content

Commit d6e63eb

Browse files
authored
Merge pull request #217 from aviateur17/lora_tx_sync
revert sendFDRS to Synchronous operations, add sendFDRSAsync
2 parents 05a86d9 + e1a2a20 commit d6e63eb

File tree

5 files changed

+244
-109
lines changed

5 files changed

+244
-109
lines changed

extras/Node.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ Loads some data into the current packet. 'data' is a float, 'type' is the data t
6262
#### `loadFDRS((float data, uint8_t type);`
6363
Same as above, but the 'id' is preset to the node's `READING_ID`.
6464
#### `bool sendFDRS();`
65-
Sends the current packet using ESP-NOW and/or LoRa. Returns true if packet is confirmed to have been recieved successfully by the gateway.
65+
Sends the current packet using ESP-NOW and/or LoRa. Returns true if packet is confirmed to have been received successfully by the gateway.
66+
#### `bool sendFDRSAsync();`
67+
Queues the current packet to be sent asynchronously (in the background). Be sure to use `loopFDRS()` to ensure the system can process the packet. Returns true if packet is successfully added to queue.
6668
#### `sleepFDRS(seconds)`
6769
Time to sleep in seconds. If ```DEEP_SLEEP``` is enabled, the device will enter sleep. Otherwise it will use a simple ```delay()```.
6870
6971
## Controller API
7072
#### ```addFDRS(void callback);```
71-
Initializes controller functionality by selecting the function to be called when incoming commands are recieved. If using LoRa, the controller will automatically recieve any packets sent with broadcastLoRa(), provided they were sent by the paired gateway. ESP-NOW requires the device to register with its gateway before it will recieve incoming commands. This is done automatically, and the ESP-NOW node will continue recieving data until the paired gateway is reset. A maximum of 16 ESP-NOW controllers can recieve data from a single gateway. There is no limit to how many LoRa controllers can listen to the same gateway.
73+
Initializes controller functionality by selecting the function to be called when incoming commands are received. If using LoRa, the controller will automatically receive any packets sent with broadcastLoRa(), provided they were sent by the paired gateway. ESP-NOW requires the device to register with its gateway before it will receive incoming commands. This is done automatically, and the ESP-NOW node will continue recieving data until the paired gateway is reset. A maximum of 16 ESP-NOW controllers can receive data from a single gateway. There is no limit to how many LoRa controllers can listen to the same gateway.
7274
#### ```subscribeFDRS(uint16_t sub_id);```
7375
Sets the device to listen for a specific DataReading id. When a DataReading with id ```sub_id``` is received, the callback function will be called and given the full DataReading as a parameter.
7476
#### ```unsubscribeFDRS(uint16_t sub_id);```
@@ -120,7 +122,7 @@ OLED I²C pins.
120122
OLED reset pin. Use '-1' if not present or known.
121123
#
122124
## Callback Function
123-
The callback function is executed when data arrives with an ID that the controller is subscribed to. Inside of this function, the user has access to the incoming DataReading. If multiple readings are recieved, the function will be called for each of them. While you should always be brief in interrupt callbacks (ISRs), it's okay to do more in this one.
125+
The callback function is executed when data arrives with an ID that the controller is subscribed to. Inside of this function, the user has access to the incoming DataReading. If multiple readings are received, the function will be called for each of them. While you should always be brief in interrupt callbacks (ISRs), it's okay to do more in this one.
124126
## Type Definitions
125127
For the moment, my thought is to reserve the first two bits of the type. I might use them in the future to indicate the data size or type (bool, char,  int, float, etc?). This leaves us with 64 possible type definitions. If you have more types to add, please get in touch!
126128
```

src/fdrs_datatypes.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ enum ping_t {
3939
ping_reply
4040
};
4141

42-
enum pingstate_t {
42+
enum commstate_t {
4343
stReady,
4444
stInProcess,
4545
stCrcMismatch,
4646
stCrcMatch,
47+
stInterMessageDelay,
4748
stCompleted
4849
};
4950

@@ -103,7 +104,7 @@ uint size;
103104
};
104105

105106
struct Ping {
106-
pingstate_t status = stReady;
107+
commstate_t status = stReady;
107108
unsigned long start;
108109
uint timeout;
109110
uint16_t address;

0 commit comments

Comments
 (0)