OTAClass Class

OTAClass Class

Description
A class used for managing OTA update service on Ameba.

Syntax
class OTAClass

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 OTA.
Public Methods 
OTAClass::beginArduinoMdnsServiceInitialise the MDNS service for OTA.
OTAClass::endArduinoMdnsServiceStop the MDNS service for OTA.
OTAClass::beginLocalStart the local OTA service.
OTAClass::setOtaAddressSet the flash address to store the OTA image.
OTAClass::setRecoverPinSet the recovery pin which allows booting from the old image.

OTAClass::beginArduinoMdnsService

Description
Initialise MDNS service for OTA.

Syntax
int beginArduinoMdnsService(char *device_name, uint16_t port);

Parameters
device_name: device name to show on MDNS service.
port: port number for the OTA service.

Returns
This function returns 0 if MDNS service begin successfully else return -1.

Example Code
Example: ota_basic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/OTA/examples/ota_basic/ota_basic.ino)

Notes and Warnings
Configures and registers the MDNS service required for the Arduino IDE to discover and recognize Ameba OTA. “OTA.h” must be included to use the class function.

OTAClass::endArduinoMdnsService

Description
Stop the MDNS service for OTA.

Syntax
int endArduinoMdnsService(void);

Parameters
NA

Returns
NA

Example Code
NA

Notes and Warnings
“OTA.h” must be included to use the class function.

OTAClass::beginLocal

Description
Start the local OTA service.

Syntax
int beginLocal(uint16_t port, bool reboot_when_success);

Parameters
port: port number for the OTA service.
reboot_when_successs: reboot after OTA update is done. Default value: True.

Returns
This function returns 0 if local OTA service starts successfully, else returns -1.

Example Code
Example: ota_basic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/OTA/examples/ota_basic/ota_basic.ino)

Notes and Warnings
“OTA.h” must be included to use the class function.

OTAClass::setOtaAddress

Description
Set the flash address to store the OTA image.

Syntax
int setOtaAddress(uint32_t address);

Parameters
address: Flash address for storing the OTA image. Default OTA address is 0x80000.

Returns
NA

Example Code
Example: ota_basic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/OTA/examples/ota_basic/ota_basic.ino)

Notes and Warnings
“OTA.h” must be included to use the class function.

OTAClass::setRecoverPin

Description
Set the recovery pin which allows booting from the old image.

Syntax
Int setRecoverPin(uint32_t pin1, uint32_t pin2);

Parameters
pin1: PIN for recovery.
pin2: PIN for recovery, default = unused.

Returns
NA

Example Code
Example: ota_basic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/OTA/examples/ota_basic/ota_basic.ino)

Notes and Warnings
Connect recovery pin to 3.3V to boot from the old image. “OTA.h” must be included to use the class function.

请先确认已安装QQ通讯软体