Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mbedclient stop issue#868

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pennam merged 3 commits intoarduino:mainfromandreagilardoni:mbedclient-stop-issue
Apr 19, 2024

Conversation

@andreagilardoni
Copy link
Contributor

TheMbedClient class has some issues in thestop() method that affect the ability to reuse the client after calling thestop() function

manchoz reacted with eyes emoji
when stop() is called on a client when the rxBuffer is not empty thereader thread won't be joined to the main thread due to the logicimplemented in the readSocket function
@pennam
Copy link
Contributor

issue arises only if stop() is called before all data is read from the client. Tested with this sketch that stops reading after downloading 1k of data and works fine. With mbed core 4.1.1 the client di not restart.

#include <WiFi.h>char ssid[] = SECRET_SSID;        // your network SSID (name)char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)int keyIndex = 0;            // your network key index number (needed only for WEP)int status = WL_IDLE_STATUS;// Initialize the WiFi client libraryWiFiClient client;// server address:char server[] = "example.org";//IPAddress server(64,131,82,241);unsigned long count = 0;unsigned long lastConnectionTime = 0;            // last time you connected to the server, in millisecondsconst unsigned long postingInterval = 10L * 1000L; // delay between updates, in millisecondsvoid setup() {  //Initialize serial and wait for port to open:  Serial.begin(9600);  while (!Serial) {    ; // wait for serial port to connect. Needed for native USB port only  }  // check for the WiFi module:  if (WiFi.status() == WL_NO_MODULE) {    Serial.println("Communication with WiFi module failed!");    // don't continue    while (true);  }  String fv = WiFi.firmwareVersion();  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {    Serial.println("Please upgrade the firmware");  }  // attempt to connect to WiFi network:  while (status != WL_CONNECTED) {    Serial.print("Attempting to connect to SSID: ");    Serial.println(ssid);    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    status = WiFi.begin(ssid, pass);    // wait 10 seconds for connection:    delay(10000);  }  // you're connected now, so print out the status:  printWifiStatus();}void loop() {  // if there's incoming data from the net connection.  // send it out the serial port.  This is for debugging  // purposes only:  while (client.available() && count < 1024) {    char c = client.read();    count++;    Serial.write(c);  }  // if ten seconds have passed since your last connection,  // then connect again and send data:  if (millis() - lastConnectionTime > postingInterval) {    httpRequest();  }}// this method makes a HTTP connection to the server:void httpRequest() {  // close any connection before send a new request.  // This will free the socket on the NINA module  client.stop();  count = 0;  // if there's a successful connection:  if (client.connect(server, 80)) {    Serial.println("connecting...");    // send the HTTP GET request:    client.println("GET / HTTP/1.1");    client.println("Host: example.org");    client.println("User-Agent: ArduinoWiFi/1.1");    client.println("Connection: close");    client.println();    // note the time that the connection was made:    lastConnectionTime = millis();  } else {    // if you couldn't make a connection:    Serial.println("connection failed");  }}void printWifiStatus() {  // print the SSID of the network you're attached to:  Serial.print("SSID: ");  Serial.println(WiFi.SSID());  // print your board's IP address:  IPAddress ip = WiFi.localIP();  Serial.print("IP Address: ");  Serial.println(ip);  // print the received signal strength:  long rssi = WiFi.RSSI();  Serial.print("signal strength (RSSI):");  Serial.print(rssi);  Serial.println(" dBm");}

@pennampennam merged commit8186f2a intoarduino:mainApr 19, 2024
@andreagilardoniandreagilardoni deleted the mbedclient-stop-issue branchApril 19, 2024 07:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pennampennampennam approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@andreagilardoni@pennam

[8]ページ先頭

©2009-2025 Movatter.jp