OTA AT Commands

Note

The OTA AT commands are disabled by default.

You can refer to Configuring SDK (menuconfig) to enter CONFIG AT CMD configuration, and check Enable OTA to enable the OTA AT command set.

For OTA functionality-related information, please refer to OTA

AT+OTAHTTP

Description

Obtain OTA image via HTTP GET method and flash it to the corresponding area for upgrade

The OTA process usually takes from tens of seconds to several minutes. To ensure other AT commands can operate normally during this period, the OTA process runs in the background, and AT Messages is used to indicate the status and progress of OTA

Command Format

AT+OTAHTTP=<sysrst>,<host>,<path>[,<port>],<conn_type>[,<cert_index>]

Response Format

Successful Response:

OK

Error Response:

ERROR:<error_no>

AT Messages

When OTA is running in the background, the following progress and result messages will be displayed:

[$][OTA][HTTP]: UPDATE <percentage>
[$][OTA][HTTP]: UPDATE SUCCESS
[$][OTA][HTTP]: UPDATE FAIL

Parameters

  • <sysrst>: Whether to automatically restart after the upgrade is complete

    • 0: Do not automatically restart after the upgrade is complete

    • 1: Automatically restart after the upgrade is complete

  • <host>: Target host, no need for http:// or https:// prefix

    • Supports domain name or IPv4 address

    • Maximum length: 128 characters

  • <path>: Resource path

    • Maximum length: 256 characters

  • <port>: HTTP server port

    • Range: [0,65535] (Default value 0)

    • 0: HTTP uses port 80, HTTPS uses port 443

  • <conn_type>: HTTP connection type

    • 1: HTTP

    • 2: HTTPS (without certificate verification)

    • 3: HTTPS (verify server certificate with CA certificate)

    • 4: HTTPS (provide client certificate for server verification)

    • 5: HTTPS (mutual authentication, both 3 and 4)

  • <cert_index>: Security certificate suite index, refer to AT Security Certificates

    • [1-10]

    • Only required when <conn_type> is 3-5

Error Codes

  • 1: Parameter error

  • 2: Memory allocation error

  • 3: OTA is in progress

  • 4: OTA initialization error

  • 5: OTA task creation error

Example

Upgrade ota_all.bin image obtained from server address 192.168.137.11 on port 8082, and automatically restart after the upgrade is complete
AT+OTAHTTP=1,192.168.137.1,8082,ota_all.bin

OK
[$][OTA][HTTP]: UPDATE 10%
[$][OTA][HTTP]: UPDATE 20%
[$][OTA][HTTP]: UPDATE 30%
[$][OTA][HTTP]: UPDATE 40%
[$][OTA][HTTP]: UPDATE 50%
[$][OTA][HTTP]: UPDATE 60%
[$][OTA][HTTP]: UPDATE 70%
[$][OTA][HTTP]: UPDATE 80%
[$][OTA][HTTP]: UPDATE 90%
[$][OTA][HTTP]: UPDATE 100%
[$][OTA][HTTP]: UPDATE SUCCESS

AT+OTAUSER

Description

Use Transparent Transmission (TT) Mode to send OTA image for upgrading

Note

This command is only supported in Master Control Mode.

Command Format

AT+USEROTA=<sysrst>,<length>

Response Format

Successful Response:

OK

Error Response:

ERROR:<error_no>

Parameters

  • <sysrst>: Whether to automatically restart after the upgrade is complete
    • 0: Do not automatically restart after the upgrade is complete

    • 1: Automatically restart after the upgrade is complete

  • <length>:
    • Total length of the OTA image.

Error Codes

  • 1: Parameter error

  • 2: Memory allocation error

  • 3: Error occurred during the upgrade process

  • 4: OTA is in progress

  • 5: OTA initialization error

Example

Send an ota image with a length of 1120704 bytes for upgrading, and do not restart after the upgrade is complete

AT+OTAUSR=0,1120704
>>>
<Send ota image content>

OK