diff --git a/bak/ambd/_common/API_Documents/GPIO/Class DHT.rst b/bak/ambd/_common/API_Documents/GPIO/Class DHT.rst deleted file mode 100644 index 8c9584c..0000000 --- a/bak/ambd/_common/API_Documents/GPIO/Class DHT.rst +++ /dev/null @@ -1,339 +0,0 @@ -Class DHT -========= - -.. contents:: - :local: - :depth: 2 - -**DHT Class** -------------- - -**Description** -~~~~~~~~~~~~~~~ - -A class to use DHT temperature and humidity sensors. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - class DHT - -**Members** -~~~~~~~~~~~ - -+-----------------------------+-----------------------------------------+ -| **Public Constructors** | -+=============================+=========================================+ -| DHT::DHT | Constructs a DHT object | -+-----------------------------+-----------------------------------------+ -| **Public Methods** | -+-----------------------------+-----------------------------------------+ -| DHT::begin | Initialize the DHT sensor | -+-----------------------------+-----------------------------------------+ -| DHT::readTemperature | Read temperature (Fahrenheit or | -| | Celsius) from the DHT sensor | -+-----------------------------+-----------------------------------------+ -| DHT::convertCtoF | Convert a value from Celsius to | -| | Fahrenheit | -+-----------------------------+-----------------------------------------+ -| DHT::convertFtoC | Convert a value from Fahrenheit to | -| | Celsius | -+-----------------------------+-----------------------------------------+ -| DHT::readHumidity | Read humidity value from the DHT sensor | -| | as percentage. | -+-----------------------------+-----------------------------------------+ -| DHT::computeHeatIndex | Compute the HeatIndex from the readings | -| | (Using both Rothfusz and Steadman's | -| | equations) | -+-----------------------------+-----------------------------------------+ -| DHT::read | Check if the sensor is readable | -+-----------------------------+-----------------------------------------+ - -**DHT::DHT** ------------- - -**Description** -~~~~~~~~~~~~~~~ - -Constructs a DHT object. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - DHT(uint8_t pin, uint8_t type, uint8_t count); - -**Parameters** -~~~~~~~~~~~~~~ - -pin: selected GPIO pin. Default value is 8. - -type: The DHT sensor type. - -- DHT11, DHT22, or DHT21. Default is DHT11. - -count: The count is ignored as the DHT reading algorithm adjusts itself based on the speed of the processor. Default value is 6 (Refer to function declaration in DHT.h) - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::begin** --------------- - -**Description** -~~~~~~~~~~~~~~~ - -Initialize the DHT sensor by setting up the sensor GPIO pin and set pull timings. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void begin(uint8_t usec); - -**Parameters** -~~~~~~~~~~~~~~ - -usec: Optionally pass pull-up time (in microseconds) before DHT reading starts. Default value is 55 (Refer to function declaration in DHT.h) - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::readTemperature** ------------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Read temperature (Fahrenheit or Celsius) from the DHT sensor in selected scale. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - float readTemperature(bool S, bool force); - -**Parameters** -~~~~~~~~~~~~~~ - -S: Scale for temperature. Default value is False (Refer to function declaration in DHT.h) - -- True (Fahrenheit) - -- False (Celsius). - -force: Enable or disable force mode. Default value is False (Refer to function declaration in DHT.h) - -- True (Force mode) - -- False (Disable force mode) - -**Returns** -~~~~~~~~~~~ - -This function returns the current temperature as a float value in selected scale. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::convertCtoF** --------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Convert a temperature value from Celsius to Fahrenheit. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - float convertCtoF(float c); - -**Parameters** -~~~~~~~~~~~~~~ - -c: Temperature in Celsius. - -**Returns** -~~~~~~~~~~~ - -This function returns the temperature in Fahrenheit as a float number. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::convertFtoC** --------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Convert a temperature value from Fahrenheit to Celsius. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - float convertFtoC(float f); - -**Parameters** -~~~~~~~~~~~~~~ - -f: Temperature in Fahrenheit. - -**Returns** -~~~~~~~~~~~ - -This function returns the temperature in Celsius as a float number. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::readHumidity** ---------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Read humidity value from the DHT sensor as percentage. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - float readHumidity(bool force); - -**Parameters** -~~~~~~~~~~~~~~ - -force: Enable or disable force mode. Default value is False (Refer to function declaration in DHT.h) - -- True (Force mode) - -- False (Disable force mode) - -**Returns** -~~~~~~~~~~~ - -This function returns current humidity value represented in float as percentage. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. Reading temperature or humidity takes about 250 milliseconds. Sensor readings may also be up to 2 seconds. - -**DHT::computeHeatIndex** -------------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Compute the HeatIndex from the readings (Using both Rothfusz and Steadman's equations). More details refer to `The Heat Index Equation `_ - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - float computeHeatIndex(bool isFahrenheit); - float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit = true); - -**Parameters** -~~~~~~~~~~~~~~ - -temperature: The temperature value in selscted scale percentHumidity: humidity value in percentage. - -isFahrenheit: choose temperature vale in Farenheit or Celsius. Default value is True. - -- True (in Fahrenheit) - -- False (Celsius) - -**Returns** -~~~~~~~~~~~ - -This function returns the heat index in Fahrenheit or Celsius as a float value. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. - -**DHT::read** -------------- - -**Description** -~~~~~~~~~~~~~~~ - -Check if the sensor is readable. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - bool read (bool force); - -**Parameters** -~~~~~~~~~~~~~~ - -force: Enable or disable force mode. Default value is False (Refer to function declaration in DHT.h) - -- True (Force mode) - -- False (Disable force mode) - -**Returns** -~~~~~~~~~~~ - -This function returns whether the sensor is readable in every 2 seconds. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DHT_Tester `_ - -.. note :: "DHT.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/GPIO/Class InterruptLock.rst b/bak/ambd/_common/API_Documents/GPIO/Class InterruptLock.rst deleted file mode 100644 index 161f890..0000000 --- a/bak/ambd/_common/API_Documents/GPIO/Class InterruptLock.rst +++ /dev/null @@ -1,32 +0,0 @@ -Class InterruptLock -=================== - -.. contents:: - :local: - :depth: 2 - -**InterruptLock Class** ------------------------ - -**Description** -~~~~~~~~~~~~~~~ - -A class for turning off/on interrupts temporarily. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - class InterruptLock - -**Members** -~~~~~~~~~~~ - -+--------------------------------+-------------------------------------+ -| **Public Constructors** | -+================================+=====================================+ -| InterruptLock::InterruptLock | Constructs a InterruptLock object | -+--------------------------------+-------------------------------------+ -| InterruptLock::~ InterruptLock | Deconstructs a InterruptLock object | -+--------------------------------+-------------------------------------+ diff --git a/bak/ambd/_common/API_Documents/GPIO/index.rst b/bak/ambd/_common/API_Documents/GPIO/index.rst deleted file mode 100644 index 0d11155..0000000 --- a/bak/ambd/_common/API_Documents/GPIO/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -GPIO -==== - -.. toctree:: - :maxdepth: 1 - - Class DHT - Class InterruptLock diff --git a/bak/ambd/_common/API_Documents/Http/Class HttpClient.rst b/bak/ambd/_common/API_Documents/Http/Class HttpClient.rst deleted file mode 100644 index 874224d..0000000 --- a/bak/ambd/_common/API_Documents/Http/Class HttpClient.rst +++ /dev/null @@ -1,863 +0,0 @@ -################### -Class HttpClient -################### - -**Description** - -Defines a class of using HttpClient - -**Syntax** - -.. code:: cpp - - class HttpClient - -**Members** - -+---------------------------------+-----------------------------------+ -| **Public Constructors** |   | -+=================================+===================================+ -| HttpClient::HttpClient | Constructs a HttpClient object | -+---------------------------------+-----------------------------------+ -| **Public Methods** |   | -+---------------------------------+-----------------------------------+ -| HttpClient::beginRequest | Start a more complex request | -+---------------------------------+-----------------------------------+ -| HttpClient::endRequest | End a more complex request | -+---------------------------------+-----------------------------------+ -| HttpClient::get | Connect to the server and start | -| | to send a GET request | -+---------------------------------+-----------------------------------+ -| HttpClient::post | Connect to the server and start | -| | to send a POST request | -+---------------------------------+-----------------------------------+ -| HttpClient::put | Connect to the server and start | -| | to send a PUT request | -+---------------------------------+-----------------------------------+ -| HttpClient::startRequest | Connect to the server and start | -| | to send the request | -+---------------------------------+-----------------------------------+ -| HttpClient::sendHeader | Send an additional header line | -+---------------------------------+-----------------------------------+ -| HttpClient::sendBasicAuth | Send a basic authentication | -| | header | -+---------------------------------+-----------------------------------+ -| HttpClient::finishRequest | Finish sending the HTTP request | -+---------------------------------+-----------------------------------+ -| HttpClient::responseStatusCode | Get the HTTP status code | -| | contained in the response | -+---------------------------------+-----------------------------------+ -| HttpClient::readHeader | Read the next character of the | -| | response headers | -+---------------------------------+-----------------------------------+ -| HttpClient::skipResponseHeaders | Skip any response headers to get | -| | to the body | -+---------------------------------+-----------------------------------+ -| HttpClient::endOfHeadersReached | Test whether all of the response | -| | headers have been consumed | -+---------------------------------+-----------------------------------+ -| HttpClient::endOfBodyReached | Test whether the end of the body | -| | has been reached | -+---------------------------------+-----------------------------------+ -| HttpClient::contentLength | Return the length of the body | -+---------------------------------+-----------------------------------+ - --------------------------------------------------- - -.. method:: HttpClient::HttpClient - - -**Description** - -Constructs a HttpClient object. If Marco “PROXY_ENABLED” is defined,currently disabled as introduces a dependency on DNS.h in Ethernet. - -**Syntax** - -.. code:: cpp - - HttpClient::HttpClient(Client& aClient, const char* aProxy = NULL,uint16_t aProxyPort = 0); - -.. code:: cpp - - HttpClient::HttpClient(Client& aClient); - -**Parameters** - -``aClient``: The object of class WiFiClient. - -``aProxy``: The proxy name. The default proxy name is “NULL”. - -``aProxyPort`` : The proxy port. The default value for the proxy port is 0. - -**Returns** - -The function returns nothing. - -**Example Code** - -The example demonstrate how to download the content from URL indicated in kHostname[]. - -.. code-block:: cpp - :caption: SimpleHttpExample - :linenos: - - #include "HttpClient.h" - #include "WiFi.h" - #include "WiFiClient.h" - char ssid[] = "YourNetwork"; // your network SSID (name) - char pass[] = "password"; // your network password (use for WPA, or use as key for WEP) - int keyIndex = 0; // your network key Index number (needed only for WEP) - //Name of the server we want to connect to - const char kHostname[] = "www.google.com"; - const char kPath[] = "/"; - //Number of milliseconds to wait without receiving any data before we give up - const int kNetworkTimeout = 30*1000; - //Number of milliseconds to wait if no data is available before trying again - const int kNetworkDelay = 1000; - int status = WL_IDLE_STATUS; - void setup() { - - Serial.begin(9600); - while ( status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - status = WiFi.begin(ssid, pass); - // wait 10 seconds for connection: - delay(10000); - } - Serial.println("Connected to wifi"); - printWifiStatus(); - - void loop() { - - int err =0; - WiFiClient c; - HttpClient http(c); - err = http.get(kHostname, kPath); - if (err == 0) - { - Serial.println("startedRequest ok"); - err = http.responseStatusCode(); - if (err >= 0) - { - Serial.print("Got status code: "); - Serial.println(err); - // Usually you'd check that the response code is 200 or a - // similar "success" code (200-299) before carrying on, - // but we'll print out whatever response we get - err = http.skipResponseHeaders(); - if (err >= 0) - { - int bodyLen = http.contentLength(); - Serial.print("Content length is: "); - Serial.println(bodyLen); - Serial.println(); - Serial.println("Body returned follows:"); - - // Now we've got to the body, so we can print it out - unsigned long timeoutStart = millis(); - char c; - // Whilst we haven't timed out & haven't reached the end of the body - while ( (http.connected() || http.available()) && - ((millis() - timeoutStart) < kNetworkTimeout) ) - { - if (http.available()) - { - c = http.read(); - // Print out this character - Serial.print(c); - - bodyLen--; - // We read something, reset the timeout counter - timeoutStart = millis(); - } - else - { - // We haven't got any data, so let's pause to allow some to arrive - delay(kNetworkDelay); - } - } - } - else - { - Serial.print("Failed to skip response headers: "); - Serial.println(err); - } - } - else - { - Serial.print("Getting response failed: "); - Serial.println(err); - } - } - else - { - Serial.print("Connect failed: "); - Serial.println(err); - } - http.stop(); - // And just stop, now that we've tried a download - while(1); - } - void printWifiStatus() { - // print the SSID of the network you're attached to: - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - // print your WiFi shield's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); - } - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ----------------------------------------------------- - -.. method:: HttpClient::beginRequest - - -**Description** - -Start a more complex request. Use this when you need to send additional headers in the request, but you will also need to call -endRequest() when you are finished. - -**Syntax** - -.. code:: cpp - - void HttpClient::beginRequest(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of HttpClient:: HttpClient. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------------------------------------------ - -.. method:: HttpClient::endRequest - - -**Description** - -End a more complex request. Use this when you need to have sent additional headers in the request, but you will also need to call -beginRequest() at the start. - -**Syntax** - -.. code:: cpp - - void HttpClient::endRequest(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of HttpClient:: HttpClient. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------------------------------------------- - -.. method:: HttpClient::get - - -**Description** - -Connect to the server and start to send a ``GET`` request. If the input -parameter contains ``aServerAddress``, the connection will not perform a -DNS lookup and just purely connect to the given IP address. - -**Syntax** - -.. code:: cpp - - int HttpClient::get(const char* aServerName, uint16_t aServerPort,const char* aURLPath, const char* aUserAgent = 0); - -.. code:: cpp - - int HttpClient::get(const char* aServerName, const char* aURLPath,const char* aUserAgent=0); - -.. code:: cpp - - int HttpClient::get(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::get(const IPAddress& aServerAddress, const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); - -**Parameters** - -``aServerName``: The name of the server being connected to. If aServerName -is “NULL”, the “Host” header line will not be sent. - -``aServerPort``: The port on which server connected. - -``aURLPath``: The URL to request. - -``aUserAgent``: User-Agent string to be sent. If aUserAgent indicated as -“NULL”, the default user-agent kUserAgent will be sent. - -``aServerAddress``: IP address of the server to connect to. - -**Returns** - -Return 0 if successful, otherwise indicates an error occurs. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ---------------------------------------------------------- - -.. method:: HttpClient::post - - -**Description** - -Connect to the server and start to send a “POST” request. If the input - -parameter has “aServerAddress”, connects doesn’t perform a DNS lookup - -and just connects to the given IP address. - -**Syntax** - -.. code:: cpp - - int HttpClient::post(const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); - - -.. code:: cpp - - int HttpClient::post(const char* aServerName, const char* aURLPath,const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::post(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::post(const IPAddress& aServerAddress, const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); - -**Parameters** - -``aServerName`` : Name of the server being connected to. If NULL, the ``Host`` header line won’t be sent. - -``aServerPort`` : Port to connect to on the server. - -``aURLPath`` : Url to request. - -``aUserAgent`` : User-Agent string to be sent. If aUserAgent indicated as ``NULL``, the default user-agent kUserAgent will be sent. - -``aServerAddress`` : IP address of the server to connect to. - -**Returns** - -Return 0 if successful, otherwise indicates an error occurs. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------ - -.. method:: HttpClient::put - - -**Description** - -Connect to the server and start to send a PUT request. If the input -parameter has “aServerAddress”, connects doesn’t perform a DNS lookup -and just connects to the given IP address. - -**Syntax** - -.. code:: cpp - - int HttpClient::put(const char* aServerName, uint16_t aServerPort,const cha* aURLPath, const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::put(const char* aServerName, const char* aURLPath,const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::put(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); - -.. code:: cpp - - int HttpClient::put(const IPAddress& aServerAddress, const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); - -**Parameters** - -``aServerName``: Name of the server being connected to. If NULL, the ``Host`` header line won’t be sent. - -``aServerPort``: Port to connect to on the server. - -``aURLPath``: Url to request. - -``aUserAgent``: User-Agent string to be sent. If aUserAgent indicated as “NULL”, the default user-agent kUserAgent will be sent. - -``aServerAddress`` : IP address of the server to connect to. - -**Returns** - -Return 0 if successful, otherwise indicates an error occurs. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ----------------------------------------------------------------- - -.. method:: HttpClient::startRequest - -**Description** - -Connect to the server and start to send the request. - -**Syntax** - -.. code:: cpp - - int HttpClient::startRequest(const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aHttpMethod, constchar* aUserAgent); - -.. code:: cpp - - int HttpClient::startRequest(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aHttpMethod, const char* aUserAgent); - -**Parameters** - -``aServerAddress``: IP address of the server to connect to. - -``aServerName``: Name of the server being connected to. If NULL, the ``Host`` header line won’t be sent. - -``aServerPort``: Port to connect to on the server. - -``aURLPath``: Url to request. - -``aHttpMethod``: Type of HTTP request to make, e.g. “GET”, “POST”, etc. - -``aUserAgent``: User-Agent string to send. If NULL the default user-agent kUserAgent will be sent. - -**Returns** - -Return 0 if successful, else error. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------- - -.. method:: HttpClient::sendHeader - - -**Description** - -The function sends an additional header line.The function void HttpClient:: sendHeader(const char\* aHeader);can -only be called in between the calls to startRequest and finishRequest.The other 2 functions void HttpClient::sendHeader(const char\* -aHeaderName, const char\* aHeaderValue); and void -HttpClient::sendHeader(const char\* aHeaderName, const int aHeaderValue); are alternate form the previous one, which takes the -header name and content as separately (as strings or integer). For example, to send an XXXXXX header, user might call sendHeader(“XXXXX”, -“Something”) or sendHeader(“XXXXX”, 123).And the call will add the “: -” in the log to separate different header in the case of multiple headers. - -**Syntax** - -.. code:: cpp - - void HttpClient::sendHeader(const char* aHeader); - -.. code:: cpp - - void HttpClient::sendHeader(const char* aHeaderName, const char* aHeaderValue); - -.. code:: cpp - - void HttpClient::sendHeader(const char* aHeaderName, const int aHeaderValue); - -**Parameters** - -``aHeader`` : Header line to send, in its entirety (but without the trailing CRLF. E.g. “Authorization: Basic YQDDCAIGES”. - -``aHeaderName`` : Type of header being sent. - -``aHeaderValue`` : Value for that header. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URLindicated in kHostname[]. Details of the code can be found in the -previous section of HttpClient:: HttpClient. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------------------------- - -.. method:: HttpClient::sendBasicAuth - - -**Description** - -The function sends a basic authentication header which will encode the -given username and password, and send them in a suitable header line -for doing Basic Authentication. - -**Syntax** - -.. code:: cpp - - void HttpClient::sendBasicAuth(const char* aUser, const char* aPassword); - -**Parameters** - -``aUser``: Username for the authorization. - -``aPassword`` : Password for the user aUser. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of HttpClient:: HttpClient. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ---------------------------------------------------------------- - -.. method:: HttpClient::finishRequest - - -**Description** - -Finish sending the HTTP request. The function sends a blank line to signify the end of the request. - -**Syntax** - -.. code:: cpp - - void HttpClient::finishRequest(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - --------------------------------- - -.. method:: HttpClient::responseStatusCode - - -**Description** - -Get the HTTP status code contained in the response. For example, “200” -for successful requests, “404” for file not found, etc. - -**Syntax** - -.. code:: cpp - - int HttpClient::responseStatusCode(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return 0 if successful, else error. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------------- - -.. method:: HttpClient::readHeader - - -**Description** - -The function reads the next character of the response headers. This -functions the same as read() but to be used when reading through the -headers which are slightly less efficient. The user might check -whether the end of the headers has been reached by calling -endOfHeadersReached(), although after that point this will still -return data as read() would. - -**Syntax** - -.. code:: cpp - - int HttpClient::readHeader(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return the next character of the response headers. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ---------------------------------------- - -.. method:: HttpClient::skipResponseHeaders - - -**Description** - -Skip any response headers to get to the body. Use this if you don’t -want to do any special processing of the headers returned in the -response. You can also use it after you’ve found all of the headers -you’re interested in, and just want to get on with processing the -body. - -**Syntax** - -.. code:: cpp - - int HttpClient::skipResponseHeaders(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return 0 if successful, else error. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - -------------------------------------------------- - -.. method:: HttpClient::endOfHeadersReached - - -**Description** - -Test whether all of the response headers have been consumed. - -**Syntax** - -.. code:: cpp - - bool HttpClient::endOfHeadersReached(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return true if we are now processing the response body, else false. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ----------------------------------- - -.. method:: HttpClient::endOfBodyReached - - -**Description** - -Test whether the end of the body has been reached. It only works if -the Content-Length header was returned by the server. - -**Syntax** - -.. code:: cpp - - bool HttpClient::endOfBodyReached(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return true if we are now at the end of the body, else false. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of ``HttpClient:: HttpClient``. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - ------------------------------------- - -.. method:: HttpClient::contentLength - - -**Description** - -The function returns the length of the body. - -**Syntax** - -.. code:: cpp - - int HttpClient::contentLength(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Return Length of the body, in bytes, or kNoContentLengthHeader if no Content-Length header was returned by the server. - -**Example Code** - -Example: SimpleHttpExample - -The example demonstrates how to download the content from the URL -indicated in kHostname[]. Details of the code can be found in the -previous section of HttpClient:: HttpClient. - -**Notes and Warnings** - -Include “HttpClient.h” to use the class function.  - diff --git a/bak/ambd/_common/API_Documents/IRDevice/Class IRDevice.rst b/bak/ambd/_common/API_Documents/IRDevice/Class IRDevice.rst deleted file mode 100644 index fe8f761..0000000 --- a/bak/ambd/_common/API_Documents/IRDevice/Class IRDevice.rst +++ /dev/null @@ -1,315 +0,0 @@ -#################### -Class IRDevice -#################### - - -**Description** - -A class used for managing, sending, and receiving data using IR. - -**Syntax** - -.. code:: cpp - - class IRDevice - -**Members** - -+-----------------------------------------------------------------+---+ -| **Public Constructors** |   | -+=================================================================+===+ -| A public constructor should not be used as this class is | | -| intended to be a singleton class. Access member functions using | | -| the object instance named IR. | | -+-----------------------------------------------------------------+---+ - -+--------------------+------------------------------------------------+ -| **Public Methods** |   | -+====================+================================================+ -| IRDevice::getFreq | Get the current IR modulation frequency | -+--------------------+------------------------------------------------+ -| IRDevice::begin | Allocate resources and start the IR device | -| | with a custom frequency | -+--------------------+------------------------------------------------+ -| IRDevice::end | Stop the IR device operations and free up | -| | resources | -+--------------------+------------------------------------------------+ -| IRDevice::send | Send IR raw data | -+--------------------+------------------------------------------------+ -| IRDevice::beginNEC | Allocate resources and start the IR device | -| | with a frequency suitable for the NEC protocol | -+--------------------+------------------------------------------------+ -| IRDevice::sendNEC | Send data using the NEC protocol | -+--------------------+------------------------------------------------+ -| IRDevice::recvNEC | Receive data using the NEC protocol | -+--------------------+------------------------------------------------+ - ---------------------------------------------------------------------------------- - -.. method:: IRDevice::getFreq - -**Description** - -Get the current IR modulation frequency. - -**Syntax** - -.. code:: cpp - - uint32_t getFreq(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Currently set IR modulation frequency in Hertz. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----------------------------------------------------------------------------------- - -.. method:: IRDevice::begin - -**Description** - -Allocate resources and start the IR device with a custom frequency. - -**Syntax** - -.. code:: cpp - - void begin(uint8_t receivePin, uint8_t transmitPin, uint32_t irMode, uint32_t freq); - -**Parameters** - -``receivePin`` : pin on which IR sensor is connected. Hardware IR receiver -is available at pins 3, 8, 17. - -``transmitPin`` : pin on which IR LED is connected. Hardware IR transmitter -is available at pins 6, 9, 16. - -``irMode``: transmit or receive mode. Valid values: IR_MODE_TX, IR_MODE_RX - -``freq`` : IR modulation frequency in Hertz - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -IR device can only operate in either transmit or receive mode. - ------ - -.. method:: IRDevice::end - - -**Description** - -Stop the IR device operations and free up resources. - -**Syntax** - -.. code:: cpp - - void end(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: IRDevice::send - -**Description** - -Send IR raw data. - -**Syntax** - -.. code:: cpp - - void send(const unsigned int buf[ ] , uint16_t len); - -**Parameters** - -``buf[ ]`` : IR raw signals (in us) in an array form. - -``len`` : total length of the IR raw signal array. - -**Returns** - -The function returns nothing. - -**Example Code** - -.. code:: cpp - - #include "IRDevice.h" - // User defined txPin, rxPin and carrier frequency - #define IR_RX_PIN 8 - #define IR_TX_PIN 9 - #define CARRIER_FREQ 38000 - - unsigned int irRawSignal[] = { - 9000, 4500, // starting bit - 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, // address 00100000 : 4 - 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, // ~ address 11011111 - 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, // data 00010000 : 8 - 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, //~ data 11101111 - 560 // stoping bit - }; - int DataLen = sizeof(irRawSignal) / sizeof(irRawSignal[0]); // 284/ 4 = 71 - - void setup() - { - Serial.begin(115200); - IR.begin(IR_RX_PIN, IR_TX_PIN, IR_MODE_TX, CARRIER_FREQ); - } - - void loop() - { - IR.send(irRawSignal, DataLen); - Serial.println("Finished Sending NEC Raw Data...."); - delay(3000); - } - - -**Notes and Warnings** - -IR device can only operate in either transmit or receive mode. Refer -to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol for -the NEC protocol. - ------ - -.. method:: IRDevice::sendNEC - - -**Description** - -Send data using the NEC protocol. - -**Syntax** - -.. code:: cpp - - void sendNEC(uint8_t adr, uint8_t cmd); - -**Parameters** - -``adr`` : 8-bit address to transmit - -``cmd`` : 8-bit command to transmit - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: IRSendNEC - -.. code:: cpp - - #include "IRDevice.h" - - uint8_t adr = 0; - uint8_t cmd = 0; - - void setup() { - //Initialize serial and wait for port to open: - Serial.begin(115200); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - IR.beginNEC(8, 9, IR_MODE_TX); // configure for NEC IR protocol - } - - void loop() { - if (cmd++ >=255) { - adr++; - } - - IR.sendNEC(adr, cmd); - Serial.print("Sent "); - Serial.print(adr); - Serial.print(cmd); - Serial.println(); - //IR.end(); // Call this method to stop IR device and free up the pins for other uses - } - - -**Notes and Warnings** - -IR device can only operate in either transmit or receive mode. Refer -to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol for -the NEC protocol. -  - ------ - -.. method:: IRDevice::recvNEC - - -**Description** - -Receive data using the NEC protocol. - -**Syntax** - -.. code:: cpp - - void recvNEC(uint8_t& adr, uint8_t& cmd uint32_t timeout); - -**Parameters** - -``adr`` : variable to store received NEC address - -``cmd`` : variable to store received NEC command - -``timeout`` : time duration to wait for an incoming transmission - -**Returns** - -The function returns “1” if data has been received, returns “0” if no -data has been received. - -**Example Code** - -Example: IRRecvNEC - -Details of the code can be found in the previous section of -IRDevice::beginNEC. - -**Notes and Warnings** - -IR device can only operate in either transmit or receive mode. Refer -to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol  for -the NEC protocol. diff --git a/bak/ambd/_common/API_Documents/MDNS/Class MDNSClass.rst b/bak/ambd/_common/API_Documents/MDNS/Class MDNSClass.rst deleted file mode 100644 index 059e8eb..0000000 --- a/bak/ambd/_common/API_Documents/MDNS/Class MDNSClass.rst +++ /dev/null @@ -1,234 +0,0 @@ -#################### -Class MDNS -#################### - -**Description** - -A class used for registering and removing MDNS service records. - -**Syntax** - -.. code:: cpp - - class MDNSClass - -**Members** - -+-----------------------------------------------------------------+---+ -| **Public Constructors** |   | -+=================================================================+===+ -| The public constructor should not be used as this class is | | -| intended to be a singleton class. Access member functions using | | -| the object instance named MDNS. | | -+-----------------------------------------------------------------+---+ - -============================ ===================== -**Public Methods**   -============================ ===================== -MDNSClass::begin Start MDNS operations -MDNSClass::end Stop MDNS operations -MDNSClass::registerService Add a service record -MDNSClass::deregisterService Remove service record -MDNSClass::updateService Update service record -============================ ===================== - ------------------------- - -.. method:: MDNSClass::begin - - -**Description** - -Start MDNS operations to begin responding to MDNS queries. - -**Syntax** - -.. code:: cpp - - void begin(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: mDNS_On_Arduino_IDE - -This example shows how to register Ameba as a service that can be - -recognized by Arduino IDE. If both of the PC runs Arduino IDE and the -Ameba board are connecting to the same local network. Then you can -find Ameba in “Tools” -> “Port” -> “Arduino at 192.168.1.238 (Ameba -RTL8195A), which means the Arduino IDE find Ameba via mDNS. - -.. code-block:: cpp - :caption: mDNS_On_Arduino_IDE - :linenos: - - #include "WiFi.h" - #include "AmebaMDNS.h" - - char ssid[] = "yourNetwork"; // your network SSID (name) - char pass[] = "secretPassword"; // your network password - - MDNSService service("MyAmeba", "_arduino._tcp", "local", 5000); - - void setup() { - printf("Try to connect to %s\r\n", ssid); - while (WiFi.begin(ssid, pass) != WL_CONNECTED) { - printf("Failed. Wait 1s and retry...\r\n"); - delay(1000); - } - printf("Connected to %s\r\n", ssid); - - service.addTxtRecord("board", strlen("ameba_rtl8195a"), "ameba_rtl8195a"); - service.addTxtRecord("auth_upload", strlen("no"), "no"); - service.addTxtRecord("tcp_check", strlen("no"), "no"); - service.addTxtRecord("ssh_upload", strlen("no"), "no"); - - printf("Start mDNS service\r\n"); - MDNS.begin(); - - printf("register mDNS service\r\n"); - MDNS.registerService(service); - } - - void loop() { - // put your main code here, to run repeatedly: - delay(1000); - } - ----------------------------------------------------------- - -.. method:: MDNSClass::end - - -**Description** - -Stop MDNS operations and stop responding to MDNS queries. - -**Syntax** - -.. code:: cpp - - void end(void); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function.  - ------------------------------------------------------------- - -.. method:: MDNSClass::registerService - - -**Description** - -Add a service record to be included in MDNS responses. - -**Syntax** - -.. code:: cpp - - void register service(MDNSService service); - -**Parameters** - -``service`` : MDNSService class object with required MDNS service data - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: mDNS_On_Arduino_IDE - -Details of the code can be found in the previous section of ``MDNSClass:: begin``. - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function.  - --------------------------------------------------------------------------------- - -.. method:: MDNSClass::deregisterService - -**Description** - -Remove a service record from MDNS responses. - -**Syntax** - -.. code:: cpp - - void deregisterService(MDNSService service); - -**Parameters** - -``service`` : MDNSService class object to be removed - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: mDNS_On_Arduino_IDE - -Details of the code can be found in the previous section of ``MDNSClass:: begin``. - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function.  - -------------------------------------------------------------- - - -.. method:: MDNSClass::updateService - - -**Description** - -Update a service record. - -**Syntax** - -.. code:: cpp - - void updateService(MDNSService service, unsigned int ttl); - -**Parameters** - -``service``: MDNSService class object to be updated - -``ttl`` : time-to-live(TTL) for service - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function. diff --git a/bak/ambd/_common/API_Documents/MDNS/Class MDNSService.rst b/bak/ambd/_common/API_Documents/MDNS/Class MDNSService.rst deleted file mode 100644 index e0c7a81..0000000 --- a/bak/ambd/_common/API_Documents/MDNS/Class MDNSService.rst +++ /dev/null @@ -1,100 +0,0 @@ -################### -Class MDNSService -################### - -**Description** - -A class used for creating MDNS service records. - -**Syntax** - -.. code:: cpp - - class MDNSService - -**Members** - -========================= =============================== -**Public Constructors**   -========================= =============================== -MDNSService::MDNSService Create a MDNS service record -========================= =============================== - -========================= =============================== -**Public Methods**   -MDNSService::addTxtRecord Add text to MDNS service record -========================= =============================== - ------------------------------------------------------------ - -.. class:: MDNSService::MDNSService - - -**Description** - -Create a MDNS service record. - -**Syntax** - -.. code:: cpp - - MDNSService(char* name, char* service_type, char* domain, unsigned short port, int bufsize); - -**Parameters** - -``name``: device name - -``service_type``: MDNS service type - -``domain``: host domain - -``port``: network port - -``bufsize`` : size of buffer for MDNS text record - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: mDNS_On_Arduino_IDE - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function. - -------------------------------------------- - -.. method:: MDNSService::addTxtRecord* - - -**Description** - -Add text to MDNS service record. - -**Syntax** - -.. code:: cpp - - int addTextRecord(char* key, int value_len, char* value); - -**Parameters** - -``key`` : record type expressed as character string - -``value_len`` : length of value string - -``value`` : record value expressed as character string - -**Returns** - -0 if add record successful - -**Example Code** - -Example: mDNS_On_Arduino_IDE - -**Notes and Warnings** - -Include “AmebaMDNS.h” to use the class function. diff --git a/bak/ambd/_common/API_Documents/MQTTClient/Class PubSubClient.rst b/bak/ambd/_common/API_Documents/MQTTClient/Class PubSubClient.rst deleted file mode 100644 index cd72843..0000000 --- a/bak/ambd/_common/API_Documents/MQTTClient/Class PubSubClient.rst +++ /dev/null @@ -1,671 +0,0 @@ -###################### -Class PubSubClient -###################### - - -**Description** - -Defines a class of MQTT implementation for Ameba. - -**Syntax** - -.. code:: cpp - - class PubSubClient - -**Members** - -+----------------------------+----------------------------------------+ -| **Public Constructors** |   | -+============================+========================================+ -| PubSubClient::PubSubClient | Constructs a PubSubClient object | -+----------------------------+----------------------------------------+ - - -+----------------------------+----------------------------------------+ -| **Public Methods** |   | -+============================+========================================+ -| PubSubClient::setServer | Set MQTT server address and port | -+----------------------------+----------------------------------------+ -| PubSubClient::setCallback | Set callback function | -+----------------------------+----------------------------------------+ -| PubSubClient::setClient | Set WiFi client | -+----------------------------+----------------------------------------+ -| PubSubClient::setStream | Set data stream | -+----------------------------+----------------------------------------+ -| PubSubClient::connect | Attempt to connect to server | -+----------------------------+----------------------------------------+ -| PubSubClient::disconnect | Disconnect from current session | -+----------------------------+----------------------------------------+ -| PubSubClient::publish | Publish a message to server | -+----------------------------+----------------------------------------+ -| PubSubClient::publish_P | Same as above | -+----------------------------+----------------------------------------+ -| PubSubClient::subscribe | Subscribe to a topic | -+----------------------------+----------------------------------------+ -| PubSubClient::unsubscribe | Unsubscribe to a topic | -+----------------------------+----------------------------------------+ -| PubSubClient::loop | Keep MQTT session alive and process | -| | any queuing tasks | -+----------------------------+----------------------------------------+ -| PubSubClient::connected | Check if client still connected | -+----------------------------+----------------------------------------+ -| PubSubClient::state | Return connection state | -+----------------------------+----------------------------------------+ - ------ - -.. method:: PubSubClient::PubSubClient - - -**Description** - -Constructs a PubSubClient object and, if applicable, sets server -address, port, callback function, data stream and wifi client. - -**Syntax** - -.. code:: cpp - - PubSubClient::PubSubClient(); - -.. code:: cpp - - PubSubClient::PubSubClient(Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(IPAddress, uint16_t, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(IPAddress, uint16_t, Client& client, Stream&); - -.. code:: cpp - - PubSubClient::PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(IPAddress, uint16_t,MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); - -.. code:: cpp - - PubSubClient::PubSubClient(uint8_t*, uint16_t, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(uint8_t*, uint16_t, Client& client, Stream&); - -.. code:: cpp - - PubSubClient::PubSubClient(uint8_t*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(uint8_t*, uint16_t,MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); - -.. code:: cpp - - PubSubClient::PubSubClient(const char*, uint16_t, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(const char*, uint16_t, Client& client, Stream&); - -.. code:: cpp - - PubSubClient::PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); - -.. code:: cpp - - PubSubClient::PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); - -**Parameters** - -``client`` : the network client to use, for example WiFiClient - -``IPAddress`` : MQTT server address - -``port`` : port for MQTT, usually 1883 for unencrypted connection - -``MQTT_CALLBACK_SIGNATURE`` : callback function for MQTT - -``Stream`` : a stream to write received messages to - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -PubSubClient::PubSubClient(Client& client) would suffice for normal -MQTT connection  - ------ - -.. method:: PubSubClient::setServer - -**Description** - -Sets the server details. - -**Syntax** - -.. code:: cpp - - PubSubClient& PubSubClient::setServer(uint8_t * ip, uint16_t port) - -.. code:: cpp - - PubSubClient& PubSubClient::setServer(IPAddress ip, uint16_t port) - -.. code:: cpp - - PubSubClient& PubSubClient::setServer(const char* domain, uint16_t - port) - - -**Parameters** - -``ip`` : the address of the server - -``port`` : the port to connect to, default 1883 - -``domain`` : the address of the server - -**Returns** - -The client instance, allowing the function to be chained - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::setCallback - - -**Description** - -Sets the message callback function. - -**Syntax** - -.. code:: cpp - - PubSubClient& PubSubClient::setCallback(MQTT_CALLBACK_SIGNATURE) - -**Parameters** - -``MQTT_CALLBACK_SIGNATURE`` : a pointer to a message callback function -called when a message arrives for a subscription created by this -client. - -**Returns** - -The client instance, allowing the function to be chained. - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::setClient - - -**Description** - -Sets the network client instance to use. - -**Syntax** - -.. code:: cpp - - PubSubClient& PubSubClient::setClient(Client& client) - -**Parameters** - -``client`` : the network client to use, for example WiFiClient - -**Returns** - -The client instance, allowing the function to be chained - -**Example Code** - -NA - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::setStream - - -**Description** - -Sets the stream to write received messages to. - -**Syntax** - -.. code:: cpp - - PubSubClient& PubSubClient::setStream(Stream& stream) - -**Parameters** - -``stream`` : a stream to write received messages to - -**Returns** - -The client instance, allowing the function to be chained. - -**Example Code** - -NA - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::connect - - -**Description** - -Connects the client to the server. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::connect(const char *id) - -.. code:: cpp - - boolean PubSubClient::connect(const char *id, const char *user, const char *pass) - -.. code:: cpp - - boolean PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) - -.. code:: cpp - - boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) - -**Parameters** - -``id`` : Client ID, a unique string identifier - -``user``: Username for authentication, default NULL - -``pass`` : Password for authentication, default NULL - -``willTopic`` : the topic to be used by the will message - -``willQoS`` : the quality of service to be used by the will message - -``willRetain`` : whether the will should be published with the retain flag - -``willMessage`` : the payload of the will message - -**Returns** - -True – connection succeeded - -False – connection failed - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -Client ID is required and should always be unique else connection -might be rejected by the server.  - ------ - -.. method:: PubSubClient::disconnect - -**Description** - -Disconnect the client - -**Syntax** - -.. code:: cpp - - void PubSubClient::disconnect(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::publish - -**Description** - -Publishes a message to the specified topic. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::publish(const char* topic, const char* payload) - -.. code:: cpp - - boolean PubSubClient::publish(const char* topic, const char* payload, boolean retained) - -.. code:: cpp - - boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength) - -.. code:: cpp - - boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) - -**Parameters** - -``topic`` : the topic to publish to - -``payload`` : the message to publish - -``plength`` : the length of the payload. Required if payload is a byte[] - -``retained`` : whether the message should be retained - -– false – not retained - -– true – retained - -**Returns** - -False – publish failed, either connection lost or message too large - -True – publish succeeded - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -Default max packet size is 128 bytes.  - ------- - -.. method:: PubSubClient::publish_P - - -**Description** - -Publishes a message stored in PROGMEM to the specified topic. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) - -**Parameters** - -``topic`` : the topic to publish to - -``payload`` : the message to publish - -``plength`` : the length of the payload. Required if payload is a byte[] - -``retained`` : whether the message should be retained - -– false – not retained - -– true – retained - -**Returns** - -False – publish failed, either connection lost or message too large - -True – publish succeeded - -**Example Code** - -NA - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::subscribe - - -**Description** - -Subscribes to messages published to the specified topic. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::subscribe(const char* topic) - -.. code:: cpp - - boolean PubSubClient::subscribe(const char* topic, uint8_t qos) - -**Parameters** - -``topic`` : the topic to subscribe to - -``qos`` : the qos to subscribe at - -**Returns** - -False – sending the subscribe failed, either connection lost or -message too large - -True – sending the subscribe succeeded - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::unsubscribe - - -**Description** - -Unsubscribes from the specified topic. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::unsubscribe(const char* topic) - -**Parameters** - -``topic`` : the topic to unsubscribe to - -**Returns** - -False – sending the unsubscribe failed, either connection lost or -message too large - -True – sending the unsubscribe succeeded - -**Example Code** - -NA - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::loop - - -**Description** - -A must method called regularly to allow the client to process incoming -messages and maintain its connection to the server. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::loop(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -False – the client is no longer connected - -True – the client is still connected - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -A required method that should not be blocked for too long.  - ------ - -.. method:: PubSubClient::connected - - -**Description** - -Checks whether the client is connected to the server. - -**Syntax** - -.. code:: cpp - - boolean PubSubClient::connected(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -False – the client is not connected - -True – the client is connected - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -NA  - ------ - -.. method:: PubSubClient::state - - -**Description** - -Returns the current state of the client. If a connection attempt -fails, this can be used to get more information about the failure. -All of the values have corresponding constants defined in -PubSubClient.h. - -**Syntax** - -.. code:: cpp - - int PubSubClient::state(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - --4 : MQTT_CONNECTION_TIMEOUT – the server didn’t respond within the - -keepalive time - --3 : MQTT_CONNECTION_LOST – the network connection was broken - --2 : MQTT_CONNECT_FAILED – the network connection failed - --1 : MQTT_DISCONNECTED – the client is disconnected cleanly - -0 : MQTT_CONNECTED – the client is connected - -1 : MQTT_CONNECT_BAD_PROTOCOL – the server doesn’t support the -requested version of MQTT - -2 : MQTT_CONNECT_BAD_CLIENT_ID – the server rejected the client -identifier - -3 : MQTT_CONNECT_UNAVAILABLE – the server was unable to accept the -connection - -4 : MQTT_CONNECT_BAD_CREDENTIALS – the username/password were rejected - -5 : MQTT_CONNECT_UNAUTHORIZED – the client was not authorized to -connect - -**Example Code** - -Example: MQTT_Basic - -**Notes and Warnings** - -NA  - diff --git a/bak/ambd/_common/API_Documents/NTPClient/Readme.rst b/bak/ambd/_common/API_Documents/NTPClient/Readme.rst deleted file mode 100644 index b21d6ab..0000000 --- a/bak/ambd/_common/API_Documents/NTPClient/Readme.rst +++ /dev/null @@ -1,14 +0,0 @@ -NTPClient library -================= - -.. contents:: - :local: - :depth: 2 - -**NTPClient library** ---------------------- - -**Description** -~~~~~~~~~~~~~~~ - -The NTPClient library is based on the NTPClient library written by Fabrice Weinberg, which can be found at `arduino-libraries/NTPClient `_ These include, NTPClient.cpp NTPClient.h These libraries are licensed under MIT License. diff --git a/bak/ambd/_common/API_Documents/PowerSave/Class PMUClass.rst b/bak/ambd/_common/API_Documents/PowerSave/Class PMUClass.rst deleted file mode 100644 index 67cb09c..0000000 --- a/bak/ambd/_common/API_Documents/PowerSave/Class PMUClass.rst +++ /dev/null @@ -1,146 +0,0 @@ -Class PMUClass -============= - -.. contents:: - :local: - :depth: 2 - -**PMUClass Class** ------------------ - -**Description** -~~~~~~~~~~~~~~~~~ - -A class used for PowerMode control. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - class PMClass - -**Members** -~~~~~~~~~~~ - -+-----------------------------------+-----------------------------------+ -| **Public Constructors** | -+===================================+===================================+ -| PMClass::PMClass | Constructs an PMClass object. | -+-----------------------------------+-----------------------------------+ -| **Public Methods** | -+-----------------------------------+-----------------------------------+ -| PMClass::begin | Initializes the PowerMode | -| | settings for device, include type | -| | of the mode, wake up sources and | -| | related source settings. | -+-----------------------------------+-----------------------------------+ -| PMClass::start | Start the PowerMode of device. | -+-----------------------------------+-----------------------------------+ - -**PMClass::begin** -~~~~~~~~~~~~~~~~~~ - -**Description** -~~~~~~~~~~~~~~~ - -Initializes the PowerMode settings for device, include type of the mode, wake up sources and related source settings. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void begin(uint32_t sleep_mode, int wakeup_source, uint32_t wakeup_setting = 0); - -**Parameters** -~~~~~~~~~~~~~~ - -sleep_mode: Power Mode selection. - -- Deepsleep mode: DEEPSLEEP_MODE; Standby mode: STANDBY_MODE - -wakeup_source: Wake up source selection. - -- AON timer, AON GPIO, RTC, PON GPIO, UART/Serial1, and Gtimer0 (0 to 5). - -wakeup_setting: Settings for different wakeup sources. Default value is 0. - -- For AON time, it is a pointer to an array that stores clock(1:4MHz; 0:100kHz) and duration(by seconds). - -- For AON GPIO, it is pin number 21 or 22. - -- For RTC, it is a pointer to an array that stores time duration as day, hour, min and sec(0, 0:0:0, to 365, 23:59:59). - -- For PON GPIO, it is pin number 0 to 11. - -- For Gtimer0, it is time duration in seconds. (start from 1s) - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DeepSleepMode `_, `StandbyMode `_ - -.. note :: "PowerMode.h" must be included to use the class function. - -**PMClass::start** ------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Start the PowerMode of device. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void start(void); - void start(int year, int month, int day, int hour, int min, int sec); - -**Parameters** -~~~~~~~~~~~~~~ - -Optional when wake up source is RTC. Default start time is 1970.1.100:00:00. - -year: Start time by year. - -- Starts from 1900 - -month: Start time by month. - -- 0 to 11 - -day: Start time by day. - -- 1 to 365 - -hour: Start time by hour - -- 0 to 23 - -min: Start time by min. - -- 0 to 59 - -sec: Start time by sec. - -- 0 to 59 - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `DeepSleepMode `_, `StandbyMode `_ - -.. note :: "PowerMode.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/Gtimer/Class GTimerClass.rst b/source/_common/ameba_d/API_Documents/Gtimer/Class GTimerClass.rst similarity index 51% rename from bak/ambd/_common/API_Documents/Gtimer/Class GTimerClass.rst rename to source/_common/ameba_d/API_Documents/Gtimer/Class GTimerClass.rst index 36e8909..64d131c 100644 --- a/bak/ambd/_common/API_Documents/Gtimer/Class GTimerClass.rst +++ b/source/_common/ameba_d/API_Documents/Gtimer/Class GTimerClass.rst @@ -11,7 +11,7 @@ Class GTimerClass **Description** ~~~~~~~~~~~~~~~ -A class used for initializing, starting, stopping Gtimer. +A class used for managing GTimer settings. GTimer is a hardware timer and occupy same resource as PWM. Please make sure the timer is not conflict with you PWM index. **Syntax** ~~~~~~~~~~ @@ -53,24 +53,19 @@ Initialize a timer and start it immediately. .. code-block:: c++ - void begin(uint32_t timerid, uint32_t duration_us, void (*handler)(uint32_t), bool periodical = true, uint32_t userdata = 0, uint32_t timer0_clk_sel = 0); + void begin(uint32_t timerid, uint32_t duration_us, void (*handler)(uint32_t), bool periodical, uint32_t userdata); **Parameters** ~~~~~~~~~~~~~~ -timerid: There are 5 valid GTimer with timer id. +``timerid``: GTimer ID. (There are 5 valid GTimer with timer id 0~4) -- 0 to 4 +``duration_us``: The duration of timer unit is microsecond (us). The precision is 32768Hz. -duration_us: The duration of timer unit is microsecond. The precision is 32768Hz. +``periodical``: By default, the timer would keep periodically countdown and reload, which means the handler would periodically be invoked. (Default value: True) -handler: As timer timeout, it would invoke this handler. +``userdata``: The user data brings to the handler. Default value is 0. -periodical: By default, the timer would keep periodically countdown and reload which leads the handler periodically invoked. - -userdata: The user data brings to the handler. Default value is 0. - -timer0_clk_sel: Select the timer0 clock, 0 for 40MHz or 1 for 4MHz. Default value is 0. **Returns** ~~~~~~~~~~~ @@ -80,7 +75,7 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `TimerOneshot `_, `TimerPeriodical `_ +Example: `TimerOneshot `_ .. note :: "GTimer.h" must be included to use the class function. @@ -102,9 +97,7 @@ Stop a specific timer. **Parameters** ~~~~~~~~~~~~~~ -timerid: Stop the timer with its timer id. - -- 0 to 4 +``timerid``: Stop the timer with the selected timer id. (There are 5 valid GTimer with timer id 0~4) **Returns** ~~~~~~~~~~~ @@ -114,7 +107,7 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `TimerOneshot `_, `TimerPeriodical `_ +Example: `TimerPeriodical `_ .. note :: "GTimer.h" must be included to use the class function. @@ -124,25 +117,21 @@ Example: `TimerOneshot `_, `TimerPeriodical `_ +NA .. note :: "GTimer.h" must be included to use the class function. @@ -162,30 +151,29 @@ Example: `TimerOneshot `_, `TimerPeriodical `_ +NA .. note :: "GTimer.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/Gtimer/index.rst b/source/_common/ameba_d/API_Documents/Gtimer/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/Gtimer/index.rst rename to source/_common/ameba_d/API_Documents/Gtimer/index.rst diff --git a/source/_common/ameba_d/API_Documents/Http/Class HttpClient.rst b/source/_common/ameba_d/API_Documents/Http/Class HttpClient.rst new file mode 100644 index 0000000..a3d0190 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/Http/Class HttpClient.rst @@ -0,0 +1,1025 @@ +Class HttpClient +================ + +.. contents:: + :local: + :depth: 2 + +**HttpClient Class** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class to use HttpClient + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class HttpClient + +**Members** +~~~~~~~~~~~ + ++---------------------------------+-----------------------------------+ +| **Public Constructors** | | ++=================================+===================================+ +| HttpClient::HttpClient | Constructs a HttpClient object | ++---------------------------------+-----------------------------------+ +| **Public Methods** | | ++---------------------------------+-----------------------------------+ +| HttpClient::stop | Disconnect from the server | ++---------------------------------+-----------------------------------+ +| HttpClient::beginRequest | Start a more complex request | ++---------------------------------+-----------------------------------+ +| HttpClient::startRequest | Connect to the server and start | +| | to send the request | ++---------------------------------+-----------------------------------+ +| HttpClient::sendHeader | Send an additional header line | ++---------------------------------+-----------------------------------+ +| HttpClient::sendBasicAuth | Send a basic authentication header| ++---------------------------------+-----------------------------------+ +| HttpClient::finishHeaders | Let the server know that we've | +| | reached the end of the headers | ++---------------------------------+-----------------------------------+ +| HttpClient::endRequest | End a more complex request | ++---------------------------------+-----------------------------------+ +| HttpClient::responseStatusCode | Get the HTTP status code | +| | contained in the response | ++---------------------------------+-----------------------------------+ +| HttpClient::get | Connect to the server and start | +| | to send a GET request | ++---------------------------------+-----------------------------------+ +| HttpClient::post | Connect to the server and start | +| | to send a POST request | ++---------------------------------+-----------------------------------+ +| HttpClient::put | Connect to the server and start | +| | to send a PUT request | ++---------------------------------+-----------------------------------+ +| HttpClient::skipResponseHeaders | Skip any response headers to get | +| | to the body | ++---------------------------------+-----------------------------------+ +| HttpClient::endOfBodyReached | Check whether the end of the body | +| | has been reached | ++---------------------------------+-----------------------------------+ +| HttpClient::read | Returns the incoming byte from the| +| | server that the client is | +| | connected to | ++---------------------------------+-----------------------------------+ +| HttpClient::readHeader | Read the next character of the | +| | response headers | ++---------------------------------+-----------------------------------+ +| HttpClient::finishRequest | Finish sending the HTTP request | ++---------------------------------+-----------------------------------+ +| HttpClient::endOfHeadersReached | The function reads the next | +| | character of the response headers | ++---------------------------------+-----------------------------------+ +| HttpClient::endOfStream | Check whether the end of the body | +| | has been reached | ++---------------------------------+-----------------------------------+ +| HttpClient::completed | Check whether the end of the body | +| | has been reached | ++---------------------------------+-----------------------------------+ +| HttpClient::contentLength | This function returns the length | +| | of the body | ++---------------------------------+-----------------------------------+ +| HttpClient::available | Get the number of bytes available | +| | for reading | ++---------------------------------+-----------------------------------+ +| HttpClient::connected | Check if client is connected | ++---------------------------------+-----------------------------------+ + +-------------------------------------------------- + +**HttpClient::HttpClient** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a HttpClient object. The Marco “PROXY_ENABLED” is defined and currently disabled as introduces a dependency on DNS.h in Ethernet. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + HttpClient(Client& aClient, const char* aProxy = NULL, uint16_t aProxyPort); + +.. code:: c++ + + HttpClient(Client& aClient); + +**Parameters** +~~~~~~~~~~~~~~ + +``aClient``: The object of class WiFiClient. + +``aProxy``: The proxy name. (The default proxy name is set to “NULL”) + +``aProxyPort``: The proxy port. (Default value: 0) + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included must be included to use the class function. + +---------------------------------------------------- + +**HttpClient::stop** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disconnect from the server and reset the status. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void stop(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “HttpClient.h” must be included to use the class function. + +----------------------------------------------------------------- + +**HttpClient::beginRequest** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start a more complex request. Use this when you need to send additional headers in the request, but you will also need to call endRequest() when you are finished. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void beginRequest(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------------------------------------ + +**HttpClient::startRequest** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the server and start to send the request. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int startRequest(const char* aServerName,uint16_t aServerPort,const char* aURLPath, const char* aHttpMethod, const char* aUserAgent); + +.. code:: c++ + + int startRequest(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aHttpMethod, const char* aUserAgent); + +**Parameters** +~~~~~~~~~~~~~~ + +``aServerAddress``: IP address of the server to connect to. + +``aServerName``: Name of the server being connected to. If NULL, the “Host” header line won't be sent. + +``aServerPort``: Port to connect to on the server. + +``aURLPath``: Url to request. + +``aHttpMethod``: Type of HTTP request to make, e.g. “GET”, “POST”, etc. + +``aUserAgent``: User-Agent string to send. If NULL the default user-agent kUserAgent will be sent. + + +**Returns** +~~~~~~~~~~~ + +This function returns 0 if successful, else returns error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +--------------------------------------------------------- + +**HttpClient::sendHeader** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +The function sends an additional header line. +The function can only be called in between startRequest and finishRequest functions. + +The other 2 functions, +void sendHeader(const char* aHeaderName, const char* aHeaderValue); +void sendHeader(const char* aHeaderName, const int aHeaderValue); +are alternate form from the void HttpClient::sendHeader(const char* aHeader); which takes the header name and content as separate strings. The call will add the “:” in the log to separate different header in the case of multiple headers. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void sendHeader(const char* aHeader); + +.. code:: c++ + + void sendHeader(const char* aHeaderName, const char* aHeaderValue); + +.. code:: c++ + + void sendHeader(const char* aHeaderName, const int aHeaderValue); + +**Parameters** +~~~~~~~~~~~~~~ + +``aHeader`` : Header line to send, in its entirety (but without the trailing CRLF. E.g. “Authorization: Basic YQDDCAIGES”. + +``aHeaderName`` : Type of header being sent. + +``aHeaderValue`` : Value for that header. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +----------------------------- + +**HttpClient::sendBasicAuth** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +The function sends a basic authentication header which will encode the given username and password, and send them in a suitable header line for doing Basic Authentication. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void sendBasicAuth(const char* aUser, const char* aPassword); + +**Parameters** +~~~~~~~~~~~~~~ + +``aUser``: Username for the authorization. + +``aPassword`` : Password for the user aUser. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::finishHeaders** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Let the server know that we've reached the end of the headers + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void finishHeaders(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::get** +------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the server and start to send a “GET” request. If the input parameter contains “aServerAddress”, DNS lookup will not be performed and just purely connect to the given IP address. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int get(const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int get(const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int get(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int get(const IPAddress& aServerAddress, const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +**Parameters** +~~~~~~~~~~~~~~ + +``aServerName``: The name of the server being connected to. If aServerName is “NULL”, the “Host” header line will not be sent. + +``aServerPort``: The port on which server connected. + +``aURLPath``: The URL to request. + +``aUserAgent``: User-Agent string to be sent. If aUserAgent indicated as “NULL”, the default user-agent kUserAgent will be sent. + +``aServerAddress``: IP address of the server to connect to. + +**Returns** +~~~~~~~~~~~ + +This function returns 0 if successful, else returns an error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +---------------------------------------------------------------- + +**HttpClient::post** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the server and start to send a “POST” request. If the input parameter has “aServerAddress”, DNS lookup will not be performed and just purely connect to the given IP address. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int post(const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int post(const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int post(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int post(const IPAddress& aServerAddress,const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +**Parameters** +~~~~~~~~~~~~~~ + +``aServerName``: Name of the server being connected to. If NULL, the “Host” header line won't be sent. + +``aServerPort``: Port to connect to on the server. + +``aURLPath``: Url to request. + +``aUserAgent``: User-Agent string to be sent. If aUserAgent indicated as “NULL”, the default user-agent kUserAgent will be sent. Default value: NULL. + +``aServerAddress``: IP address of the server to connect to. + +**Returns** +~~~~~~~~~~~ + +This function returns 0 if successful, else returns error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +---------------------------------------------------------------- + +**HttpClient::put** +------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connect to the server and start to send a PUT request. If the input parameter has “aServerAddress”, DNS lookup will not be performed and just connect to the given IP address. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int put(const char* aServerName, uint16_t aServerPort,const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int put(const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int put(const IPAddress& aServerAddress,const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aUserAgent = NULL); + +.. code:: c++ + + int put(const IPAddress& aServerAddress,const char* aServerName, const char* aURLPath, const char* aUserAgent = NULL); + +**Parameters** +~~~~~~~~~~~~~~ + +``aServerName``: Name of the server being connected to. If NULL, the “Host” header line won't be sent. + +``aServerPort``: Port to connect to on the server. + +``aURLPath``: Url to request. + +``aUserAgent``: User-Agent string to be sent. If aUserAgent indicated as “NULL”, the default user-agent kUserAgent will be sent. Default value: NULL. + +``aServerAddress``: IP address of the server to connect to. + +**Returns** +~~~~~~~~~~~ + +This function returns 0 if successful, else returns error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +---------------------------------------------------------------- + +**HttpClient::endOfHeadersReached** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check whether the end of the headers have been reached. Test whether all of the response headers have been consumed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool endOfHeadersReached(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns "true" if the end of response header has reached and we are now processing the response body, else returns "false". + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------ + +**HttpClient::endRequest** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +End a more complex request. Use this when you need to have sent additional headers in the request, but you will also need to call beginRequest() at the start. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void endRequest(void);; + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +--------------------------------------------------------------- + +**HttpClient::responseStatusCode** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the HTTP status code contained in the response. For example, “200” for successful requests, “404” for file not found, etc. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int responseStatusCode(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns 0 indicates “HTTP_SUCCESS”, else returns other negative error codes. + + 1. HTTP_ERROR_CONNECTION_FAILED + 2. HTTP_ERROR_API + 3. HTTP_ERROR_TIMED_OUT + 4. HTTP_ERROR_INVALID_RESPONSE + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +--------------------------------------- + +**HttpClient::skipResponseHeaders** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Skip any response headers to get to the body. Use this if you don't want to do any special processing of the headers returned in the response. You can also use it after you've found all of the headers you're interested in, and just want to get on with processing the body. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int skipResponseHeaders(); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns 0 indicates “HTTP_SUCCESS”, else returns other negative error codes. + + 1. HTTP_ERROR_CONNECTION_FAILED + 2. HTTP_ERROR_API + 3. HTTP_ERROR_TIMED_OUT + 4. HTTP_ERROR_INVALID_RESPONSE + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +----------------------------------------------------- + +**HttpClient::endOfBodyReached** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check whether the end of the body has been reached. It only works if the Content-Length header was returned by the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool endOfBodyReached(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if the end of the body has been reached, else false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::read** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Returns the incoming byte recving from the server that the client is connected to. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int read (); + +.. code:: c++ + + int read(uint8_t *buf, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +``buf``: buffer to hold incoming byte + +``size``: maximum size of the buffer + +**Returns** +~~~~~~~~~~~ + +Returns the incoming byte from the server that the client is connected to. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------------------- + +**HttpClient::readHeader** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +The function reads the next character of the response headers. This function is the same as read() but to be used when reading through the headers which are slightly less efficient. The user might check whether the end of the headers has been reached by calling endOfHeadersReached(), although after endOfHeadersReached() is called, data return will be the same as read(). + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int readHeader(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next character of the response headers. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------------------- + +**HttpClient::finishRequest** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Finish sending the HTTP request. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int finishRequest(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the blank line to signify the end of the request + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “HttpClient.h” must be included to use the class function. + +-------------------------------- + +**HttpClient::endOfHeadersReached** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +The function reads the next character of the response headers. This function is the same as read() but to be used when reading through the headers which are slightly less efficient. The user might check whether the end of the headers has been reached by calling endOfHeadersReached(), although after endOfHeadersReached() is called, data return will be the same as read(). + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int endOfHeadersReached(); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if we are at the end of the header, else false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +.. note :: “HttpClient.h” must be included to use the class function. + +---------------------------------- + +**HttpClient::endOfStream** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check whether the end of the body has been reached. It only works if the Content-Length header was returned by the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool endOfStream(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if the end of the body has been reached, else false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::completed** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check whether the end of the body has been reached. It only works if the Content-Length header was returned by the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool completed(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if the end of the body has been reached, else false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::contentLength** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +This function returns the length of the body. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int contentLength(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the length of the body (in bytes) or kNoContentLengthHeader if no Content-Length header was returned by the server. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::available** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the number of bytes available for reading + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int available(); + +**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: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. + +------------------------------------ + +**HttpClient::connected** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if the client is connected + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + Uint_8 connected(); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if connected, returns “0” if not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SimpleHttpExample `_ + +.. note :: “HttpClient.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/Http/index.rst b/source/_common/ameba_d/API_Documents/Http/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/Http/index.rst rename to source/_common/ameba_d/API_Documents/Http/index.rst diff --git a/source/_common/ameba_d/API_Documents/IRDevice/Class IRDevice.rst b/source/_common/ameba_d/API_Documents/IRDevice/Class IRDevice.rst new file mode 100644 index 0000000..1f53702 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/IRDevice/Class IRDevice.rst @@ -0,0 +1,315 @@ +Class IRDevice +============== + +.. contents:: + :local: + :depth: 2 + +**IRDevice Class** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +A class used for managing, sending, and receiving data using IR (Infra-Red). + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class IRDevice + +**Members** +~~~~~~~~~~~ + ++---------------------------+-----------------------------------------+ +| **Public Constructors** | ++===========================+=========================================+ +| A public constructor should not be used as this class is | +| intended to be a singleton class. Access member functions using | +| the object instance named IR. | ++---------------------------+-----------------------------------------+ +| **Public Methods** | ++---------------------------+-----------------------------------------+ +| IRDevice::getFreq | Get the current IR modulation frequency | ++---------------------------+-----------------------------------------+ +| IRDevice::begin | Allocate resources and start the IR | +| | device with a custom frequency | ++---------------------------+-----------------------------------------+ +| IRDevice::end | Stop the IR device operations and | +| | free up resources | ++---------------------------+-----------------------------------------+ +| IRDevice::send | Send IR raw data | ++---------------------------+-----------------------------------------+ +| IRDevice::beginNEC | Allocate resources and start the | +| | IR device with a frequency suitable for | +| | the NEC protocol | ++---------------------------+-----------------------------------------+ +| IRDevice::sendNEC | Send data using the NEC protocol | ++---------------------------+-----------------------------------------+ +| IRDevice::recvNEC | Receive data using the NEC protocol | ++---------------------------+-----------------------------------------+ + +--------------------------------------------------------------------------------- + +**IRDevice::getFreq** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the current IR modulation frequency. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint32_t getFreq(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the IR modulation frequency (in Hz) set currently. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “IRDevice.h” must be included to use the class function. + +---------------------------------------------------------------------------------- + +**IRDevice::begin** +------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Select IR mode as transmitting or receiving mode on IR transmitting or receiving pin. Allocate resources and start the IR device with a custom frequency. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin(uint8_t irPin, uint32_t irMode, uint32_t freq); + +.. code:: c++ + + void begin(uint8_t receivePin, uint8_t transmitPin, uint32_t irMode, uint32_t freq); + +**Parameters** +~~~~~~~~~~~~~~ + +``irPin``: define pin for IR receiver and transmitter if irMode == IR_MODE_TX or IR_MODE_RX. + +``receivePin``: Hardware IR receiving pin that connected with the IR Receiver. + +``transmitPin``: Hardware IR transmitting pin that connected with the IR Transmistter. + +``irMode``: set IR transmit or receive mode. (Valid values: IR_MODE_TX and IR_MODE_RX) + +``freq``: modulation frequency for IR signal (in Hz). + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: IR device can only operate in either transmit or receive mode. “IRDevice.h” must be included to use the class function. + +------------------------------------- + +**IRDevice::end** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Stop the IR device operations and free up resources allocated to the IR transmitting and receiving pins. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void end(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `IRSendRaw `_ + +.. note :: “IRDevice.h” must be included to use the class function. + +----------------------------------- + +**IRDevice::send** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Send data by entering customized IR raw data and data length in IR transmission buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void send(const unsigned int buf[ ] , uint16_t len); + +**Parameters** +~~~~~~~~~~~~~~ + +``buf[ ]``: IR raw signals (in us) in an array form. + +``len``: total length of the IR raw signal array. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `IRSendRaw `_ + +.. note :: “IRDevice.h” must be included to use the class function. IR Raw Data array contains information in the form of consecutive microseconds (us). For more details, please refer to: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html. + +-------------------------------- + +**IRDevice::beginNEC** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Allocate resources and start the IR device with a frequency suitable for the NEC protocol. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void beginNEC(uint8_t receivePin, uint8_t transmitPin, uint32_t irMode); + +**Parameters** +~~~~~~~~~~~~~~ + +``receivePin``: Hardware IR receiving pin that connected with the IR Receiver. + +``transmitPin``: Hardware IR transmitting pin that connected with the IR Transmistter. + +``irMode``: transmit or receive mode. (Valid values: IR_MODE_TX and IR_MODE_RX). + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `IRRecvNEC `_ + +.. note :: “IRDevice.h” must be included to use the class function. IR device can only operate in either transmit or receive mode. Refer to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol for the NEC protocol. + +-------------------------------- + +**IRDevice::sendNEC** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send data using the NEC protocol. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void sendNEC(uint8_t adr, uint8_t cmd); + +**Parameters** +~~~~~~~~~~~~~~ + +``adr``: 8-bit NEC address data to be transmit + +``cmd``: 8-bit NEC command data to be transmit + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `IRSendNEC `_ + +.. note :: IR device can only operate in either transmit or receive mode. Refer to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol for the NEC protocol. “IRDevice.h” must be included to use the class function. + +--------------------------------- + +**IRDevice::recvNEC** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Receive data using the NEC protocol. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void recvNEC(uint8_t& adr, uint8_t& cmd uint32_t timeout); + +**Parameters** +~~~~~~~~~~~~~~ + +``adr``: 8-bit NEC address data to be transmit + +``cmd``: 8-bit NEC command data to be transmit + +``timeout``: time duration (in ms) to wait for an incoming transmission + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if data has been received or returns “0” if no data has been received within the timeout period. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `IRRecvNEC `_ + +.. note :: “IRDevice.h” must be included to use the class function. IR device can only operate in either transmit or receive mode. Refer to https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol for the NEC protocol. + diff --git a/bak/ambd/_common/API_Documents/IRDevice/index.rst b/source/_common/ameba_d/API_Documents/IRDevice/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/IRDevice/index.rst rename to source/_common/ameba_d/API_Documents/IRDevice/index.rst diff --git a/source/_common/ameba_d/API_Documents/MDNS/Class MDNSClass.rst b/source/_common/ameba_d/API_Documents/MDNS/Class MDNSClass.rst new file mode 100644 index 0000000..d0f79ba --- /dev/null +++ b/source/_common/ameba_d/API_Documents/MDNS/Class MDNSClass.rst @@ -0,0 +1,217 @@ +Class MDNS +========== + +.. contents:: + :local: + :depth: 2 + +**MDNS Class** +-------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for registering and removing MDNS service records. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class MDNSClass + +**Members** +~~~~~~~~~~~ + ++-------------------------------+-------------------------------------+ +| **Public Constructors** | | ++===============================+=====================================+ +| The public constructor should not be used as this class is | +| intended to be a singleton class. Access member functions using | +| the object instance named MDNS. | ++-------------------------------+-------------------------------------+ +| **Public Methods** | ++-------------------------------+-------------------------------------+ +| MDNSClass::begin | Start MDNS operations | ++-------------------------------+-------------------------------------+ +| MDNSClass::end | Stop MDNS operations | ++-------------------------------+-------------------------------------+ +| MDNSClass::registerService | Add a service record | ++-------------------------------+-------------------------------------+ +| MDNSClass::deregisterService | Remove service record | ++-------------------------------+-------------------------------------+ +| MDNSClass::updateService | Update service record | ++-------------------------------+-------------------------------------+ + +------------------------ + +**MDNSClass::begin** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start MDNS operations to begin responding to MDNS queries. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `mDNS_On_Arduino_IDE `_ + +.. note :: “AmebaMDNS.h” must be included to use the class function. + +---------------------------------------------------------- + +**MDNSClass::end** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Stop MDNS operations and stop responding to MDNS queries. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void end(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “AmebaMDNS.h” must be included to use the class function. + +------------------------------------------------------------ + +**MDNSClass::registerService** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Add a service record to be included in MDNS responses. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void registerService(MDNSService service); + +**Parameters** +~~~~~~~~~~~~~~ + +``service``: MDNSService class object with required MDNS service data + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `mDNS_On_Arduino_IDE `_ + +.. note :: “AmebaMDNS.h” must be included to use the class function. + +-------------------------------------------------------------------------------- + +**MDNSClass::deregisterService** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Remove a service record from MDNS responses. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void deregisterService(MDNSService service); + +**Parameters** +~~~~~~~~~~~~~~ + +``service`` : MDNSService class object to be removed + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `mDNS_On_Arduino_IDE `_ + +.. note :: “AmebaMDNS.h” must be included to use the class function. + +------------------------------------------------------------- + + +**MDNSClass::updateService** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Update a service record. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void updateService(MDNSService service, unsigned int ttl); + +**Parameters** +~~~~~~~~~~~~~~ + +``service``: MDNSService class object to be updated + +``ttl``: time-to-live(TTL) for service + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “AmebaMDNS.h” must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/MDNS/Class MDNSService.rst b/source/_common/ameba_d/API_Documents/MDNS/Class MDNSService.rst new file mode 100644 index 0000000..bba2b6a --- /dev/null +++ b/source/_common/ameba_d/API_Documents/MDNS/Class MDNSService.rst @@ -0,0 +1,114 @@ +Class MDNSService +================= + +.. contents:: + :local: + :depth: 2 + +**MDNSService Class** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for creating MDNS service records. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class MDNSService + +**Members** +~~~~~~~~~~~ + ++---------------------------+---------------------------------+ +| **Public Constructors** | | ++===========================+=================================+ +| MDNSService::MDNSService | Create a MDNS service record | ++---------------------------+---------------------------------+ +| **Public Methods** | | ++---------------------------+---------------------------------+ +| MDNSService::addTxtRecord | Add text to MDNS service record | ++---------------------------+---------------------------------+ + +----------------------------------------------------------- + +**MDNSService::MDNSService** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Create a MDNS service record. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + MDNSService(char* name, char* service_type, char* domain, unsigned short port, int bufsize); + +**Parameters** +~~~~~~~~~~~~~~ + +``name``: device name + +``service_type``: MDNS service type + +``domain``: host domain + +``port``: network port + +``bufsize`` : size of buffer for MDNS text record + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `mDNS_On_Arduino_IDE `_ + +.. note :: “AmebaMDNS.h” must be included to use the class function. + +------------------------------------------- + +**MDNSService::addTxtRecord** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Add text to MDNS service record. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int addTextRecord(char* key, int value_len, char* value); + +**Parameters** +~~~~~~~~~~~~~~ + +``key``: item key name expressed as character string. + +``value_len``: length of value string + +``value``: new value of the key expressed as character string + +**Returns** +~~~~~~~~~~~ + +This function returns 0 if the text record is added to the MDNS service record successfully. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `mDNS_On_Arduino_IDE `_ + +.. note :: “AmebaMDNS.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/MDNS/index.rst b/source/_common/ameba_d/API_Documents/MDNS/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/MDNS/index.rst rename to source/_common/ameba_d/API_Documents/MDNS/index.rst diff --git a/source/_common/ameba_d/API_Documents/MQTTClient/Class PubSubClient.rst b/source/_common/ameba_d/API_Documents/MQTTClient/Class PubSubClient.rst new file mode 100644 index 0000000..57a2e74 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/MQTTClient/Class PubSubClient.rst @@ -0,0 +1,887 @@ +Class PubSubClient +================== + +.. contents:: + :local: + :depth: 2 + +.. note :: The Ameba MQTT related APIs and examples are works based on the PubSubClient libraries written by Nicholas O’Leary (http://pubsubclient.knolleary.net). + +.. note :: These include, PubSubClient.cpp and PubSubClient.h + +.. Caution :: These libraries are under MIT License. + +**PubSubClient Class** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for implementing MQTT for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class PubSubClient + +**Members** +~~~~~~~~~~~ + ++--------------------------------+------------------------------------+ +| **Public Constructors** | Description | ++================================+====================================+ +| PubSubClient::PubSubClient | Constructs a PubSubClient object | ++--------------------------------+------------------------------------+ +| **Public Methods** | ++--------------------------------+------------------------------------+ +| PubSubClient::setServer | Define the server to connect to | ++--------------------------------+------------------------------------+ +| PubSubClient::setCallback | Set callback function | ++--------------------------------+------------------------------------+ +| PubSubClient::setClient | Set the network client to be used | ++--------------------------------+------------------------------------+ +| PubSubClient::setStream | Set the message stream to store | +| | received messages | ++--------------------------------+------------------------------------+ +| PubSubClient::setKeepAlive | Set the keep alive interval used by| +| | the client | ++--------------------------------+------------------------------------+ +| PubSubClient::setSocketTimeout | Set the socket timeout used by | +| | the client | ++--------------------------------+------------------------------------+ +| PubSubClient::setBufferSize | Set the size, in bytes, of the | +| | internal send/receive buffer | ++--------------------------------+------------------------------------+ +| PubSubClient::getBufferSize | Get the current size of the | +| | internal buffer | ++--------------------------------+------------------------------------+ +| PubSubClient::connect | Connect the client to the server | ++--------------------------------+------------------------------------+ +| PubSubClient::disconnect | Disconnect the client from | +| | the server | ++--------------------------------+------------------------------------+ +| PubSubClient::publish | Publish a message to specific topic| ++--------------------------------+------------------------------------+ +| PubSubClient::publish_P | Publish a message stored in PROGMEM| +| | to a specific topic | ++--------------------------------+------------------------------------+ +| PubSubClient::write | Write to the publish payload | ++--------------------------------+------------------------------------+ +| PubSubClient::subscribe | Subscribe to a specified topic | ++--------------------------------+------------------------------------+ +| PubSubClient::unsubscribe | Unsubscribe from a specified topic | ++--------------------------------+------------------------------------+ +| PubSubClient::loop | Keep MQTT session alive and process| +| | any queuing tasks | ++--------------------------------+------------------------------------+ +| PubSubClient::connected | Check if client is still connected | ++--------------------------------+------------------------------------+ +| PubSubClient::state | Get current state of the client | ++--------------------------------+------------------------------------+ + +----------------------------------------- + +**PubSubClient::PubSubClient** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a PubSubClient object and, if applicable, sets server address, port, callback function, data stream and wifi client. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient(void); + +.. code:: c++ + + PubSubClient(Client& client); + +.. code:: c++ + + PubSubClient(IPAddress, uint16_t, Client& client); + +.. code:: c++ + + PubSubClient(IPAddress, uint16_t, Client& client, Stream&); + +.. code:: c++ + + PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); + +.. code:: c++ + + PubSubClient(IPAddress, uint16_t,MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); + +.. code:: c++ + + PubSubClient(uint8_t*, uint16_t, Client& client); + +.. code:: c++ + + PubSubClient(uint8_t*, uint16_t, Client& client, Stream&); + +.. code:: c++ + + PubSubClient(uint8_t*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); + +.. code:: c++ + + PubSubClient(uint8_t*, uint16_t,MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); + +.. code:: c++ + + PubSubClient(const char*, uint16_t, Client& client); + +.. code:: c++ + + PubSubClient(const char*, uint16_t, Client& client, Stream&); + +.. code:: c++ + + PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client); + +.. code:: c++ + + PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE, Client& client, Stream&); + +**Parameters** +~~~~~~~~~~~~~~ + +``client``: the network client to use, for example WiFiClient + +``IPAddress``: MQTT server address + +``port``: the port to connect to for MQTT, usually 1883 for unencrypted connection + +``MQTT_CALLBACK_SIGNATURE``: a pointer to a message callback function called when a message arrives for a subscription created by this client. + +``Stream``: a message stream to store received messages. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: PubSubClient::PubSubClient(Client& client) would suffice for normal MQTT connection. “PubSubClient.h” must be included to use the class function. + +------------------------------------------ + +**PubSubClient::setServer** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Define the server to connect to by setting the parameters such as IP address, port number and domain. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setServer(uint8_t * ip, uint16_t port); + +.. code:: c++ + + PubSubClient& setServer(IPAddress ip, uint16_t port); + +.. code:: c++ + + PubSubClient& setServer(const char* domain, uint16_t port); + +**Parameters** +~~~~~~~~~~~~~~ + +``ip``: the address of the server + +``port``: the port to connect to for MQTT, usually 1883 for unencrypted connection. Default: 1883 + +``domain``: name of the server + +**Returns** +~~~~~~~~~~~ + +This function returns the parameters such as ip address, port number and domain, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: “PubSubClient.h” must be included to use the class function. + +------------------------- + +**PubSubClient::setCallback** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Sets the message callback function. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE); + +**Parameters** +~~~~~~~~~~~~~~ + +``MQTT_CALLBACK_SIGNATURE``: a pointer to a message callback function called when a message arrives for a subscription created by this client. + +**Returns** +~~~~~~~~~~~ + +This function returns the client instance, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------- + +**PubSubClient::setClient** + +**Description** +~~~~~~~~~~~~~~~ + +Set the network client to be used. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setClient(Client& client); + +**Parameters** +~~~~~~~~~~~~~~ + +``client`` : the network client to use, for example WiFiClient + +**Returns** +~~~~~~~~~~~ + +This function returns the client instance, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +--------------------------- + +**PubSubClient::setStream** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the message stream to store received messages. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setStream(Stream& stream); + +**Parameters** +~~~~~~~~~~~~~~ + +``stream``: a message stream to store received messages. + +**Returns** +~~~~~~~~~~~ + +This function returns the client instance, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------------- + +**PubSubClient::setKeepAlive** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set the keep alive interval used by the client + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setKeepAlive(uint16_t keepAlive); + +**Parameters** +~~~~~~~~~~~~~~ + +``keepAlive``: the keep alive interval, in seconds. + +**Returns** +~~~~~~~~~~~ + +This function returns the client instance, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------------- + +**PubSubClient::setSocketTimeout** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the socket timeout used by the client. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setSocketTimeout(uint16_t timeout); + +**Parameters** +~~~~~~~~~~~~~~ + +``Timeout``: the socket timeout, in seconds. + +**Returns** +~~~~~~~~~~~ + +This function returns the client instance, allowing the function to be chained. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------------- + +**PubSubClient::setBufferSize** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the size, in bytes, of the internal send/receive buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& setBufferSize(uint16_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +``size``: the size, in bytes, for the internal buffer. + +**Returns** +~~~~~~~~~~~ + +This function returns false when the buffer could not be resized, returns true when the buffer was resized. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------------- + +**PubSubClient::getBufferSize** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the current size of the internal buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + PubSubClient& getBufferSize(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the size of the internal buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +-------------------------- + +**PubSubClient::connect** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Connects the client to the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean connect(const char *id); + +.. code:: c++ + + boolean connect(const char *id, const char *user, const char *pass); + +.. code:: c++ + + boolean connect(const char *id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); + +.. code:: c++ + + boolean connect(const char *id, const char *user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage); + +.. code:: c++ + + boolean connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage, boolean cleanSession); + +**Parameters** +~~~~~~~~~~~~~~ + +``id`` : Client ID, a unique string identifier + +``user``: Username for authentication, default NULL + +``pass`` : Password for authentication, default NULL + +``willTopic`` : the topic to be used by the will message + +``willQoS`` : the quality of service to be used by the will message + +``willRetain`` : whether the will should be published with the retain flag + +``willMessage`` : the payload of the will message + +``cleanSession``: whether the session should be cleared when the client disconnects + +**Returns** +~~~~~~~~~~~ + +This function returns true if the connection is successful, else, return false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: Client ID is required and should always be unique else connection might be rejected by the server. “PubSubClient.h” must be included to use the class function. + +------------------------------ + +**PubSubClient::disconnect** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disconnect the client from the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void disconnect(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +--------------------------- + +**PubSubClient::publish** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Publishes a message to the specified topic. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean publish(const char* topic, const char* payload) + +.. code:: c++ + + boolean publish(const char* topic, const char* payload, boolean retained) + +.. code:: c++ + + boolean publish(const char* topic, const uint8_t* payload, unsigned int plength) + +.. code:: c++ + + boolean publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) + +**Parameters** +~~~~~~~~~~~~~~ + +``topic``: the topic to publish to + +``payload``: the message to publish + +``plength``: the length of the payload. Required if payload is a byte[] + +``retained``: whether the message should be retained False - not retained. True - retained. + +**Returns** +~~~~~~~~~~~ + +This function returns true if it published successfully, else returns false. If publishing fails, it is either due to connection lost or messages too large. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: Default max packet size is 128 bytes. “PubSubClient.h” must be included to use the class function. + +------------------------------------ + +**PubSubClient::publish_P** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Publishes a message stored in PROGMEM to the specified topic. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean publish_P(const char* topic, const char* payload, boolean retained); + +.. code:: c++ + + boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained); + +**Parameters** +~~~~~~~~~~~~~~ + +``topic`` : the topic that the message will be publishing to + +``payload`` : the contents/messages that will be published to the topic. + +``plength`` : the length of the payload. Required if payload is a byte[] + +``retained`` : whether the message should be retained. False - not retained. True - retained. + +**Returns** +~~~~~~~~~~~ + +This function returns true if it published successfully, else returns false. If publishing fails, it is either due to connection lost or messages too large. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +------------------------------------- + +**PubSubClient::write** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Write a byte from the buffer into the payload. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + size_t write(uint8_t data); + +**Parameters** +~~~~~~~~~~~~~~ + +``data``: a byte to write to the publish payload. + +**Returns** +~~~~~~~~~~~ + +This function returns true if it published successfully, else returns false. If publishing fails, it is either due to connection lost or messages too large. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +------------------------------------- + +**PubSubClient::subscribe** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Subscribe to a specified topic. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean subscribe(const char* topic); + +.. code:: c++ + + boolean subscribe(const char* topic, uint8_t qos); + +**Parameters** +~~~~~~~~~~~~~~ + +``topic``: the topic to subscribe to + +``qos``: MQTT quality of service. Valid value: 0 or 1. 0 – At most once (no guarantee of delivery) 1- At least once (guaranteed). + +**Returns** +~~~~~~~~~~~ + +This function returns true if it published successfully, else returns false. If publishing fails, it is either due to connection lost or messages too large. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: “PubSubClient.h” must be included to use the class function. + +--------------------------- + +**PubSubClient::unsubscribe** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Unsubscribes from the specified topic. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean unsubscribe (const char* topic); + +**Parameters** +~~~~~~~~~~~~~~ + +``topic`` : the topic to unsubscribe to + +**Returns** +~~~~~~~~~~~ + +This function returns true if it published successfully, else returns false. If publishing fails, it is either due to connection lost or messages too large. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “PubSubClient.h” must be included to use the class function. + +------------------------- + +**PubSubClient::loop** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A method that should be called regularly to allow the client to process incoming messages and maintain its connection to the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean loop(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if the client is still connected to the server else return false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: A required method that should not be blocked for too long. “PubSubClient.h” must be included to use the class function. + +----------------------------- + +**PubSubClient::connected** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Checks whether the client is still connected to the server. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean connected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if the client is connected to the server else return false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: “PubSubClient.h” must be included to use the class function. + +--------------------------- + +**PubSubClient::state** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the current state of the client. For example, if a connection attempt fails, this can be used to get more information about the failure. All of the values have corresponding constants defined in PubSubClient.h. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int PubSubClient::state(void); + +.. code:: c++ + + int state(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the current state of the client as an integer from **-4 to 5** representing different definition. + +``-4``: MQTT_CONNECTION_TIMEOUT -- the server didn't respond within the keepalive time + +``-3``: MQTT_CONNECTION_LOST -- the network connection was broken + +``-2``: MQTT_CONNECT_FAILED -- the network connection failed + +``-1``: MQTT_DISCONNECTED -- the client is disconnected cleanly + +``0``: MQTT_CONNECTED -- the client is connected + +``1``: MQTT_CONNECT_BAD_PROTOCOL -- the server doesn't support the requested version of MQTT + +``2``: MQTT_CONNECT_BAD_CLIENT_ID -- the server rejected the client identifier + +``3``: MQTT_CONNECT_UNAVAILABLE -- the server was unable to accept the connection + +``4``: MQTT_CONNECT_BAD_CREDENTIALS -- the username/password were rejected + +``5``: MQTT_CONNECT_UNAUTHORIZED -- the client was not authorized to connect + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MQTT_Basic `_ + +.. note :: “PubSubClient.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/MQTTClient/index.rst b/source/_common/ameba_d/API_Documents/MQTTClient/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/MQTTClient/index.rst rename to source/_common/ameba_d/API_Documents/MQTTClient/index.rst diff --git a/source/_common/ameba_d/API_Documents/NTPClient/Readme.rst b/source/_common/ameba_d/API_Documents/NTPClient/Readme.rst new file mode 100644 index 0000000..421e63d --- /dev/null +++ b/source/_common/ameba_d/API_Documents/NTPClient/Readme.rst @@ -0,0 +1,13 @@ +NTPClient library +================= + +.. contents:: + :local: + :depth: 2 + + +.. note :: The NTPClient library is based on the NTPClient library written by Fabrice Weinberg, which can be found at `arduino-libraries/NTPClient `_ + +.. note :: These include, NTPClient.cpp and NTPClient.h + +.. Caution :: These libraries are licensed under MIT License. diff --git a/bak/ambd/_common/API_Documents/NTPClient/index.rst b/source/_common/ameba_d/API_Documents/NTPClient/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/NTPClient/index.rst rename to source/_common/ameba_d/API_Documents/NTPClient/index.rst diff --git a/source/_common/ameba_d/API_Documents/PowerSave/Class PMUClass.rst b/source/_common/ameba_d/API_Documents/PowerSave/Class PMUClass.rst new file mode 100644 index 0000000..29cebae --- /dev/null +++ b/source/_common/ameba_d/API_Documents/PowerSave/Class PMUClass.rst @@ -0,0 +1,1084 @@ +Class PMUClass +============== + +.. contents:: + :local: + :depth: 2 + +**PMUClass Class** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +A class used for reducing power consumption. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class PMUClass + +**Members** +~~~~~~~~~~~ + ++--------------------------------------+----------------------------------------------+ +| **Public Constructors** | ++======================================+==============================================+ +| PMUClass::PMUClass | Constructs a PMUClass object. | ++--------------------------------------+----------------------------------------------+ +| **Public Methods** | ++--------------------------------------+----------------------------------------------+ +| PMUClass::begin | Initialize the PMUClass and select sleep | +| | mode as Deep Sleep mode or Tickless mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AONTimerDuration | Set the duration of always-on (AON) Timer. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AONTimerCmd | Disable the AON Timer. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::RTCWakeSetup | Set up RTC Timer for power save usage. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::enable | Enable power save Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AONWakeReason | Get the source that awakens AON. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::WakePinCheck | Check for AON GPIO wake pin index used as | +| | wake-up source. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AONWakeClear | Clear all the AON wakeup sources. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::DsleepWakeStatusGet | Get deep sleep mode status. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::TL_sysactive_time | Set the system active time for tickless | +| | mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::TL_wakelock | Set tickless mode wakelock. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::DS_AON_TIMER_WAKEUP | AON timer set as wake-up source for Deep | +| | Sleep Mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::DS_RTC_WAKEUP | RTC timer is set as wake-up source for | +| | Deep Sleep Mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::TL_UART_WAKEUP | LOGUART is set as wake-up source for | +| | Tickless Mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::TL_RTC_WAKEUP | RTC timer is set as wake-up source for | +| | Tickless Mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA12 | AON GPIO pin 12 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA13 | AON GPIO pin 13 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA14 | AON GPIO pin 14 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA15 | AON GPIO pin 15 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA16 | AON GPIO pin 16 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA17 | AON GPIO pin 17 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA18 | AON GPIO pin 18 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA19 | AON GPIO pin 19 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA20 | AON GPIO pin 20 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA21 | AON GPIO pin 21 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA25 | AON GPIO pin 25 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ +| PMUClass::AON_WAKEPIN_WAKEUP_GPIOA26 | AON GPIO pin 26 set as wake-up source for | +| | Deep Sleep mode. | ++--------------------------------------+----------------------------------------------+ + +--------------------------------------- + +**PMUClass::PMUClass** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a PMUClass object. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + PMUClass(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::begin** +------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Initialize the PMUClass and select sleep mode as Deep Sleep mode or Tickless mode. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void begin (uint32_t sleep_mode); + +**Parameters** +~~~~~~~~~~~~~~ + +``sleep_mode``: “11” indicates Deep Sleep Mode, “22” indicates Tickless Mode. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AONTimerDuration** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set the duration of Always ON (AON) Timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AONTimerDuration(uint32_t duration_ms); + +**Parameters** +~~~~~~~~~~~~~~ + +``duration_ms``: Set Always ON timer duration (in ms), acceptable range between 0 – 32,760,000ms. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AONTimerCmd** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Disable the AON timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AONTimerDuration(uint32_t duration_ms); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::RTCWakeSetup** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set up a RTC timer for power usage. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void RTCWakeSetup(uint32_t duration_d, uint32_t duration_h, uint32_t duration_m, uint32_t duration_s); + +**Parameters** +~~~~~~~~~~~~~~ + +``duration_d``: set the duration in days. Minimum valid value from 0. Valid value must be 0 or greater than 0. + +``duration_h``: set the duration in hours. Minimum valid value from 0. Valid value must be 0 or greater than 0. + +``duration_m``: set the duration in minutes. Minimum valid value from 0. Valid value must be 0 or greater than 0. + +``duration_s``: set the duration in seconds. Minimum valid value from 0. Valid value must be 0 or greater than 0. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::enable** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Enable power save deep sleep mode. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void enable(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AONWakeReason** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the source that awakens AON. There are a total of 3 sources, using AON GPIO, RTC timer and AON timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t AONWakeReason(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the wake-up source represented as an integer value. + +``1111``: wake by AON timer + +``2222``: wake by RTC timer + +``3333``: wake by AON GPIO pin + +``0``: NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::WakePinCheck** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check for AON GPIO pins that are used as wake up source. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int WakePinCheck(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the wake-up source represented as an integer value. + +``1``: BIT(0): wakepin0 + +``2``: BIT(1): wakepin1 + +``4``: BIT(2): wakepin2 + +``8``: BIT(3): wakepin3 + +``0``: NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AONWakeClear** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Clear all AON Wakeup source. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AONWakeClear(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::DsleepWakeStatusGet** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get Deep Sleep mode status, check if Deep Sleep mode is set. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + bool DsleepWakeStatusGet(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “true” when Deep Sleep mode is entered. Otherwise, return “false”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::TL_sysactive_time** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the system active time for tickless mode. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void TL_sysactive_time(uint32_t duration_ms); + +**Parameters** +~~~~~~~~~~~~~~ + +``duration_ms``: Set the duration of system active time (in ms). + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::TL_wakelock** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set tickless mode wakelock. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void TL_wakelock(uint32_t select_lock); + +**Parameters** +~~~~~~~~~~~~~~ + +select_lock: + +``1``: acquire to avoid KM4 from entering the Deep Sleep mode. +``0``: release and allow KM4 to enter the Deep Sleep mode. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::DS_AON_TIMER_WAKEUP** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON timer is set as the wake-up source for Deep Sleep Mode. “Set Deepsleep wakeup AON timer.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void DS_AON_TIMER_WAKEUP(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::DS_RTC_WAKEUP** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +RTC timer is set as the wake-up source for Deep Sleep Mode. “Set Deepsleep wakeup RTC.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void DS_RTC_WAKEUP(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::TL_UART_WAKEUP** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +LOGUART is set as the wake-up source for Tickless Mode. “Set Tickless wakeup LOGUART.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void TL_UART_WAKEUP(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::TL_RTC_WAKEUP** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +RTC timer is set as the wake-up source for Tickless Mode. “Set Tickless wakeup RTC.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void TL_RTC_WAKEUP(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA12** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 12 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA12.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA12(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA13** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 13 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA13.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA13(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA14** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 14 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA14.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA14(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA15** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 15 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA15.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA15(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA16** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 16 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA16.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA16(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA17** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 17 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA17.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA17(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA18** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 18 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA18.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA18(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA19** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 19 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA19.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA19(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA20** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 20 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA20.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA20(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA21** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 21 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA21.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA21(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA25** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 25 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA25.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA25(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. + +--------------------------------------- + +**PMUClass::AON_WAKEPIN_WAKEUP_GPIOA26** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +AON GPIO pin 26 is set as the wake-up source for Deep Sleep mode. “Set Deepsleep wakeup AON pin GPIOA26.” will be printed on Serial Monitor when this function is called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void AON_WAKEPIN_WAKEUP_GPIOA26(void) + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `DeepSleep_DHT_Eink_Example `_ + +.. note :: “PMUClass.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/PowerSave/index.rst b/source/_common/ameba_d/API_Documents/PowerSave/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/PowerSave/index.rst rename to source/_common/ameba_d/API_Documents/PowerSave/index.rst diff --git a/source/ameba_d/amb21/API_Documents/index.rst b/source/ameba_d/amb21/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/amb21/API_Documents/index.rst +++ b/source/ameba_d/amb21/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/amb23/API_Documents/index.rst b/source/ameba_d/amb23/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/amb23/API_Documents/index.rst +++ b/source/ameba_d/amb23/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/amb25/API_Documents/index.rst b/source/ameba_d/amb25/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/amb25/API_Documents/index.rst +++ b/source/ameba_d/amb25/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/amb26/API_Documents/index.rst b/source/ameba_d/amb26/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/amb26/API_Documents/index.rst +++ b/source/ameba_d/amb26/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/aw-cu488/API_Documents/index.rst b/source/ameba_d/aw-cu488/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/aw-cu488/API_Documents/index.rst +++ b/source/ameba_d/aw-cu488/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/bw16-typeb/API_Documents/index.rst b/source/ameba_d/bw16-typeb/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/bw16-typeb/API_Documents/index.rst +++ b/source/ameba_d/bw16-typeb/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/API_Documents/index.rst b/source/ameba_d/bw16-typec/API_Documents/index.rst index 5ea0eb6..25fa9d8 100644 --- a/source/ameba_d/bw16-typec/API_Documents/index.rst +++ b/source/ameba_d/bw16-typec/API_Documents/index.rst @@ -11,5 +11,12 @@ API Documents FatfsSDcard/index FlashMemory/index GPIO/index + Gtimer/index + Http/index + IRDevice/index + MDNS/index + MQTTClient/index + NTPClient/index OTA/index + PowerSave/index WiFi/index \ No newline at end of file diff --git a/source/custom_script.py b/source/custom_script.py index 25ad1f7..5e9d3ab 100644 --- a/source/custom_script.py +++ b/source/custom_script.py @@ -10,37 +10,44 @@ 'amb21': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'amb23': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'amb25': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'amb26': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'bw16-typeb': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'aw-cu488': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], 'bw16-typec': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' - , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC'], + , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], } def create_folder(folder_name):