diff --git a/wled00/wled00.ino b/wled00/wled00.ino index b2fbed748..824d65d92 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -89,7 +89,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1903111 +#define VERSION 1903112 char versionString[] = "0.8.4-dev"; diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 61b978aba..e1420248c 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -153,13 +153,13 @@ void sappends(char stype, char* key, char* val) } } + //get values for settings form in javascript void getSettingsJS(byte subPage) { //0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec DEBUG_PRINT("settings resp"); DEBUG_PRINTLN(subPage); - olen = 0; obuf[0] = 0; //clear buffer if (subPage <1 || subPage >6) return; @@ -324,7 +324,7 @@ void getSettingsJS(byte subPage) sappend('c',"CF",!useAMPM); sappend('i',"TZ",currentTimezone); sappend('v',"UO",utcOffsetSecs); - sappends('m',"(\"times\")[0]",(char*)getTimeString().c_str()); + sappends('m',"(\"times\")[0]",getTimeString()); sappend('i',"OL",overlayCurrent); sappend('v',"O1",overlayMin); sappend('v',"O2",overlayMax); diff --git a/wled00/wled10_ntp.ino b/wled00/wled10_ntp.ino index 4ea2c598e..23eb4b6b4 100644 --- a/wled00/wled10_ntp.ino +++ b/wled00/wled10_ntp.ino @@ -73,22 +73,22 @@ void handleNetworkTime() void sendNTPPacket() { WiFi.hostByName(ntpServerName, ntpServerIP); - DEBUG_PRINTLN("send NTP packet"); + DEBUG_PRINTLN("send NTP"); + byte pbuf[NTP_PACKET_SIZE]; + memset(pbuf, 0, NTP_PACKET_SIZE); - memset(obuf, 0, NTP_PACKET_SIZE); - - obuf[0] = 0b11100011; // LI, Version, Mode - obuf[1] = 0; // Stratum, or type of clock - obuf[2] = 6; // Polling Interval - obuf[3] = 0xEC; // Peer Clock Precision + pbuf[0] = 0b11100011; // LI, Version, Mode + pbuf[1] = 0; // Stratum, or type of clock + pbuf[2] = 6; // Polling Interval + pbuf[3] = 0xEC; // Peer Clock Precision // 8 bytes of zero for Root Delay & Root Dispersion - obuf[12] = 49; - obuf[13] = 0x4E; - obuf[14] = 49; - obuf[15] = 52; + pbuf[12] = 49; + pbuf[13] = 0x4E; + pbuf[14] = 49; + pbuf[15] = 52; ntpUdp.beginPacket(ntpServerIP, 123); //NTP requests are to port 123 - ntpUdp.write((byte*)obuf, NTP_PACKET_SIZE); + ntpUdp.write(pbuf, NTP_PACKET_SIZE); ntpUdp.endPacket(); } @@ -96,13 +96,13 @@ bool checkNTPResponse() { int cb = ntpUdp.parsePacket(); if (cb) { - DEBUG_PRINT("packet received, l="); + DEBUG_PRINT("NTP recv, l="); DEBUG_PRINTLN(cb); + byte pbuf[NTP_PACKET_SIZE]; + ntpUdp.read(pbuf, NTP_PACKET_SIZE); // read the packet into the buffer - ntpUdp.read(obuf, NTP_PACKET_SIZE); // read the packet into the buffer - - unsigned long highWord = word(obuf[40], obuf[41]); - unsigned long lowWord = word(obuf[42], obuf[43]); + unsigned long highWord = word(pbuf[40], pbuf[41]); + unsigned long lowWord = word(pbuf[42], pbuf[43]); if (highWord == 0 && lowWord == 0) return false; unsigned long secsSince1900 = highWord << 16 | lowWord; @@ -123,14 +123,24 @@ void updateLocalTime() local = timezones[currentTimezone]->toLocal(tmc); } -String getTimeString() +char* getTimeString() { updateLocalTime(); - String ret = monthStr(month(local)); - ret = ret + " "; + char out[32]; + sprintf(out,"%i-%i-%i, %i:%s%i:%s%i",year(local), month(local), day(local), + (useAMPM)? hour(local)%12:hour(local), + (minute(local)<10)?"0":"",minute(local), + (second(local)<10)?"0":"",second(local)); + if (useAMPM) + { + strcat(out,(hour(local) > 11)? " PM":" AM"); + } + return out; + /* + String ret = year(local) + "-"; + ret = ret + month(local); + ret = ret + "-"; ret = ret + day(local); - ret = ret + " "; - ret = ret + year(local); ret = ret + ", "; ret += (useAMPM)? hour(local)%12:hour(local); ret = ret + ":"; @@ -144,6 +154,7 @@ String getTimeString() ret += (hour(local) > 11)? " PM":" AM"; } return ret; + */ } void setCountdown() diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 2a499c8c3..15bb63152 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -248,8 +248,8 @@ void serveJson(AsyncWebServerRequest* request) serializeState(state); JsonObject& info = doc.createNestedObject("info"); serializeInfo(info); - doc["effects"] = RawJson(JSON_mode_names); - doc["palettes"] = RawJson(JSON_palette_names); + doc["effects"] = RawJson(String(JSON_mode_names)); + doc["palettes"] = RawJson(String(JSON_palette_names)); } response->setLength();