diff --git a/Sensor-API.md b/Sensor-API.md index 8b0f1a27..d5e974a0 100644 --- a/Sensor-API.md +++ b/Sensor-API.md @@ -8,33 +8,64 @@ Sensor libraries are located in the `lib/` directory. Sensor drivers are located Conditional compiling of a sensor driver is achieved by commenting/uncommenting a pre-processor directive of the scheme `USE_` in `user_config.h`. Accordingly the driver code has to be wrapped in `#ifdef USE_ ... #endif // USE_`. Any Sensor driver must contain a pre-processor directive defining the driver ID by the scheme `#define XSNS_`. ## Callback function + Any sensor driver needs a callback function following the scheme ``` +// Define driver ID +#define XSNS_ + /** - * The function Xsns() interfaces Tasmota with the driver. + * The callback function Xsns() interfaces Tasmota with the sensor driver. + * + * It provides the Tasmota callback IDs. * - * It provides the function IDs - * FUNC_INIT to initialize a driver, - * FUNC_EVERY_50_MSECOND for near real-time operation, - * FUNC_JSON_APPEND for telemetry data and - * FUNC_WEB_APPEND for displaying data in the Tasmota web-interface - * ` * @param byte function Tasmota function ID. * @return boolean ??? * @pre None. * @post None. * */ -boolean Xsns(byte callback_id) -{ +boolean Xsns(byte callback_id) { + // ??? boolean result = false; - // Check which function is called by Tasmota + // Check which callback ID is called by Tasmota switch (callback_id) { - case : - - break; + case FUNC_PRE_INIT: + break; + case FUNC_INIT: + break; + case FUNC_LOOP: + break; + case FUNC_EVERY_50_MSECOND: + break; + case FUNC_EVERY_SECOND: + break; + case FUNC_PREP_BEFORE_TELEPERIOD: + break; + case FUNC_JSON_APPEND: + break; + case FUNC_WEB_APPEND: + break; + case FUNC_SAVE_BEFORE_RESTART: + break; + case FUNC_COMMAND: + break; + case FUNC_MQTT_SUBSCRIBE: + break; + case FUNC_MQTT_INIT: + break; + case FUNC_MQTT_DATA: + break; + case FUNC_SET_POWER: + break; + case FUNC_SHOW_SENSOR: + break; + case FUNC_RULES_PROCESS: + break; + case FUNC_FREE_MEM + break; } // Return boolean result @@ -126,4 +157,4 @@ AddLogSerial(LOG_LEVEL_INFO); ## Useful pre-processor directives ### PSTR("string") -This pre-processor directive save RAM by storing strings in flash instead of RAM \ No newline at end of file +This pre-processor directive saves RAM by storing strings in flash instead of RAM. \ No newline at end of file