From e7b35de0d26969fc86c6ee1a81b38952a5cf93b7 Mon Sep 17 00:00:00 2001 From: andrethomas Date: Sat, 14 Jul 2018 20:55:38 +0200 Subject: [PATCH] Updated Sensor API (markdown) --- Sensor-API.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Sensor-API.md b/Sensor-API.md index f71b66a8..6b851742 100644 --- a/Sensor-API.md +++ b/Sensor-API.md @@ -102,7 +102,28 @@ This callback ID is called every 50 milliseconds, e.g. for near real-time operat This callback ID is called every second. ### FUNC_PREP_BEFORE_TELEPERIOD -??? +This callback ID is called before TELEPERIOD and is intended. + +You would normally want to make sure you've detected and initialised before it is used by JSON_APPEND etc so that its ready to serve data. + +The generally accepted way to use this would be to detect your sensor and once this is done set a sensor value accordingly so that the function does not use unnecessary resources during future calls, for example: +``` +void MySensorDetect() +{ + if (MySensorDetected) { return; } + /* + * Perform the code which needs to be completed to + * detect your sensor and then set MySensorDetected to + * a non-zero value which will prevent this section + * of your code to re-run every time the function is + * called. + * + * Under normal circumstances you'd not need to do + * re-detect or initialise your sensor once it has been + * done + */ +} +``` ### FUNC_JSON_APPEND This callback ID is called when `TELEPERIOD` is due to append telemetry data to the MQTT JSON string, e.g.