mirror of https://github.com/arendst/Tasmota.git
Add Driver and Sensor info to status 4
* Add Driver and Sensor info to status 4 * Change WebSensor return information to show disabled state using exclamation mark * Clean up debug code
This commit is contained in:
parent
049dd72ca5
commit
54364484fa
|
@ -331,13 +331,16 @@ void CmndStatus(void)
|
|||
}
|
||||
|
||||
if ((0 == payload) || (4 == payload)) {
|
||||
char sensors[LOGSZ];
|
||||
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\""
|
||||
D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHCHIPID "\":\"%06X\",\"" D_JSON_FLASHMODE "\":%d,\""
|
||||
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"],\"Sensors\":%s}}"),
|
||||
D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"),
|
||||
ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024,
|
||||
ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP.getFlashChipId(), ESP.getFlashChipMode(),
|
||||
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5, XsnsSensorsAvailable(sensors));
|
||||
LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2, feature5);
|
||||
XsnsDriverState();
|
||||
ResponseAppend_P(PSTR(",\"Sensors\":"));
|
||||
XsnsSensorState();
|
||||
ResponseAppend_P(PSTR("}}"));
|
||||
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "4"));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,27 +32,12 @@ const uint8_t WIFI_CONFIG_SEC = 180; // seconds before restart
|
|||
const uint8_t WIFI_CHECK_SEC = 20; // seconds
|
||||
const uint8_t WIFI_RETRY_OFFSET_SEC = 20; // seconds
|
||||
|
||||
/*
|
||||
// This worked for 2_5_0_BETA2 but fails since then. Waiting for a solution from core team (#4952)
|
||||
#ifdef USE_MQTT_TLS
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
#else
|
||||
#define USING_AXTLS
|
||||
#include <ESP8266WiFi.h>
|
||||
// force use of AxTLS (BearSSL is now default) which uses less memory (#4952)
|
||||
#include <WiFiClientSecureAxTLS.h>
|
||||
using namespace axTLS;
|
||||
#endif // ARDUINO_ESP8266_RELEASE prior to 2_5_0
|
||||
#else
|
||||
#include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager
|
||||
#endif // USE_MQTT_TLS
|
||||
*/
|
||||
#include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager
|
||||
#include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager
|
||||
|
||||
struct WIFI {
|
||||
uint32_t last_event = 0; // Last wifi connection event
|
||||
uint32_t downtime = 0; // Wifi down duration
|
||||
uint16_t link_count = 0; // Number of wifi re-connect
|
||||
uint32_t last_event = 0; // Last wifi connection event
|
||||
uint32_t downtime = 0; // Wifi down duration
|
||||
uint16_t link_count = 0; // Number of wifi re-connect
|
||||
uint8_t counter;
|
||||
uint8_t retry_init;
|
||||
uint8_t retry;
|
||||
|
@ -60,7 +45,7 @@ struct WIFI {
|
|||
uint8_t wps_result;
|
||||
uint8_t config_type = 0;
|
||||
uint8_t config_counter = 0;
|
||||
uint8_t mdns_begun = 0; // mDNS active
|
||||
uint8_t mdns_begun = 0; // mDNS active
|
||||
uint8_t scan_state;
|
||||
uint8_t bssid[6];
|
||||
} Wifi;
|
||||
|
|
|
@ -2569,8 +2569,10 @@ void CmndWebSensor(void)
|
|||
if (XdrvMailbox.payload >= 0) {
|
||||
bitWrite(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32, XdrvMailbox.payload &1);
|
||||
}
|
||||
ResponseCmndIdxChar(GetStateText(bitRead(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32)));
|
||||
}
|
||||
Response_P(PSTR("{\"" D_CMND_WEBSENSOR "\":"));
|
||||
XsnsSensorState();
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
|
|
@ -508,13 +508,15 @@ void CmndFreemem(void)
|
|||
void CmndSetSensor(void)
|
||||
{
|
||||
if (XdrvMailbox.index < MAX_XSNS_DRIVERS) {
|
||||
if ((XdrvMailbox.payload >= 0) && XsnsPresent(XdrvMailbox.index)) {
|
||||
if (XdrvMailbox.payload >= 0) {
|
||||
bitWrite(Settings.sensors[XdrvMailbox.index / 32], XdrvMailbox.index % 32, XdrvMailbox.payload &1);
|
||||
if (1 == XdrvMailbox.payload) {
|
||||
restart_flag = 2; // To safely re-enable a sensor currently most sensor need to follow complete restart init cycle
|
||||
}
|
||||
}
|
||||
Response_P(S_JSON_COMMAND_XVALUE, XdrvMailbox.command, XsnsGetSensors().c_str());
|
||||
Response_P(PSTR("{\"" D_CMND_SETSENSOR "\":"));
|
||||
XsnsSensorState();
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,237 @@ bool (* const xdrv_func_ptr[])(uint8_t) = { // Driver Function Pointers
|
|||
&Xdrv32,
|
||||
#endif
|
||||
|
||||
// Optional user defined drivers in range 91 - 99
|
||||
#ifdef XDRV_33
|
||||
&Xdrv33,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_34
|
||||
&Xdrv34,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_35
|
||||
&Xdrv35,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_36
|
||||
&Xdrv36,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_37
|
||||
&Xdrv37,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_38
|
||||
&Xdrv38,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_39
|
||||
&Xdrv39,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_40
|
||||
&Xdrv40,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_41
|
||||
&Xdrv41,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_42
|
||||
&Xdrv42,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_43
|
||||
&Xdrv43,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_44
|
||||
&Xdrv44,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_45
|
||||
&Xdrv45,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_46
|
||||
&Xdrv46,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_47
|
||||
&Xdrv47,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_48
|
||||
&Xdrv48,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_49
|
||||
&Xdrv49,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_50
|
||||
&Xdrv50,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_51
|
||||
&Xdrv51,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_52
|
||||
&Xdrv52,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_53
|
||||
&Xdrv53,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_54
|
||||
&Xdrv54,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_55
|
||||
&Xdrv55,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_56
|
||||
&Xdrv56,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_57
|
||||
&Xdrv57,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_58
|
||||
&Xdrv58,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_59
|
||||
&Xdrv59,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_60
|
||||
&Xdrv60,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_61
|
||||
&Xdrv61,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_62
|
||||
&Xdrv62,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_63
|
||||
&Xdrv63,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_64
|
||||
&Xdrv64,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_65
|
||||
&Xdrv65,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_66
|
||||
&Xdrv66,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_67
|
||||
&Xdrv67,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_68
|
||||
&Xdrv68,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_69
|
||||
&Xdrv69,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_70
|
||||
&Xdrv70,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_71
|
||||
&Xdrv71,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_72
|
||||
&Xdrv72,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_73
|
||||
&Xdrv73,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_74
|
||||
&Xdrv74,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_75
|
||||
&Xdrv75,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_76
|
||||
&Xdrv76,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_77
|
||||
&Xdrv77,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_78
|
||||
&Xdrv78,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_79
|
||||
&Xdrv79,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_80
|
||||
&Xdrv80,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_81
|
||||
&Xdrv81,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_82
|
||||
&Xdrv82,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_83
|
||||
&Xdrv83,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_84
|
||||
&Xdrv84,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_85
|
||||
&Xdrv85,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_86
|
||||
&Xdrv86,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_87
|
||||
&Xdrv87,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_88
|
||||
&Xdrv88,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_89
|
||||
&Xdrv89,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_90
|
||||
&Xdrv90,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_91
|
||||
&Xdrv91,
|
||||
|
@ -192,6 +422,431 @@ bool (* const xdrv_func_ptr[])(uint8_t) = { // Driver Function Pointers
|
|||
|
||||
const uint8_t xdrv_present = sizeof(xdrv_func_ptr) / sizeof(xdrv_func_ptr[0]); // Number of drivers found
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Xdrv available list
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef XFUNC_PTR_IN_ROM
|
||||
const uint8_t kXdrvList[] PROGMEM = {
|
||||
#else
|
||||
const uint8_t kXdrvList[] = {
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_01
|
||||
XDRV_01,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_02
|
||||
XDRV_02,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_03
|
||||
XDRV_03,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_04
|
||||
XDRV_04,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_05
|
||||
XDRV_05,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_06
|
||||
XDRV_06,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_07
|
||||
XDRV_07,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_08
|
||||
XDRV_08,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_09
|
||||
XDRV_09,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_10
|
||||
XDRV_10,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_11
|
||||
XDRV_11,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_12
|
||||
XDRV_12,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_13
|
||||
XDRV_13,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_14
|
||||
XDRV_14,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_15
|
||||
XDRV_15,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_16
|
||||
XDRV_16,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_17
|
||||
XDRV_17,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_18
|
||||
XDRV_18,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_19
|
||||
XDRV_19,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_20
|
||||
XDRV_20,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_21
|
||||
XDRV_21,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_22
|
||||
XDRV_22,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_23
|
||||
XDRV_23,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_24
|
||||
XDRV_24,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_25
|
||||
XDRV_25,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_26
|
||||
XDRV_26,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_27
|
||||
XDRV_27,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_28
|
||||
XDRV_28,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_29
|
||||
XDRV_29,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_30
|
||||
XDRV_30,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_31
|
||||
XDRV_31,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_32
|
||||
XDRV_32,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_33
|
||||
XDRV_33,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_34
|
||||
XDRV_34,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_35
|
||||
XDRV_35,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_36
|
||||
XDRV_36,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_37
|
||||
XDRV_37,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_38
|
||||
XDRV_38,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_39
|
||||
XDRV_39,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_40
|
||||
XDRV_40,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_41
|
||||
XDRV_41,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_42
|
||||
XDRV_42,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_43
|
||||
XDRV_43,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_44
|
||||
XDRV_44,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_45
|
||||
XDRV_45,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_46
|
||||
XDRV_46,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_47
|
||||
XDRV_47,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_48
|
||||
XDRV_48,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_49
|
||||
XDRV_49,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_50
|
||||
XDRV_50,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_51
|
||||
XDRV_51,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_52
|
||||
XDRV_52,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_53
|
||||
XDRV_53,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_54
|
||||
XDRV_54,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_55
|
||||
XDRV_55,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_56
|
||||
XDRV_56,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_57
|
||||
XDRV_57,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_58
|
||||
XDRV_58,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_59
|
||||
XDRV_59,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_60
|
||||
XDRV_60,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_61
|
||||
XDRV_61,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_62
|
||||
XDRV_62,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_63
|
||||
XDRV_63,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_64
|
||||
XDRV_64,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_65
|
||||
XDRV_65,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_66
|
||||
XDRV_66,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_67
|
||||
XDRV_67,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_68
|
||||
XDRV_68,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_69
|
||||
XDRV_69,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_70
|
||||
XDRV_70,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_71
|
||||
XDRV_71,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_72
|
||||
XDRV_72,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_73
|
||||
XDRV_73,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_74
|
||||
XDRV_74,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_75
|
||||
XDRV_75,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_76
|
||||
XDRV_76,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_77
|
||||
XDRV_77,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_78
|
||||
XDRV_78,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_79
|
||||
XDRV_79,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_80
|
||||
XDRV_80,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_81
|
||||
XDRV_81,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_82
|
||||
XDRV_82,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_83
|
||||
XDRV_83,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_84
|
||||
XDRV_84,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_85
|
||||
XDRV_85,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_86
|
||||
XDRV_86,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_87
|
||||
XDRV_87,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_88
|
||||
XDRV_88,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_89
|
||||
XDRV_89,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_90
|
||||
XDRV_90,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_91
|
||||
XDRV_91,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_92
|
||||
XDRV_92,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_93
|
||||
XDRV_93,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_94
|
||||
XDRV_94,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_95
|
||||
XDRV_95,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_96
|
||||
XDRV_96,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_97
|
||||
XDRV_97,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_98
|
||||
XDRV_98,
|
||||
#endif
|
||||
|
||||
#ifdef XDRV_99
|
||||
XDRV_99
|
||||
#endif
|
||||
};
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
void XsnsDriverState(void)
|
||||
{
|
||||
ResponseAppend_P(PSTR(",\"Drivers\":\"")); // Use string for future enable/disable signal
|
||||
for (uint32_t i = 0; i < sizeof(kXdrvList); i++) {
|
||||
#ifdef XFUNC_PTR_IN_ROM
|
||||
uint32_t driverid = pgm_read_byte(kXdrvList + i);
|
||||
#else
|
||||
uint32_t driverid = kXdrvList[i];
|
||||
#endif
|
||||
ResponseAppend_P(PSTR("%s%d"), (i) ? "," : "", driverid);
|
||||
}
|
||||
ResponseAppend_P(PSTR("\""));
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
bool XdrvMqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uint16_t sdataBuf)
|
||||
{
|
||||
XdrvMailbox.index = stopicBuf;
|
||||
|
|
|
@ -809,7 +809,23 @@ const uint8_t kXsnsList[] = {
|
|||
#endif
|
||||
|
||||
#ifdef XSNS_95
|
||||
XSNS_95
|
||||
XSNS_95,
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_96
|
||||
XSNS_96,
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_97
|
||||
XSNS_97,
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_98
|
||||
XSNS_98,
|
||||
#endif
|
||||
|
||||
#ifdef XSNS_99
|
||||
XSNS_99
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -828,20 +844,22 @@ bool XsnsEnabled(uint32_t sns_index)
|
|||
return true;
|
||||
}
|
||||
|
||||
char* XsnsSensorsAvailable(char* sensors)
|
||||
void XsnsSensorState(void)
|
||||
{
|
||||
// Return string like [2,3,4,5,8,9,10,14,15,17,18,34]
|
||||
sensors[0] = '\0';
|
||||
ResponseAppend_P(PSTR("\"")); // Use string for enable/disable signal
|
||||
for (uint32_t i = 0; i < sizeof(kXsnsList); i++) {
|
||||
#ifdef XFUNC_PTR_IN_ROM
|
||||
uint32_t sensorid = pgm_read_byte(kXsnsList + i);
|
||||
#else
|
||||
uint32_t sensorid = kXsnsList[i];
|
||||
#endif
|
||||
snprintf_P(sensors, LOGSZ, PSTR("%s%s%d"), sensors, (!i) ? "[" : ",", sensorid);
|
||||
bool disabled = false;
|
||||
if (sensorid < MAX_XSNS_DRIVERS) {
|
||||
disabled = !bitRead(Settings.sensors[sensorid / 32], sensorid % 32);
|
||||
}
|
||||
ResponseAppend_P(PSTR("%s%s%d"), (i) ? "," : "", (disabled) ? "!" : "", sensorid);
|
||||
}
|
||||
snprintf_P(sensors, LOGSZ, PSTR("%s]"), sensors); // Max length is about 3 x 96 < LOGSZ
|
||||
return sensors;
|
||||
ResponseAppend_P(PSTR("\""));
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
zzzz_debug.ino - debug support for Sonoff-Tasmota
|
||||
|
||||
Copyright (C) 2019 Theo Arends
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
/*********************************************************************************************\
|
||||
* Virtual debugging support - Part 2
|
||||
*
|
||||
* Needs to be the last alphabetical file due to DEFINE compile order
|
||||
\*********************************************************************************************/
|
||||
|
||||
bool XsnsPresent(uint8_t sns_index)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
for (uint32_t i = 0; i < sizeof(kXsnsList); i++) {
|
||||
#ifdef XFUNC_PTR_IN_ROM
|
||||
index = pgm_read_byte(kXsnsList + i);
|
||||
#else
|
||||
index = kXsnsList[i];
|
||||
#endif
|
||||
if (index == sns_index) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String XsnsGetSensors(void)
|
||||
{
|
||||
char state[2] = { 0 };
|
||||
|
||||
String data = F("[");
|
||||
for (uint32_t i = 0; i < MAX_XSNS_DRIVERS; i++) {
|
||||
if (i && (!(i % 16))) { data += F(","); }
|
||||
if (!(i % 16)) { data += F("\""); }
|
||||
state[0] = '-';
|
||||
if (XsnsPresent(i)) { state[0] = bitRead(Settings.sensors[i / 32], i % 32) ? '1' : '0'; }
|
||||
data += String(state);
|
||||
if (i && (!((i +1) % 16))) { data += F("\""); }
|
||||
}
|
||||
data += F("]");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endif // USE_DEBUG_DRIVER
|
Loading…
Reference in New Issue