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

Added non-blocking connect method #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KrazyKerbalnaut
Copy link

@KrazyKerbalnaut KrazyKerbalnaut commented Jan 7, 2021

This is not completely non-blocking. Please review the delay of 100ms after setting passphrase or key of the normal "begin()" method. To resolution is a little un-optimized at the moment but I needed to to work for now:

WiFi.cpp:

int WiFiClass::setCredNB(const char* ssid, const char *passphrase)
{
  uint8_t status = WL_CONNECT_FAILED;
  startConnection = millis();
  delayStartConnection = millis();

  if (WiFiDrv::wifiSetPassphrase(ssid, strlen(ssid), passphrase, strlen(passphrase))!= WL_FAILURE) {
    status = WiFiDrv::getConnectionStatus();
  }

  return status;
}

int WiFiClass::beginNB()
{
  uint8_t status = WL_CONNECT_FAILED;

  if ((millis() - startConnection) < _timeout) {
    if ((millis() - delayStartConnection) > WL_DELAY_START_CONNECTION) {
      status = WiFiDrv::getConnectionStatus();
      delayStartConnection = millis();
    }
  }

  return status;
}

WiFi.h, add to public section:

unsigned long startConnection;
unsigned long delayStartConnection;

int setCredNB(const char* ssid, const char* passphrase);
int beginNB();

@KrazyKerbalnaut KrazyKerbalnaut marked this pull request as ready for review January 7, 2021 16:53
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants