-
Notifications
You must be signed in to change notification settings - Fork 24
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
WiFiClient not working as expected #279
Comments
Hello, hope this message finds you well. Congrats to your first Issue! We will review it as soon as possiable. Feel free to have a look at https://www.amebaiot.com/en/ameba-arduino-summary/ for more information |
Hi, have you tried setting non blocking mode for your server? Uncomment this line: //server.setNonBlockingMode(); in your set up loop. Thank you. |
If I enable non-blocking mode, I will get error like:
[ERROR] get_available Accept connection failed
right after the sketch started looping in loop()
and here is the sketch I used
/*
Example guide:
https://www.amebaiot.com/en/amebapro2-arduino-server-client/
*/
#include <WiFi.h>
char ssid[] = "..."; // your network SSID (name)
char 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; // Indicator of Wifi status
WiFiServer server(5000);
void setup()
{
Serial.begin(115200); // initialize serial communication
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (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);
for (int i = 0; i < 10; i++) {
Serial.println("... wait ...");
delay(1000);
}
}
server.setNonBlockingMode(); // R4 doesn't have this
server.begin(); // start the tcp server on port 5000
}
void loop()
{
WiFiClient client = server.available();
bool firstConnected = false;
while (client.connected()) {
if (firstConnected) {
Serial.println("***** connected *****");
}
firstConnected = true;
if (client.available()) {
char c = client.read();
Serial.print(c);
}
}
client.stop();
Serial.println("***** the end *****");
}
…On Fri, 22 Nov 2024 at 15:31, Kelvin Huang ***@***.***> wrote:
Hi, have you tried setting non blocking mode for your server? Uncomment
this line: //server.setNonBlockingMode(); in your set up loop. Thank you.
—
Reply to this email directly, view it on GitHub
<#279 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHRXLPALQ4WZBXO6A7RH2OL2B3MV7AVCNFSM6AAAAABRMRZ5ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJTGA2TMMZXGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This issue is stale because it has been open for 14 days with no activity. |
Boards
AMB82-mini
External Hardware
no`
Hardware Configuration
no
Version
other
IDE Name
Arduino IDE 2.3.3
Operating System
Windows
Auto Flash Mode
Disable
Erase All Flash Memory (16MB)
Disable
Standard Lib
Arduino_STD_PRINTF
Upload Speed
2000000
Description
The sample SimpleTCPServer.ino (https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/SimpleTCPServer/SimpleTCPServer.ino) works fine.
However, if the loop() is changed to be like
it doesn't seem to work as expected,
Note that I tried the same modified sketch with UNO R4 and it works fine with UNO R4
Thanks for looking into the issue.
Sketch
Error/Debug Message
Reproduce remarks
No response
I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
The text was updated successfully, but these errors were encountered: