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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user