Updated on 2023-12-28 GMT+08:00

AT+HMCON

This command is used to set MQTT connection parameters.

Command

Parameter

Default Parameter Processing

AT Response

Example

AT+HMCON=bsmode,lifetime,serverip,serverport,deviceid,passwd,codec

bsmode: The value 0 indicates the non-BS mode.

Default value: 0

-

AT+HMCON=0,10,"iot-mqtts.cn-north-4.myhuaweicloud.com","8883","testID","testPasswd",0

lifetime: MQTT heartbeat keep-alive duration. You are advised to set it to a value greater than or equal to 30.

Default value: 300

+HMCON OK (Connection successful)

serverip: IP address of the device access server or bootstrap server.

Default value: IP address of the bootstrap server

+HMCON ERR: code (Connection failed. code indicates the failure cause code.)

serverport: port number of the device access server or bootstrap server.

Default value: MQTTS port 8883

-

id: device ID, which contains a maximum of 256 characters.

Obtained after a device is registered.

-

pwd: device secret, which contains a maximum of 256 characters.

Obtained after a device is registered.

-

codec: payload encoding mode. The value 0 indicates the original encoding mode, and the value 1 indicates the hexadecimal encoding mode.

Default value: 0

-