m5stack / ATOM_DTU_NB

MIT License
6 stars 4 forks source link

MQTT Last Will and Testament #2

Closed 1mek closed 2 years ago

1mek commented 2 years ago

I was hoping i could only change. DTU.sendMsg("AT+CMQCON=0,3,\"myclient\",600,1,0\r\n");

to DTU.sendMsg("AT+CMQCON=0,3,\"myclient\",600,1,1,\"topic=WILL,QoS=1,retained=1,message_len=1,message=1\"\r\n");

And get will and testament working. But it only returns ERROR.

According to the docs. AT+CMQCON=<mqtt_id>,<version>,<client_id>,<keepalive_interval>,<cleansession>,<will_flag>[,<will_options>][,<username>,<password>]

<will_flag> Integer , will flag, can be 0 or 1
<will_options> String, will options, mandatory if will_flag is 1, the format is as follows:
 topic=xxx,QoS=xxx,retained=xxx,message_len=xxx,message=xxx

Anyone else tried getting this to work? I guess my format is wrong somehow. But I cant find an example using this.

1mek commented 2 years ago

I figured it out. Seems like message= should be in hex.

DTU.sendMsg("AT+CMQCON=0,3,\"myclient\",600,1,1,\"topic=WILL,QoS=1,retained=1,message_len=2,message=31\"\r\n")