From 792e5fbc490823c974e98a605b1aa3c5a9f5cd99 Mon Sep 17 00:00:00 2001 From: Rene Bartsch Date: Thu, 12 Jul 2018 15:20:44 +0200 Subject: [PATCH] All XsnsFunctions added. --- Sensor-API.md | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Sensor-API.md b/Sensor-API.md index dbf6d6a0..8dd86a92 100644 --- a/Sensor-API.md +++ b/Sensor-API.md @@ -47,12 +47,22 @@ boolean Xsns(byte callback_id) ### Callback IDs +#### FUNC_PRE_INIT +??? #### FUNC_INIT This callback ID is called when sensor drivers should be initialized. +#### FUNC_LOOP +??? #### FUNC_EVERY_50_MSECOND This callback ID is called every 50 milliseconds, e.g. for near real-time operation +#### FUNC_EVERY_SECOND +This callback ID is called every second. + +#### FUNC_PREP_BEFORE_TELEPERIOD +??? + #### FUNC_JSON_APPEND This callback ID is called when `TELEPERIOD` is due to append telemetry data to the MQTT JSON string, e.g. ``` @@ -66,11 +76,36 @@ snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{s}MPR121%c Button%d{m}%d{e}"), ``` It should be wrapped in `#ifdef USE_WEBSERVER ... #endif // USE_WEBSERVER` -### Useful functions -#### `int snprintf_P(char * __s, size_t __n, const char * format_string, char* text)` -This function formats text like `printf()`. +#### FUNC_SAVE_BEFORE_RESTART +??? -#### `void MqttPublishPrefixTopic_P(uint8_t prefix, const char* subtopic, boolean retained)` +#### FUNC_COMMAND +??? + +#### FUNC_MQTT_SUBSCRIBE +??? + +#### FUNC_MQTT_INIT +??? + +#### FUNC_MQTT_DATA +??? + +#### FUNC_SET_POWER +??? + +#### FUNC_SHOW_SENSOR +??? + +#### FUNC_RULES_PROCESS +??? + +#### FUNC_FREE_MEM +??? + +### Useful functions + +#### void MqttPublishPrefixTopic_P(uint8_t prefix, const char* subtopic, boolean retained) This function publishes MQTT messages immediately, e.g. ``` snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"MPR121%c\":{\"Button%i\":%i}}"), pS->id[i], j, BITC(i,j)); @@ -87,6 +122,7 @@ snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " AddLogSerial(LOG_LEVEL_INFO); ``` #### void AddLogMissed(char *sensor, uint8_t misses) +??? ### Useful pre-processor directives ### `PSTR("string")`