diff --git a/lighthub/homiedef.h b/lighthub/homiedef.h index 288bfe5..0f7b923 100644 --- a/lighthub/homiedef.h +++ b/lighthub/homiedef.h @@ -10,6 +10,12 @@ const char name_P[] PROGMEM = "$name"; const char nameval_P[] PROGMEM = "LightHub "; const char nodes_P[] PROGMEM = "$nodes"; +const char localip_P[] PROGMEM = "$localip"; +const char mac_P[] PROGMEM = "$mac"; +const char fwname_P[] PROGMEM = "$fw/name"; +const char fwversion_P[] PROGMEM = "$fw/version"; +const char implementation_P[] PROGMEM = "$implementation"; +const char interval_P[] PROGMEM = "$stats/interval"; const char color_P[] PROGMEM = "color"; const char datatype_P[] PROGMEM = "$datatype"; diff --git a/lighthub/inputs.cpp b/lighthub/inputs.cpp index 947d42b..b87a3f9 100644 --- a/lighthub/inputs.cpp +++ b/lighthub/inputs.cpp @@ -113,6 +113,8 @@ int Input::poll() { #ifndef DHT_DISABLE else if (inType & IN_DHT22) dht22Poll(); + #endif + #ifndef COUNTER_DISABLE else if (inType & IN_COUNTER) counterPoll(); else if (inType & IN_UPTIME) @@ -497,20 +499,6 @@ void Input::onAnalogChanged(int newValue) { } -void Input::printUlongValueToStr(char *valstr, unsigned long value) { - char buf[11]; - int i=0; - for(;value>0;i++){ - unsigned long mod = value - ((unsigned long)(value/10))*10; - buf[i]=mod+48; - value = (unsigned long)(value/10); - } - - for(int n=0;n<=i;n++){ - valstr[n]=buf[i-n-1]; - } - valstr[i]='\0'; -} bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, const char *format, ...) { #ifdef WITH_DOMOTICZ diff --git a/lighthub/inputs.h b/lighthub/inputs.h index ca53537..9815fe0 100644 --- a/lighthub/inputs.h +++ b/lighthub/inputs.h @@ -126,7 +126,6 @@ protected: void uptimePoll(); - void printUlongValueToStr(char *valstr, unsigned long value); bool publishDataToDomoticz(int , aJsonObject *, const char *format, ...); char* getIdxField(); diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 972c2df..cb43f31 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -1398,22 +1398,22 @@ void publishStat(){ long fr = freeRam(); char topic[64]; char intbuf[16]; - uint32_t ut = millis()/1000; + uint32_t ut = millis()/1000UL; // debugSerial<0;i++){ + unsigned long mod = value - ((unsigned long)(value/10))*10; + buf[i]=mod+48; + value = (unsigned long)(value/10); + } + + for(int n=0;n<=i;n++){ + valstr[n]=buf[i-n-1]; + } + valstr[i]='\0'; +} + #pragma message(VAR_NAME_VALUE(debugSerial)) #pragma message(VAR_NAME_VALUE(SERIAL_BAUD)) diff --git a/lighthub/utils.h b/lighthub/utils.h index d3c69a5..4f5e55d 100644 --- a/lighthub/utils.h +++ b/lighthub/utils.h @@ -54,3 +54,4 @@ int inet_aton(const char* aIPAddrString, IPAddress& aResult); char *inet_ntoa_r(IPAddress addr, char *buf, int buflen); void printIPAddress(IPAddress ipAddress); char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix = NULL); +void printUlongValueToStr(char *valstr, unsigned long value);