mirror of
https://github.com/anklimov/lighthub
synced 2025-12-08 04:39:49 +03:00
fixed longint conversion Mega
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -126,7 +126,6 @@ protected:
|
||||
|
||||
void uptimePoll();
|
||||
|
||||
void printUlongValueToStr(char *valstr, unsigned long value);
|
||||
bool publishDataToDomoticz(int , aJsonObject *, const char *format, ...);
|
||||
|
||||
char* getIdxField();
|
||||
|
||||
@@ -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<<F("\nfree RAM: ")<<fr;
|
||||
setTopic(topic,sizeof(topic),T_DEV);
|
||||
strncat_P(topic, stats_P, sizeof(topic));
|
||||
strncat(topic, "/", sizeof(topic));
|
||||
strncat_P(topic, freeheap_P, sizeof(topic));
|
||||
|
||||
mqttClient.publish(topic,itoa(fr,intbuf,10),true);
|
||||
printUlongValueToStr(intbuf, fr);
|
||||
mqttClient.publish(topic,intbuf,true);
|
||||
|
||||
setTopic(topic,sizeof(topic),T_DEV);
|
||||
strncat_P(topic, stats_P, sizeof(topic));
|
||||
strncat(topic, "/", sizeof(topic));
|
||||
strncat_P(topic, uptime_P, sizeof(topic));
|
||||
|
||||
mqttClient.publish(topic,itoa(ut,intbuf,10),true);
|
||||
printUlongValueToStr(intbuf, ut);
|
||||
mqttClient.publish(topic,intbuf,true);
|
||||
}
|
||||
|
||||
void setupMacAddress() {
|
||||
|
||||
@@ -412,5 +412,22 @@ return buf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void 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';
|
||||
}
|
||||
|
||||
#pragma message(VAR_NAME_VALUE(debugSerial))
|
||||
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user