File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < RestClient.h>
2+ #include < WiFi101.h>
3+ #include " config.h"
4+
5+ char serverAddress[] = " 192.168.0.3" ; // server address
6+ int port = 8080 ;
7+
8+ WiFiClient wifi;
9+ RestClient client = RestClient(wifi, serverAddress, port);
10+ int status = WL_IDLE_STATUS;
11+ String response;
12+ int statusCode = 0 ;
13+
14+ void setup () {
15+ Serial.begin (9600 );
16+ while ( status != WL_CONNECTED) {
17+ Serial.print (" Attempting to connect to Network named: " );
18+ Serial.println (ssid); // print the network name (SSID);
19+
20+ // Connect to WPA/WPA2 network:
21+ status = WiFi.begin (ssid, pass);
22+ }
23+
24+ // print the SSID of the network you're attached to:
25+ Serial.print (" SSID: " );
26+ Serial.println (WiFi.SSID ());
27+
28+ // print your WiFi shield's IP address:
29+ IPAddress ip = WiFi.localIP ();
30+ Serial.print (" IP Address: " );
31+ Serial.println (ip);
32+ }
33+
34+ void loop () {
35+ Serial.println (" making POST request" );
36+ String postData = " name=Alice&age=12" ;
37+ statusCode = client.post (" /" , postData);
38+ response = client.readResponse ();
39+ Serial.print (" Status code: " );
40+ Serial.println (statusCode);
41+ Serial.print (" Response: " );
42+ Serial.println (response);
43+
44+ Serial.println (" Wait five seconds" );
45+ delay (5000 );
46+ }
You can’t perform that action at this time.
0 commit comments