@@ -178,170 +178,13 @@ Please take a look at other examples, as well.
178178
179179#### 1. File [ AsyncHTTPRequest.ino] ( examples/AsyncHTTPRequest/AsyncHTTPRequest.ino )
180180
181- ``` cpp
182- #include " defines.h"
183-
184- #define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
185- #define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
186-
187- // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
188- #include < AsyncHTTPRequest_RP2040W.h> // https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W
189-
190- AsyncHTTPRequest request;
191-
192- int status = WL_IDLE_STATUS;
193-
194- void sendRequest ()
195- {
196- static bool requestOpenResult;
197-
198- if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
199- {
200- //requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt ");
201- requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt ");
202- //requestOpenResult = request.open("GET", "http://213.188.196.246/api/timezone/America/Toronto.txt ");
203-
204- if (requestOpenResult)
205- {
206- Serial.println("Request sent");
207-
208- // Only send() if open() returns true, or crash
209- request.send();
210- }
211- else
212- {
213- Serial.println("Can't send bad request");
214- }
215- }
216- else
217- {
218- Serial.println("Can't send request");
219- }
220- }
221-
222- void requestCB (void* optParm, AsyncHTTPRequest* request, int readyState)
223- {
224- (void) optParm;
225-
226- if (readyState == readyStateDone)
227- {
228- Serial.println("\n************************************** ");
229- Serial.println(request->responseText());
230- Serial.println("************************************** ");
231-
232- request->setDebug(false);
233- }
234- }
235-
236- void printWifiStatus()
237- {
238- // print the SSID of the network you're attached to:
239- Serial.print("SSID: ");
240- Serial.println(WiFi.SSID());
241-
242- // print your board's IP address:
243- IPAddress ip = WiFi.localIP();
244- Serial.print("Local IP Address: ");
245- Serial.println(ip);
246-
247- // print the received signal strength:
248- long rssi = WiFi.RSSI();
249- Serial.print("signal strength (RSSI):");
250- Serial.print(rssi);
251- Serial.println(" dBm");
252- }
253-
254- void setup()
255- {
256- Serial.begin(115200);
257- while (!Serial);
258-
259- Serial.print("\nStart AsyncHTTPRequest on "); Serial.println(BOARD_NAME);
260- Serial.println(ASYNCTCP_RP2040W_VERSION);
261- Serial.println(ASYNC_HTTP_REQUEST_RP2040W_VERSION);
262-
263- #if defined(ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN)
264- if (ASYNC_HTTP_REQUEST_RP2040W_VERSION_INT < ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN)
265- {
266- Serial.print("Warning. Must use this example on Version equal or later than : ");
267- Serial.println(ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET);
268- }
269- #endif
270-
271- ///////////////////////////////////
272-
273- // check for the WiFi module:
274- if (WiFi.status() == WL_NO_MODULE)
275- {
276- Serial.println("Communication with WiFi module failed!");
277- // don't continue
278- while (true);
279- }
280-
281- Serial.print(F("Connecting to SSID: "));
282- Serial.println(ssid);
283-
284- status = WiFi.begin(ssid, pass);
285-
286- delay(1000);
287-
288- // attempt to connect to WiFi network
289- while ( status != WL_CONNECTED)
290- {
291- delay(500);
292-
293- // Connect to WPA/WPA2 network
294- status = WiFi.status();
295- }
296-
297- printWifiStatus();
298-
299- ///////////////////////////////////
300-
301- request.setDebug(false);
302-
303- request.onReadyStateChange(requestCB);
304- }
305-
306- void sendRequestRepeat()
307- {
308- static unsigned long sendRequest_timeout = 0;
309-
310- #define SEND_REQUEST_INTERVAL 60000L
311-
312- // sendRequest every SEND_REQUEST_INTERVAL (60) seconds: we don't need to sendRequest frequently
313- if ((millis() > sendRequest_timeout) || (sendRequest_timeout == 0))
314- {
315- sendRequest();
316-
317- sendRequest_timeout = millis() + SEND_REQUEST_INTERVAL;
318- }
319- }
320-
321- void loop()
322- {
323- sendRequestRepeat();
324- }
325- ```
181+ https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W/blob/39eb61479ae868729b43ebb2c86bc11437fce2f8/examples/AsyncHTTPRequest/AsyncHTTPRequest.ino#L41-L177
326182
327183---
328184
329185#### 2. File [ defines.h] ( examples/AsyncHTTPRequest/defines.h )
330186
331-
332- ```cpp
333- #ifndef defines_h
334- #define defines_h
335-
336- #if !( defined(ARDUINO_RASPBERRY_PI_PICO_W) )
337- #error For RASPBERRY_PI_PICO_W only
338- #endif
339-
340- char ssid[] = "your_ssid"; // your network SSID (name)
341- char pass[] = "12345678"; // your network password (use for WPA, or use as key for WEP), length must be 8+
342-
343- #endif //defines_h
344- ```
187+ https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W/blob/39eb61479ae868729b43ebb2c86bc11437fce2f8/examples/AsyncHTTPRequest/defines.h#L1-L30
345188
346189---
347190---
@@ -351,50 +194,50 @@ char pass[] = "12345678"; // your network password (use for WPA, or use
351194#### 1. [ AsyncHTTPRequest] ( examples/AsyncHTTPRequest ) running on RASPBERRY_PI_PICO_W using CYW43439 WiFi
352195
353196```
354- Start AsyncHTTPRequest on RASPBERRY_PI_PICO_W with RP2040W CYW43439 WiFi
197+
198+ Start AsyncHTTPRequest on RASPBERRY_PI_PICO_W
355199AsyncTCP_RP2040W v1.0.0
356- AsyncHTTPRequest_RP2040W v1.0.0
200+ AsyncHTTPRequest_RP2040W v1.0.1
357201Connecting to SSID: HueNet1
358202SSID: HueNet1
359- Local IP Address: 192.168.2.94
360- signal strength (RSSI):-25 dBm
361-
203+ Local IP Address: 192.168.2.180
362204Request sent
205+
363206**************************************
364- abbreviation: EST
365- client_ip: aaa.bbb.ccc.ddd
366- datetime: 2022-01-23T19:06:29.846071-05 :00
367- day_of_week: 0
368- day_of_year: 23
369- dst: false
370- dst_from:
371- dst_offset: 0
372- dst_until:
207+ abbreviation: EDT
208+ client_ip: 69.165.159.183
209+ datetime: 2022-08-15T21:53:32.353173-04 :00
210+ day_of_week: 1
211+ day_of_year: 227
212+ dst: true
213+ dst_from: 2022-03-13T07:00:00+00:00
214+ dst_offset: 3600
215+ dst_until: 2022-11-06T06:00:00+00:00
373216raw_offset: -18000
374217timezone: America/Toronto
375- unixtime: 1642982789
376- utc_datetime: 2022-01-24T00:06:29.846071 +00:00
377- utc_offset: -05 :00
378- week_number: 3
218+ unixtime: 1660614812
219+ utc_datetime: 2022-08-16T01:53:32.353173 +00:00
220+ utc_offset: -04 :00
221+ week_number: 33
379222**************************************
380223Request sent
381224
382225**************************************
383- abbreviation: EST
384- client_ip: aaa.bbb.ccc.ddd
385- datetime: 2022-01-23T19:08:29.871390-05 :00
386- day_of_week: 0
387- day_of_year: 23
388- dst: false
389- dst_from:
390- dst_offset: 0
391- dst_until:
226+ abbreviation: EDT
227+ client_ip: 69.165.159.183
228+ datetime: 2022-08-15T21:54:32.316488-04 :00
229+ day_of_week: 1
230+ day_of_year: 227
231+ dst: true
232+ dst_from: 2022-03-13T07:00:00+00:00
233+ dst_offset: 3600
234+ dst_until: 2022-11-06T06:00:00+00:00
392235raw_offset: -18000
393236timezone: America/Toronto
394- unixtime: 1642982909
395- utc_datetime: 2022-01-24T00:08:29.871390 +00:00
396- utc_offset: -05 :00
397- week_number: 3
237+ unixtime: 1660614872
238+ utc_datetime: 2022-08-16T01:54:32.316488 +00:00
239+ utc_offset: -04 :00
240+ week_number: 33
398241**************************************
399242```
400243
@@ -405,11 +248,10 @@ week_number: 3
405248```
406249Start AsyncDweetPOST on RASPBERRY_PI_PICO_W with RP2040W CYW43439 WiFi
407250AsyncTCP_RP2040W v1.0.0
408- AsyncHTTPRequest_RP2040W v1.0.0
251+ AsyncHTTPRequest_RP2040W v1.0.1
409252Connecting to SSID: HueNet1
410253SSID: HueNet1
411- Local IP Address: 192.168.2.94
412- signal strength (RSSI):-25 dBm
254+ Local IP Address: 192.168.2.180
413255
414256Making new POST request
415257
@@ -426,13 +268,12 @@ Actual value: 88
426268#### 3. [ AsyncWebClientRepeating] ( examples/AsyncWebClientRepeating ) running on RASPBERRY_PI_PICO_W using CYW43439 WiFi
427269
428270```
429- Start AsyncWebClientRepeating on RASPBERRY_PI_PICO_W with RP2040W CYW43439 WiFi
271+ Start AsyncWebClientRepeating on RASPBERRY_PI_PICO_W
430272AsyncTCP_RP2040W v1.0.0
431- AsyncHTTPRequest_RP2040W v1.0.0
273+ AsyncHTTPRequest_RP2040W v1.0.1
432274Connecting to SSID: HueNet1
433275SSID: HueNet1
434- Local IP Address: 192.168.2.94
435- signal strength (RSSI):-26 dBm
276+ Local IP Address: 192.168.2.180
436277
437278**************************************
438279
0 commit comments