Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection state management modified #291

Merged
merged 1 commit into from
Apr 24, 2016

Conversation

jnsbyr
Copy link
Contributor

@jnsbyr jnsbyr commented Apr 23, 2016

  • check member _connected first in connect_client() to prevent querying
    connected() of disconnected _client
  • added method status() to check TCP connection state (ESP8266 only)

- check member _connected first in connect_client() to prevent querying
connected() of disconnected _client
- added method status() to check TCP connection state (ESP8266 only)
@jnsbyr
Copy link
Contributor Author

jnsbyr commented Apr 23, 2016

This change may help to resolve the cross platform connect/disconnect issues mentioned here.

For the ESP8266 an additional change is required that is not included in this merge request. At least when SERIAL_DEBUG is enabled, calling pinMode(1, OUTPUT); indirectly in systemResetCallback() causes a hang/crash at startup with 1 being the serial TX pin already in use. A possible solution could be:

  for (byte i = 0; i < TOTAL_PINS; i++) {
    // pins with analog capability default to analog input
    // otherwise, pins default to digital output
    if (IS_PIN_ANALOG(i)) {
      // turns off pullup, configures everything
      setPinModeCallback(i, PIN_MODE_ANALOG);
    } else if (IS_PIN_DIGITAL(i)) {
#if defined(ESP8266)      
      if (i == 1) continue;
#endif      
      // sets the output to 0, configures portConfigInputs
      setPinModeCallback(i, OUTPUT);
    }

With these two changes combined connect and disconnect is signalled each time in client and server mode on the ESP8266.

@jnsbyr jnsbyr mentioned this pull request Apr 23, 2016
@soundanalogous
Copy link
Member

This should probably use a pin ignore macro:

#define IS_IGNORE_ESP8266(p) ((p) == 1 && SERIAL_DEBUG)

I can add this later since I actually want to simplify this to use a single IS_IGNORE_PIN macro rather than being architecture specific which will remove a few more #ifdefs from StandardFirmataWiFi.

@jnsbyr
Copy link
Contributor Author

jnsbyr commented Apr 23, 2016

Made another test that confirms that the issue with pin 1 only arises when SERIAL_DEBUG is enabled.

Another temporary way to avoid the pin 1 issue could be to add Firmata.setPinMode(1, PIN_MODE_IGNORE); to ignoreWiFiPins() for the ESP8266 with SERIAL_DEBUG.

The IS_IGNORE_PIN approach that you suggest is the better solution though.

@soundanalogous
Copy link
Member

Tested in both client and server modes with all of my Wi-Fi boards and shields and everything is working as expected. Merging...

@soundanalogous soundanalogous merged commit c553c3b into firmata:wifi-client Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants