From 490c583e74d65368b8b6d087c32f68e1df65b300 Mon Sep 17 00:00:00 2001 From: Kevin Loo Keng Leong Date: Thu, 5 Sep 2024 18:19:47 +0800 Subject: [PATCH 1/2] Add Class WiFi API - Class WiFiClient, WiFiServer, WiFiSSLClient, WiFiUdp API - Add E-Paper QR Code example guide - Delete HTTP and E-Paper backup --- bak/API_Documents/WiFi/Class WiFiClient.rst | 348 ------- .../WiFi/Class WiFiSSLClient.rst | 869 ------------------ bak/API_Documents/WiFi/Class WiFiServer.rst | 155 ---- bak/API_Documents/WiFi/Class WiFiUdp.rst | 486 ---------- bak/API_Documents/WiFi/index.rst | 11 - ...er - 7.5-inch e-Book with MicroSD card.rst | 129 --- .../E-paper - Display Images.rst | 145 --- .../E-paper - Display Text.rst | 123 --- ...paper - Display User-generated QR code.rst | 131 --- .../HTTP - HTTP Post MP4.rst | 69 -- .../HTTP - Retrieve HTTP Image and MP4.rst | 45 - .../HTTP - Retrieve HTTP webs.rst | 59 -- .../HTTP - Use IFTTT for Web Service.rst | 247 ----- .../API_Documents/WiFi/Class WiFiClient.rst | 462 ++++++++++ .../WiFi/Class WiFiSSLClient.rst | 526 +++++++++++ .../API_Documents/WiFi/Class WiFiServer.rst | 220 +++++ source/API_Documents/WiFi/Class WiFiUdp.rst | 605 ++++++++++++ source/API_Documents/WiFi/index.rst | 4 + .../Display User-generated QR code.rst | 112 +++ source/Example_Guides/E-Paper/index.rst | 7 + source/Example_Guides/index.rst | 1 + 21 files changed, 1937 insertions(+), 2817 deletions(-) delete mode 100644 bak/API_Documents/WiFi/Class WiFiClient.rst delete mode 100644 bak/API_Documents/WiFi/Class WiFiSSLClient.rst delete mode 100644 bak/API_Documents/WiFi/Class WiFiServer.rst delete mode 100644 bak/API_Documents/WiFi/Class WiFiUdp.rst delete mode 100644 bak/API_Documents/WiFi/index.rst delete mode 100644 bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-Paper - 7.5-inch e-Book with MicroSD card.rst delete mode 100644 bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Images.rst delete mode 100644 bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Text.rst delete mode 100644 bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display User-generated QR code.rst delete mode 100644 bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - HTTP Post MP4.rst delete mode 100644 bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP Image and MP4.rst delete mode 100644 bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP webs.rst delete mode 100644 bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Use IFTTT for Web Service.rst create mode 100644 source/API_Documents/WiFi/Class WiFiClient.rst create mode 100644 source/API_Documents/WiFi/Class WiFiSSLClient.rst create mode 100644 source/API_Documents/WiFi/Class WiFiServer.rst create mode 100644 source/API_Documents/WiFi/Class WiFiUdp.rst create mode 100644 source/Example_Guides/E-Paper/Display User-generated QR code.rst create mode 100644 source/Example_Guides/E-Paper/index.rst diff --git a/bak/API_Documents/WiFi/Class WiFiClient.rst b/bak/API_Documents/WiFi/Class WiFiClient.rst deleted file mode 100644 index 9d8e3b5..0000000 --- a/bak/API_Documents/WiFi/Class WiFiClient.rst +++ /dev/null @@ -1,348 +0,0 @@ -**WiFiClient Class** - -| **Description** -| A class of WiFi Client implementation for Ameba. - -| **Syntax** -| class WiFiClient - -**Members** - -+------------------------------+---------------------------------------+ -| **Public Constructors** |   | -+------------------------------+---------------------------------------+ -| `WiFiClient::WiFiClient `__ | | -+------------------------------+---------------------------------------+ -| **Public Methods** |   | -+------------------------------+---------------------------------------+ -| `WiFiClient::connect < | Connect to the IP address and port | -| https://www.amebaiot.com/en/ | | -| rtl8722dm-arduino-api-wificl | | -| ient/#WiFiClient_connect>`__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::write | Write data (single byte) to the | -| `__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::available `__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::rea | Read the incoming byte from the | -| d `__ | | -+------------------------------+---------------------------------------+ -| WiFiClient::recv | Read the received byte from the | -| | server that the client is connected | -| | to. | -+------------------------------+---------------------------------------+ -| `WiFiClient::pee | Get the next byte from the current | -| k `__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::flush | Clear all the bytes that have been | -| `__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::sto | Disconnect from the server | -| p `__ | | -+------------------------------+---------------------------------------+ -| `WiFiClient::connected `__ | | -+------------------------------+---------------------------------------+ -| `WiFiCli | Set the amount of time the client | -| ent::setRecvTimeout `__ | | -+------------------------------+---------------------------------------+ -| | | -+------------------------------+---------------------------------------+ -| | | -+------------------------------+---------------------------------------+ - -**WiFiClient::WiFiClient** - -| **Description** -| Constructs a WiFiClient instance that connects to a specified IP - address and port. - -| **Syntax** -| WiFiClient(void); - -WiFiClient(uint8_t sock); - -| **Parameters** -| sock: socket state - -| **Returns** -| NA - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::connect** - -| **Description** -| Connect to the IP address and port. - -**Syntax** - -int connect(const char \*host, uint16_t port); - -int connect(IPAddress ip, uint16_t port); - -| **Parameters** -| ip: IP address that the client will connect to -| host: Host name that the client will connect to -| port: the port that the client will connect to - -**Returns** - -This function returns “1” if the connection is successful, else returns -“0”. - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::write** - -| **Description** -| Write data (single byte) to the server that the client is connected - to. - -| **Syntax** -| size_t write(uint8_t b); -| size_t write(const uint8_t \*buf, size_t size); - -| **Parameters** -| b: the byte or char to write -| buf: a pointer to an array containing the outgoing message -| size: the size of the buffer - -**Returns** - -This function returns the byte/ character that will be written to the -server or the size of the buffer. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::available** - -**Description** - -Get the number of bytes available for reading. - -| **Syntax** -| int available(void); - -**Parameters** - -NA - -**Returns** - -This function returns 1 and number of bytes available for reading if -there are available data, else returns 0. - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::read** - -| **Description** -| Read the incoming byte from the server that the client is connected - to. - -**Syntax** - -int read(void); - -int read(uint8_t \*buf, size_t size); - -int read(char \*buf, size_t size); - -| **Parameters** -| buf: buffer to hold incoming byte -| size: maximum size of the buffer - -| **Returns** -| This function returns the size of the buffer or returns -1 if no - buffer is available. - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - -**WiFiClient::recv** - -| **Description** -| Read the received byte from the server that the client is connected - to. - -**Syntax** - -int recv (uint8_t\* buf, size_t size); - -| **Parameters** -| buf: buffer to hold received byte -| size: maximum size of the buffer - -| **Returns** -| This function returns 1 and number of bytes received or returns –1 if - no data is available. - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::peek** - -| **Description** -| Get the next byte from the current packet without moving on to the - next byte. - -| **Syntax** -| int peek(void); - -| **Parameters** -| NA - -**Returns** - -This function returns the next byte or character, else returns -1 if -none is available. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::flush** - -**Description** - -Clear all the bytes that have been written to the client but not yet -read. - -| **Syntax** -| void flush(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::stop** - -| **Description** -| Disconnect from the server. - -| **Syntax** -| void stop(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::connected** - -| **Description** -| Check if client is connected. - -| **Syntax** -| virtual uint8_t connected(void); - -| **Parameters** -| NA - -| **Returns** -| This function returns “1” if connected, returns “0” if not connected. - -| **Example Code** -| Example: WiFiWebClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebClient/WiFiWebClient.ino) - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. - - -**WiFiClient::setRecvTimeout** - -| **Description** -| Set the amount of time the client will wait for new data to arrive - each time WiFiClient::read() is called. - -| **Syntax** -| int setRecvTimeout(int timeout); - -| **Parameters** -| timeout: timeout in seconds - -| **Returns** -| This function returns “0” if client is not connected. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiClient.h” must be included to use the class function. diff --git a/bak/API_Documents/WiFi/Class WiFiSSLClient.rst b/bak/API_Documents/WiFi/Class WiFiSSLClient.rst deleted file mode 100644 index a697078..0000000 --- a/bak/API_Documents/WiFi/Class WiFiSSLClient.rst +++ /dev/null @@ -1,869 +0,0 @@ -**WiFiSSLClient Class** - -| **Description** -| A class for Wi-Fi Secure Socket Layer Client implementation for Ameba. - -| **Syntax** -| class WiFiSSLClient - -**Members** - -+---------------------------+---+-----------------------------------------+ -| **Public Constructors** | |   | -+===========================+===+=========================================+ -| `W | C | | -| iFiSSLClient::WiFiSSLClie | o | | -| nt `__ | r | | -| | u | | -| | c | | -| | t | | -| | s | | -| | a | | -| | W | | -| | i | | -| | F | | -| | i | | -| | S | | -| | S | | -| | L | | -| | C | | -| | l | | -| | i | | -| | e | | -| | n | | -| | t | | -| | i | | -| | n | | -| | s | | -| | t | | -| | a | | -| | n | | -| | c | | -| | e | | -| | t | | -| | h | | -| | a | | -| | t | | -| | a | | -| | l | | -| | w | | -| | a | | -| | y | | -| | s | | -| | c | | -| | o | | -| | n | | -| | n | | -| | e | | -| | c | | -| | t | | -| | s | | -| | i | | -| | n | | -| | S | | -| | S | | -| | L | | -| | t | | -| | o | | -| | t | | -| | h | | -| | e | | -| | s | | -| | p | | -| | e | | -| | c | | -| | i | | -| | f | | -| | i | | -| | e | | -| | d | | -| | I | | -| | P | | -| | a | | -| | d | | -| | d | | -| | r | | -| | e | | -| | s | | -| | s | | -| | a | | -| | n | | -| | d | | -| | p | | -| | o | | -| | r | | -| | t | | -+---------------------------+---+-----------------------------------------+ -| **Public Methods** |   | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLClient: | C | | -| :connect `__ | e | | -| | c | | -| | t | | -| | t | | -| | o | | -| | t | | -| | h | | -| | e | | -| | I | | -| | P | | -| | a | | -| | d | | -| | d | | -| | r | | -| | e | | -| | s | | -| | s | | -| | a | | -| | n | | -| | d | | -| | p | | -| | o | | -| | r | | -| | t | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLCli | W | | -| ent::write `__ | e | | -| | d | | -| | a | | -| | t | | -| | a | | -| | ( | | -| | s | | -| | i | | -| | n | | -| | g | | -| | l | | -| | e | | -| | b | | -| | y | | -| | t | | -| | e | | -| | ) | | -| | t | | -| | o | | -| | t | | -| | h | | -| | e | | -| | s | | -| | e | | -| | r | | -| | v | | -| | e | | -| | r | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLClient::ava | G | | -| ilable `__ | h | | -| | e | | -| | a | | -| | v | | -| | a | | -| | i | | -| | l | | -| | a | | -| | b | | -| | i | | -| | l | | -| | i | | -| | t | | -| | y | | -| | o | | -| | f | | -| | t | | -| | h | | -| | e | | -| | W | | -| | i | | -| | - | | -| | F | | -| | i | | -| | S | | -| | S | | -| | L | | -| | s | | -| | o | | -| | c | | -| | k | | -| | e | | -| | t | | -| | f | | -| | o | | -| | r | | -| | r | | -| | e | | -| | a | | -| | d | | -| | i | | -| | n | | -| | g | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLC | R | | -| lient::read `__ | t | | -| | h | | -| | e | | -| | i | | -| | n | | -| | c | | -| | o | | -| | m | | -| | i | | -| | n | | -| | g | | -| | b | | -| | y | | -| | t | | -| | e | | -| | f | | -| | r | | -| | o | | -| | m | | -| | t | | -| | h | | -| | e | | -| | s | | -| | e | | -| | r | | -| | v | | -| | e | | -| | r | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLC | G | | -| lient::peek `__ | h | | -| | e | | -| | n | | -| | e | | -| | x | | -| | t | | -| | b | | -| | y | | -| | t | | -| | e | | -| | f | | -| | r | | -| | o | | -| | m | | -| | t | | -| | h | | -| | e | | -| | c | | -| | u | | -| | r | | -| | r | | -| | e | | -| | n | | -| | t | | -| | p | | -| | a | | -| | c | | -| | k | | -| | e | | -| | t | | -| | w | | -| | i | | -| | t | | -| | h | | -| | o | | -| | u | | -| | t | | -| | m | | -| | o | | -| | v | | -| | i | | -| | n | | -| | g | | -| | o | | -| | n | | -| | t | | -| | o | | -| | t | | -| | h | | -| | e | | -| | n | | -| | e | | -| | x | | -| | t | | -| | b | | -| | y | | -| | t | | -| | e | | -| | . | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLCli | C | | -| ent::flush `__ | r | | -| | a | | -| | l | | -| | l | | -| | t | | -| | h | | -| | e | | -| | b | | -| | y | | -| | t | | -| | e | | -| | s | | -| | t | | -| | h | | -| | a | | -| | t | | -| | h | | -| | a | | -| | v | | -| | e | | -| | b | | -| | e | | -| | e | | -| | n | | -| | w | | -| | r | | -| | i | | -| | t | | -| | t | | -| | e | | -| | n | | -| | t | | -| | o | | -| | t | | -| | h | | -| | e | | -| | c | | -| | l | | -| | i | | -| | e | | -| | n | | -| | t | | -| | b | | -| | u | | -| | t | | -| | n | | -| | o | | -| | t | | -| | y | | -| | e | | -| | t | | -| | r | | -| | e | | -| | a | | -| | d | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLC | D | | -| lient::stop `__ | o | | -| | n | | -| | n | | -| | e | | -| | c | | -| | t | | -| | f | | -| | r | | -| | o | | -| | m | | -| | t | | -| | h | | -| | e | | -| | s | | -| | e | | -| | r | | -| | v | | -| | e | | -| | r | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLClient::con | C | | -| nected `__ | k | | -| | i | | -| | f | | -| | S | | -| | S | | -| | L | | -| | c | | -| | l | | -| | i | | -| | e | | -| | n | | -| | t | | -| | i | | -| | s | | -| | c | | -| | o | | -| | n | | -| | n | | -| | e | | -| | c | | -| | t | | -| | e | | -| | d | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLClient::set | S | | -| RootCA `__ | o | | -| | o | | -| | t | | -| | C | | -| | A | | -| | f | | -| | o | | -| | r | | -| | a | | -| | u | | -| | t | | -| | h | | -| | e | | -| | n | | -| | t | | -| | i | | -| | c | | -| | a | | -| | t | | -| | i | | -| | o | | -| | n | | -+---------------------------+---+-----------------------------------------+ -| `WiFiSSLClient:: | S | | -| setClientCertificate `__ | r | | -| | t | | -| | i | | -| | f | | -| | i | | -| | c | | -| | a | | -| | t | | -| | e | | -| | o | | -| | f | | -| | t | | -| | h | | -| | e | | -| | c | | -| | l | | -| | i | | -| | e | | -| | n | | -| | t | | -+---------------------------+---+-----------------------------------------+ -| `WiF | S | | -| iSSLClient::setRecvTimeou | e | | -| t `__ | c | | -| | e | | -| | i | | -| | v | | -| | i | | -| | n | | -| | g | | -| | t | | -| | i | | -| | m | | -| | e | | -| | o | | -| | u | | -| | t | | -+---------------------------+---+-----------------------------------------+ -| `WiFiS | S | | -| SLClient::setPreSharedKey | e | | -| `__ | e | | -| | P | | -| | r | | -| | e | | -| | S | | -| | h | | -| | a | | -| | r | | -| | e | | -| | d | | -| | K | | -| | e | | -| | y | | -| | ( | | -| | P | | -| | S | | -| | K | | -| | ) | | -| | t | | -| | o | | -| | u | | -| | s | | -| | e | | -| | f | | -| | o | | -| | r | | -| | a | | -| | u | | -| | t | | -| | h | | -| | e | | -| | n | | -| | t | | -| | i | | -| | c | | -| | a | | -| | t | | -| | i | | -| | o | | -| | n | | -+---------------------------+---+-----------------------------------------+ - - -**WiFiSSLClient::WiFiSSLClient** - -| **Description** -| Constructs a WiFiSSLClient instance that always connects in SSL to the - specified IP address and port. - -| **Syntax** -| WiFiSSLClient(void); - -WiFiSSLClient(uint8_t sock); - -| **Parameters** -| sock: socket state, default -1 - -| **Returns** -| NA - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::connect** - -| **Description** -| Connect to the IP address and port. - -**Syntax** - -virtual int connect(IPAddress ip, uint16_t port); - -virtual int connect(const char \*host, uint16_t port); - -virtual uint8_t connected(void); - -int connect(const char \*host, uint16_t port, unsigned char\* -rootCABuff, unsigned char\* cli_cert, unsigned char\* cli_key); - -int connect(IPAddress ip, uint16_t port, unsigned char\* rootCABuff, -unsigned char\* cli_cert, unsigned char\* cli_key); - -int connect(const char \*host, uint16_t port, unsigned char\* pskIdent, -unsigned char\* psKey); - -int connect(IPAddress ip, uint16_t port, unsigned char\* pskIdent, -unsigned char\* psKey); - -| **Parameters** -| ip: IP address -| host: Host name -| port: the port to listen to -| rootCABuff: buffer that store root CA -| cli_cert: buffer that store client certificate -| cli_key: buffer that store client key pair - -| pskIdent: identity for PSK -| psKey: Pre shared key - -| **Returns** -| This function returns “1” if successful, else returns “0”. - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - -**WiFiSSLClient::write** - -**Description** - -Write data (single byte) to the server the SSL client is connected to. - -| **Syntax** -| virtual size_t write(uint8_t); - -virtual size_t write(const uint8_t \*buf, size_t size); - -| **Parameters** -| buf: a pointer to an array containing the outgoing message -| size: the size of the buffer - -| **Returns** -| This function returns the byte/ character that will be written to the - server or the size of the buffer. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::available** - -| **Description** -| Get the availability of the Wi-Fi SSL socket for reading. - -| **Syntax** -| virtual int available(void); - -| **Parameters** -| NA - -**Returns** - -This function returns “1” and number of bytes available for reading if -there are available data, else returns 0. - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::read** - -| **Description** -| Read the incoming byte from the server that the SSL client is - connected to. - -| **Syntax** -| virtual int read(void); - -virtual int read(uint8_t \*buf, size_t size); - -| **Parameters** -| buf: buffer that holds incoming data in 8-bit -| size: maximum size of the buffer - -| **Returns** -| This function returns the size of the buffer or returns “-1” if no - buffer is available. - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::peek** - -| **Description** -| Get the next byte from the current packet without moving on to the - next byte. - -| **Syntax** -| virtual int peek(void); - -| **Parameters** -| NA - -**Returns** - -This function returns the next byte or character, else returns -1 if -none is available. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::flush** - -| **Description** -| Clear all the bytes that have been written to the client but not yet - read. - -| **Syntax** -| virtual void flush(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::stop** - -| **Description** -| Disconnect from the server. - -**Syntax** - -virtual void stop (void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::connected** - -| **Description** -| Check if SSL client is connected. - -| **Syntax** -| virtual uint8_t connected(void); - -| **Parameters** -| NA - -| **Returns** -| The function returns “1” if the SSLClient socket is connected, else - returns “0” if not connected. - -| **Example Code** -| Example: WiFiSSLClient - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino) - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::setRootCA** - -| **Description** -| Set Root CA(certification authority) for SSL authentication. - -| **Syntax** -| void setRootCA(unsigned char \*rootCA); - -| **Parameters** -| rootCA: a string of rootCA - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::setClientCertificate** - -| **Description** -| Set certificate of the client. - -| **Syntax** -| void setClientCertificate(unsigned char \*client_ca, unsigned char - \*private_key); - -| **Parameters** -| client_ca: Client certificate -| private_key: client’s private key pair - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::setRecvTimeout** - -| **Description** -| This function sets the SSL client socket receiving timeout. - -| **Syntax** -| int setRecvTimeout(int timeout); - -| **Parameters** -| timeout: timeout in seconds - -| **Returns** -| The function returns “0”. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiSSLClient.h” must be included to use the class function. - - -**WiFiSSLClient::setPreSharedKey** - -| **Description** -| Set the Pre Shared Key (PSK) to use for authentication. - -| **Syntax** -| void setPreSharedKey(unsigned char \*pskIdent, unsigned char \*psKey); - -| **Parameters** -| pskIdent: identity for PSK -| psKey: Pre shared key - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| Do not set a root CA and client certificate if PSK should be used for - authentication. If root CA, client certificate and PSK are all set, - certificate-based authentication will be used. “WiFiSSLClient.h” must - be included to use the class function. diff --git a/bak/API_Documents/WiFi/Class WiFiServer.rst b/bak/API_Documents/WiFi/Class WiFiServer.rst deleted file mode 100644 index 2451025..0000000 --- a/bak/API_Documents/WiFi/Class WiFiServer.rst +++ /dev/null @@ -1,155 +0,0 @@ -**WiFiServer Class** - -| **Description** -| A class of WiFi server implementation for Ameba. - -| **Syntax** -| class WiFiServer - -**Members** - -+------------------------+---------------------------------------------+ -| **Public |   | -| Constructors** | | -+========================+=============================================+ -| `W | Constructs a WiFiServer object and creates | -| iFiServer::WiFiServer | a server that listens for incoming | -| `__ | | -+------------------------+---------------------------------------------+ -| **Public Methods** |   | -+------------------------+---------------------------------------------+ -| `WiFiServer::available | Gets a client that is connected to the | -| `__ | | -+------------------------+---------------------------------------------+ -| `WiFiServer::b | Server start listening for incoming | -| egin `__ | | -+------------------------+---------------------------------------------+ -| `WiFiServer::w | Write data to all the clients connected to | -| rite `__ | | -+------------------------+---------------------------------------------+ - - -**WiFiServer::WiFiServer** - -| **Description** -| Constructs a WiFiServer object and creates a server that listens for - incoming connections on the specified port. - -| **Syntax** -| WiFiServer (uint16_t port); - -| **Parameters** -| port: The port number being connected to. - -| **Returns** -| NA - -| **Example Code** -| Example: SimpleServerWiFi - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/SimpleServerWiFi/SimpleServerWiFi.ino) - -| **Notes and Warnings** -| “WiFiServer.h” must be included to use the class function. - - -**WiFiServer::available** - -| **Description** -| Gets a client that is connected to the server and has data available - for reading. The connection persists when the returned client object - goes out of scope; you can close it by calling the client.stop(). - -| **Syntax** -| WiFiClient available(uint8_t\* status = NULL); - -| **Parameters** -| status: Wi-Fi availability status. Default value: NULL - -| **Returns** -| This function returns a client object; if no Client has data available - for reading, this object will evaluate to false in an if-statement - -| **Example Code** -| Example: SimpleServerWiFi - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/SimpleServerWiFi/SimpleServerWiFi.ino) - -| **Notes and Warnings** -| “WiFiServer.h” must be included to use the class function. - - -**WiFiServer::begin** - -| **Description** -| Server start listening for incoming connections. - -| **Syntax** -| void begin(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| Example: SimpleServerWiFi - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/SimpleServerWiFi/SimpleServerWiFi.ino) - -| **Notes and Warnings** -| “WiFiServer.h” must be included to use the class function. - -**WiFiServer::connected** - -| **Description** -| Check if server is still connected - -| **Syntax** -| uint8_t connected(); - -| **Parameters** -| NA - -| **Returns** -| This function returns ‘1’ if connected, returns ‘0’ if not connected. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiServer.h” must be included to use the class function. - -**WiFiServer::write** - -| **Description** -| Write data to all the clients connected to a server. - -| **Syntax** -| virtual size_t write(uint8_t b); - -| **Parameters** -| b: byte to be written -| buf: data buffer -| size: size of the data buffer - -| **Returns** -| This function returns the number of bytes written. It is not necessary - to read this. - -| **Example Code** -| Example: SimpleServerWiFi - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/SimpleServerWiFi/SimpleServerWiFi.ino) - -| **Notes and Warnings** -| “WiFiServer.h” must be included to use the class function. diff --git a/bak/API_Documents/WiFi/Class WiFiUdp.rst b/bak/API_Documents/WiFi/Class WiFiUdp.rst deleted file mode 100644 index 3ddb0e5..0000000 --- a/bak/API_Documents/WiFi/Class WiFiUdp.rst +++ /dev/null @@ -1,486 +0,0 @@ -**WiFiUDP Class** - -| **Description** -| A class used for managing WiFi UDP implementation for Ameba. - -| **Syntax** -| class WiFiUDP - -**Members** - -+----------------------+-----------------------------------------------+ -| **Public |   | -| Constructors** | | -+======================+===============================================+ -| `WiFiUDP::WiFiUDP | Constructs a WiFiUDP instance of the Wi-Fi | -| `__ | | -+----------------------+-----------------------------------------------+ -| **Public Methods** |   | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::beg | Initialize Wi-Fi UDP library, network | -| in `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::s | Disconnect from the server | -| top `__ | | -+----------------------+-----------------------------------------------+ -| `WiFi | Start building up a packet to send to the | -| UDP::beginPacket `__ | | -+----------------------+-----------------------------------------------+ -| ` | Finish off this packet and send it | -| WiFiUDP::endPacket < | | -| https://www.amebaiot | | -| .com/en/rtl8722dm-ar | | -| duino-api-wifiudp/#W | | -| iFiUDP_endPacket>`__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::wri | Write UDP data (single byte) to remote | -| te `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::write | Send packet immediately from the buffer | -| Immediately `__ | | -+----------------------+-----------------------------------------------+ -| `WiFi | Check for the presence of a UDP packets and | -| UDP::parsePacket `__ | | -+----------------------+-----------------------------------------------+ -| ` | Get the number of bytes (characters) | -| WiFiUDP::available < | available for reading from the buffer | -| https://www.amebaiot | | -| .com/en/rtl8722dm-ar | | -| duino-api-wifiudp/#W | | -| iFiUDP_available>`__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::r | Read UDP data from specified buffer | -| ead `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::p | Get the next byte from the current packet | -| eek `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::flu | Clear all the bytes that have been written to | -| sh `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::remoteIP | Get the IP address of the remote connection | -| `__ | | -+----------------------+-----------------------------------------------+ -| `Wi | Get the port of the remote UDP connection who | -| FiUDP::remotePort `__ | | -+----------------------+-----------------------------------------------+ -| `WiFiUDP::s | Set receiving timeout | -| etRecvTimeout `__ | | -+----------------------+-----------------------------------------------+ - - -**WiFiUDP::WiFiUDP** - -| **Description** -| Constructs a WiFiUDP instance of the Wi-Fi UDP class that can send and - receive UDP messages. - -| **Syntax** -| WiFiUDP (void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| This constructor does not take in any parameter, thus use another - method to set up the IP address and port number. “WiFiUdp.h” must be - included to use the class function. - - -**WiFiUDP::begin** - -| **Description** -| Initialize Wi-Fi UDP library, network settings and start listening at - specified local port. - -| **Syntax** -| virtual uint8_t begin(uint16_t); - -| **Parameters** -| port: the local port to listen on - -**Returns** - -This function returns 1 if successful, else returns 0 if there are no -sockets available to use. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::stop** - -| **Description** -| Disconnect from the server. Release any resource being used during the - UDP session. - -| **Syntax** -| virtual void stop(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::beginPacket** - -**Description** - -Start building up a packet to send to the remote host-specific in IP and -port. - -| **Syntax** -| virtual int beginPacket(IPAddress ip, uint16_t port); - -virtual int beginPacket(const char \*host, uint16_t port); - -| **Parameters** -| host: remote host name -| port: the port of the remote connection -| ip: IP address of the remote connection - -**Returns** - -This function returns “1” of successful, else returns “0” if there is a -problem with the given IP address or port. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::endPacket** - -| **Description** -| Finish off the packet and send it. - -| **Syntax** -| virtual int endPacket(void); - -| **Parameters** -| NA - -**Returns** - -This function returns “1” if packet was sent successfully, else returns -“0” if there was an error. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::write** - -**Description** - -Write UDP data (single byte) to remote connection. - -| **Syntax** -| virtual size_t write(uint8_t); - -virtual size_t write(const uint8_t \*buffer, size_t size); - -| **Parameters** -| buf: a pointer to an array containing the outgoing message -| size: the size of the buffer - -| **Returns** -| This function returns the byte/ character that will be written to the - server or the size of the buffer. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| This function must be wrapped between beginPacket() and endPacket(). - beginPacket() initializes the packet of data, it is not sent until - endPacket() is called. “WiFiUdp.h” must be included to use the class - function. - - -**WiFiUDP::writeImmediately** - -| **Description** -| Send packet immediately from the buffer. - -| **Syntax** -| size_t writeImmediately(const uint8_t \*buffer, size_t size); - -| **Parameters** -| buf: a pointer to an array containing the outgoing message -| size: the size of the buffer - -| **Returns** -| This function returns the byte/ character that will be written to the - server or the size of the buffer. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::parsePacket** - -| **Description** -| Check for the presence of a UDP packets and start processing the next - available incoming packet. - -| **Syntax** -| virtual int parsePacket(void); - -| **Parameters** -| NA - -**Returns** - -This function returns the number of bytes available in the current -packet, will return "0” if WiFiUDP.parsePacket() hasn't been called yet. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::available** - -| **Description** -| Get the number of bytes (characters) available for reading from the - buffer. - -| **Syntax** -| virtual int available(void); - -| **Parameters** -| NA - -**Returns** - -This function returns the number of bytes available in the current -packet, else returns “0” if WiFiUDP.parsePacket() hasn’t been called -yet. - -| **Example Code** -| NA - -| **Notes and Warnings** -| This function can only be successfully called after - WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class - function. - - -**WiFiUDP::read** - -| **Description** -| Read UDP data from specified buffer. - -| **Syntax** -| virtual int read (void); -| virtual int read (char\* buffer, size_t len); - -| **Parameters** -| buf: buffer to hold incoming byte -| size: maximum size of the buffer - -| **Returns** -| This function returns the size of the buffer or returns -1 if no - buffer is available. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| This function can only be successfully called after - WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class - function. - - -**WiFiUDP::peek** - -| **Description** -| Get the next byte from the current packet without moving on to the - next byte. - -| **Syntax** -| virtual int peek (void); - -| **Parameters** -| NA - -**Returns** - -This function returns the next byte or character or returns -1 if none -is available. - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function.\ ** - -**WiFiUDP::flush** - -| **Description** -| Clear all the bytes that have been written to the client but not yet - read. - -| **Syntax** -| virtual void flush(void); - -| **Parameters** -| NA - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. - - -**WiFiUDP::remoteIP** - -| **Description** -| Get the IP address of the remote connection who sent the current - incoming packet. - -| **Syntax** -| virtual IPAddress remoteIP(void); - -| **Parameters** -| NA - -| **Returns** -| This function returns the IP address of the remote connection. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -**Notes and Warnings** - -This function must be called after WiFiUDP.parsePacket(). “WiFiUdp.h” -must be included to use the class function. - - -**WiFiUDP::remotePort** - -| **Description** -| Get the port of the remote UDP connection who sent the current - incoming packet. - -| **Syntax** -| virtual uint16_t remotePort(void); - -| **Parameters** -| NA - -| **Returns** -| This function returns the port of the remote connection. - -| **Example Code** -| Example: WiFiUdpSendReceiveString - (https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino) - -| **Notes and Warnings** -| This function must be called after WiFiUDP.parsePacket(). “WiFiUdp.h” - must be included to use the class function. - - -**WiFiUDP::setRecvTimeout** - -| **Description** -| Set receiving timeout - -| **Syntax** -| void setRecvTimeout(int timeout); - -| **Parameters** -| timeout: timeout in seconds - -| **Returns** -| NA - -| **Example Code** -| NA - -| **Notes and Warnings** -| “WiFiUdp.h” must be included to use the class function. diff --git a/bak/API_Documents/WiFi/index.rst b/bak/API_Documents/WiFi/index.rst deleted file mode 100644 index c7c18c4..0000000 --- a/bak/API_Documents/WiFi/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -WiFi -==== - -.. toctree:: - :maxdepth: 1 - - Class WiFi - Class WiFiClient - Class WiFiServer - Class WiFiSSLClient - Class WiFiUdp diff --git a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-Paper - 7.5-inch e-Book with MicroSD card.rst b/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-Paper - 7.5-inch e-Book with MicroSD card.rst deleted file mode 100644 index 87b69a9..0000000 --- a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-Paper - 7.5-inch e-Book with MicroSD card.rst +++ /dev/null @@ -1,129 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- Waveshare E-Paper [7.5-inch E-Ink display HAT] x1 - -- Button x 1 - -- MicroSD card x 1 - -- 330 Ohm resistor x1 - -Introduction - -In this example, we will be connecting Ameba Pro2 board to Waveshare -7.5-inch e-Paper module to be used as an e-Book. The 7.5” active area -contains 800 x 480 pixels and has 1-bit white/black full display -capabilities. An integrated circuit contains gate buffer, source buffer, -interface, timing control logic, oscillator, etc. are supplied with each -panel. You may refer to [7.5inch-e-paper-specification] -(https://www.waveshare.com/w/upload/6/60/7.5inch_e-Paper_V2_Specification.pdf) -for more information about this e-Paper module. - -Procedure - -**AMB82-Mini wiring diagram:** - -Do note that Display Config should be set to B and Interface Config -should be set to 0. - -|image1| - -|image2| - -| Next, download the Eink zip library, AmebaEink.zip, - at https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_zip_libraries -| Then install the AmebaEink.zip by navigating to “Sketch” -> “Include - Library” -> “Add .ZIP Library…”. - -After AmebaEink.zip is installed, Open the “Eink_7in5_Ebook” example by -selecting “File” -> “Examples” -> “AmebaEink” -> “EPD_7in5” -> -“Eink_7in5_Ebook”. - -|image3| - -Next, insert the MicroSD card into your computer and create a new text -file named “User_Ebook.txt”. Then, save the content that you would like -to display in the text file (Note: do only include words). The content -of “User_Ebook.txt” shown below is for illustration purposes only. - -|image4| - -|image5| - -Alternatively, if you prefer another filename for your text file, you -can modify the highlighted code snippet in the sketch with the new -filename. - -|image6| - -Once the file is created, insert the MicroSD card into the onboard SD -card reader on AMB82 Mini. Upload the code and press the reset button -once the uploading is done. When the reset button is pressed, the -e-Paper display will refresh and display a cover page. - -|image7| - -By pressing the button, the content in the selected text file saved in -MicroSD card will be read and displayed onto the e-Paper display. The -content will be split into pages. - -To proceed to the next page, press the button once more. The page number -will be shown at the bottom right-hand corner as the page changes. You -will see the following in either portrait or landscape mode based on -your orientation choice after button is pressed: - -|image8| |image9| - -You can modify the highlighted code snippet to change the font size or -orientation of the displayed text. - -| Supported font size: 16, 20, 24 -| Supported orientation: 0 degree – 0 (landscape), 90 degree – 1 - (portrait), 180 degree- 2 (landscape), 270 degree – 3 (portrait) - -|image10| - -Code Reference - -| [1] We use waveshare 7.5-inch e-Paper display module/ 800×480 - Resolution driver code to get e-Paper successfully display: -| https://github.com/waveshare/e-Paper/tree/master/Arduino/epd7in5_V2 - -[2] EPD libraries can be obtained from: -https://github.com/waveshare/e-Paper - -| [3] Text Wrap function was written reference to: -| https://www.cprogramming.com/snippets/source-code/word-wrap-in-c - -.. |image1| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image01.png - :width: 3.63575in - :height: 4.66995in -.. |image2| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image02.png - :width: 6.25347in - :height: 3.36389in -.. |image3| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image03.png - :width: 3.696in - :height: 4.00332in -.. |image4| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image04.png - :width: 4.09722in - :height: 1.06292in -.. |image5| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image05.png - :width: 4.32639in - :height: 0.92571in -.. |image6| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image06.png - :width: 4.11435in - :height: 4.456in -.. |image7| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image7.jpeg - :width: 2.6495in - :height: 3.536in -.. |image8| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image8.jpeg - :width: 2.64931in - :height: 3.53574in -.. |image9| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image9.jpeg - :width: 3.368in - :height: 2.7056in -.. |image10| image:: ../../_static/Example_Guides/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card/E-Paper_-_7.5-inch_e-Book_with_MicroSD_card_images/image10.png - :width: 4.12913in - :height: 4.472in diff --git a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Images.rst b/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Images.rst deleted file mode 100644 index fead225..0000000 --- a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Images.rst +++ /dev/null @@ -1,145 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- Waveshare E-Paper [2.9inch E-Paper HAT (D)/ 2.9inch E-Paper V2/ - 2.9inch e-Paper Module (B)/ 4.2inch e-Paper Module/ 7.5-inch E-Ink - display HAT] x1 - -Example - -Introduction -============ - -In this example, Ameba Pro2 board will be used to connect to a Waveshare -e-Paper module (2.9inch/ 4.2inch/ 7.5inch) to display images. The -display uses the flexible substrate as base plate, with an interface and -a reference system design. You may refer to the -official `datasheet `__ to -know more information about these modules. - -Procedure -========= - -**AMB82-Mini wiring diagram:** - -*2.9inch HAT (D) e-Paper Module* - -|image1| - -*2.9inch E-Paper V2 e-Paper Module/ 2.9inch e-Paper Module (B)* - -|image2| - -*4.2inch e-Paper Module* - -|image3| - -*7.5-inch e-Paper Module* - -Do note that Display Config should be set to B and Interface Config -should be set to 0. - -|image4| - -Firstly, prepare a picture/photo and resize the image based on the -e-Paper display that you are using. You can look for a photo resizing -tool online, for example, the `Online Image -Resizer `__. Simply follow the instructions on -the website to resize the picture and download the resized image in JPEG -format. - -2.9” e-Paper module: 296×128 pixels - -4.2” e-Paper module: 400x300 pixels - -7.5” e-Paper module: 800x480 pixels - -Secondly, -use `Image2LCD `__ tool -to convert the resized JPEG image into hexadecimal codes. You can visit -this `YouTube `__ link -to learn more about how to use the Image2LCD tool. - -| Next, download the Eink zip library, AmebaEink.zip, - at https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_zip_libraries -| Then install the AmebaEink.zip by navigating to “Sketch” -> “Include - Library” -> “Add .ZIP Library…”. - -Eink examples are categorised based on the size and modules of the -e-Paper display. - -|image5| - -Open one of the “EinkDisplayImages” examples. For example, “File” → -“Examples” → “AmebaEink” → “EPD_2in9v2”-> “EinkDisplayImages”: - -|image6| - -You may choose any GPIO pins for Busy, Reset and DC pin. You can refer -to -https://www.amebaiot.com/en/amebapro2-amb82-mini-arduino-getting-started/ -for AMB82-Mini’s pinmap. - -|A screenshot of a computer Description automatically generated| - -Upload the code to the board and press the reset button after uploading -is done. Wait for around 1-2 seconds for the e-Paper module to refresh -its screen. Images will start to loop on the e-Paper display, each image -will be displaying for 4 seconds. - -|image7| |image8| - -The 2.9-inch e-Paper Module (B) supports three colours—red, black, and -white. You may refer to the example for 2.9-inch e-Paper Module (B) to -learn how to display red images by navigating to “File” → “Examples” → -“AmebaEink” → “EPD_2in9b”-> “EinkDisplayImages”. - -Red image displaying on 2.9-inch Module (B) e-Paper display is shown -below. - -|image9| - -Code Reference - -| [1] We use Good Display GDEH029A1 2.9 Inch / 296×128 Resolution / - Partial Refresh Arduino Sample Code to get the e-Paper successfully - Display: -| http://www.good-display.com/product/201.html - -[2] EPD libraries can be obtained from: -https://github.com/waveshare/e-Paper - -| [3] Generate a QR code on the E-paper module: -| https://eugeniopace.org/qrcode/arduino/eink/2019/07/01/qrcode-on-arduino.html - -.. |image1| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image01.png - :width: 4.99828in - :height: 2.48in -.. |image2| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image02.png - :width: 5.112in - :height: 2.3361in -.. |image3| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image03.png - :width: 4.64935in - :height: 2.68645in -.. |image4| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image04.png - :width: 4.53247in - :height: 3.07025in -.. |image5| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image05.png - :width: 3.76736in - :height: 4.24392in -.. |image6| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image06.png - :width: 3.76736in - :height: 4.24392in -.. |A screenshot of a computer Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image07.png - :width: 3.37392in - :height: 3.79781in -.. |image7| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image8.jpeg - :width: 2.98067in - :height: 3.784in -.. |image8| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image9.jpeg - :width: 2.83714in - :height: 3.78642in -.. |image9| image:: ../../_static/Example_Guides/E-paper_-_Display_Images/E-paper_-_Display_Images_images/image10.jpeg - :width: 4.32in - :height: 3.23724in diff --git a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Text.rst b/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Text.rst deleted file mode 100644 index 8906222..0000000 --- a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display Text.rst +++ /dev/null @@ -1,123 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- Waveshare E-Paper [2.9inch E-Paper HAT (D)/ 2.9inch E-Paper V2/ - 2.9inch e-Paper Module (B)/ 4.2inch e-Paper Module/ 7.5-inch E-Ink - display HAT] x1 - -Example - -Introduction -============ - -In this example, Ameba Pro2 board will be used to connect to a Waveshare -e-Paper module (2.9inch/ 4.2inch/ 7.5inch) to display texts. The display -uses the flexible substrate as base plate, with an interface and a -reference system design. You may refer to the -official `datasheet `__ to -know more information about these modules. - -Procedure -========= - -**AMB82-Mini wiring diagram:** - -*2.9inch HAT (D) e-Paper Module* - -|A picture containing text, rectangle, screenshot, design Description -automatically generated| - -*2.9inch E-Paper V2 e-Paper Module/ 2.9inch e-Paper Module (B)* - -|A picture containing text, screenshot, rectangle Description -automatically generated| - -*4.2inch e-Paper Module* - -|A picture containing electronics, text, circuit, electronic component -Description automatically generated| - -*7.5-inch e-Paper Module* - -Do note that Display Config should be set to B and Interface Config -should be set to 0. - -|A picture containing text, screenshot, electronic engineering, -electronics Description automatically generated| - -| Next, download the Eink zip library, AmebaEink.zip, - at https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_zip_libraries -| Then install the AmebaEink.zip by navigating to “Sketch” -> “Include - Library” -> “Add .ZIP Library…”. - -Eink examples are categorised based on the size and modules of the -e-Paper display. - -|A screenshot of a computer Description automatically generated| - -Open one of the “EinkDisplayText” examples. For example, “File” → -“Examples” → “AmebaEink” → “EPD_2in9v2”-> “EinkDisplayText”: - -|image1| - -You may choose any GPIO pins for Busy, Reset and DC pin. You can refer -to -https://www.amebaiot.com/en/amebapro2-amb82-mini-arduino-getting-started/ -for AMB82-Mini’s pinmap. - -|image2| - -Upload the code to the board and press the reset button after uploading -is done. You will find these texts displayed on the boards: - -The 2.9-inch e-Paper Module (B) supports three colours—red, black, and -white. Therefore, it can display red on the e-Paper display shown on the -most left. - -|image3| - -|image4| - -|image5| - -Code Reference - -| [1] We use Good Display GDEH029A1 2.9 Inch / 296×128 Resolution / - Partial Refresh Arduino Sample Code to get the e-Paper successfully - Display: -| http://www.good-display.com/product/201.html - -[2] EPD libraries can be obtained from: -https://github.com/waveshare/e-Paper - -.. |A picture containing text, rectangle, screenshot, design Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image01.png - :width: 4.99828in - :height: 2.48in -.. |A picture containing text, screenshot, rectangle Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image02.png - :width: 5.112in - :height: 2.3361in -.. |A picture containing electronics, text, circuit, electronic component Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image03.png - :width: 4.64935in - :height: 2.68645in -.. |A picture containing text, screenshot, electronic engineering, electronics Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image04.png - :width: 4.53247in - :height: 3.07025in -.. |A screenshot of a computer Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image05.png - :width: 3.76736in - :height: 4.24392in -.. |image1| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image06.png - :width: 4.14334in - :height: 4.38679in -.. |image2| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image07.png - :width: 4.03641in - :height: 4.27358in -.. |image3| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image8.jpeg - :width: 2.80117in - :height: 3.73779in -.. |image4| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image9.jpeg - :width: 2.97575in - :height: 3.97075in -.. |image5| image:: ../../_static/Example_Guides/E-paper_-_Display_Text/E-paper_-_Display_Text_images/image10.jpeg - :width: 3.96626in - :height: 5.29245in diff --git a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display User-generated QR code.rst b/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display User-generated QR code.rst deleted file mode 100644 index 0450e2b..0000000 --- a/bak/Example_Guides/E-Paper - 7.5-inch e-Book with MicroSD card/E-paper - Display User-generated QR code.rst +++ /dev/null @@ -1,131 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- Waveshare E-Paper [2.9inch E-Paper HAT (D)/ 2.9inch E-Paper V2/ - 2.9inch e-Paper Module (B)/ 4.2inch e-Paper Module/ 7.5-inch E-Ink - display HAT] x1 - -Example - -Introduction -============ - -In this example, Ameba Pro2 board will be used to connect to a Waveshare -e-Paper module (2.9inch/ 4.2inch/ 7.5inch) to display texts. The display -uses the flexible substrate as base plate, with an interface and a -reference system design. You may refer to the -official `datasheet `__ to -know more information about these modules. - -Procedure -========= - -**AMB82-Mini wiring diagram:** - -*2.9inch HAT (D) e-Paper Module* - -|A picture containing text, rectangle, screenshot, design Description -automatically generated| - -*2.9inch E-Paper V2 e-Paper Module/ 2.9inch e-Paper Module (B)* - -|A picture containing text, screenshot, rectangle Description -automatically generated| - -*4.2inch e-Paper Module* - -|A picture containing electronics, text, circuit, electronic component -Description automatically generated| - -*7.5-inch e-Paper Module* - -Do note that Display Config should be set to B and Interface Config -should be set to 0. - -|A picture containing text, screenshot, electronic engineering, -electronics Description automatically generated| - -| Next, download the Eink zip library, AmebaEink.zip, - at https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_zip_libraries -| Then install the AmebaEink.zip by navigating to “Sketch” -> “Include - Library” -> “Add .ZIP Library…”. - -Eink examples are categorised based on the size and modules of the -e-Paper display. - -|A screenshot of a computer Description automatically generated| - -Open one of the “EinkDisplayQR” examples. For example, “File” → -“Examples” → “AmebaEink” → “EPD_2in9v2”-> “EinkDisplayQR”: - -|image1| - -You may choose any GPIO pins for Busy, Reset and DC pin. You can refer -to -https://www.amebaiot.com/en/amebapro2-amb82-mini-arduino-getting-started/ -for AMB82-Mini’s pinmap. - -|image2| - -Modify the URL in the loop() section highlighted in yellow for your QR -code, then upload the code to the Ameba board. Upload the code to the -board and press the reset button after uploading is done. - -A QR code generated based on the input URL will be shown on the E-paper -module. In the example, the QR code links to `Ameba IoT official -website `__. - -|image3| - -Upload the code to the board and press the reset button after uploading -is done. Wait for around 1-2 seconds for the e-Paper module to refresh -its screen. - -|image4| - -Code Reference - -| [1] We use Good Display GDEH029A1 2.9 Inch / 296×128 Resolution / - Partial Refresh Arduino Sample Code to get the e-Paper successfully - Display: -| http://www.good-display.com/product/201.html - -[2] EPD libraries can be obtained from: -https://github.com/waveshare/e-Paper - -| [3] Provide the link to how to generate a QR code on the E-paper - module: -| https://eugeniopace.org/qrcode/arduino/eink/2019/07/01/qrcode-on-arduino.html - -[4] A simple library for generating QR codes in C, optimized for -processing and memory-constrained systems: -https://github.com/ricmoo/QRCode#data-capacities - -.. |A picture containing text, rectangle, screenshot, design Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image01.png - :width: 4.99828in - :height: 2.48in -.. |A picture containing text, screenshot, rectangle Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image02.png - :width: 5.112in - :height: 2.3361in -.. |A picture containing electronics, text, circuit, electronic component Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image03.png - :width: 4.64935in - :height: 2.68645in -.. |A picture containing text, screenshot, electronic engineering, electronics Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image04.png - :width: 4.53247in - :height: 3.07025in -.. |A screenshot of a computer Description automatically generated| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image05.png - :width: 3.76736in - :height: 4.24392in -.. |image1| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image06.png - :width: 4.11872in - :height: 4.64622in -.. |image2| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image07.png - :width: 4.27732in - :height: 4.63368in -.. |image3| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image08.png - :width: 3.8877in - :height: 4.38561in -.. |image4| image:: ../../_static/Example_Guides/E-paper_-_Display_User-generated_QR_code/E-paper_-_Display_User-generated_QR_code_images/image9.jpeg - :width: 3.27083in - :height: 4.35749in diff --git a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - HTTP Post MP4.rst b/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - HTTP Post MP4.rst deleted file mode 100644 index f12f7dc..0000000 --- a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - HTTP Post MP4.rst +++ /dev/null @@ -1,69 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- PushButton x1 - -- 220 ohm resistor x1 - -Example - -These examples illustrate how to send HTTP Post request of MP4 audio -file to a HTTP server. - -This guide will be relevant to 2 examples: - -1) HTTP_Post_MP4_Whisper_Server - -2) RecordMP4_HTTP_Post_Whisper_Server - -The difference between these 2 examples is that for -HTTP_Post_MP4_Whisper_Server.ino, one is expected to have an MP4 file -already saved inside the SD card. Whereas for the -RecordMP4_HTTP_Post_Whisper_Server.ino, it is not necessary to have a -MP4 file inside the SD card. - -This is the block diagram for the example flow. - -|image1| - -Connect the pushbutton and resistor to AMB82 Mini as shown below. - -|image2| - -Open “File”-> “Examples” -> “AmebaHTTP” -> -“HTTP_Post_MP4_Whisper_Server” OR “RecordMP4_HTTP_Post_Whisper_Server”. - -|image3| - -Compile and run the code. - -Set up the http server by locating the python script called -“whisper_llm_server.py” in src folder. Go to command prompt and go to -the src folder and execute this command: python3 whisper_llm_server.py. -Follow the readme in the python script. - -Press the push button for 2s to trigger the recording. Speak into the -microphone to ask the AI. This should be the expected output on the -terminal that was running the python script. Please note that if you are -to use a more powerful model such as MediaTek 7B model, you will need a -PC with a powerful GPU to test. Purely CPU will not be able to run that -model. - -Please note that this server can only be run on **Linux OS**. Mac OS and -Windows have not been supported yet. - -|image4| - -.. |image1| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_MP4/HTTP_-_HTTP_Post_MP4_images/image01.png - :width: 6.26806in - :height: 2.21319in -.. |image2| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_MP4/HTTP_-_HTTP_Post_MP4_images/image02.png - :width: 4.41458in - :height: 3.58264in -.. |image3| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_MP4/HTTP_-_HTTP_Post_MP4_images/image03.png - :width: 5.55972in - :height: 3.47361in -.. |image4| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_MP4/HTTP_-_HTTP_Post_MP4_images/image04.png - :width: 6.26806in - :height: 1.26736in diff --git a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP Image and MP4.rst b/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP Image and MP4.rst deleted file mode 100644 index ba1f79c..0000000 --- a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP Image and MP4.rst +++ /dev/null @@ -1,45 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -- PushButton x1 - -- 220 ohm resistor x1 - -Example - -In this example, we are doing a Post request with image and recorded -audio file together to LLM Server. This example does not contain -integration to the LLM server but integration to the HTTP server. - -Then open “File” -> “Examples” -> “AmebaHttp” -> -“Capture_Image_HTTP_Post_Image_Llava_Server” - -|image1| - -Connect the pushbutton and resistor to AMB82 Mini as shown below. - -|image2| - -Compile and run the example. - -Set up the HTTP server by locating the python script called -whisper_server_test_2_endpoints.py. Go to command prompt and go to the -src folder. Execute this command python3 -whisper_server_test_2_endpoints.py. - -Please note that this server can only be run on **Linux OS**. Mac OS and -Windows have not been supported yet. - -Press button for 2s when you wish to take a snapshot and speak into the -mic for the prompt to ask the Visual Language Model (VLM). - -If the HTTP Post image and audio file is successful, the image and audio -file will be saved at the location where this script is being run at. - -.. |image1| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_Image_and_MP4/HTTP_-_Retrieve_HTTP_Image_and_MP4_images/image01.png - :width: 6.26806in - :height: 3.91597in -.. |image2| image:: ../../_static/Example_Guides/HTTP_-_HTTP_Post_Image_and_MP4/HTTP_-_Retrieve_HTTP_Image_and_MP4_images/image02.png - :width: 4.92292in - :height: 3.99514in diff --git a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP webs.rst b/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP webs.rst deleted file mode 100644 index 4e3b386..0000000 --- a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Retrieve HTTP webs.rst +++ /dev/null @@ -1,59 +0,0 @@ -Materials - -- AmebaPro2 [AMB82 MINI] x 1 - -Example - -| In this example, the HttpClient library is used to retrieve a webpage - using the HTTP protocol. -| First, make sure that the correct Ameba development board is selected - in “Tools” -> “Board” - -Then open “File” -> “Examples” -> “AmebaHttp” -> “RetrieveHttpWebs” - -|image1| - -In the sample code, modify the highlighted section to enter the -information required (ssid, password, key index) to connect to your WiFi -network. - -|4-2| - -Upload the code and press the reset button on Ameba once the upload is -finished. Open the serial monitor in the Arduino IDE and you can see the -information retrieved from the website. - -|4-3| - -  - -  - -Code Reference - -| Use WiFi.begin() to establish WiFi connection: -| https://www.arduino.cc/en/Reference/WiFiBegin -| To get the information of a WiFi connection: -| Use WiFi.SSID() to get SSID of the current connected network. -| https://www.arduino.cc/en/Reference/WiFiSSID -| Use WiFi.RSSI() to get the signal strength of the connection. -| https://www.arduino.cc/en/Reference/WiFiRSSI -| Use WiFi.localIP() to get the IP address of Ameba. -| https://www.arduino.cc/en/Reference/WiFiLocalIP -| Use WiFiClient to create a client to handle the WiFi connection. -| https://www.arduino.cc/en/Reference/WiFiClient -| Use HTTPClient to create a client to handle the HTTP connection. - -Use http.get() to send a GET request to the website. - -  - -.. |image1| image:: ../../_static/Example_Guides/HTTP_-_Retrieve_HTTP_webs/HTTP_-_Retrieve_HTTP_webs_images/image01.png - :width: 4.12964in - :height: 5.71497in -.. |4-2| image:: ../../_static/Example_Guides/HTTP_-_Retrieve_HTTP_webs/HTTP_-_Retrieve_HTTP_webs_images/image02.png - :width: 4.73542in - :height: 4.70866in -.. |4-3| image:: ../../_static/Example_Guides/HTTP_-_Retrieve_HTTP_webs/HTTP_-_Retrieve_HTTP_webs_images/image03.png - :width: 6.26806in - :height: 4.13264in diff --git a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Use IFTTT for Web Service.rst b/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Use IFTTT for Web Service.rst deleted file mode 100644 index baa30d7..0000000 --- a/bak/Example_Guides/HTTP - HTTP Post Image and MP4/HTTP - Use IFTTT for Web Service.rst +++ /dev/null @@ -1,247 +0,0 @@ -Introduction to IFTTT -===================== - -IFTTT, known as If This Then That, is a website and mobile app and free -web-based service to create the applets, or the chains of simple -conditional statements. The applet is triggered by changes that occur -within other web services such as Gmail, Facebook, Telegram, Instagram, -Pinterest, Line Notify etc. - -Preparation -=========== - -- AmebaPro2 - [ `AMB82-MINI `__ ] - x 1 - -- An account from https://ifttt.com/ , to access IFTTT service\* - -|1| - -\*Note: Upon log in, there are several cloud and online services that -are integrated with IFTTT platforms. Some IFTTT services may require -IFTTT Pro+, that is an online billing service. - -Example -======= - -- Generate Applet from IFTTT - -In this example, we obtain an example of IFTTT Applet to send email to -specified recipient. - -To run the example, HTTP POST feature of the Ameba is used to post a -simple webhook service that is received by IFTTT platform and in turn be -used to trigger a response (sending an email). - -After logging in https://ifttt.com/, click **Create** from the top bar. - -|image1| - -Click “Add” to add the trigger. - -|image2| - -Choose Webhooks service as shown below. Alternatively, search the -service by typing into the search bar. - -|image3| - -After that, the available triggers will appear. Choose “Receive a Web -request”. - -|A picture containing text Description automatically generated| - -Next, an Event Name is required to identify the trigger successfully. In -this example, set the Event name as “test_event”. - -|image4| - -Next, click Add in Then That field to create the action service taken in -response to the last trigger. - -|image5| - -Choose Email as the action service. - -|image6| - -Click on Send me an email. - -|Graphical user interface Description automatically generated| - -Under the template of Send me an Email, the contents of the email, such -as subject and body is editable. Click Create Action to complete the -action. Take note that Email service is offered to the email address -registered under IFTTT account. - -|image7| - -- Post the Trigger via Ameba - -| Once the Applet is ready in the IFTTT dashboard, the example program - can be flashed onto the Ameba board to post the HTTP request. -| Open the example code in “File” -> “Examples” -> “AmebaHttp” -> - “HTTP_IFTTT_Post”. |Graphical user interface Description automatically - generated with low confidence| - -In the example program, edit the following 3 items inside the code to -make the program work. - -1. The WiFi credentials to connect to the Wi-Fi hotspot or access point - of desirable choice. - -2. Under the Host name field, enter the host name of the IFTTT service - “maker.ifttt.com”. - -3. Under the Path name field, enter the “Event name” and key field - “kPath”: “/trigger/Event name/with/key/Key Field”. - -- Event name: The event name should be the same as the one specified in - the IFTTT applet. In this example, the event name is “test_event”. - -- Key Field: Available under webhook service in individual IFTTT - account. - -|Graphical user interface, text, application Description automatically -generated| - -To obtain a key from documentation tab of the Webhooks, find the webhook -service in the Explore tab. - -|image8| - -On the Webhooks service page, click on the “Documentation” tab. - -|image9| - -The key can be found in the documentation page. Also, information on how -HTTP request can be used. - -|image10| - -| Once the example is ready, Connect the Ameba board via USB cable. -| On the Arduino IDE, compile the code and upload the code onto Ameba - and press the reset button. After the event has been successfully - fired, “Congratulations! You have fired the test_event event” can be - seen on the serial monitor and an email reminder for this event will - be delivered. - -|image11| - -Thereafter an email is sent to recipient email account registered at -IFTTT Applet and an email will be received. - -|image12| - -- IFTTT Line Notify - -Alternatively, an example to send a message with the LINE messaging app -on iPhone or Android using IFTTT Applet is available. It can be achieved -by modifying the “Then That” settings. - -You may follow the same steps previously in “Generate Applet from IFTTT” -section to create a Webhooks service as the trigger. The Event Name -required to identify the trigger will remain as “test_event”. Next, -click the “Add” button in “Then That” field to create the action service -taken in response to the last trigger. - -|image13| - -Choose Line as the action service. - -|Graphical user interface, application Description automatically -generated| - -Click on “Send message”. - -|image14| - -Click on “Connect” and login to your Line Account. - -|image15| - -Select LINE account, set the Recipient to “1-on-1 chat with LINE Notify” -which means the message triggered by IFTTT will directly send to your -chats. Next, input your desired message in the input box under -“Message”. For sending images, you can insert a link to your photo in -the input box under “Photo URL”. - -|image16| - -On the Arduino IDE, compile the code and upload the code onto Ameba and -press the reset button. After the event has been successfully fired, you -will receive a message from “LINE Notify” on your Mobile devices or PC. - -|A screenshot of a video game Description automatically generated with -medium confidence| - -.. |1| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image01.png - :width: 6.27in - :height: 3.40669in -.. |image1| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image02.png - :width: 6.27in - :height: 0.91068in -.. |image2| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image03.png - :width: 6.27in - :height: 4.98766in -.. |image3| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image04.png - :width: 6.26806in - :height: 3.42194in -.. |A picture containing text Description automatically generated| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image05.png - :width: 6.26806in - :height: 5.20486in -.. |image4| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image06.png - :width: 6.26806in - :height: 5.01181in -.. |image5| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image07.png - :width: 6.26806in - :height: 4.84167in -.. |image6| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image08.png - :width: 6.26806in - :height: 3.77014in -.. |Graphical user interface Description automatically generated| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image09.png - :width: 6.26806in - :height: 4.39236in -.. |image7| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image10.png - :width: 6.26806in - :height: 5.75069in -.. |Graphical user interface Description automatically generated with low confidence| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image11.png - :width: 6.26806in - :height: 6.98472in -.. |Graphical user interface, text, application Description automatically generated| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image12.png - :width: 6.26806in - :height: 6.96042in -.. |image8| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image13.png - :width: 6.26806in - :height: 2.83194in -.. |image9| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image14.png - :width: 6.26806in - :height: 3.2375in -.. |image10| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image15.png - :width: 6.26806in - :height: 2.88056in -.. |image11| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image16.png - :width: 6.26806in - :height: 6.14444in -.. |image12| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image17.png - :width: 6.22909in - :height: 5.34687in -.. |image13| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image07.png - :width: 6.26806in - :height: 4.84167in -.. |Graphical user interface, application Description automatically generated| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image18.png - :width: 6.27784in - :height: 3.71591in -.. |image14| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image19.png - :width: 6.26806in - :height: 4.41389in -.. |image15| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image20.png - :width: 4.87106in - :height: 4.69566in -.. |image16| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image21.png - :width: 6.26806in - :height: 6.79306in -.. |A screenshot of a video game Description automatically generated with medium confidence| image:: ../../_static/Example_Guides/HTTP_-_Use_IFTTT_for_Web_Service/HTTP_-_Use_IFTTT_for_Web_Service_images/image22.jpeg - :width: 4.05172in - :height: 8.01724in diff --git a/source/API_Documents/WiFi/Class WiFiClient.rst b/source/API_Documents/WiFi/Class WiFiClient.rst new file mode 100644 index 0000000..001f33c --- /dev/null +++ b/source/API_Documents/WiFi/Class WiFiClient.rst @@ -0,0 +1,462 @@ +Class WiFiClient +================ + +.. contents:: + :local: + :depth: 2 + +**WiFiClient Class** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class of WiFi Client implementation for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class WiFiClient + +**Members** +~~~~~~~~~~~ + ++------------------------------+---------------------------------------+ +| **Public Constructors** | ++==============================+=======================================+ +| WiFiClient::WiFiClient | Constructs a WiFiClient instance that | +| | connects to the specified IP address | +| | and port. | +| | | ++------------------------------+---------------------------------------+ +| **Public Methods** | ++------------------------------+---------------------------------------+ +| WiFiClient::connect | Connect to the IP address and port | +| | | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::write | Write data (single byte) to the | +| | server | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::available | Get the number of bytes available for | +| | reading | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::read | Read the incoming byte from the | +| | server | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::recv | Read the received byte from the | +| | server that the client is connected | +| | to. | ++------------------------------+---------------------------------------+ +| WiFiClient::peek | Get the next byte from the current | +| | packet without moving on to the next | +| | byte | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::flush | Clear all the bytes that have been | +| | written to the client but not yet | +| | read | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::stop | Disconnect from the server | +| | | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::connected | Check if client is connected | +| | | +| | | +| | | ++------------------------------+---------------------------------------+ +| WiFiClient::setRecvTimeout | Set the amount of time the client | +| | will wait for new data to arrive each | +| | time WiFiClient::read() is called. | +| | | +| | | ++------------------------------+---------------------------------------+ + + +**WiFiClient::WiFiClient** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a WiFiClient instance that connects to a specified IP address and port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + WiFiClient(void); + + WiFiClient(uint8_t sock); + +**Parameters** +~~~~~~~~~~~~~~ + +sock: socket state + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::connect** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the IP address and port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int connect(const char *host, uint16_t port); + + int connect(IPAddress ip, uint16_t port); + +**Parameters** +~~~~~~~~~~~~~~ + +ip: IP address that the client will connect to +host: Host name that the client will connect to +port: the port that the client will connect to + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if the connection is successful, else returns +“0”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::write** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Write data (single byte) to the server that the client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + size_t write(uint8_t b); + size_t write(const uint8_t *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +b: the byte or char to write +buf: a pointer to an array containing the outgoing message +size: the size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the byte/ character that will be written to the +server or the size of the buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::available** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the number of bytes available for reading. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int available(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns 1 and number of bytes available for reading if +there are available data, else returns 0. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::read** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ +Read the incoming byte from the server that the client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int read(void); + + int read(uint8_t *buf, size_t size); + + int read(char *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: buffer to hold incoming byte +size: maximum size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the size of the buffer or returns -1 if no buffer is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + +**WiFiClient::recv** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read the received byte from the server that the client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int recv (uint8_t *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: buffer to hold received byte +size: maximum size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns 1 and number of bytes received or returns -1 if no data is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::peek** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the next byte from the current packet without moving on to the next byte. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int peek(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next byte or character, else returns -1 if none is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiClient.h” must be included to use the class function. + +**WiFiClient::flush** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Clear all the bytes that have been written to the client but not yet read. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void flush(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::stop** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disconnect from the server. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void stop(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + +**WiFiClient::connected** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if client is connected. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual uint8_t connected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if connected, returns “0” if not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiWebClient `_ + +.. note :: “WiFiClient.h” must be included to use the class function. + + +**WiFiClient::setRecvTimeout** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set the amount of time the client will wait for new data to arrive each time WiFiClient::read() is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int setRecvTimeout(int timeout); + +**Parameters** +~~~~~~~~~~~~~~ + +timeout: timeout in seconds + +**Returns** +~~~~~~~~~~~ + +This function returns “0” if client is not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiClient.h” must be included to use the class function. diff --git a/source/API_Documents/WiFi/Class WiFiSSLClient.rst b/source/API_Documents/WiFi/Class WiFiSSLClient.rst new file mode 100644 index 0000000..d96d4ae --- /dev/null +++ b/source/API_Documents/WiFi/Class WiFiSSLClient.rst @@ -0,0 +1,526 @@ +Class WiFiSSLClient +=================== + +.. contents:: + :local: + :depth: 2 + +**WiFiSSLClient Class** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class for Wi-Fi Secure Socket Layer Client implementation for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class WiFiSSLClient + +**Members** +~~~~~~~~~~~ + ++---------------------------------------+----------------------------------------------------------------------+ +| **Public Constructors** | ++=======================================+======================================================================+ +| WiFiSSLClient::WiFiSSLClient | Constructs a WiFiSSLClient instance that always connects in SSL | +| | to the specified IP address and port. | ++---------------------------------------+----------------------------------------------------------------------+ +| **Public Methods** | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::connect | Connect to the IP address and port. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::write | Write data (single byte) to the server. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::available | Get the availability of the Wi-Fi SSL socket for reading. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::read | Read the incoming byte from the server. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::peek | Get the next byte from the current packet without moving on | +| | to the next byte. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::flush | Clear all the bytes that have been written to the client but not | +| | yet read. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::stop | Disconnect from the server. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::connected | Check if SSL client is connected. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::setRootCA | Set Root CA for authentication. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::setClientCertificate | Set certificate of the client. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::setRecvTimeout | Set receiving timeout. | ++---------------------------------------+----------------------------------------------------------------------+ +| WiFiSSLClient::setPreSharedKey | Set the Pre Shared Key (PSK) to use for authentication. | ++---------------------------------------+----------------------------------------------------------------------+ + + +**WiFiSSLClient::WiFiSSLClient** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a WiFiSSLClient instance that always connects in SSL to the specified IP address and port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + WiFiSSLClient(void); + + WiFiSSLClient(uint8_t sock); + +**Parameters** +~~~~~~~~~~~~~~ + +sock: socket state, default -1 + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::connect** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the IP address and port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int connect(IPAddress ip, uint16_t port); + + virtual int connect(const char *host, uint16_t port); + + virtual uint8_t connected(void); + + int connect(const char *host, uint16_t port, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); + + int connect(IPAddress ip, uint16_t port, unsigned char *rootCABuff, unsigned char *cli_cert, unsigned char *cli_key); + + int connect(const char *host, uint16_t port, unsigned char *pskIdent, unsigned char *psKey); + + int connect(IPAddress ip, uint16_t port, unsigned char *pskIdent, unsigned char *psKey); + +**Parameters** +~~~~~~~~~~~~~~ + +ip: IP address + +host: Host name + +port: the port to listen to + +rootCABuff: buffer that store root CA + +cli_cert: buffer that store client certificate + +cli_key: buffer that store client key pair + +pskIdent: identity for PSK + +psKey: Pre shared key + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if successful, else returns “0”. + +**Example Code** +~~~~~~~~~~~~~~~~ +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + +**WiFiSSLClient::write** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Write data (single byte) to the server the SSL client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual size_t write(uint8_t); + + virtual size_t write(const uint8_t *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: a pointer to an array containing the outgoing message + +size: the size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the byte/ character that will be written to the server or the size of the buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::available** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the availability of the Wi-Fi SSL socket for reading. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int available(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “1” and number of bytes available for reading if there are available data, else returns 0. + +**Example Code** +~~~~~~~~~~~~~~~~ +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::read** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read the incoming byte from the server that the SSL client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int read(void); + + virtual int read(uint8_t *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: buffer that holds incoming data in 8-bit + +size: maximum size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the size of the buffer or returns “-1” if no buffer is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::peek** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the next byte from the current packet without moving on to the next byte. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int peek(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next byte or character, else returns -1 if none is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::flush** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Clear all the bytes that have been written to the client but not yet read. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual void flush(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ +NA + + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::stop** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disconnect from the server. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual void stop (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::connected** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if SSL client is connected. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual uint8_t connected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns “1” if the SSLClient socket is connected, else returns “0” if not connected. + +**Example Code** + +Example: `WiFiSSLClient `_ + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::setRootCA** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set Root CA(certification authority) for SSL authentication. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void setRootCA(unsigned char *rootCA); + +**Parameters** +~~~~~~~~~~~~~~ + +rootCA: a string of rootCA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::setClientCertificate** +--------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set certificate of the client. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void setClientCertificate(unsigned char *client_ca, unsigned char *private_key); + +**Parameters** +~~~~~~~~~~~~~~ + +client_ca: Client certificate + +private_key: client's private key pair + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ +NA + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::setRecvTimeout** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +This function sets the SSL client socket receiving timeout. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int setRecvTimeout(int timeout); + +**Parameters** +~~~~~~~~~~~~~~ + +timeout: timeout in seconds + +**Returns** +~~~~~~~~~~~ + +The function returns “0”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiSSLClient.h” must be included to use the class function. + + +**WiFiSSLClient::setPreSharedKey** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the Pre Shared Key (PSK) to use for authentication. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void setPreSharedKey(unsigned char *pskIdent, unsigned char *psKey); + +**Parameters** +~~~~~~~~~~~~~~ + +pskIdent: identity for PSK + +psKey: Pre shared key + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: Do not set a root CA and client certificate if PSK should be used for + authentication. If root CA, client certificate and PSK are all set, + certificate-based authentication will be used. “WiFiSSLClient.h” must + be included to use the class function. diff --git a/source/API_Documents/WiFi/Class WiFiServer.rst b/source/API_Documents/WiFi/Class WiFiServer.rst new file mode 100644 index 0000000..7e71bbe --- /dev/null +++ b/source/API_Documents/WiFi/Class WiFiServer.rst @@ -0,0 +1,220 @@ +Class WiFiServer +================ + +.. contents:: + :local: + :depth: 2 + +**WiFiServer Class** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class of WiFi server implementation for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class WiFiServer + +**Members** +~~~~~~~~~~~ + ++----------------------------+---------------------------------------------+ +| **Public Constructors** | ++============================+=============================================+ +| WiFiServer::WiFiServer | Constructs a WiFiServer object and creates | +| | a server that listens for incoming | +| | connections on the specified port. | +| | | +| | | +| | | ++----------------------------+---------------------------------------------+ +| **Public Methods** | ++----------------------------+---------------------------------------------+ +| WiFiServer::available | Gets a client that is connected to the | +| | server and has data available for reading. | +| | | +| | | +| | | ++----------------------------+---------------------------------------------+ +| WiFiServer::begin | Server start listening for incoming | +| | connections. | +| | | +| | | +| | | ++----------------------------+---------------------------------------------+ +| WiFiServer::write | Write data to all the clients connected to | +| | a server. | +| | | +| | | +| | | ++----------------------------+---------------------------------------------+ + + +**WiFiServer::WiFiServer** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a WiFiServer object and creates a server that listens for incoming connections on the specified port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + WiFiServer (uint16_t port); + +**Parameters** +~~~~~~~~~~~~~~ + +port: The port number being connected to. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleServerWiFi `_ + +.. note :: “WiFiServer.h” must be included to use the class function. + + +**WiFiServer::available** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Gets a client that is connected to the server and has data available for reading. The connection persists when the returned client object goes out of scope; you can close it by calling the client.stop(). + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + WiFiClient available(uint8_t *status = NULL); + +**Parameters** +~~~~~~~~~~~~~~ + +status: Wi-Fi availability status. Default value: NULL + +**Returns** +~~~~~~~~~~~ + +This function returns a client object; if no Client has data available for reading, this object will evaluate to false in an if-statement + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleServerWiFi `_ + +.. note :: “WiFiServer.h” must be included to use the class function. + + +**WiFiServer::begin** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Server start listening for incoming connections. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void begin(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleServerWiFi `_ + +.. note :: “WiFiServer.h” must be included to use the class function. + +**WiFiServer::connected** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if server is still connected + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint8_t connected(); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns "1" if connected, returns "0" if not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiServer.h” must be included to use the class function. + +**WiFiServer::write** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Write data to all the clients connected to a server. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual size_t write(uint8_t b); + +**Parameters** +~~~~~~~~~~~~~~ + +b: byte to be written +buf: data buffer +size: size of the data buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes written. It is not necessary to read this. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleServerWiFi `_ + +.. note :: “WiFiServer.h” must be included to use the class function. diff --git a/source/API_Documents/WiFi/Class WiFiUdp.rst b/source/API_Documents/WiFi/Class WiFiUdp.rst new file mode 100644 index 0000000..bd344b2 --- /dev/null +++ b/source/API_Documents/WiFi/Class WiFiUdp.rst @@ -0,0 +1,605 @@ +Class WiFiUdp +============= + +.. contents:: + :local: + :depth: 2 + +**WiFiUDP Class** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for managing WiFi UDP implementation for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class WiFiUDP + +**Members** +~~~~~~~~~~~ + ++-------------------------------------+-----------------------------------------------+ +| **Public Constructors** | ++=====================================+===============================================+ +| WiFiUDP::WiFiUDP | Constructs a WiFiUDP instance of the Wi-Fi | +| | UDP class that can send and receive UDP | +| | messages | +| | | +| | | ++-------------------------------------+-----------------------------------------------+ +| **Public Methods** | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::begin | Initialize Wi-Fi UDP library, network | +| | settings and start listening at specified | +| | local port | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::stop | Disconnect from the server | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::beginPacket | Start building up a packet to send to the | +| | remote host-specific in IP and port | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::endPacket | Finish off this packet and send it | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::write | Write UDP data (single byte) to remote | +| | connection | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::write | Send packet immediately from the buffer | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::parsePacket | Check for the presence of a UDP packets and | +| | start processing the next available incoming | +| | packet | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::available | Get the number of bytes (characters) | +| | available for reading from the buffer | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::read | Read UDP data from specified buffer | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::peek | Get the next byte from the current packet | +| | without moving on to the next byte | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::flush | Clear all the bytes that have been written to | +| | the client but not yet read | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::remoteIP | Get the IP address of the remote connection | +| | who sent the current incoming packet | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::remotePort | Get the port of the remote UDP connection who | +| | sent the current incoming packet | ++-------------------------------------+-----------------------------------------------+ +| WiFiUDP::setRecvTimeout | Set receiving timeout | ++-------------------------------------+-----------------------------------------------+ + + +**WiFiUDP::WiFiUDP** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a WiFiUDP instance of the Wi-Fi UDP class that can send and receive UDP messages. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + WiFiUDP (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + + +.. note :: This constructor does not take in any parameter, thus use another + method to set up the IP address and port number. “WiFiUdp.h” must be + included to use the class function. + + +**WiFiUDP::begin** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Initialize Wi-Fi UDP library, network settings and start listening at specified local port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual uint8_t begin(uint16_t); + +**Parameters** +~~~~~~~~~~~~~~ + +port: the local port to listen on + +**Returns** +~~~~~~~~~~~ + +This function returns 1 if successful, else returns 0 if there are no +sockets available to use. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::stop** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disconnect from the server. Release any resource being used during the UDP session. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual void stop(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::beginPacket** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Start building up a packet to send to the remote host-specific in IP and port. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int beginPacket(IPAddress ip, uint16_t port); + + virtual int beginPacket(const char *host, uint16_t port); + +**Parameters** +~~~~~~~~~~~~~~ + +host: remote host name + +port: the port of the remote connection + +ip: IP address of the remote connection + +**Returns** +~~~~~~~~~~~ + +This function returns “1” of successful, else returns “0” if there is a +problem with the given IP address or port. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::endPacket** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Finish off the packet and send it. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int endPacket(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if packet was sent successfully, else returns +“0” if there was an error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::write** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Write UDP data (single byte) to remote connection. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual size_t write(uint8_t); + + virtual size_t write(const uint8_t *buffer, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: a pointer to an array containing the outgoing message + +size: the size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the byte/ character that will be written to the server or the size of the buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + +.. note :: This function must be wrapped between beginPacket() and endPacket(). + beginPacket() initializes the packet of data, it is not sent until + endPacket() is called. “WiFiUdp.h” must be included to use the class + function. + + +**WiFiUDP::writeImmediately** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send packet immediately from the buffer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + size_t writeImmediately(const uint8_t *buffer, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: a pointer to an array containing the outgoing message + +size: the size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the byte/ character that will be written to the server or the size of the buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::parsePacket** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Check for the presence of a UDP packets and start processing the next available incoming packet. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int parsePacket(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes available in the current +packet, will return "0” if WiFiUDP.parsePacket() hasn't been called yet. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::available** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the number of bytes (characters) available for reading from the buffer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int available(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes available in the current +packet, else returns “0” if WiFiUDP.parsePacket() hasn't been called +yet. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: This function can only be successfully called after + WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class + function. + + +**WiFiUDP::read** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read UDP data from specified buffer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int read (void); + + virtual int read (char *buffer, size_t len); + +**Parameters** +~~~~~~~~~~~~~~ + +buf: buffer to hold incoming byte + +size: maximum size of the buffer + +**Returns** +~~~~~~~~~~~ + +This function returns the size of the buffer or returns -1 if no buffer is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + + +.. note :: This function can only be successfully called after + WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class + function. + + +**WiFiUDP::peek** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the next byte from the current packet without moving on to the next byte. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual int peek (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next byte or character or returns -1 if none is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiUdp.h” must be included to use the class function.\ ** + +**WiFiUDP::flush** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Clear all the bytes that have been written to the client but not yet read. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual void flush(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::remoteIP** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the IP address of the remote connection who sent the current incoming packet. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual IPAddress remoteIP(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the IP address of the remote connection. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + +.. note :: This function must be called after WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::remotePort** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the port of the remote UDP connection who sent the current incoming packet. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + virtual uint16_t remotePort(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the port of the remote connection. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WiFiUdpSendReceiveString `_ + +.. note :: This function must be called after WiFiUDP.parsePacket(). “WiFiUdp.h” must be included to use the class function. + + +**WiFiUDP::setRecvTimeout** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set receiving timeout + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void setRecvTimeout(int timeout); + +**Parameters** +~~~~~~~~~~~~~~ + +timeout: timeout in seconds + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WiFiUdp.h” must be included to use the class function. diff --git a/source/API_Documents/WiFi/index.rst b/source/API_Documents/WiFi/index.rst index 05ed44c..29fb133 100644 --- a/source/API_Documents/WiFi/index.rst +++ b/source/API_Documents/WiFi/index.rst @@ -5,4 +5,8 @@ WiFi :maxdepth: 1 Class WiFi + Class WiFiClient + Class WiFiServer + Class WiFiSSLClient + Class WiFiUdp diff --git a/source/Example_Guides/E-Paper/Display User-generated QR code.rst b/source/Example_Guides/E-Paper/Display User-generated QR code.rst new file mode 100644 index 0000000..100d964 --- /dev/null +++ b/source/Example_Guides/E-Paper/Display User-generated QR code.rst @@ -0,0 +1,112 @@ +Display User-generated QR code +============================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- `AMB82-mini `_ x 1 + +- Waveshare E-Paper [2.9inch E-Paper HAT (D)/ 2.9inch E-Paper V2/ 2.9inch e-Paper Module (B)/ 4.2inch e-Paper Module/ 7.5-inch E-Ink display HAT] x1 + +Example +------- + +**Introduction** + +In this example, Ameba Pro2 board will be used to connect to a Waveshare e-Paper module (2.9inch/ 4.2inch/ 7.5inch) to display texts. The display uses the flexible substrate as base plate, with an interface and a reference system design. You may refer to the +official `datasheet `_ to know more information about these modules. + +**Procedure** + +**AMB82-Mini wiring diagram:** + +2.9inch HAT (D) e-Paper Module + +|image01| + +2.9inch E-Paper V2 e-Paper Module/ 2.9inch e-Paper Module (B) + +|image02| + +4.2inch e-Paper Module + +|image03| + +7.5-inch e-Paper Module + +Do note that Display Config should be set to B and Interface Config +should be set to 0. + +|image04| + +| Next, download the Eink zip library, AmebaEink.zip, at https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_zip_libraries +| Then install the AmebaEink.zip by navigating to “Sketch” -> “Include Library” -> “Add .ZIP Library…”. + +Eink examples are categorised based on the size and modules of the e-Paper display. + +|image05| + +Open one of the “EinkDisplayQR” examples. For example, “File” → “Examples” → “AmebaEink” → “EPD_2in9v2”-> “EinkDisplayQR”: + +|image06| + +You may choose any GPIO pins for Busy, Reset and DC pin. You can refer to https://www.amebaiot.com/en/amebapro2-amb82-mini-arduino-getting-started/ for AMB82-Mini's pinmap. + +|image07| + +Modify the URL in the loop() section highlighted in yellow for your QR code, then upload the code to the Ameba board. Upload the code to the board and press the reset button after uploading is done. + +A QR code generated based on the input URL will be shown on the E-paper module. In the example, the QR code links to Ameba IoT official website. + +|image08| + +Upload the code to the board and press the reset button after uploading is done. Wait for around 1-2 seconds for the e-Paper module to refresh its screen. + +|image09| + +Code Reference +-------------- + +| [1] We use Good Display GDEH029A1 2.9 Inch / 296x128 Resolution / Partial Refresh Arduino Sample Code to get the e-Paper successfully Display: +| http://www.good-display.com/product/201.html + +| [2] EPD libraries can be obtained from: +| https://github.com/waveshare/e-Paper + +| [3] Provide the link to how to generate a QR code on the E-paper module: +| https://eugeniopace.org/qrcode/arduino/eink/2019/07/01/qrcode-on-arduino.html + +| [4] A simple library for generating QR codes in C, optimized for processing and memory-constrained systems: +| https://github.com/ricmoo/QRCode#data-capacities + +.. |image01| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image01.png + :width: 1006 px + :height: 499 px +.. |image02| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image02.png + :width: 971 px + :height: 443 px +.. |image03| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image03.png + :width: 955 px + :height: 552 px +.. |image04| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image04.png + :width: 1015 px + :height: 688 px +.. |image05| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image05.png + :width: 768 px + :height: 832 px +.. |image06| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image06.png + :width: 738 px + :height: 832 px +.. |image07| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image07.png + :width: 768 px + :height: 832 px +.. |image08| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image08.png + :width: 738 px + :height: 832 px +.. |image09| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image09.png + :width: 833 px + :height: 625 px diff --git a/source/Example_Guides/E-Paper/index.rst b/source/Example_Guides/E-Paper/index.rst new file mode 100644 index 0000000..cf861d3 --- /dev/null +++ b/source/Example_Guides/E-Paper/index.rst @@ -0,0 +1,7 @@ +E-Paper +======= + +.. toctree:: + :maxdepth: 1 + + Display User-generated QR code \ No newline at end of file diff --git a/source/Example_Guides/index.rst b/source/Example_Guides/index.rst index 09169c4..6ef4380 100644 --- a/source/Example_Guides/index.rst +++ b/source/Example_Guides/index.rst @@ -5,6 +5,7 @@ Example Guides :maxdepth: 2 Basic/index + E-Paper/index Flash Memory/index GPIO/index GTimer/index From ae17920d52e1cfc9a3abaf126dd5037475854b71 Mon Sep 17 00:00:00 2001 From: Michael Zhang <35476432+M-ichae-l@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:35:32 +0800 Subject: [PATCH 2/2] Update Display User-generated QR code.rst --- .../E-Paper/Display User-generated QR code.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/Example_Guides/E-Paper/Display User-generated QR code.rst b/source/Example_Guides/E-Paper/Display User-generated QR code.rst index 100d964..b370f41 100644 --- a/source/Example_Guides/E-Paper/Display User-generated QR code.rst +++ b/source/Example_Guides/E-Paper/Display User-generated QR code.rst @@ -83,30 +83,30 @@ Code Reference | [4] A simple library for generating QR codes in C, optimized for processing and memory-constrained systems: | https://github.com/ricmoo/QRCode#data-capacities -.. |image01| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image01.png +.. |image01| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image01.png :width: 1006 px :height: 499 px -.. |image02| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image02.png +.. |image02| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image02.png :width: 971 px :height: 443 px -.. |image03| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image03.png +.. |image03| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image03.png :width: 955 px :height: 552 px -.. |image04| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image04.png +.. |image04| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image04.png :width: 1015 px :height: 688 px -.. |image05| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image05.png +.. |image05| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image05.png :width: 768 px :height: 832 px -.. |image06| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image06.png +.. |image06| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image06.png :width: 738 px :height: 832 px -.. |image07| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image07.png +.. |image07| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image07.png :width: 768 px :height: 832 px -.. |image08| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image08.png +.. |image08| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image08.png :width: 738 px :height: 832 px -.. |image09| image:: ../../_static/Example_Guides/E-paper/Display_User-generated_QR_code/image09.png +.. |image09| image:: ../../_static/Example_Guides/E-Paper/Display_User-generated_QR_code/image09.png :width: 833 px :height: 625 px