forked fromzephyrproject-rtos/arduino-core-zephyr
Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34
Add WiFiWebClient example#150
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
Closed
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
6d5e2b9 SerialUSB: fix missing overload after #123
facchinmfdc4356 WiFi add SSID() and RSSI()
pennam2b7243d WiFi allow status() to be called before begin()
pennam6452f1e WiFi wait for event NET_EVENT_WIFI_CONNECT_RESULT in blocking mode
pennam067f686 WiFi make begin() blocking by default
pennam29c6037 WiFi make begin() return status()
pennam13d666d WiFi add WiFiWebclient example
pennam76a3152 ZEP-55: Implemented WiFi.scan() functionality.
bogdanarduino6f27f6f ZEP-55: Device will try to connect using default connection parameter…
bogdanarduinoFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionscores/arduino/SerialUSB.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionslibraries/SocketWrapper/WiFi.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #include "WiFi.h" | ||
| WiFiClass WiFi; | ||
| WiFiClass* WiFiClass::instance = nullptr; |
161 changes: 138 additions & 23 deletionslibraries/SocketWrapper/WiFi.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletionslibraries/SocketWrapper/examples/WiFiWebClient/WiFiWebClient.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /* | ||
| Web client | ||
| This sketch connects to a website (http://example.com) using the WiFi module. | ||
| This example is written for a network using WPA encryption. For | ||
| WEP or WPA, change the Wifi.begin() call accordingly. | ||
| created 13 July 2010 | ||
| by dlf (Metodo2 srl) | ||
| modified 31 May 2012 | ||
| by Tom Igoe | ||
| */ | ||
| #include <ZephyrClient.h> | ||
| #include <WiFi.h> | ||
| #include "arduino_secrets.h" | ||
| ///////please enter your sensitive data in the Secret tab/arduino_secrets.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; | ||
| // if you don't want to use DNS (and reduce your sketch size) | ||
| // use the numeric IP instead of the name for the server: | ||
| // IPAddress server(93,184,216,34); // IP address for example.com (no DNS) | ||
| char server[] = "example.com"; // host name for example.com (using DNS) | ||
| ZephyrClient client; | ||
| void 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_SHIELD) { | ||
| Serial.println("Communication with WiFi module failed!"); | ||
| // don't continue | ||
| while (true); | ||
| } | ||
| // 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); | ||
| Serial.print("Wifi begin status: "); | ||
| Serial.println(status); | ||
| // wait 6 seconds for connection: | ||
| delay(6000); | ||
| } | ||
| Serial.println("Connected to wifi"); | ||
| printWifiStatus(); | ||
| Serial.println("\nStarting connection to server..."); | ||
| // if you get a connection, report back via serial: | ||
| if (client.connect(server, 80)) { | ||
| Serial.println("connected to server"); | ||
| // Make a HTTP request: | ||
| client.println("GET /index.html HTTP/1.1"); | ||
| client.print("Host: "); | ||
| client.println(server); | ||
| client.println("Connection: close"); | ||
| client.println(); | ||
| } | ||
| } | ||
| void loop() { | ||
| // if there are incoming bytes available | ||
| // from the server, read them and print them: | ||
| while (client.available()) { | ||
| char c = client.read(); | ||
| Serial.write(c); | ||
| } | ||
| // if the server's disconnected, stop the client: | ||
| if (!client.connected()) { | ||
| Serial.println(); | ||
| Serial.println("disconnecting from server."); | ||
| client.stop(); | ||
| // do nothing forevermore: | ||
| while (true); | ||
| } | ||
| } | ||
| 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"); | ||
| } |
2 changes: 2 additions & 0 deletionslibraries/SocketWrapper/examples/WiFiWebClient/arduino_secrets.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #define SECRET_SSID "" | ||
| #define SECRET_PASS "" |
1 change: 1 addition & 0 deletionsloader/llext_exports.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.