MCPcopy Create free account
hub / github.com/Hieromon/AutoConnect / measure

Method measure

examples/WebSocketServer/MeasureRSSI.cpp:33–62  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

31 * @return false Measurement in progress.
32 */
33bool 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected