firmata / arduino

Firmata firmware for Arduino
GNU Lesser General Public License v2.1
1.55k stars 516 forks source link

Issue with StandardFirmataWIFI using AP mode #392

Open jguille2 opened 6 years ago

jguille2 commented 6 years ago

Hi! I want to use Firmata with the ESP8266.

I tried StandardFirmataWiFi and it's ok (Thanks!!!) It has different options... but it connects to WiFi always in Station mode (connecting to a pre-existing WiFi network).

Then, I've tried to add to StandardFirmataWiFi another option to use AP mode... but I 've had a problem.

I see this problem is with the WiFi.status() command. It is working in AP mode in a different way.

I will report this to the ESP8266/Arduino project (I think current behavior is not right)... but in the meantime, we can change maintain function in WiFiServerStream.h, changing if ( !_listening && WiFi.status() == WL_CONNECTED ) for if ( !_listening && ( WiFi.status() == WL_CONNECTED || WiFi.getMode() == WIFI_AP ))

and then,we will be able to implement stream sketches in this AP mode.

If you think this change is right... I will try to implement this AccessPoint option into StandardFirmataWiFi.ino example.

Thanks for all (I enjoy using firmata!!)

Joan

soundanalogous commented 6 years ago

If WiFi.getMode() and WIFI_AP are only defined for ESP8266, then that statement would have to be specific to ESP8266. Otherwise I don't see any issue in making that change.

jguille2 commented 6 years ago

Thanks Jeff,

I have already reported this problem to esp8266/arduino... but according to your words, I'll send a PR with that change, doing it specific to ESP8266. It will be:

#ifdef ESP8266
if ( !_listening && ( WiFi.status() == WL_CONNECTED || WiFi.getMode() == WIFI_AP ))
#else
if ( !_listening && WiFi.status() == WL_CONNECTED )
#endif
{
// start TCP server after first WiFi connect
...

Is it fine? Thanks!

Joan

soundanalogous commented 6 years ago

I've been trying to avoid adding any #ifdefs in WiFiServerStream.h. I need to think about this a bit.