Skip to content

Commit

Permalink
add:mqtt加pong消息上报
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed Sep 25, 2024
1 parent f7f193a commit b7dfde6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/network/libemqtt/luat_lib_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ int32_t luatos_mqtt_callback(lua_State *L, void* ptr){
luat_mqtt_ping(mqtt_ctrl);
break;
}
case MQTT_MSG_PINGRESP : {
if (mqtt_ctrl->mqtt_cb) {
lua_geti(L, LUA_REGISTRYINDEX, mqtt_ctrl->mqtt_cb);
if (lua_isfunction(L, -1)) {
lua_geti(L, LUA_REGISTRYINDEX, mqtt_ctrl->mqtt_ref);
lua_pushstring(L, "pong");
lua_call(L, 2, 0);
}
lua_getglobal(L, "sys_pub");
if (lua_isfunction(L, -1)) {
lua_pushstring(L, "MQTT_PONG");
lua_geti(L, LUA_REGISTRYINDEX, mqtt_ctrl->mqtt_ref);
lua_call(L, 2, 0);
}
}
break;
}
case MQTT_MSG_RECONNECT : {
luat_mqtt_reconnect(mqtt_ctrl);
break;
Expand Down
2 changes: 2 additions & 0 deletions components/network/libemqtt/luat_mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ static int luat_mqtt_msg_cb(luat_mqtt_ctrl_t *mqtt_ctrl) {
}
case MQTT_MSG_PINGRESP : {
LLOGD("MQTT_MSG_PINGRESP");
msg_id = mqtt_parse_msg_id(mqtt_ctrl->mqtt_packet_buffer);
l_luat_mqtt_msg_cb(mqtt_ctrl, MQTT_MSG_PINGRESP, msg_id);
break;
}
case MQTT_MSG_DISCONNECT : {
Expand Down

0 comments on commit b7dfde6

Please sign in to comment.