mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
update mqtt pkg
This commit is contained in:
parent
3afb460bf4
commit
f65697a423
@ -33,9 +33,13 @@ print("subscribe ret:%d" % ret)
|
||||
ret = client.subscribe('topic_pikapy_qos2', callback2, 2)
|
||||
print("subscribe ret:%d" % ret)
|
||||
|
||||
client._fakeMsg("topic_pikapy_qos0", 0, "hello qos0")
|
||||
client._fakeMsg("topic_pikapy_qos1", 1, "hello qos1")
|
||||
client._fakeMsg("topic_pikapy_qos2", 2, "hello qos2")
|
||||
|
||||
# sleep wait for recv data
|
||||
T = PikaStdDevice.Time()
|
||||
T.sleep_s(5)
|
||||
# T.sleep_s(5)
|
||||
|
||||
out = client.listSubscribeTopic()
|
||||
print('listSubscribeTopic out', out)
|
||||
@ -56,7 +60,7 @@ print("setDisconnectHandler:%d" % ret)
|
||||
# T.sleep_s(5)
|
||||
# print("sleep_s:5s")
|
||||
|
||||
T.sleep_s(30)
|
||||
# T.sleep_s(30)
|
||||
# exit()
|
||||
ret = client.disconnect()
|
||||
print("disconnect ret:%d" % ret)
|
||||
|
@ -68,6 +68,10 @@ class _MQTT:
|
||||
pass
|
||||
"""set disconnect callback fun."""
|
||||
|
||||
def _fakeMsg(self, topic: str, qos: int, msg: str):
|
||||
pass
|
||||
"""fake msg for subscribe test"""
|
||||
|
||||
|
||||
def __del__():
|
||||
pass
|
||||
|
@ -629,6 +629,18 @@ void Subscribe_Handler(void* client, message_data_t* msg) {
|
||||
// MQTT_LOG_I("------------------<<<");
|
||||
}
|
||||
|
||||
void _mqtt__MQTT__fakeMsg(PikaObj* self, char* topic, int qos, char* msg) {
|
||||
message_data_t msg_data;
|
||||
mqtt_message_t mqtt_msg;
|
||||
mqtt_msg.payload = msg;
|
||||
mqtt_msg.payloadlen = strlen(msg);
|
||||
mqtt_msg.qos = qos;
|
||||
mqtt_msg.retained = 0;
|
||||
msg_data.message = &mqtt_msg;
|
||||
strcpy(msg_data.topic_name, topic);
|
||||
Subscribe_Handler(NULL, &msg_data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// 函 数 名:_mqtt___del__
|
||||
// 功能说明:释放事件处理器
|
||||
|
Loading…
x
Reference in New Issue
Block a user