Abstract internet communication module.
More...
#include <InternetPlat.h>
|
struct | ClientCleanup |
| Simply close the socket when the client dissapears, we don't want to delete the object because the client needs to cache sessions. More...
|
|
struct | UDPDeletor |
| Close the socket and delete the UDP object when the unique ptr dissapears. More...
|
|
|
|
using | UDPPtr = std::unique_ptr< UDP, UDPDeletor > |
| Cleaner name for UDP smart pointer. More...
|
|
using | ClientSession = std::unique_ptr< Client, ClientCleanup > |
| Cleaner name for Client smart pointer. More...
|
|
enum | Type {
Type::Unknown = 0,
Type::Other =1000,
Type::Interrupt_Manager,
Type::Sleep_Manager,
Type::Multiplexer,
Type::NTP,
Type::TempSync,
Type::WarmUp_Manager,
Type::Sensor =2000,
Type::Analog,
Type::Digital,
Type::I2C =2100,
Type::ADS1115,
Type::AS7262,
Type::AS7263,
Type::AS7265X,
Type::FXAS21002,
Type::FXOS8700,
Type::LIS3DH,
Type::MB1232,
Type::MMA8451,
Type::MPU6050,
Type::MS5803,
Type::SHT31D,
Type::TMP007,
Type::TSL2561,
Type::TSL2591,
Type::ZXGesture,
Type::STEMMA,
Type::SDI12 =2200,
Type::Decagon5TM,
Type::DecagonGS3,
Type::SPI =2300,
Type::MAX31855,
Type::MAX31856,
Type::L_SERIAL =2400,
Type::K30,
Type::L_RTC =3000,
Type::DS3231,
Type::PCF8523,
Type::Actuator =4000,
Type::Neopixel,
Type::Relay,
Type::Servo,
Type::Stepper,
Type::LogPlat =5000,
Type::OLED,
Type::SDCARD,
Type::BATCHSD,
Type::CommPlat =6000,
Type::LoRa,
Type::nRF,
Type::Bluetooth,
Type::InternetPlat =7000,
Type::Ethernet,
Type::WiFi,
Type::LTE,
Type::PublishPlat =8000,
Type::GoogleSheets,
Type::MaxPub,
Type::SpoolPub,
Type::SubscribePlats =9000,
Type::MaxSub
} |
| Enum to check against to when finding individual component managed by a LoomManager. More...
|
|
enum | Category {
Category::Unknown =0,
Category::Other =1,
Category::Sensor =2,
Category::L_RTC =3,
Category::Actuator =4,
Category::LogPlat =5,
Category::CommPlat =6,
Category::InternetPlat =7,
Category::PublishPlat =8,
Category::SubscribePlat =9
} |
| Enum to classify modules. More...
|
|
|
virtual void | package (JsonObject json) override |
| No package necessary for internet platforms. More...
|
|
virtual ClientSession | http_request (const char *domain, const char *url, const char *body, const char *verb) |
| Make HTTP request. More...
|
|
ClientSession | http_get_request (const char *domain, const char *url, const char *body=nullptr) |
| Make HTTP GET request. More...
|
|
ClientSession | http_post_request (const char *domain, const char *url, const char *body=nullptr) |
| Make HTTP POST request. More...
|
|
virtual ClientSession | connect_to_domain (const char *domain) |
| Connect to a domain, but don't write any HTTP stuff, Let the module figure that out. More...
|
|
virtual ClientSession | connect_to_ip (const IPAddress &ip, const uint16_t port) |
| Connect to a domain, but don't write any HTTP stuff, Let the module figure that out. More...
|
|
virtual UDPPtr | open_socket (const uint port)=0 |
| Open a UDP socket for sending and recieving incoming data. More...
|
|
virtual void | connect ()=0 |
|
virtual void | disconnect () |
|
virtual bool | is_connected () const =0 |
|
uint32_t | get_time () |
| make NTP request to get UTC time, using the UDP function above More...
|
|
Abstract internet communication module.
All internet modules inherit from this class.
- Resources
-
Cleaner name for Client smart pointer.
Cleaner name for UDP smart pointer.
Loom Internet Platform module constructor.
- Parameters
-
[in] | module_name | String | <"Internet-Plat"> | null | Internet Platform module name |
virtual LoomInternetPlat::~LoomInternetPlat |
( |
| ) |
|
|
virtualdefault |
virtual void LoomInternetPlat::connect |
( |
| ) |
|
|
pure virtual |
Connect to a domain, but don't write any HTTP stuff, Let the module figure that out.
- Attention
- Remember to close the socket!
- Parameters
-
[in] | domain | The domain to connect to "www.google.com" |
- Returns
- A client reference. The client::connected method will return true if the connection succeeded, and false otherwise.
Connect to a domain, but don't write any HTTP stuff, Let the module figure that out.
- Attention
- Remember to close the socket!
- Parameters
-
[in] | ip | The IPAddress to connect to |
[in] | port | The port to connect to |
- Returns
- A client reference. The client::connected method will return true if the connection succeeded, and false otherwise.
virtual void LoomInternetPlat::disconnect |
( |
| ) |
|
|
inlinevirtual |
virtual SSLClient& LoomInternetPlat::get_client |
( |
| ) |
|
|
protectedpure virtual |
virtual const SSLClient& LoomInternetPlat::get_client |
( |
| ) |
const |
|
protectedpure virtual |
uint32_t LoomInternetPlat::get_time |
( |
| ) |
|
make NTP request to get UTC time, using the UDP function above
- Returns
- a unix timestamp if success, or 0 if failure.
ClientSession LoomInternetPlat::http_get_request |
( |
const char * |
domain, |
|
|
const char * |
url, |
|
|
const char * |
body = nullptr |
|
) |
| |
|
inline |
Make HTTP GET request.
See http_request() for parameter and return details.
ClientSession LoomInternetPlat::http_post_request |
( |
const char * |
domain, |
|
|
const char * |
url, |
|
|
const char * |
body = nullptr |
|
) |
| |
|
inline |
Make HTTP POST request.
See http_request() for parameter and return details.
Make HTTP request.
- Parameters
-
[in] | domain | The domain to connect to (e.g "www.google.com") |
[in] | url | The URL string to send with the http request, not including the domain (ex. "/arduino?thing=otherthing"). |
[in] | body | The body string to use for the rest of the request, including additional headers. Will be appended directly to the request (right after the last header appended by the library) and will need newlines at the top or between additional headers and body. Example: "some-header: thing\r\nsome-other-header:29\r\n\r\n{\"my-json-body":"nice"}" adds two headers (some-header and some-other-header) and has a simple JSON body. Can be nullptr for none. |
[in] | result_size | Size of the buffer pointed to by result, in bytes. If the size of the buffer is exceeded, this function will return false. |
[out] | result | Pointer to the buffer to put data returned from the request in. Can be nullptr if result data is to be discarded. |
[in] | verb | HTTP verb ("PUT", "GET", etc.) to use with this request. |
- Returns
- A client session pointer, or a nullptr if the connection failed. When this pointer is destroyed the client will automatically close the connection.
virtual bool LoomInternetPlat::is_connected |
( |
| ) |
const |
|
pure virtual |
virtual UDPPtr LoomInternetPlat::open_socket |
( |
const uint |
port | ) |
|
|
pure virtual |
Open a UDP socket for sending and recieving incoming data.
- Warning
- Be careful about recieving data from an open socket!
- Returns
- A UDP socket for transmitting and recieving, or a nullptr if opening the socket failed. The socket will automatically close when the pointer is destructed.
Implemented in Loom_LTE, Loom_WiFi, and Loom_Ethernet.
virtual void LoomInternetPlat::package |
( |
JsonObject |
json | ) |
|
|
inlineoverridevirtual |
No package necessary for internet platforms.
implement with empty body.
Implements LoomModule.
Reimplemented in Loom_WiFi.
void LoomInternetPlat::write_http_request |
( |
Stream & |
client, |
|
|
const char * |
domain, |
|
|
const char * |
url, |
|
|
const char * |
body, |
|
|
const char * |
verb |
|
) |
| |
|
protected |
The documentation for this class was generated from the following files: