From: hcj <1224667075@qq.com> Date: Thu, 11 Apr 2024 08:03:35 +0000 (+0800) Subject: APP通讯录协议对接 X-Git-Tag: release_V1.2.70_20241020_135402~1210^2~5^2^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=a56393f9889deb3fe692ebc9aacea02876322409;p=mirrors%2FFD230.git APP通讯录协议对接 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp index 66cffb2ad..dee76b5b5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp @@ -7,6 +7,7 @@ */ #include "findphone/include/FindPhoneModel.h" +#include "bletest.h" namespace OHOS { @@ -25,6 +26,6 @@ namespace OHOS /*获取蓝牙是否已连接*/ bool FindPhoneModel::GetBlueToothConnectedState() { - return isBlueToothConnected; + return ble_is_ready() && ble_is_connect_ready(); } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp index 50aeb34f3..6b4982c6d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp @@ -12,6 +12,8 @@ #include "findphone/include/FindPhonePresenter.h" #include "common/key_code.h" #include +#include "bleEvent.h" + namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -60,6 +62,7 @@ namespace OHOS //发送指令停止震动 uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); NativeAbility::GetInstance().ChangeSlice(preSlice); + senfindphoneSend(0); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp index b98408148..642b2b2ed 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp @@ -10,6 +10,8 @@ #include "wearable_log.h" #include "findphone/include/FindPhoneModel.h" #include "UiConfig.h" +#include "bletest.h" +#include "bleEvent.h" namespace OHOS { @@ -288,6 +290,7 @@ namespace OHOS if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态 { FindPhoneViewInit_BlueToothConnected(); + senfindphoneSend(1); } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp index bf8a38974..a192e5910 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp @@ -690,11 +690,11 @@ namespace OHOS //InitIView(); initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin"); const power_display_svr_api_t *display_api = power_display_svr_get_api(); - // if (display_api->get_screen_state() != SCREEN_ON) - // { - // display_api->turn_on_screen(); - // } - // display_api->set_screen_set_keepon_timeout(-1); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(-1); } void testView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index 99f73a0b0..134213dc8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -604,7 +604,7 @@ namespace OHOS labelButton1_exit->SetViewId("labelButton1_exit");// Set style // Set additional property - labelButton1_exit->SetText("退出"); + labelButton1_exit->SetText("exit"); labelButton1_exit->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); labelButton1_exit->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton1_exit->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt index 56aa04d34..08fa110e2 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt +++ b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt @@ -13,6 +13,7 @@ ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits ${ROOT_DIR}/application/wearable/nativeapp/nativeui/heartrate/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/weather/include +${ROOT_DIR}/application/wearable/fd230app/nativeui/heart_blood/health_service ) diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 45acec4cc..cd98d98b5 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -15,6 +15,7 @@ #include "thread_adapter.h" #include "graphic_service.h" #include "WeatherModel.h" +#include "health_service.h" #ifdef __cplusplus #if __cplusplus @@ -43,6 +44,9 @@ extern "C" { #include "custom_utils.h" #include "string.h" +#include "bleService.h" + + // struct Weather_data // { // int humidity; @@ -52,7 +56,22 @@ extern "C" { // int temp; // int iconNight; // }; +uint8_t ble_falg=0; + +uint8_t ble_is_ready(void) +{ + return ble_falg; +} +uint8_t ble_is_connect_ready(void) +{ + return Bleconnect; +} + +void set_ble_falg(bool falg) +{ + ble_falg=falg; +} void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight) { diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index 6335a4a14..a89f9ffde 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -22,7 +22,12 @@ extern "C" { void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight); void set_weather_address_data(int lat, char* atm, char* city,char* subLocality,int lon); -void set_weather_one_data(int tempMin, int iconDay,int fxDate, int tempMax, char *textDay,int x) ; +void set_weather_one_data(int tempMin, int iconDay,int fxDate, int tempMax, char *textDay,int x); + +uint8_t ble_is_ready(void); +void set_ble_falg(uint8_t falg); +uint8_t ble_is_connect_ready(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 9e84c0ffc..2f88f6760 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -751,7 +751,8 @@ void cleanUnbindInfor(void)//和旧手机解绑清除配对信息 if(0!=remove(PHONE_WATCH_CONFIG_PATH)) { printf("json remove fail\r\n"); - } + } + set_ble_falg(0); } void sendBindInfor(uint8_t *crcnum) @@ -879,6 +880,7 @@ void sendParieSuccess(uint8_t flag,bd_addr_t *addr)//发送配对成功指令to WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sendParieSuccess:0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\r\n",addr->addr[0],addr->addr[1],addr->addr[2],addr->addr[3],addr->addr[4],addr->addr[5]); if(first_bond == 1 && phoneDataFlag == 1)//第一次连接绑定 { + set_ble_falg(1); uint8_t value[25]; uint8_t length = 0; memset(value,0,25); @@ -969,6 +971,25 @@ void checkCrcSend(uint8_t type,uint8_t typeID,uint8_t crcflag)//获取时间 sendBleData(sendBuf,19); } +//发送查找手机 +void senfindphoneSend(uint8_t flag) +{ + uint32_t tmp = 1; + uint16_t tmp_data = 1; + uint8_t sendBuf[19]; + memset(sendBuf,0,19); + sendBuf[0] = 0x72; + sendBuf[1] = 0x05; + sendBuf[2] = 0x01; //3 + memcpy(sendBuf+3,&tmp,4); + memcpy(sendBuf+7,&tmp,4); + memcpy(sendBuf+11,&tmp,4); //15 + memcpy(sendBuf+15,&tmp_data,2); //17 + sendBuf[17] = flag; + sendBuf[18] = Calculate_CRC(sendBuf,18); + sendBleData(sendBuf,19); +} + static void jsonCheck_time(uint8_t *buf)//json 格式解析 { char time_data[24]; @@ -1510,6 +1531,99 @@ void getUserInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,ui void getTRAIN_TARGETInfo(uint16_t cmd,uint8_t *crcnum,uint16_t len,uint8_t *totalData,uint8_t crcvalue)// { +} + +//电话薄解析函数 +void Parse_addressbook_bin(uint8_t *crcnum,uint16_t len) +{ + int num=crcnum[0];//人数 + int offset=1; + while (num) + { + uint8 sex = crcnum[offset]; + printf("性别: %d\r\n",sex); + offset=offset+1; + uint8 name_len=crcnum[offset]; + printf("name_len %d\r\n",name_len); + char name[32]={0}; + if(name_len==0) + { + name_len=strlen("未知"); + printf("未知\r\n"); + } + else + { + memcpy(name,&crcnum[offset+1],name_len); + printf("姓名: %s\r\n",name); + // for(int i=0;iwatch #define SET_BLE_NAME_CMD 0x0203 //修改蓝牙名称 #define SET_TRAIN_TARGET_CMD 0x0204 //设置训练目标 +#define SET_address_book_CMD 0x020b //设置通讯录 #define SYN_WATCH_LCD_PARAM_CMD 0x020E//同步屏幕参数app-watch #define SYN_VOICE_VIBRATION_PARAM_CMD 0x020f //同步参数app-watch #define SET_PHONE_INFOR_CMD 0x0210 //app发送手机信息 @@ -585,6 +586,7 @@ void getDeviceState(void); void cleanUnbindInfor(void);//和旧手机解绑清除配对信息 void comfirmPaire(uint8_t flag);//发送确认配对指令 1确认配对 0取消配对 void cameraSend(void); +void senfindphoneSend(uint8_t flag); #ifdef __cplusplus } #endif