Skip to content

Commit 3800560

Browse files
committed
WiFiS3 Library Initial Release
Former-commit-id: 9a77b31
1 parent a1d5621 commit 3800560

File tree

303 files changed

+55839
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+55839
-0
lines changed

libraries/WiFiS3/keywords.txt

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#######################################
2+
# Syntax Coloring Map For WiFi
3+
#######################################
4+
5+
#######################################
6+
# Library (KEYWORD3)
7+
#######################################
8+
9+
WiFi KEYWORD3
10+
11+
#######################################
12+
# Datatypes (KEYWORD1)
13+
#######################################
14+
15+
WiFi KEYWORD1
16+
WiFiClient KEYWORD1
17+
WiFiServer KEYWORD1
18+
WiFiUDP KEYWORD1
19+
WiFiClientSecure KEYWORD1
20+
21+
#######################################
22+
# Methods and Functions (KEYWORD2)
23+
#######################################
24+
25+
status KEYWORD2
26+
mode KEYWORD2
27+
connect KEYWORD2
28+
write KEYWORD2
29+
available KEYWORD2
30+
config KEYWORD2
31+
setDNS KEYWORD2
32+
read KEYWORD2
33+
flush KEYWORD2
34+
stop KEYWORD2
35+
connected KEYWORD2
36+
begin KEYWORD2
37+
beginMulticast KEYWORD2
38+
disconnect KEYWORD2
39+
macAddress KEYWORD2
40+
localIP KEYWORD2
41+
subnetMask KEYWORD2
42+
gatewayIP KEYWORD2
43+
SSID KEYWORD2
44+
psk KEYWORD2
45+
BSSID KEYWORD2
46+
RSSI KEYWORD2
47+
encryptionType KEYWORD2
48+
beginPacket KEYWORD2
49+
beginPacketMulticast KEYWORD2
50+
endPacket KEYWORD2
51+
parsePacket KEYWORD2
52+
destinationIP KEYWORD2
53+
remoteIP KEYWORD2
54+
remotePort KEYWORD2
55+
softAP KEYWORD2
56+
softAPIP KEYWORD2
57+
softAPmacAddress KEYWORD2
58+
softAPConfig KEYWORD2
59+
printDiag KEYWORD2
60+
hostByName KEYWORD2
61+
scanNetworks KEYWORD2
62+
63+
#######################################
64+
# Constants (LITERAL1)
65+
#######################################
66+
WiFi_AP LITERAL1
67+
WiFi_STA LITERAL1
68+
WiFi_AP_STA LITERAL1

libraries/WiFiS3/library.properties

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=WiFiS3
2+
version=0.0.0
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=Enables network connection (local and Internet) with the Arduino Leven.
6+
paragraph=With this library you can instantiate Servers, Clients and send/receive UDP packets through WiFi. The board can connect either to open or encrypted networks (WEP, WPA). The IP address can be assigned statically or through a DHCP. The library can also manage DNS.
7+
category=Communication
8+
url=http://www.arduino.cc/en/Reference/WiFiS3
9+
architectures=*
10+
includes=WiFiS3.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
WiFi Web Server LED Blink
3+
4+
A simple web server that lets you blink an LED via the web.
5+
This sketch will create a new access point (with no password).
6+
It will then launch a new server and print out the IP address
7+
to the Serial Monitor. From there, you can open that address in a web browser
8+
to turn on and off the LED on pin 13.
9+
10+
If the IP address of your board is yourAddress:
11+
http://yourAddress/H turns the LED on
12+
http://yourAddress/L turns it off
13+
14+
created 25 Nov 2012
15+
by Tom Igoe
16+
adapted to WiFi AP by Adafruit
17+
*/
18+
19+
#include "WiFi.h"
20+
#include "WiFiServer.h"
21+
22+
23+
24+
#include "arduino_secrets.h"
25+
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
26+
char ssid[] = SECRET_SSID; // your network SSID (name)
27+
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
28+
int keyIndex = 0; // your network key index number (needed only for WEP)
29+
30+
int led = LED_BUILTIN;
31+
int status = WL_IDLE_STATUS;
32+
WiFiServer server(80);
33+
34+
void setup() {
35+
//Initialize serial and wait for port to open:
36+
Serial.begin(9600);
37+
while (!Serial) {
38+
; // wait for serial port to connect. Needed for native USB port only
39+
}
40+
Serial.println("Access Point Web Server");
41+
42+
pinMode(led, OUTPUT); // set the LED pin mode
43+
44+
// check for the WiFi module:
45+
if (WiFi.status() == WL_NO_MODULE) {
46+
Serial.println("Communication with WiFi module failed!");
47+
// don't continue
48+
while (true);
49+
}
50+
51+
String fv = WiFi.firmwareVersion();
52+
if (fv < WiFi_FIRMWARE_LATEST_VERSION) {
53+
Serial.println("Please upgrade the firmware");
54+
}
55+
56+
// by default the local IP address will be 192.168.4.1
57+
// you can override it with the following:
58+
//WiFi.config(IPAddress(10, 10, 5, 1));
59+
60+
// print the network name (SSID);
61+
Serial.print("Creating access point named: ");
62+
Serial.println(ssid);
63+
64+
// Create open network. Change this line if you want to create an WEP network:
65+
status = WiFi.beginAP(ssid, pass);
66+
if (status != WL_AP_LISTENING) {
67+
Serial.println("Creating access point failed");
68+
// don't continue
69+
while (true);
70+
}
71+
72+
// wait 10 seconds for connection:
73+
delay(10000);
74+
75+
// start the web server on port 80
76+
server.begin();
77+
78+
// you're connected now, so print out the status
79+
printWiFiStatus();
80+
}
81+
82+
83+
void loop() {
84+
// compare the previous status to the current status
85+
if (status != WiFi.status()) {
86+
// it has changed update the variable
87+
status = WiFi.status();
88+
89+
if (status == WL_AP_CONNECTED) {
90+
// a device has connected to the AP
91+
Serial.println("Device connected to AP");
92+
} else {
93+
// a device has disconnected from the AP, and we are back in listening mode
94+
Serial.println("Device disconnected from AP");
95+
}
96+
}
97+
98+
WiFiClient client = server.available(); // listen for incoming clients
99+
100+
if (client) { // if you get a client,
101+
Serial.println("new client"); // print a message out the serial port
102+
String currentLine = ""; // make a String to hold incoming data from the client
103+
while (client.connected()) { // loop while the client's connected
104+
delayMicroseconds(10); // This is required for the Arduino Nano RP2040 Connect - otherwise it will loop so fast that SPI will never be served.
105+
if (client.available()) { // if there's bytes to read from the client,
106+
char c = client.read(); // read a byte, then
107+
Serial.write(c); // print it out to the serial monitor
108+
if (c == '\n') { // if the byte is a newline character
109+
110+
// if the current line is blank, you got two newline characters in a row.
111+
// that's the end of the client HTTP request, so send a response:
112+
if (currentLine.length() == 0) {
113+
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
114+
// and a content-type so the client knows what's coming, then a blank line:
115+
client.println("HTTP/1.1 200 OK");
116+
client.println("Content-type:text/html");
117+
client.println();
118+
119+
// the content of the HTTP response follows the header:
120+
client.print("<p style=\"font-size:7vw;\">Click <a href=\"/H\">here</a> turn the LED off<br></p>");
121+
client.print("<p style=\"font-size:7vw;\">Click <a href=\"/L\">here</a> turn the LED on<br></p>");
122+
123+
// The HTTP response ends with another blank line:
124+
client.println();
125+
// break out of the while loop:
126+
break;
127+
}
128+
else { // if you got a newline, then clear currentLine:
129+
currentLine = "";
130+
}
131+
}
132+
else if (c != '\r') { // if you got anything else but a carriage return character,
133+
currentLine += c; // add it to the end of the currentLine
134+
}
135+
136+
// Check to see if the client request was "GET /H" or "GET /L":
137+
if (currentLine.endsWith("GET /H")) {
138+
digitalWrite(led, HIGH); // GET /H turns the LED on
139+
}
140+
if (currentLine.endsWith("GET /L")) {
141+
digitalWrite(led, LOW); // GET /L turns the LED off
142+
}
143+
}
144+
}
145+
// close the connection:
146+
client.stop();
147+
Serial.println("client disconnected");
148+
}
149+
}
150+
151+
void printWiFiStatus() {
152+
// print the SSID of the network you're attached to:
153+
Serial.print("SSID: ");
154+
Serial.println(WiFi.SSID());
155+
156+
// print your WiFi shield's IP address:
157+
IPAddress ip = WiFi.localIP();
158+
Serial.print("IP Address: ");
159+
Serial.println(ip);
160+
161+
// print where to go in a browser:
162+
Serial.print("To see this page in action, open a browser to http://");
163+
Serial.println(ip);
164+
165+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Both SSID and password must be 8 characters or longer
2+
#define SECRET_SSID "testAP"
3+
#define SECRET_PASS "123456789"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
SerialPassthroughESP32-C3 - Use esptool to flash the ES32-C3 module on Santiago and Portenta H33
3+
4+
Copyright (c) 2022 Arduino SA. All rights reserved.
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
unsigned long baud = 9600;
22+
23+
int rts = -1;
24+
int dtr = -1;
25+
26+
27+
#ifdef ARDUINO_PORTENTA_H33
28+
29+
#warning Compiling for Portenta H33
30+
#ifndef SerialNina
31+
#define SerialNina Serial5
32+
#endif
33+
34+
#ifndef NINA_GPIO0
35+
#define NINA_GPIO0 (100)
36+
#endif
37+
38+
#ifndef NINA_RESETN
39+
#define NINA_RESETN (101)
40+
#endif
41+
42+
#else
43+
44+
#warning Compiling for Santiago
45+
46+
#ifndef SerialNina
47+
#define SerialNina Serial2
48+
#endif
49+
50+
#ifndef NINA_GPIO0
51+
#define NINA_GPIO0 (28)
52+
#endif
53+
54+
#ifndef NINA_RESETN
55+
#define NINA_RESETN (29)
56+
#endif
57+
58+
#endif
59+
60+
void setup() {
61+
Serial.begin(baud, SERIAL_8N1);
62+
SerialNina.begin(baud);
63+
while (!Serial);
64+
65+
pinMode(NINA_GPIO0, OUTPUT);
66+
pinMode(NINA_RESETN, OUTPUT);
67+
68+
digitalWrite(NINA_GPIO0, HIGH);
69+
delay(100);
70+
digitalWrite(NINA_RESETN, HIGH);
71+
digitalWrite(NINA_RESETN, LOW);
72+
digitalWrite(NINA_RESETN, HIGH);
73+
74+
rts = Serial.rts();
75+
dtr = Serial.dtr();
76+
}
77+
78+
void loop() {
79+
80+
auto _rts = Serial.rts();
81+
auto _dtr = Serial.dtr();
82+
83+
if ((rts != _rts) || (dtr != _dtr)) {
84+
digitalWrite(NINA_RESETN, _rts ? LOW : HIGH);
85+
rts = _rts;
86+
digitalWrite(NINA_GPIO0, _dtr ? LOW : HIGH);
87+
dtr = _dtr;
88+
}
89+
90+
int len = 0;
91+
uint8_t auc_buffer[488];
92+
while (Serial.available() && len < sizeof(auc_buffer)) {
93+
auc_buffer[len++] = Serial.read();
94+
}
95+
if (len) {
96+
SerialNina.write(auc_buffer, len);
97+
}
98+
99+
len = 0;
100+
while (SerialNina.available() && len < sizeof(auc_buffer)) {
101+
auc_buffer[len++] = SerialNina.read();
102+
}
103+
if (len) {
104+
Serial.write(auc_buffer, len);
105+
}
106+
107+
// check if the USB virtual serial wants a new baud rate
108+
if (Serial.baud() != baud) {
109+
//rts = -1;
110+
//dtr = -1;
111+
112+
baud = Serial.baud();
113+
SerialNina.end();
114+
SerialNina.begin(baud);
115+
}
116+
}

0 commit comments

Comments
 (0)