Page 1 of 1

Problems with kolban's cpp_utils WiFi.h

Posted: Mon Jan 08, 2018 5:02 pm
by ogensyts
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?

Re: Problems with kolban's cpp_utils WiFi.h

Posted: Tue Jan 09, 2018 4:58 am
by kolban
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.

Re: Problems with kolban's cpp_utils WiFi.h

Posted: Tue Jan 09, 2018 3:30 pm
by ogensyts
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 !