forked from khoih-prog/AsyncHTTPRequest_Generic
v1.9.0 to fix bug and optimize code
### Releases v1.9.0 1. Fix long timeout if using `IPAddress`. Check [setTimeout() hasn't any effect #38](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38) 2. Optimize code 3. Display only successful responseText in examples 4. Improve debug messages by adding functions to display error messages instead of `cryptic error number` 5. Remove support to STM32 using **LAN8720** due to problem with new STM32 core v2.3.0 5. Update `Packages' Patches`
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
//char GET_ServerAddress[] = "192.168.2.110/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -68,26 +68,35 @@ void sendRequest(void)
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
Serial.println();
|
||||
AHTTP_LOGDEBUG(F("**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
request->setDebug(false);
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
else
|
||||
{
|
||||
AHTTP_LOGERROR(F("Response error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.println("\nStart AsyncCustomHeader_STM32 on " + String(BOARD_NAME));
|
||||
Serial.print("\nStart AsyncCustomHeader_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
|
||||
@@ -35,8 +35,8 @@ const char GET_ServerAddress[] = "dweet.io";
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/currentSecond?second=";
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -119,25 +119,36 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
Serial.println();
|
||||
AHTTP_LOGDEBUG(F("**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
parseResponse(responseText);
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
request->setDebug(false);
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AHTTP_LOGERROR(F("Response error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncDweetGET_STM32 on " + String(BOARD_NAME));
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.print("\nStart AsyncDweetGET_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
|
||||
@@ -29,8 +29,8 @@ const char POST_ServerAddress[] = "dweet.io";
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/pinA0-Read?";
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -116,25 +116,36 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
Serial.println();
|
||||
AHTTP_LOGDEBUG(F("**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
parseResponse(responseText);
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
request->setDebug(false);
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AHTTP_LOGERROR(F("Response error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncDweetPOST_STM32 on " + String(BOARD_NAME));
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.print("\nStart AsyncDweetPOST_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 4
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
@@ -68,10 +68,8 @@ const char* password = "your_pass";
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include <AsyncHTTPRequest_Impl_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
@@ -150,9 +148,15 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
|
||||
#if 1
|
||||
// Bypass hourly
|
||||
@@ -163,7 +167,7 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
#else
|
||||
// hourly too long, not display anyway. Not enough heap.
|
||||
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
@@ -173,7 +177,7 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
@@ -65,8 +65,8 @@ const char* password = "your_pass";
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
@@ -122,17 +122,21 @@ void sendRequest()
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
|
||||
request->setDebug(false);
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +144,7 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
delay(200);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.print(F("\nStarting AsyncHTTPRequest_ESP using ")); Serial.println(ARDUINO_BOARD);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
@@ -93,14 +93,10 @@
|
||||
|
||||
using TCPClient = WiFiClient;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.1"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007001
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
@@ -156,17 +152,21 @@ void sendRequest()
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
|
||||
request->setDebug(false);
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,8 +211,8 @@ void setup()
|
||||
|
||||
delay(200);
|
||||
|
||||
Serial.print(F("\nStarting AsyncHTTPRequest_ESP8266_Ethernet on ")); Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(F(" using ")); Serial.println(SHIELD_TYPE);
|
||||
Serial.print("\nStart AsyncHTTPRequest_ESP8266_Ethernet on "); Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(" using "); Serial.println(SHIELD_TYPE);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
initEthernet();
|
||||
|
||||
@@ -126,9 +126,19 @@ void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(thisRequest->responseText());
|
||||
Serial.println("**************************************");
|
||||
AHTTP_LOGERROR(F("\n**************************************"));
|
||||
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
else
|
||||
{
|
||||
AHTTP_LOGERROR(F("Response error"));
|
||||
}
|
||||
|
||||
thisRequest->setDebug(false);
|
||||
readySend[0] = true;
|
||||
@@ -141,9 +151,19 @@ void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(thisRequest->responseText());
|
||||
Serial.println("**************************************");
|
||||
AHTTP_LOGERROR(F("\n**************************************"));
|
||||
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
else
|
||||
{
|
||||
AHTTP_LOGERROR(F("Response error"));
|
||||
}
|
||||
|
||||
thisRequest->setDebug(false);
|
||||
readySend[1] = true;
|
||||
@@ -154,9 +174,9 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.println("\nStarting AsyncHTTPRequest_ESP_Multi using " + String(ARDUINO_BOARD));
|
||||
Serial.print("\nStart AsyncHTTPRequest_ESP_Multi on "); Serial.println(ARDUINO_BOARD);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.12.1"
|
||||
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1012001
|
||||
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.13.0"
|
||||
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1013000
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
@@ -556,17 +556,21 @@ void sendRequest()
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
|
||||
request->setDebug(false);
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +578,7 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
@@ -634,7 +638,7 @@ void setup()
|
||||
#if ( USING_ESP32_S2 || USING_ESP32_C3 )
|
||||
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, "AutoConnectAP");
|
||||
#else
|
||||
DNSServer dnsServer;
|
||||
AsyncDNSServer dnsServer;
|
||||
|
||||
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP");
|
||||
#endif
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -55,12 +55,12 @@
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
void sendRequest();
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
void sendRequest()
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
@@ -85,26 +85,30 @@ void sendRequest(void)
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.print("\nStart AsyncHTTPRequest_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
@@ -138,7 +142,7 @@ void setup(void)
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -37,12 +37,12 @@ char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toro
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
void sendRequest();
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
void sendRequest()
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
@@ -66,26 +66,30 @@ void sendRequest(void)
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
request->setDebug(false);
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.println("\nStart AsyncSimpleGET_STM32 on " + String(BOARD_NAME));
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.print("\nStart AsyncSimpleGET_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
@@ -105,8 +109,7 @@ void setup(void)
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : ")); Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
@@ -119,7 +122,7 @@ void setup(void)
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char GET_ServerAddress[] = "arduino.cc";
|
||||
const char GET_ServerAddress[] = "arduino.tips";
|
||||
|
||||
// GET location
|
||||
String GET_Location = "/asciilogo.txt";
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
@@ -39,12 +39,12 @@ String GET_Location = "/asciilogo.txt";
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
void sendRequest();
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
void sendRequest()
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
@@ -68,26 +68,30 @@ void sendRequest(void)
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
{
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
Serial.println("\nStart AsyncWebClientRepeating_STM32 on " + String(BOARD_NAME));
|
||||
Serial.print("\nStart AsyncWebClientRepeating_STM32 on "); Serial.println(BOARD_NAME);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
@@ -119,7 +123,7 @@ void setup(void)
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
void loop()
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
|
||||
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
@@ -152,9 +152,15 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.print("\n***************"); Serial.print(requestName[ requestIndex ]); Serial.println("***************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
|
||||
#if 1
|
||||
// Bypass hourly
|
||||
@@ -165,7 +171,7 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
#else
|
||||
// hourly too long, not display anyway. Not enough heap.
|
||||
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
@@ -176,12 +182,12 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
Serial.print("\nStarting AsyncHTTPRequest_WT32_ETH01 on " + String(ARDUINO_BOARD));
|
||||
Serial.println(" with " + String(SHIELD_TYPE));
|
||||
Serial.print("\nStart AsyncHTTPMultiRequests_WT32_ETH01 on "); Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(" with "); Serial.println(SHIELD_TYPE);
|
||||
Serial.println(WEBSERVER_WT32_ETH01_VERSION);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
|
||||
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
@@ -126,17 +126,21 @@ void sendRequest()
|
||||
}
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
AHTTP_LOGDEBUG(F("\n**************************************"));
|
||||
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
|
||||
|
||||
if (request->responseHTTPcode() == 200)
|
||||
{
|
||||
Serial.println(F("\n**************************************"));
|
||||
Serial.println(request->responseText());
|
||||
Serial.println(F("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,10 +148,12 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.print("\nStarting AsyncHTTPRequest_WT32_ETH01 on " + String(ARDUINO_BOARD));
|
||||
Serial.println(" with " + String(SHIELD_TYPE));
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
Serial.print("\nStart AsyncHTTPRequest_WT32_ETH01 on "); Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(" with "); Serial.println(SHIELD_TYPE);
|
||||
Serial.println(WEBSERVER_WT32_ETH01_VERSION);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.8.2"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1008002
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
|
||||
|
||||
#include "multiFileProject.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user