Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of Portenta_H7_AsyncTCP library for Portenta_7, using Vision-shield thernet or Murata WiFi. This library, which is relied on Portenta_H7_AsyncTCP, is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequ…

License

Notifications You must be signed in to change notification settings

khoih-prog/Portenta_H7_AsyncHTTPRequest

Repository files navigation

Portenta_H7_AsyncHTTPRequest Library

arduino-library-badge GitHub release contributions welcome GitHub issues

Donate to my libraries using BuyMeACoffee



Table of Contents



Important Change from v1.2.0

Please have a look at HOWTO Fix Multiple Definitions Linker Error



Why do we need this Async Portenta_H7_AsyncHTTPRequest library

Features

  1. Asynchronous HTTP Request library for Portenta_H7 using Murata WiFi or Vision-shield Ethernet.
  2. Providing a subset of HTTP.
  3. Relying on on Khoi Hoang's Portenta_H7_AsyncTCP
  4. Methods similar in format and usage to XmlHTTPrequest in Javascript.

Supports

  1. GET, POST, PUT, PATCH, DELETE and HEAD
  2. Request and response headers
  3. Chunked response
  4. Single String response for short (<~5K) responses (heap permitting).
  5. Optional onData callback.
  6. Optional onReadyStatechange callback.

Principles of operation

This library adds a simple HTTP layer on top of the Portenta_H7_AsyncTCP library to facilitate REST communication from a Client to a Server. The paradigm is similar to the XMLHttpRequest in Javascript, employing the notion of a ready-state progression through the transaction request.

Synchronization can be accomplished using callbacks on ready-state change, a callback on data receipt, or simply polling for ready-state change. Data retrieval can be incremental as received, or bulk retrieved when the transaction completes provided there is enough heap to buffer the entire response.

The underlying buffering uses a new xbuf class. It handles both character and binary data. Class xbuf uses a chain of small (64 byte) segments that are allocated and added to the tail as data is added and deallocated from the head as data is read, achieving the same result as a dynamic circular buffer limited only by the size of heap. The xbuf implements indexOf and readUntil functions.

For short transactions, buffer space should not be an issue. In fact, it can be more economical than other methods that use larger fixed length buffers. Data is acked when retrieved by the caller, so there is some limited flow control to limit heap usage for larger transfers.

Request and response headers are handled in the typical fashion.

Chunked responses are recognized and handled transparently.

This library is based on, modified from:

  1. Bob Lemaire's asyncHTTPrequest Library

Currently Supported Boards

  1. Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core using Vision-shield Ethernet or Murata WiFi



Prerequisites

  1. Arduino IDE 1.8.19+ for Arduino. GitHub release
  2. ArduinoCore-mbed mbed_portenta core 3.5.4+ for Arduino Portenta_H7 boards, such as Portenta_H7 Rev2 ABX00042, etc.. GitHub release
  3. Portenta_H7_AsyncTCP library v1.4.0+ for Portenta_H7 using Vision-shield Ethernet or Murata WiFi. To install. check arduino-library-badge


Installation

Use Arduino Library Manager

The best and easiest way is to use Arduino Library Manager. Search for Portenta_H7_AsyncHTTPRequest, then select / install the latest version. You can also use this link arduino-library-badge for more detailed instructions.

Manual Install

  1. Navigate to Portenta_H7_AsyncHTTPRequest page.
  2. Download the latest release Portenta_H7_AsyncHTTPRequest-main.zip.
  3. Extract the zip file to Portenta_H7_AsyncHTTPRequest-main directory
  4. Copy the whole Portenta_H7_AsyncHTTPRequest-main folder to Arduino libraries' directory such as ~/Arduino/libraries/.

VS Code & PlatformIO

  1. Install VS Code
  2. Install PlatformIO
  3. Install Portenta_H7_AsyncHTTPRequest library by using Library Manager. Search for Portenta_H7_AsyncHTTPRequest in Platform.io Author's Libraries
  4. Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File


Packages' Patches

1. For Portenta_H7 boards using Arduino IDE in Linux

To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).

Then run the following command using sudo

$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh

This will create the file /etc/udev/rules.d/49-portenta_h7.rules as follows:

# Portenta H7 bootloader mode UDEV rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"

Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh

Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh

2. To fix compile error relating to dns_gethostbyname and LwIP stack

To be able to compile, run on Portenta_H7 boards, you have to copy the whole mbed_portenta Packages_Patches directory into Arduino mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1).

Supposing the Arduino mbed_portenta version is 3.4.1. These file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/libraries/SocketWrapper/src/MbedUdp.h
  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/libraries/SocketWrapper/src/MbedUdp.cpp
  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/cores/arduino/src/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h


HOWTO Fix Multiple Definitions Linker Error

The current library implementation, using xyz-Impl.h instead of standard xyz.cpp, possibly creates certain Multiple Definitions Linker error in certain use cases.

You can include this .hpp file

// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "Portenta_H7_AsyncHTTPRequest.hpp"     //https://github.com/khoih-prog/Portenta_H7_AsyncHTTPRequest

in many files. But be sure to use the following .h file in just 1 .h, .cpp or .ino file, which must not be included in any other file, to avoid Multiple Definitions Linker Error

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "Portenta_H7_AsyncHTTPRequest.h"           //https://github.com/khoih-prog/Portenta_H7_AsyncHTTPRequest

Check the new multiFileProject example for a HOWTO demo.

Have a look at the discussion in Different behaviour using the src_cpp or src_h lib #80



Examples

1. For Vision-shield Ethernet

  1. AsyncHTTPRequest
  2. AsyncCustomHeader
  3. AsyncDweetGet
  4. AsyncDweetPost
  5. AsyncSimpleGET
  6. AsyncWebClientRepeating

2. For Murata WiFi

  1. AsyncHTTPRequest
  2. AsyncCustomHeader
  3. AsyncDweetGet
  4. AsyncDweetPost
  5. AsyncSimpleGET
  6. AsyncWebClientRepeating

3. For Portenta_H7

  1. multiFileProject New

Please take a look at other examples, as well.

#include "defines.h"
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.4.2"
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1004002
// Uncomment for certain HTTP site to optimize
//#define NOT_SEND_HEADER_AFTER_CONNECTED true
// Seconds for timeout, default is 3s
#define DEFAULT_RX_TIMEOUT 5
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <Portenta_H7_AsyncHTTPRequest.h> // https://github.com/khoih-prog/Portenta_H7_AsyncHTTPRequest
AsyncHTTPRequest request;
void sendRequest()
{
static bool requestOpenResult;
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
//requestOpenResult = request.open("GET", "http://213.188.196.246/api/timezone/America/Toronto.txt");
if (requestOpenResult)
{
Serial.println("Request sent");
// Only send() if open() returns true, or crash
request.send();
}
else
{
Serial.println("Can't send bad request");
}
}
else
{
Serial.println("Can't send request");
}
}
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGWARN(F("\n**************************************"));
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 5000);
Serial.print("\nStart AsyncHTTPRequest on ");
Serial.println(BOARD_NAME);
Serial.println(PORTENTA_H7_ASYNC_TCP_VERSION);
Serial.println(PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION);
#if defined(PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN)
if (PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_INT < PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET);
}
#endif
///////////////////////////////////
// start the ethernet connection and the server
// Use random mac
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[index], ip);
// Use DHCP dynamic IP and random mac
Ethernet.begin(mac[index]);
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("No Ethernet found. Stay here forever");
while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF)
{
Serial.println("Not connected Ethernet cable");
}
Serial.print(F("Using mac index = "));
Serial.println(index);
Serial.print(F("Connected! IP address: "));
Serial.println(Ethernet.localIP());
///////////////////////////////////
request.setDebug(false);
request.onReadyStateChange(requestCB);
}
void sendRequestRepeat()
{
static unsigned long sendRequest_timeout = 0;
#define SEND_REQUEST_INTERVAL 10000L
// sendRequest every SEND_REQUEST_INTERVAL (60) seconds: we don't need to sendRequest frequently
if ((millis() > sendRequest_timeout) || (sendRequest_timeout == 0))
{
sendRequest();
sendRequest_timeout = millis() + SEND_REQUEST_INTERVAL;
}
}
void loop()
{
sendRequestRepeat();
}


2. File defines.h

#ifndef defines_h
#define defines_h
#if !( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) )
#error For Portenta_H7 only
#endif
#define PORTENTA_H7_ASYNC_HTTP_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _PORTENTA_H7_ATCP_LOGLEVEL_ 1
#define _ASYNC_HTTP_LOGLEVEL_ 1
#include <Portenta_Ethernet.h>
#include <Ethernet.h>
#warning Using Portenta_Ethernet lib for Portenta_H7.
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
};
#endif //defines_h



Debug Terminal Output Samples

1. AsyncHTTPRequest running on PORTENTA_H7_M7 WiFi

Start AsyncHTTPRequest on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Using mac index = 15
Connected! IP address: 192.168.2.101
Request sent
**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2023-01-31T23:01:30.472515-05:00
day_of_week: 2
day_of_year: 31
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1675224090
utc_datetime: 2023-02-01T04:01:30.472515+00:00
utc_offset: -05:00
week_number: 5
**************************************

**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2023-01-31T23:02:24.463788-05:00
day_of_week: 2
day_of_year: 31
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1675224144
utc_datetime: 2023-02-01T04:02:24.463788+00:00
utc_offset: -05:00
week_number: 5
**************************************

2. AsyncDweetPOST running on PORTENTA_H7_M7 WiFi

Start AsyncDweetPOST on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Connecting to SSID: HueNet1
SSID: HueNet1
Local IP Address: 192.168.2.94
signal strength (RSSI):-25 dBm

Making new POST request

**************************************
{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":"pinA0-Read","created":"2021-10-15T04:17:43.768Z","content":{"sensorValue":88},"transaction":"34ca3083-054b-42ef-bcb0-91f7150dc680"}}
**************************************
"sensorValue":88
Value string: 88
Actual value: 88

3. AsyncWebClientRepeating running on PORTENTA_H7_M7 WiFi

Start AsyncWebClientRepeating on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Connecting to SSID: HueNet1
SSID: HueNet1
Local IP Address: 192.168.2.94
signal strength (RSSI):-26 dBm

**************************************

           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

**************************************

4. AsyncCustomHeader running on PORTENTA_H7_M7 Ethernet

Start AsyncCustomHeader on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Using mac index = 15
Connected! IP address: 192.168.2.87

Sending GET Request to http://worldtimeapi.org/api/timezone/America/Toronto.txt

**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2023-01-31T23:03:24.464007-05:00
day_of_week: 2
day_of_year: 31
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1675224204
utc_datetime: 2023-02-01T04:03:24.464007+00:00
utc_offset: -05:00
week_number: 5
**************************************

5. AsyncWebClientRepeating running on PORTENTA_H7_M7 Ethernet

Start AsyncWebClientRepeating on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Using mac index = 16
Connected! IP address: 192.168.2.87

**************************************

           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

**************************************

6. AsyncSimpleGET running on PORTENTA_H7_M7 Ethernet

Start AsyncSimpleGET on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.5.0
Using mac index = 7
Connected! IP address: 192.168.2.87

**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2023-01-31T23:04:24.464088-05:00
day_of_week: 2
day_of_year: 31
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1675224264
utc_datetime: 2023-02-01T04:04:24.464088+00:00
utc_offset: -05:00
week_number: 5
**************************************
HH HHHH
**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2023-01-31T23:05:24.465017-05:00
day_of_week: 2
day_of_year: 31
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1675224324
utc_datetime: 2023-02-01T04:05:24.465017+00:00
utc_offset: -05:00
week_number: 5
************************************


Debug

Debug is enabled by default on Serial.

You can also change the debugging level from 0 to 4

#define PORTENTA_H7_ASYNC_HTTP_DEBUG_PORT       Serial

// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _PORTENTA_H7_ATCP_LOGLEVEL_             1
#define _ASYNC_HTTP_LOGLEVEL_                   1

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the mbed_portenta core for Arduino.

Sometimes, the library will only work if you update the mbed_portenta core to the latest version because I am using newly added functions.


Issues

Submit issues to: Portenta_H7_AsyncHTTPRequest issues


TO DO

  1. Fix bug. Add enhancement
  2. Add many more examples.

DONE

  1. Add support to Portenta_H7 using Vision-shield Ethernet
  2. Add support to Murata WiFi
  3. Add debugging features.
  4. Add PUT, PATCH, DELETE and HEAD besides GET and POST.
  5. Fix multiple-definitions linker error and weird bug related to src_cpp.
  6. Optimize library code by using reference-passing instead of value-passing
  7. Fix long timeout if using IPAddress
  8. Display only successful responseText in examples
  9. Improve debug messages by adding functions to display error messages instead of cryptic error number
  10. Not try to reconnect to the same host:port after connected
  11. Fix bug of wrong reqStates
  12. Default to reconnect to the same host:port after connected for new HTTP sites.
  13. Use allman astyle and add utils
  14. Fix bug of _parseURL(). Check Bug with _parseURL() #21
  15. Improve README.md so that links can be used in other sites, such as PIO


Contributions and Thanks

This library is based on, modified, bug-fixed and improved from:

  1. Bob Lemaire's asyncHTTPrequest Library to use the better asynchronous features of Portenta_H7_AsyncTCP.
boblemaire
⭐️ Bob Lemaire


Contributing

If you want to contribute to this project:

  • Report bugs and errors
  • Ask for enhancements
  • Create issues and pull requests
  • Tell other people about this library

License and credits

  • The library is licensed under GPLv3

Copyright

Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>

Copyright (C) 2021- Khoi Hoang

About

Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of Portenta_H7_AsyncTCP library for Portenta_7, using Vision-shield thernet or Murata WiFi. This library, which is relied on Portenta_H7_AsyncTCP, is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequ…

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published