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

undeprecate WiFiServer::available() #9027

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

SuGlider
Copy link
Collaborator

Description of Change

Removes depricated message for WiFiServer::available() to follow Arduino upstream API.

Tests scenarios

None

Related links

None

@SuGlider SuGlider added the Area: BT&Wifi BT & Wifi related issues label Dec 20, 2023
@SuGlider SuGlider added this to the 3.0.0-RC1 milestone Dec 20, 2023
@SuGlider SuGlider self-assigned this Dec 20, 2023
@SuGlider SuGlider requested a review from me-no-dev December 20, 2023 13:58
Copy link
Contributor

github-actions bot commented Dec 20, 2023

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "undeprecate available()":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 Hello SuGlider, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 129ab21

@SuGlider SuGlider added the Status: Pending Merge Pull Request is ready to be merged label Dec 20, 2023
@JAndrassy
Copy link
Contributor

JAndrassy commented Dec 20, 2023

do you want to implement the available() as it should work? the WiFiServer then has to mange the connected clients and return with available() only a client which has data available().
this example must work https://github.com/JAndrassy/Arduino/blob/d5eb265f78bff9deb7063d10030a02d021c8c66c/libraries/ESP8266WiFi/examples/PagerServer/PagerServer.ino#L61

in esp8266 core https://github.com/JAndrassy/Arduino/blob/master/libraries/ESP8266WiFi/src/ArduinoWiFiServer.h

@me-no-dev me-no-dev merged commit 5d97e02 into espressif:master Dec 20, 2023
46 checks passed
@SuGlider SuGlider deleted the patch-3 branch December 20, 2023 14:33
@SuGlider
Copy link
Collaborator Author

@JAndrassy - We have discussed it and decided to follow WiFi Arduino API as much as possible. That's just it.
You are always welcome to add PRs and improvements.

If you consider worthy, please submit it upstream Arduino in their Github. We will follow!

@JAndrassy
Copy link
Contributor

the Arduino Core API doesn't have anything about server.available(). the Server class is

class Server : public Print {
  public:
    virtual void begin() = 0;
};

@SuGlider
Copy link
Collaborator Author

the Arduino Core API doesn't have anything about server.available(). the Server class is

class Server : public Print {
  public:
    virtual void begin() = 0;
};

https://www.arduino.cc/reference/en/libraries/wifi/server.available/

@JAndrassy
Copy link
Contributor

JAndrassy commented Dec 20, 2023

https://www.arduino.cc/reference/en/libraries/wifi/server.available/

"Gets a client that is connected to the server AND has data available for reading"

from the PagerServer example

void loop() {

  WiFiClient client = server.available();     // returns first client which has data to read or a 'false' client
  if (client) {                               // client is true only if it is connected and has data to read
    String s = client.readStringUntil('\n');  // read the message incoming from one of the clients
    s.trim();                                 // trim eventual \r
    Serial.println(s);                        // print the message to Serial Monitor
    client.print("echo: ");                   // this is only for the sending client
    server.println(s);                        // send the message to all connected clients
    server.flush();                           // flush the buffers
  }
}

in the next loop it can return the same client. going out of scope with client object doesn't close the connection

@SuGlider
Copy link
Collaborator Author

This is the Arduino example that closes the client connection:

void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {

    if (client.connected()) {
      Serial.println("Connected to client");
    }

    // close the connection:
    client.stop();
  }
}

JAndrassy added a commit to JAndrassy/arduino-esp32 that referenced this pull request Jan 23, 2024
me-no-dev pushed a commit that referenced this pull request Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

4 participants