* If the real-time measurement is required, the MeasreRSSI::measure function * should always be called within the loop function. A sketch does not have to * intentionally create a measurement period. In particular, don't use delay. * It just adds unnecessary delays. * @return true The measurement is completed. MeasureRSSI::rssi has the * average value of RSSI measured for the specified numb
| 31 | * @return false Measurement in progress. |
| 32 | */ |
| 33 | bool MeasureRSSI::measure(void) { |
| 34 | unsigned long ct = millis(); |
| 35 | |
| 36 | if (ct - _tm < period) |
| 37 | return false; |
| 38 | |
| 39 | if (ct - _tmCycle < _cycle) |
| 40 | return false; |
| 41 | |
| 42 | _tmCycle = ct; |
| 43 | |
| 44 | if (!_rssi) |
| 45 | _rssi = new int8_t[points]; |
| 46 | |
| 47 | _rssi[_n++] = WiFi.RSSI(); |
| 48 | |
| 49 | if (_n >= points) { |
| 50 | rssi = 0; |
| 51 | do { |
| 52 | rssi += _rssi[--_n]; |
| 53 | } while (_n); |
| 54 | rssi = rssi / points; |
| 55 | delete[] _rssi; |
| 56 | _rssi = nullptr; |
| 57 | _tm = _tmCycle; |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | return false; |
| 62 | } |
nothing calls this directly
no outgoing calls
no test coverage detected