ln:时间线获取优化,未绑定状态不能获取
authorluozheng <1732036298@qq.com>
Thu, 30 Oct 2025 06:10:43 +0000 (14:10 +0800)
committerluozheng <1732036298@qq.com>
Thu, 30 Oct 2025 06:10:43 +0000 (14:10 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp
code/sdk/zhihui/leiniao/imsl_ln/ln_api.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api.h
code/sdk/zhihui/leiniao/imsl_ln/ln_api_device_info.c

index d94ee35..b70d034 100644 (file)
@@ -105,7 +105,11 @@ static void LN_OPERATE_AlarmCallBackProcC(struct tm curTime)
     //整点上报时间线状态\r
     if(curTime.tm_min == 0 && curTime.tm_sec == 0)\r
     {\r
-        do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_TIMELINE_GET_STATUS, NULL, 0);\r
+        //获取是否绑定\r
+        if(uapi_ln_is_device_bound()) \r
+        {\r
+            do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_TIMELINE_GET_STATUS, NULL, 0);\r
+        }\r
     }\r
     //每天凌晨2点检查夜间更新状态\r
     if(curTime.tm_hour == 2 && curTime.tm_min == 0 && curTime.tm_sec == 0)\r
index c4f586b..0f356f8 100644 (file)
@@ -39,7 +39,7 @@ char *g_ln_last_package_url = NULL;      // 最近一次查询到的 OTA 包 URL
 char *g_ln_last_target_version = NULL;   // 最近一次查询到的 OTA 包目标版本(动态分配)
 char *g_ln_last_package_md5 = NULL;      // 最近一次查询到的 OTA 包 MD5(动态分配)
 int g_ln_last_package_size = 0;          // 最近一次查询到的 OTA 包大小(字节)
-int g_ln_is_device_bound = 0;            /* 设备绑定状态 */
+static int g_ln_is_device_bound = 0;     /* 设备绑定状态 */
 char g_ln_device_user_id[64] = {0};      // 设备绑定用户ID
 static int g_ln_is_file_downloading = 0; // 是否正在下载文件
 char g_ln_character_id[64] = {0};        // 角色ID
@@ -423,6 +423,16 @@ int uapi_ln_get_audio_play_status(void)
 {
     return g_audio_play_status;
 }
+//是否绑定设备
+int uapi_ln_is_device_bound(void)
+{
+    return g_ln_is_device_bound;
+}
+//设置是否绑定设备
+void uapi_ln_set_device_bound(int bound)
+{
+    g_ln_is_device_bound = bound;
+}
 
 /* 下载文件
 @param url 文件URL
@@ -921,6 +931,7 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type)
         printf("[WS] DeviceBind:设备绑定\n");
         do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, NULL, 0);
         push_bind_and_unbind_notification(LN_DEVICE_BIND_STATUS_BOUND);
+        uapi_ln_set_device_bound(1);
         ln_ws_ack_user_id_from_json(json_str);
         ln_ws_send_device_bind_ack(uapi_ln_get_user_id(), true, "绑定成功");
         break;
@@ -929,6 +940,7 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type)
     {
         printf("[WS] DeviceUnbind:设备解绑\n");
         push_bind_and_unbind_notification(LN_DEVICE_BIND_STATUS_UNBOUND);
+        uapi_ln_set_device_bound(0);
         ln_ws_ack_user_id_from_json(json_str);
         ln_ws_send_device_unbind_ack(uapi_ln_get_user_id(), true, "解绑成功");
         break;
index f7bcd64..baf5b55 100644 (file)
@@ -259,6 +259,10 @@ int uapi_ln_download_file_resume_with_retry(const char *url, const char *save_pa
 void uapi_ln_set_audio_play_status(int status);
 /* 获取ws音频播放状态 */
 int uapi_ln_get_audio_play_status(void);
+//是否绑定设备
+int uapi_ln_is_device_bound(void);
+//设置是否绑定设备
+void uapi_ln_set_device_bound(int bound);
 
 /* ============================== 共享全局状态(跨文件) ============================== */
 extern char *g_device_token;
index 4ef623d..50ce014 100644 (file)
@@ -620,12 +620,14 @@ uint32_t ln_device_get_user_id_http(const char *device_id,
                     if (data == NULL || cJSON_IsNull(data))
                     {
                         push_bind_and_unbind_notification(LN_DEVICE_BIND_STATUS_UNBOUND);
+                        uapi_ln_set_device_bound(0);
                     }
                     else if (cJSON_IsString(data) && data->valuestring && data->valuestring[0])
                     {
                         printf("device getUserId: data=%s\n", data->valuestring);
                         do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, NULL, 0);
                         push_bind_and_unbind_notification(LN_DEVICE_BIND_STATUS_BOUND);
+                        uapi_ln_set_device_bound(1);
                     }
                 }
                 cJSON_Delete(root);