From 94cfb27b89be2b310b406b8e909a5206fba0dff7 Mon Sep 17 00:00:00 2001 From: liufeng24015 Date: Mon, 22 Nov 2021 11:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3=E5=92=8C?= =?UTF-8?q?=E6=B5=8B=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/app/TW001_OS_helloworld/hello_world.c | 9 +++++---- ...6\214\207\345\257\274\346\211\213\345\206\214.md" | 12 ++++++------ vendor/talkweb/niobe/hals/utils/token/hal_token.c | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/applications/app/TW001_OS_helloworld/hello_world.c b/applications/app/TW001_OS_helloworld/hello_world.c index 50f398ce..63c4676c 100644 --- a/applications/app/TW001_OS_helloworld/hello_world.c +++ b/applications/app/TW001_OS_helloworld/hello_world.c @@ -53,9 +53,9 @@ static void SystemTopicCallback(char *ptopic, char *pdata) static void OnConnectionedCallback() { // 属性设置 - SubscribeMQTTTopic("tlink/${ProductKey}/${DeviceName}/command/setProperty/exec",SystemTopicCallback); + SubscribeMQTTTopic("tlink/${productKey}/${deviceName}/command/setProperty/exec",SystemTopicCallback); // 属性上报 - SubscribeMQTTTopic("tlink/${ProductKey}/${DeviceName}/event/propertyReport/post", UserTopicCallback); + SubscribeMQTTTopic("tlink/${productKey}/${deviceName}/event/propertyReport/post", UserTopicCallback); printf("[Application][TaskID:%p][OnConnectionedCallback]!\n", osThreadGetId()); } @@ -88,8 +88,9 @@ static void StartMqttTask(void) step = 0; } - PushMQTTMessage("tlink/${ProductKey}/${DeviceName}/command/setProperty/exec", buf); - PushMQTTMessage("tlink/${ProductKey}/${DeviceName}/event/propertyReport/post", buf); + PushMQTTMessage("tlink/${productKey}/${deviceName}/command/setProperty/exec", buf); + // PushMQTTMessage("tlink/${productKey}/${deviceName}/event/propertyReport/post", buf); + PushMQTTMessageQOS("tlink/${productKey}/${deviceName}/event/propertyReport/post", buf,1); } } diff --git "a/docs/talkwebOS\345\274\200\345\217\221\346\214\207\345\257\274\346\211\213\345\206\214.md" "b/docs/talkwebOS\345\274\200\345\217\221\346\214\207\345\257\274\346\211\213\345\206\214.md" index 02055b6d..4f644f06 100644 --- "a/docs/talkwebOS\345\274\200\345\217\221\346\214\207\345\257\274\346\211\213\345\206\214.md" +++ "b/docs/talkwebOS\345\274\200\345\217\221\346\214\207\345\257\274\346\211\213\345\206\214.md" @@ -113,18 +113,18 @@ MQTT连接上IOT平台:等待网络连接执行CheckWIFITask,连接成功 -- void StartServices(); 启动MQTT服务。 +订阅接口:SubscribeMQTTTopic(const char *sub_topic, PMQTTMessageCallback callback); +取消订阅接口:UnSubscribeMQTTTopic(const char *topic); +发布接口:PushMQTTMessage(char *topic, const char *message); 默认QOS为0 + PushMQTTMessageQOS(char *topic, const char *message, MQTT_MESSAGE_QOS qos); 注册系统消息处理回调:int32 MQTTSystemTopicNotification(PMQTTMessageCallback callback); - 注册联网处理回调:void ConnectionedNotification(ConnectionedNotificationCallback callback); - -在联网回调处理函数中用SubscribeMQTTTopic接口订阅主题,接着用PushMQTTMessage或PushMQTTMessageQOS接口向某个主题发送消息,串口消息中能体现消息发送成功,如图:![image-20211108142535267](figure/image-20211108142535267.png) - 注册离线处理回调:void DisConnectionNotification(DisConnectionNotificationCallback callback); - 设置客户端调试模式:void SetTWClientDebugMode(MQTT_DEBUG_MODE mode); - MQTT_DEBUG_MODE_DISENABLE:关闭调试日志,MQTT_DEBUG_MODE_ENABLE:开启调试日志 +在联网回调处理函数中用SubscribeMQTTTopic接口订阅主题,接着用PushMQTTMessage或PushMQTTMessageQOS接口向某个主题发送消息,串口消息中能体现消息发送成功,如图:![image-20211108142535267](figure/image-20211108142535267.png) + 接口使用例子参考:base\components\tlinksdk\lite\example\useMqttSDK\example.c **demo调用参考:** diff --git a/vendor/talkweb/niobe/hals/utils/token/hal_token.c b/vendor/talkweb/niobe/hals/utils/token/hal_token.c index fdcc836d..cd50a80e 100644 --- a/vendor/talkweb/niobe/hals/utils/token/hal_token.c +++ b/vendor/talkweb/niobe/hals/utils/token/hal_token.c @@ -18,8 +18,8 @@ #include "ohos_types.h" static char ProductId[] = {"11223344"}; -static char ProductSecret[] = {"1d75ad5e36581caf"}; -static char ProductKey[] = {"O0uS10SO0"}; // ProductKey by OEM. +static char ProductSecret[] = {"ec76e4a427446224"}; +static char ProductKey[] = {"k0bvhXvUX"}; // ProductKey by OEM. static char ProductVersion[] = {"01.01.01"}; static int OEMReadToken(char *token, unsigned int len) -- Gitee