减少ble代码中的文件路径维护
authorhcj <1224667075@qq.com>
Tue, 5 Nov 2024 08:43:39 +0000 (16:43 +0800)
committerhcj <1224667075@qq.com>
Tue, 5 Nov 2024 08:43:39 +0000 (16:43 +0800)
code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h

index 06fa4e4..d506cb8 100644 (file)
@@ -49,6 +49,8 @@ ${ROOT_DIR}/application/wearable/fd230app/nativeui/alipay/include
 # ${ROOT_DIR}/middleware/services/media/foundation/player/interfaces/kits
 # ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits
 ${ROOT_DIR}/application/wearable/fd230app/nativeui/player/include
+${ROOT_DIR}/application/wearable/fd230app/nativelauncher/include
+
 )
 
 set(SOURCES
index 67b085f..021761b 100644 (file)
@@ -48,7 +48,7 @@
 #include "BluetoothModel.h"
 #include "MusicPlayerModel.h"
 #include "goal_notification.h"
-
+#include "UiConfig.h"
 // #include "AlarmClockModel.h"
 
 //#include "AlarmClockModel.h"
@@ -92,6 +92,32 @@ extern "C" {
 #include "AlipayC.h"
 #include "PlayersModelC.h"
 
+//#define APP_DOWNLOAD_DIAL_PATH "/user/dial/offline_dial" /*表盘市场安装路径*/
+#define DIAL_DATA_DIR APP_DOWNLOAD_DIAL_PATH
+
+// #define DIAL_DATA_DIR "/user/dial/offline_dial"
+
+
+char * get_dial_path(void)
+{
+    return DIAL_DATA_DIR;
+}
+
+errcode_t get_dial_file_path(char* input_dialname ,uint32_t input_size, char* output_file_path , uint32_t max_output_size)
+{
+    if(input_dialname == NULL || output_file_path == NULL)
+    {
+        return ERRCODE_FAIL;
+    }
+
+    int ret = sprintf_s(output_file_path,max_output_size,"%s/%s.bin",DIAL_DATA_DIR,input_dialname);
+    if (ret < 0)
+        return ERRCODE_FAIL;
+
+    return ERRCODE_SUCC;
+} 
+
+
 
 uint8_t get_dial_num()
 {
@@ -2101,10 +2127,10 @@ void set_goal_other_notification(uint8_t data)
     p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER,data);
     if(data==1)
     {
-        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_CALOREIE);
-        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_STAND);
-        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_FAT);
-        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_DISTANCE);
+        OHOS::set_Is_show_flag(1,OHOS::GOAL_CALOREIE);
+        OHOS::set_Is_show_flag(1,OHOS::GOAL_STAND);
+        OHOS::set_Is_show_flag(1,OHOS::GOAL_FAT);
+        OHOS::set_Is_show_flag(1,OHOS::GOAL_DISTANCE);
 
     }
 
@@ -2119,7 +2145,7 @@ void set_goal_step_notification(uint8_t data)
     p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEP,data);
     if(data==1)
     {
-        OHOS::set_Is_shouw_falg(1,OHOS::GOAL_STEP);
+        OHOS::set_Is_show_flag(1,OHOS::GOAL_STEP);
     }
 
     SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0);
index 26d0c4e..95c071a 100644 (file)
@@ -409,6 +409,11 @@ void test_paly(uint8_t falg);
 
 bool ble_is_Alipay_bind(void);
 
+char * get_dial_path(void);
+
+
+errcode_t get_dial_file_path(char* input_dialname ,uint32_t input_size, char* output_file_path , uint32_t max_output_size);
+
 #ifdef __cplusplus
 #if __cplusplus
 }
index c3573a8..d0edf12 100644 (file)
@@ -45,6 +45,7 @@ extern "C" {
 #include "bleANCS.h"\r
 #include "Bluetooyhpabpserver.h"\r
 \r
+\r
 #define DEBUG_TEST (0)\r
 #define CRC_CHECK_ERR 0 //crc校验失败\r
 #define JSON_CHECK_OK 1 //json解析成功\r
@@ -223,19 +224,8 @@ static errcode_t get_custom_dial_file_path(uint16_t id,char *filename,uint32_t i
     return ERRCODE_SUCC;\r
 \r
 }\r
-static errcode_t get_dial_file_path(char* input_dialname ,uint32_t input_size, char* output_file_path , uint32_t max_output_size)\r
-{\r
-    if(input_dialname == NULL || output_file_path == NULL)\r
-    {\r
-        return ERRCODE_FAIL;\r
-    }\r
 \r
-    int ret = sprintf_s(output_file_path,max_output_size,"/user/dial/offline_dial/%s.bin",input_dialname);\r
-    if (ret < 0)\r
-        return ERRCODE_FAIL;\r
 \r
-    return ERRCODE_SUCC;\r
-} \r
 \r
 \r
 int char_to_dec(char ch)\r
@@ -7387,9 +7377,9 @@ static errcode_t install_dial(void)
     if (lzmaindex != NULL)\r
     {\r
         struct stat info;\r
-        if (stat(DIAL_DATA_DIR, &info) != 0)\r
+        if (stat(get_dial_path(), &info) != 0)\r
         {\r
-            if (mkdir(DIAL_DATA_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)\r
+            if (mkdir(get_dial_path(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)\r
             {\r
                 return ERRCODE_FAIL; // \r
             }\r
@@ -7490,7 +7480,7 @@ bool Read_tar_file_buf_send_Data(uint16_t pack_size,uint8_t id)
     uint32_t pack_id=1;\r
     if(fp==NULL)\r
     {\r
-          WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"fopen fail %s\r\n",file_name);\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"fopen fail %s\r\n",file_name);\r
         free(data);\r
         return false;\r
     }\r
@@ -7501,7 +7491,7 @@ bool Read_tar_file_buf_send_Data(uint16_t pack_size,uint8_t id)
         read_size=fread(data,1,pack_size,fp);\r
         if(read_size!=0)\r
         {\r
-            ble_data_type type_={0x05,id,read_size,pack,pack_id};\r
+            ble_data_type type_={0x05,id,file_size,pack,pack_id};\r
             send_big_data(type_,(char *)data,read_size);\r
         }\r
         \r
index 9f607d4..800b1ca 100644 (file)
@@ -10,11 +10,12 @@ extern "C" {
 #include "errcode.h"
 #include "bts_def.h"
 // #include "bletest.h"
+
 #define PHONE_WATCH_CONFIG_PATH "/user/userdata/phone_watch.json"
 #define ALARM_DATA_CONFIG_PATH "/user/userdata/alarm_test.json"
 #define ANCS_DATA_CONFIG_DIR "/user/userdata/message"
 
-#define DIAL_DATA_DIR "/user/dial/offline_dial"
+
 
 #define ANCS_DATA_CJSON_PATH "/user/userdata/message/ancs.json" //消息文件可以任意更改