Problems with kolban's cpp_utils WiFi.h

ogensyts
Posts: 9
Joined: Fri Jan 05, 2018 2:41 pm
Location: Quebec, Canada

Problems with kolban's cpp_utils WiFi.h

Postby ogensyts » Mon Jan 08, 2018 5:02 pm

Hi. I am trying to use C++ and C on the ESP32.

-> kolban's CPP Utils (https://github.com/nkolban/esp32-snippe ... /cpp_utils)

My code is simple, i used the snippet in kolban's book and i followed the readme.md (i followed instructions) :

Code: Select all

#include "WiFi.h"

extern "C" {
   void app_main();
}

void app_main() {
   // Your code goes here
   WiFi *pWifi = new WiFi(); 
   
   pWiFi->connectAP("SSID", "PASSWORD");
}
But i get these errors while issuing command "make" :

In function 'void app_main()':
/main/main.cpp:14:4: error: 'pWiFi' was not declared in this scope
pWiFi->connectAP("s7-oles", "esp32-12345678");

/main/main.cpp:12:10: warning: unused variable 'pWifi' [-Wunused-variable]
WiFi *pWifi = new WiFi();

what is the problem?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Problems with kolban's cpp_utils WiFi.h

Postby kolban » Tue Jan 09, 2018 4:58 am

Howdy ... in your code you coded:

Code: Select all

WiFi *pWifi = new WiFi(); 
and later on coded:

Code: Select all

pWiFi->connectAP("SSID", "PASSWORD");
In the first fragment, the name of the variable was "pWifi" while in the second it was "pWiFi". Note the change in case between the variable names which are case sensitive. It is very possible that I myself introduce this error assuming you copied and pasted the code. If you can point me to where you got it from, I'll review and resolve if needed. Apologies for the mistake.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ogensyts
Posts: 9
Joined: Fri Jan 05, 2018 2:41 pm
Location: Quebec, Canada

Re: Problems with kolban's cpp_utils WiFi.h

Postby ogensyts » Tue Jan 09, 2018 3:30 pm

Haha ! I laughed at myself ! :P

Indeed i copied and pasted it from your book (kolban-ESP32.pdf), page 990.

I fixed it and now it connects to AP with no problem.

Hey it's my error too, i should have seen it !

by the way i just want to let you know that i appreciate your work and the documentation you provide for the ESP32. Your book is very helpful.

Thank you !

Who is online

Users browsing this forum: No registered users and 63 guests