#605 APP iOS/安卓 手表切换表盘,APP上不同步
authorCaisking <3449750381@qq.com>
Wed, 25 Sep 2024 09:37:15 +0000 (17:37 +0800)
committerCaisking <3449750381@qq.com>
Wed, 25 Sep 2024 09:37:15 +0000 (17:37 +0800)
code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModel.h
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialPresenter.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h

index e345221..4255684 100644 (file)
@@ -56,6 +56,7 @@ namespace OHOS
         bool DeleteCustomDial(uint16_t Id);
         void TestDialConfig(void);
         std::string GetSaveDir(int Id,uint8_t type);
+        void RegisterDial(uint16_t ID, const char *dialname,uint8_t type); 
 
     private:
         void LoadAllDialFromRam(void);
index c4008b9..d5df0dc 100644 (file)
@@ -128,6 +128,21 @@ SetDialModel &SetDialModel::GetInstance() {
 
 /* 注册表盘map */
 void SetDialModel::RegisterDial(uint16_t ID, const char *dialname) {
+
+  if (ID == 0 || strlen(dialname) == 0)
+    return;
+
+  registeredDials[ID] = std::string(dialname); // 唯一性
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RegisterDial %d %s is ok!", ID,
+                dialname);
+
+  LoadAllDial();
+  saveDialfile();
+}
+
+/* 注册表盘map_ble*/
+void SetDialModel::RegisterDial(uint16_t ID, const char *dialname,uint8_t type) {
   // 增加 ID 对应
   if (ID <= 4) {
     ID++;
@@ -142,7 +157,6 @@ void SetDialModel::RegisterDial(uint16_t ID, const char *dialname) {
                 dialname);
 
   LoadAllDial();
-
   saveDialfile();
 }
 
@@ -353,7 +367,6 @@ bool SetDialModel::UninstallDial(uint16_t ID) {
       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                     "UninstallDial: Failed to uninstall custom dial %d", ID);
       return false;
-
     default:
       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                     "UninstallDial: dial ID %d is offline dial", ID);
@@ -646,7 +659,7 @@ void SetDialModel::LoadAllDialFromRam() {
     // RegisterDial(dialInfo.id, dialInfo.dialName.c_str());
 
     // 日志输出
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                   "Parsed Dial: ID: %u, Name: %s, Image: %s", dialInfo.id,
                   dialInfo.dialName.c_str(), dialInfo.imageFullName.c_str());
   }
index a62750d..ed0bb20 100644 (file)
@@ -18,7 +18,8 @@
 #include "KeyInputListener.h"
 #include "custom_utils.h"
 #include "common/key_code.h"
-
+#include "bleService.h"
+#include "bleEvent.h"
 namespace OHOS
 {
     SetDialPresenter::SetDialPresenter()
@@ -55,8 +56,11 @@ namespace OHOS
 
     bool SetDialPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::OnClick");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetDialPresenter::OnClick");
         OnClickAction();
+        //具有延迟
+        svr_ble_read_data_value_updata_noyify();
+        Watch_SendDial_ToAppCmd();
         return true;
     }
 
index 73889b0..5e3553a 100644 (file)
@@ -4006,6 +4006,15 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_
     \r
 }\r
 //发送当前表盘到app\r
+\r
+void Watch_SendDial_ToAppCmd(void)\r
+{\r
+  \r
+    uint16_t dialNum =ble_get_dial_id();\r
+    ble_data_type type_={0x01,0x17,2,1,1};\r
+    send_big_data(type_,(char *)&dialNum,2);\r
+}\r
+\r
 static void SendDialToAppCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue)\r
 {\r
     uint8_t value[20];\r
index f2e2cae..0304681 100644 (file)
@@ -818,6 +818,8 @@ void GetCurDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,ui
 
 bool get_ctkd_flag(void);
 
+void Watch_SendDial_ToAppCmd(void);
+
 uint8_t parse_jsonCheck_weather(uint8_t *buf,uint8_t *check);//json 格式解析 天气数据
 uint8_t read_jsonHistory_weather(void);
 void GetwatchSaveMac(uint8_t *mac,uint8_t *mactype);