shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

Add serial info to new IP on ver 2.1.14 #79

Open bosoft-ESP opened 3 years ago

bosoft-ESP commented 3 years ago

Hello I have been thinking about adding these lines in the CTBotWifiSetup.cpp file to report the IP change in the CTBotWifiSetup::setIP function.

Following the same rules as in the line 111-113 in function CTBotWifiSetup::wifiConnect

if` (WiFi.status() == WL_CONNECTED) {
        IPAddress ip = WiFi.localIP();
        message = (String)FSTR("\nWiFi connected IPAddress: ") + ip.toString() + (String)"\n";
        serialLog(message, CTBOT_DEBUG_WIFI);

I have inserted the same to line 71-73 in function CTBotWifiSetup::setIP

    if (WiFi.config(IP, GW, SN, DNS1, DNS2)){
        IPAddress ip = WiFi.localIP();
        String message = (String)FSTR("New IP address: ") + ip.toString() + (String)"\n";
        serialLog(message, CTBOT_DEBUG_WIFI);

Although it would be better if these lines were like this:

        #ifdef CTBOT_DEBUG_DISABLED == 1
        IPAddress ip = WiFi.localIP();
        String message = (String)FSTR("New IP address: ") + ip.toString() + (String)"\n";
        serialLog(message, CTBOT_DEBUG_WIFI);
        #endif

this way it would not compile if CTBOT_DEBUG_DISABLED == 0

Thanks for your hard work. Regards

shurillu commented 3 years ago

Hello bosoft-ESP, I added the functionality you asked for in the v 2.1.5 (with others patches) and a new release is on the way. Thanks fo using the library!

Cheers

Stefano

bosoft-ESP commented 3 years ago

Thanks to you for your great work Best regards