JAndrassy / WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
GNU Lesser General Public License v2.1
288 stars 44 forks source link

Create EspAtDrv.cpp.patch #19

Closed cb0b closed 2 years ago

cb0b commented 4 years ago

Hi Juraj, I found out that the new EspressIF firmware v1.7x has the CIPSNTPTIME command but does lack the extension by LoBo firmware. Currently I'm using the original firmware and wanted to use getTime() as this is very very convenient. So I added just a couple of functions converting the Time String but not changing the original version by using an #ifdef . It would be great if you could have a look on it and decide to add this to your wonderful library. The file has been created with: diff -u EspAtDrv.cpp.orig EspAtDrv.cpp >patch.diff Best, Robert Sailer

JAndrassy commented 4 years ago

if would be better to only return the string with WiFiClass::getTimeString(char*) and to add an example sketch with the parsing

WvdM commented 4 years ago

Hi Robert I am new to this environment and I hope I am doing this correctly. I am building a project with an Arduino Mega and ESP-01 as WiFi connection to the internet. The ESP-01 connects serially to comport 1 of the Arduino Mega as I am using comport 0 for debugging. The firmware of my ESP is v1.7x as you mentioned previously. If I send the AT command "CIPSNTPTIME" directly to my ESP it returns the time 100% correctly and is a very nice feature to use, as I can use it to set the time on my RTC. But if I use the SNTP example in the WiFiEspAt library I do not get any time back from the internet. So, if I understand your comment to Juraj correctly, you made some changes to implement the "CIPSNTPTIME" function. Can you please help me as I want to use the WiFiEspAt library to get time from the internet but cannot get it to work, and what you are doing is way above my programming skills. Hope this makes sense and that you will be able to assist. Thanks in advance. Regards Wimpie

cb0b commented 4 years ago

Hi Wimpie,

the best option is to use the LoBo firmware as this will keep you in-sync with the upstream of Juraj's library.

Anyway I added the patch I created for the standard Espressif Firmware - but you are on your own with it.

Good luck and best wishes

Robert

On 30.09.20 11:20, WvdM wrote:

Hi Robert I am new to this environment and I hope I am doing this correctly. I am building a project with an Arduino Mega and ESP-01 as WiFi connection to the internet. The ESP-01 connects serially to comport 1 of the Arduino Mega as I am using comport 0 for debugging. The firmware of my ESP is v1.7x as you mentioned previously. If I send the AT command "CIPSNTPTIME" directly to my ESP it returns the time 100% correctly and is a very nice feature to use, as I can use it to set the time on my RTC. But if I use the SNTP example in the WiFiEspAt library I do not get any time back from the internet. So, if I understand your comment to Juraj correctly, you made some changes to implement the "CIPSNTPTIME" function. Can you please help me as I want to use the WiFiEspAt library to get time from the internet but cannot get it to work, and what you are doing is way above my programming skills. Hope this makes sense and that you will be able to assist. Thanks in advance. Regards Wimpie

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jandrassy/WiFiEspAT/pull/19#issuecomment-701271382, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD4TTKPKJC3DTFGP5LXUXI3SILZ6DANCNFSM4OX5Z5QA.

--- EspAtDrv.cpp.orig 2020-07-12 20:11:50.000000000 +0200 +++ EspAtDrv.cpp 2020-07-12 20:49:19.000000000 +0200 @@ -19,6 +19,11 @@

include "EspAtDrv.h"

include "EspAtDrvLogging.h"

+// #define useLoBoFirmware +#ifndef useLoBoFirmware +// this is for using SNTP with ESP +#include "TimeLib.h" // https://github.com/PaulStoffregen/Time +#endif

if defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F4)

include

@@ -1029,6 +1034,7 @@ return sendCommand(); }

+#ifdef useLoBoFirmware unsigned long EspAtDrvClass::sntpTime() { maintain();

@@ -1043,6 +1049,89 @@ readOK(); return res; } +#else +// use standard EspressIF firmware v1.7+ +// src is from http://nopnop2002.webcrow.jp/ESP-AT-Firmware/ESP-AT-Firmware-43.html +int LeapYear(int yyyy) {