| CODE |
| function handle_mqtt_error() --定义mqtt错误处理函数 print错误代码 function do_mqtt_connect(client) --定义连接mqtt处理函数 |
| --推送消息 |
| --订阅成功消息 |
| End
|
| --连接服务器(网址,端口号,mqtt错误处理函数,连接mqtt处理函数) |
|
|
| function do_mqtt_message(client,topic,data)--定义订阅消息接受处理函数 |
| if data ~= nil then |
| if data ~= ‘1’ then |
| --GPIO管脚写入高电平 |
| else |
| --GPIO管脚写入低电平 |
| end |
| end |
| end |