File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1212#define SAMPLING_THRESHOLD 14
1313
1414static volatile uint8_t state = STATE_IDLE;
15+ static SemaphoreHandle_t rx_wait_sem;
1516
1617// this function is called when a complete packet
1718// is transmitted by the module
2223void setFlag (void ) {
2324 // we sent a packet, set the flag
2425 state |= STATE_INT_READY;
26+
27+ if (state & STATE_RX) xSemaphoreGive (rx_wait_sem);
2528}
2629
2730void RadioLibWrapper::begin () {
@@ -38,13 +41,21 @@ void RadioLibWrapper::begin() {
3841 // start average out some samples
3942 _num_floor_samples = 0 ;
4043 _floor_sample_sum = 0 ;
44+
45+ rx_wait_sem = xSemaphoreCreateBinary ();
46+ xSemaphoreGive (rx_wait_sem);
47+ xSemaphoreTake (rx_wait_sem, portMAX_DELAY);
4148}
4249
4350void RadioLibWrapper::idle () {
4451 _radio->standby ();
4552 state = STATE_IDLE; // need another startReceive()
4653}
4754
55+ int RadioLibWrapper::blockTaskUntilRXEvent (unsigned int timeout = 5000 ) {
56+ return xSemaphoreTake (rx_wait_sem, pdMS_TO_TICKS (timeout));
57+ }
58+
4859void RadioLibWrapper::triggerNoiseFloorCalibrate (int threshold) {
4960 _threshold = threshold;
5061 if (_num_floor_samples >= NUM_NOISE_FLOOR_SAMPLES) { // ignore trigger if currently sampling
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ class RadioLibWrapper : public mesh::Radio {
3636 return isChannelActive ();
3737 }
3838
39+ int blockTaskUntilRXEvent (unsigned int timeout);
40+
3941 virtual float getCurrentRSSI () =0;
4042
4143 int getNoiseFloor () const override { return _noise_floor; }
You can’t perform that action at this time.
0 commit comments