From 34c6da4b250da6dd2205f5e23b93d1eee47f0600 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Wed, 25 Sep 2024 14:22:16 +0000 Subject: [PATCH] Merge #1012 into sdk602patch0626 from refs/changes/1012/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 胡传军 * refs/changes/1012/head: (26 commits squashed) - 修复同步实时运动数据存在的BUG - 蓝牙文件取消传输修改 - 电话bug综合修复 - 电话bug综合修复(补) - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 修复电话死机问题 - 修复蓝牙通话死机问题 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 修复天气json数据异常导致的死机问题,更改sos协议,更改语言切换逻辑 - 修复天气json数据异常导致的死机问题(补) - Mp3文件传输重写 - 修复自定义表盘ID不能对应问题 - 修复站立目标设置没生效bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 训练协议修改,待测试 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 修复蓝牙动画可能卡死问题 #616 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 - 电话综合修复 #547 - ble广播将不在随开关控制,增加JSON判断 - ble闹钟修复 - ble广播将不在随开关控制,增加JSON判断(补 ) - 增加循环震动 #753 - 优化OTA传输过程中刷新进度条代码#725待测试是否不再复现 - 适配通讯录人名长度修改 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1012 --- .../nativeui/bluetooth/src/BluetoothModel.cpp | 17 +- .../callerlog/include/CallerLogModel.h | 12 + .../nativeui/callerlog/src/CallerLogModel.cpp | 70 +++- .../src/BluetoothServiceOptionsView.cpp | 8 +- .../makephone/src/CallerDisplayView.cpp | 4 +- .../nativeui/makephone/src/CallingView.cpp | 4 +- .../makephone/src/DialingScreenView.cpp | 2 + .../makephone/src/MainCallingPresenter.cpp | 29 +- .../makephone/src/WaitingHintsView.cpp | 4 +- .../nativeui/phone/include/PhoneDirView.h | 10 +- .../phone/include/phoneaddressmodel.h | 2 +- .../nativeui/phone/src/MainPhoneView.cpp | 73 ++-- .../nativeui/phone/src/PhoneDirPresenter.cpp | 2 +- .../nativeui/phone/src/PhoneDirView.cpp | 84 ++++- .../phone/src/TelephonyInitInterface.cpp | 2 +- .../nativeui/phone/src/phoneaddressmodel.cpp | 8 +- .../service/ble_service/blemoder/bletest.cpp | 63 ++++ .../service/ble_service/blemoder/bletest.h | 2 + .../service/ble_service/bleservice/bleEvent.c | 344 ++++++++++++------ .../service/ble_service/bleservice/bleEvent.h | 7 + .../ble_service/bleservice/bleService.c | 132 +------ .../msg_center/src/msg_center_customer.cpp | 39 +- .../src/notify/makephone_notification.cpp | 80 ++-- .../msg_center/src/notify/transmitting.cpp | 15 +- .../slip/cat1Service/cat1_server.cpp | 3 +- 25 files changed, 643 insertions(+), 373 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index c553830d1..922cea15b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -213,12 +213,15 @@ void bluetooth_enable_all(void) // bts_feature.bt_auto_reconnect_closed = 0; // ret = bts_set_features(&bts_feature); // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt bts_set_features ret = %u", ret); - gap_ble_sec_params_t sec_param = { 1, GAP_BLE_IO_CAPABILITY_NOINPUTNOOUTPUT, 1, GAP_BLE_GAP_SECURITY_MODE1_LEVEL3 }; - // gap_ble_sec_params_t sec_param = { 1, GAP_BLE_IO_CAPABILITY_NOINPUTNOOUTPUT, 0, GAP_BLE_GAP_SECURITY_MODE1_LEVEL2 }; - ret = gap_ble_set_sec_param(&sec_param); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_ble_set_sec_param ret = %u", ret); + // gap_ble_sec_params_t sec_param = { 1, GAP_BLE_IO_CAPABILITY_NOINPUTNOOUTPUT, 1, GAP_BLE_GAP_SECURITY_MODE1_LEVEL3 }; + // // gap_ble_sec_params_t sec_param = { 1, GAP_BLE_IO_CAPABILITY_NOINPUTNOOUTPUT, 0, GAP_BLE_GAP_SECURITY_MODE1_LEVEL2 }; + // ret = gap_ble_set_sec_param(&sec_param); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_ble_set_sec_param ret = %u", ret); + + ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt gap_br_set_bt_scan_mode ret = %u", ret); /**开始ble广播*/ - custom_ble_service_start(); + // custom_ble_service_start(); } } @@ -227,10 +230,12 @@ void bluetooth_close_all(void) errcode_t ret; /**停止Ble广播,断开链接,清除协议缓存*/ - custom_ble_service_stop(); + // custom_ble_service_stop(); /** 停止BR广播 */ + ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 0); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bluetooth_close_all gap_br_set_bt_scan_mode ret = %u", ret); /**TODO: 停止BR扫描**/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h index a81d20a15..9130e27a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h @@ -144,11 +144,22 @@ CallSource GetCallSource(void) phoneNumberCAT1.append(reinterpret_cast(number), number_len); } + /* 设置cat1临时来电号码显示 */ + void tempSetoperateNumberCAT1END(const char *number, char number_len) + { + phoneNumberCAT1END.clear(); + phoneNumberCAT1END.append(reinterpret_cast(number), number_len); + } + std::string GettempPhoneNumber(void) { return phoneNumberCAT1; } + std::string GettempPhoneendNumber(void) + { + return phoneNumberCAT1END; + } @@ -163,6 +174,7 @@ private: std::string callDuration; // 通话时长 std::string phoneNumber; // 电话号码 std::string phoneNumberCAT1; // 4G电话号码 + std::string phoneNumberCAT1END; // 4G挂断电话号码 std ::string call_name; bool mulitplePhoneStatus{false}; // 判断是否多路通话界面 bool waitingStatus{false}; // 判断是否等待提醒界面 diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 13cfe6eac..35a0c5e05 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -37,6 +37,9 @@ static PhoneCallInfo callInfo{}; static int g_retNum{0}; // 电话个数 static int g_volumeLocal{0}; // 错误码返回 osTimerId_t g_startCounting = nullptr; // 定时器 +// +osTimerId_t g_shake = nullptr; // 循环震动定时器 + static constexpr uint64_t MS_ONE_SECONDS = 1000; static PhoneCallInfo callList[MULTI_CALL_MAX_NUME]{}; // 电话优先级标志位 @@ -88,6 +91,19 @@ static void SetPriorityNumber() return; } + +static void DisshakeTimer() +{ + if (g_shake != nullptr) { + osStatus_t ret = osTimerDelete(g_shake); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret); + return; + } + g_shake = nullptr; + } +} + /* 关闭定时器 */ static void DisableCallingTimer() { @@ -116,15 +132,14 @@ void StatusReset(void) CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::callleisure); NotificationManager::GetInstance()->SetWatchCallStatus(false); CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); - - PhoneServiceScreenCtr(false); + DisshakeTimer(); // If the call is handling in the notification, the slice is not switched if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { + PhoneServiceScreenCtr(false); if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) { - //NativeAbility::GetInstance().ChangeSlice(NativeAbility::GetInstance().GetPreSliceId()); NativeAbility::GetInstance().Back_CountSlice_make_phone(); } @@ -154,11 +169,22 @@ static void CallTimerCallbackProc(int data) SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str()); } +static void snakeCallback(int data) +{ + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + ui_api_vibrate_once_func(); + } +} + + static void CallTimerCallback(int data) { GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallbackProc, data)); } + + /* 开启定时器 */ static void InitCallingTimer() { @@ -187,6 +213,35 @@ static void InitCallingTimer() } } +static void InitshakeTimer() +{ + if (g_shake != nullptr) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer already exists!!"); + return; + } + g_shake = osTimerNew((osTimerFunc_t)snakeCallback, osTimerPeriodic, nullptr, nullptr); + if (g_shake == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer osTimerNew failed!!"); + return; + } + int tick = osMs2Tick(MS_ONE_SECONDS); + osStatus_t retTimer = osTimerStart(g_shake, tick); + if (retTimer != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer osTimerStart failed, ret = %lx!!", retTimer); + if (g_shake != nullptr) { + retTimer = osTimerDelete(g_shake); + if (retTimer != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::osTimerDelete failed, ret = %lx!!", retTimer); + return; + } + g_shake = nullptr; + } + return; + } +} + + + /* 判断是否有电话,判断优先级 */ bool FindCallListInfoAndSetPriorityNumber() { @@ -518,7 +573,7 @@ void CAT1_ChangeStatusScreendisplay(int lastStatus) { // If the call is handling in the notification, the slice is not switched if (lastStatus != OPERATE_PHONE_ACTIVE) { - NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); } } @@ -562,6 +617,8 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UsingPhoneChangeStatusCallback] operate:%d, callNUm:%d, call flow:%d", phoneCall->operate, GetCurrCallNum(), IsCompleteCallFlow()); + DisshakeTimer(); + if (phoneCall->operate == OPERATE_WATCH_FINISH && GetCurrCallNum() == 0) { g_callOperate = OPERATE_WATCH_FINISH; WatchFinishHandle(); @@ -582,7 +639,10 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) case OPERATE_INCOMING: // 显示电话呼入 { - IncomingHandle(); + InitshakeTimer(); + + IncomingHandle(); + } break; case OPERATE_WAITING: diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp index 15f937d01..ec7f598f6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp @@ -108,28 +108,28 @@ namespace OHOS case BluetoothServiceOptionsView::CONNECT_HFP: if(uapi_hfp_connect_state()) { - BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); + //BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); connect_state=true; } break; case BluetoothServiceOptionsView::DISCONNECT_HFP: if(!uapi_hfp_connect_state()) { - BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); + //BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); connect_state=true; } break; case BluetoothServiceOptionsView::CONNECT_A2DP: if(uapi_a2dp_snk_get_device_connect_state()) { - BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); + //BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); connect_state=true; } break; case BluetoothServiceOptionsView::DISCONNECT_A2DP: if(!uapi_a2dp_snk_get_device_connect_state()) { - BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); + //BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false); connect_state=true; } break; diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp index 55d105770..eb5a5ef4b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp @@ -121,7 +121,7 @@ bool CallerDisplayView::InitImageViewDisplay() imageperson->SetTouchable(true); imageperson->SetViewId("headset"); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; uint8_t sex; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) { @@ -158,7 +158,7 @@ bool CallerDisplayView::InitUILabelDisplay() TITLE_LABEL_DEFAULT_HEIGHT); callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) { callerDisplay->SetText(name_buf); diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp index 6e89244c4..e354eabc3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp @@ -212,7 +212,7 @@ bool CallingView::InitImageViewDisplay() imageperson->SetViewId("headset"); group->Add(imageperson); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; uint8_t sex; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) { @@ -245,7 +245,7 @@ bool CallingView::InitUILabelDisplay() 289, 40); callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) { callerDisplay->SetText(name_buf); diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/DialingScreenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/DialingScreenView.cpp index f9b20d5db..1c11fc2eb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/DialingScreenView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/DialingScreenView.cpp @@ -77,7 +77,9 @@ bool DialingScreenView::InitUILabelDisplay() dialingId->SetPosition(LABEL_ADRESS_POSITION_X, LABEL_ADRESS_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); dialingId->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + dialingId->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + dialingId->SetAlign(TEXT_ALIGNMENT_CENTER); dialingId->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_AIALING_SIZE); dialingId->SetTextColor(Color::White()); diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp index 574e098e1..fcb146827 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp @@ -193,11 +193,28 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) if (strcmp(view.GetViewId(), "microphoneChange") == 0) { if (changeImage == 0) { changeImage = 1; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_CLOSE_IMAGE_PATH); + if(CallerLogModel::GetInstance()->GetCallStatus()) + { + view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_CLOSE_IMAGE_PATH); + + } + else + { + view_->GetScreenView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_CLOSE_IMAGE_PATH); + } SetMicMute(true); + } else { changeImage = 0; - view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + if(CallerLogModel::GetInstance()->GetCallStatus()) + { + view_->GetCallingView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + + } + else + { + view_->GetScreenView()->GetImageMicrophone()->SetSrc(PNG_230_MICROPHONE_OPEN_IMAGE_PATH); + } SetMicMute(false); } return true; @@ -207,9 +224,9 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) { if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) { - + cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); cat1_call_hungup(); - cat1_handle_call_disconnected("callnumb"); + } else { @@ -224,6 +241,7 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) { if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) { + cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); cat1_call_hungup(); return true; //#endif @@ -252,8 +270,9 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) { + cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); cat1_call_hungup(); - cat1_handle_call_disconnected("callnumb"); + return true; //#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp index a8d08adaa..d6f8faaa3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp @@ -163,7 +163,7 @@ bool WaitingHintsView::InitImageViewDisplay() imageperson->SetTouchable(true); imageperson->SetViewId("headset"); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; uint8_t sex; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) { @@ -188,7 +188,7 @@ bool WaitingHintsView::InitUILabelDisplay() TITLE_LABEL_DEFAULT_HEIGHT); callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) { callerDisplay->SetText(name_buf); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h index ea71cb65a..43322dc97 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirView.h @@ -60,19 +60,23 @@ namespace OHOS void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc); void Set_onepage_address(const char *idstr); void onepage_address_init(void); + bool get_container_one_page_is_Visible(); private: UIView::OnDragListener *draglistener{nullptr}; PhoneDirView(PhoneDirView &&) = delete; PhoneDirView &operator=(PhoneDirView &&) = delete; - UILabelButtonExt *button[20]={NULL}; - UILabelButtonExt *number_button[2]={NULL}; + UILabelExt *label[20] ={nullptr}; + UILabelButtonExt *button[20]={nullptr}; + UILabelButtonExt *number_button[2]={nullptr}; UILabelExt * label1_phone_name=nullptr; UIImageView *phone_name=nullptr; + UIImageView *phone_name_=nullptr; + UILabelExt *label1_ =nullptr; UIScrollView *container_ =nullptr; UIScrollView *container_one_page=nullptr; - + UILabelExt *label1_no =nullptr; UILabelExt *label2_no=nullptr; UIImageView *image1_no=nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h index 4bdf238ee..f79b08122 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/phoneaddressmodel.h @@ -4,7 +4,7 @@ #define ADDRESS_BOOK_PATH "/user/userdata/addressbook.bin" -#define NAME_LEN (10*3) +#define NAME_LEN (30*3) #define NUMBER_LEN 20 #define AREA_LEN (20*3) #define OPERATOR_LEN (4*3) diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp index eb3cc077c..383d136ec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -54,8 +54,9 @@ namespace OHOS button->SetText(buttonconfig.str); button->SetAlign(TEXT_ALIGNMENT_LEFT); - button->SetLabelPosition(50,-23); - button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + button->SetLabelPosition(50,30); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 23); + button->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED); return button; @@ -278,13 +279,15 @@ namespace OHOS void MainPhoneView:: NewcalllogButtonExtupdata(CallLogInfo *data, uint8_t index,uint8_t i) { + return; + if(index==0) { //SwipeViewItem[i][0] char *txt; char buf[20]={0}; sprintf_s(buf,20,"%s",(const char*)(data)->tel); - char name[64]={0}; + char name[NAME_LEN+1]={0}; if(get_phone_addrss_name(name,buf,NULL)) { txt=name; @@ -362,16 +365,17 @@ namespace OHOS buttonconfig.h = 104; buttonconfig.ViewId="xxxx"; - char buf[20]={0}; - sprintf_s(buf,20,"%s",(const char*)(data)->tel); - char name[64]={0}; - if(get_phone_addrss_name(name,buf,NULL)) - { - buttonconfig.str=name; - }else - { - buttonconfig.str=buf; - } + + time_t currtime; + struct tm *timeinfo; + currtime=(data)->creationTime; + timeinfo = localtime(&currtime); + char time_buf[20]={0}; + + + sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min); + buttonconfig.str=time_buf; + buttonconfig.ViewId=(const char*)(data)->tel; button_calllog[i]=SetTheButton_ext(buttonconfig,ButtonOnclickListen); if(button_calllog[i]==nullptr) @@ -381,30 +385,32 @@ namespace OHOS TempGroup_->Add(button_calllog[i]); + + + TelephonyInitInterface::LabelParams labelParam = { - .x = 50, - .y = 60, - .width = 160, - .height = 35, - .fontSize = 23, + .x = 49, + .y = 19, + .width = 280, + .height = 41, + .fontSize = 35, .lineHeigh = 0, - .text = "2023-1-23 14:22", - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + .text = "xxx", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, }; - time_t currtime; - struct tm *timeinfo; - currtime=(data)->creationTime; - timeinfo = localtime(&currtime); - char time_buf[20]={0}; - - labelParam.x=50, - labelParam.text=time_buf; - labelParam.fontSize = 23; - sprintf_s(time_buf,20 ,"%d-%d-%d %d:%02d", timeinfo->tm_year + 1900,timeinfo->tm_mon + 1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min); - - - button_calllog_time[i] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + char buf[20]={0}; + sprintf_s(buf,20,"%s",(const char*)(data)->tel); + char name[NAME_LEN+1]={0}; + if(get_phone_addrss_name(name,buf,NULL)) + { + labelParam.text=name; + } + else + { + labelParam.text=buf; + } + button_calllog_time[i] = TelephonyInitInterface::LabelViewInit(labelParam,Color::GetColorFromRGBA(0xEE, 0xEE, 0xEE, 0xEE)); if (button_calllog_time[i] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); @@ -413,6 +419,7 @@ namespace OHOS labelParam.fontSize=18; labelParam.x=223+30; + labelParam.y=60; labelParam.lineBreakMode=UILabel::LINE_BREAK_MARQUEE; labelParam.width=72; labelParam.height=21; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp index 0203d1a92..7f1198662 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -87,7 +87,7 @@ namespace OHOS //if(strview.GetViewId()) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirPresenter----------%s ---",view.GetViewId()); - if(strlen(view.GetViewId())<5) + if(PhoneDirView::GetInstance()->get_container_one_page_is_Visible()==false) { PhoneDirView::GetInstance()->Set_onepage_address(view.GetViewId()); Set_onepage_address=true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index bb620618b..0e82dd01d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -58,7 +58,7 @@ namespace OHOS button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); - button->SetImagePosition(25, 25); + button->SetImagePosition(20, 20); return button; } @@ -78,7 +78,21 @@ namespace OHOS for(int i=0;iSetPosition(x+107, buttonconfig.y+33); // widget's left position and top position + label[i]->Resize(210, 35); // widget's width and height + label[i]->SetViewId("label1");// Set style + label[i]->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label[i]->SetText(addressbook_t.Contact_t[i].name); + label[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label[i]->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + label[i]->SetRollSpeed(70); + label[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + label[i]->SetVisible(true); + //char buf[32]={0}; //sprintf(buf,"1",i); //buf[0]=i+48; @@ -90,8 +104,10 @@ namespace OHOS buttonconfig.Fontsize=30; buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; button[i] = SetTheButton_ext(buttonconfig, clickListener); + buttonconfig.y+=interval; container_->Add(button[i]); + container_->Add(label[i]); } onepage_address_init(); /* -------------------------------------------------------------------------- */ @@ -105,7 +121,7 @@ namespace OHOS //container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0); container_one_page->SetViewId("container_one_page"); container_one_page->SetScrollBlankSize(35); - container_one_page->SetReboundSize(35); + //container_one_page->SetReboundSize(50); container_one_page->SetDirection(1); } @@ -113,8 +129,8 @@ namespace OHOS if (label1_phone_name == nullptr) { label1_phone_name = new UILabelExt(); } - label1_phone_name->SetPosition(40+20, 52); // widget's left position and top position - label1_phone_name->Resize(466-80-40, 30); // widget's width and height + label1_phone_name->SetPosition(128, 52); // widget's left position and top position + label1_phone_name->Resize(210, 30); // widget's width and height label1_phone_name->SetViewId("label1");// Set style label1_phone_name->SetStyle(STYLE_TEXT_FONT, 30); @@ -167,9 +183,7 @@ namespace OHOS for(int i=0;i<2;i++) { buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number; - char buf[32]={0}; - sprintf(buf,"%s",i); - buttonconfig.ViewId =buf; + buttonconfig.ViewId =addressbook_t.Contact_t[0].phone_number_t[0].number; buttonconfig.ImageSrc=nullptr; buttonconfig.label_x=50; buttonconfig.label_y=0; @@ -188,12 +202,28 @@ namespace OHOS } container_one_page->SetOnDragListener(draglistener); + if (phone_name_ == nullptr) { + phone_name_ = new UIImageView(); + } + phone_name_->SetPosition(0, 520); // widget's left position and top position + phone_name_->Resize(466, 30); // widget's width and height + phone_name_->SetViewId("phone_sex");// Set style + + container_one_page->Add(phone_name_); + + phone_name_->SetVisible(true); return; } + bool PhoneDirView::get_container_one_page_is_Visible() + { + return container_one_page->IsVisible(); + } + + void PhoneDirView::Set_onepage_address(const char *idstr) { if(strcmp("container_one_page",idstr)==0) @@ -203,13 +233,20 @@ namespace OHOS return; } - - //container_->SetVisible(false); + container_one_page->ScrollBy(0, 100); + container_->SetVisible(false); container_one_page->SetVisible(true); uint8_t id= atoi(idstr);//idstr[16]; + if(id>=20) + { + return; + } + if(addressbook_t.Contact_t[id].name) label1_phone_name->SetText(addressbook_t.Contact_t[id].name); + label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl); int len =addressbook_t.Contact_t[id].phone_num; @@ -256,6 +293,16 @@ namespace OHOS } } + for(int i=0;iRemoveAll(); @@ -267,6 +314,14 @@ namespace OHOS delete phone_name; phone_name = nullptr; } + if(phone_name_) + { + delete phone_name_; + phone_name_ = nullptr; + } + + + ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_BOY_1); ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_GIRL_1); @@ -435,8 +490,17 @@ namespace OHOS RootView::GetInstance()->Add(container_); if(container_one_page) + { + if (draglistener == nullptr) + { + return; + } + container_one_page->SetOnDragListener(draglistener); + } RootView::GetInstance()->Add(container_one_page); + + // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp index f8c00f864..756ca2279 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp @@ -69,7 +69,7 @@ namespace OHOS label->SetText(params.text); // 内容 label->SetTextColor(color); label->SetLineBreakMode(params.lineBreakMode); // 断行模式 - // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); // 设置此文本的对齐模式 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, params.fontSize); // 设置标签的字体 return label; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp index d8bfb9d25..e63161b7a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp @@ -174,7 +174,7 @@ namespace OHOS //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0) if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[0].number)) { - strcpy(name,addressbook_t.Contact_t[i].name); + strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name); if(sex!=NULL) *sex=addressbook_t.Contact_t[i].sex; return true; @@ -184,14 +184,14 @@ namespace OHOS //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0) if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[1].number)) { - strcpy(name,addressbook_t.Contact_t[i].name); + strcpy_s(name,NAME_LEN+1,addressbook_t.Contact_t[i].name); if(sex!=NULL) *sex=addressbook_t.Contact_t[i].sex; return true; } } } - strcpy(name,"未知"); + strcpy_s(name,NAME_LEN+1,"未知"); return false; } @@ -344,7 +344,7 @@ namespace OHOS void set_address_number(char * number) { - memset(address_number,0,20); + memset(address_number,0,NUMBER_LEN); memcpy_s(address_number,20,number,strlen(number)); } 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 b118cfad7..fe9fd3699 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -368,6 +368,69 @@ cJSON* ble_get_recs_data() return data_arryJSON; } +//通过时间戳获取训练数据 +cJSON* ble_get_Trainingdata_by_timetamp(uint32_t timetamp) +{ + struct Trainingdata * data=NULL; + int i=0; + + time_t currtime=timetamp; + struct tm *timeinfo; + timeinfo = localtime(&currtime); + int y=timeinfo->tm_year+ 1900; + int m=timeinfo->tm_mon+1; + int d=timeinfo->tm_mday; + int h=timeinfo->tm_hour; + int min=timeinfo->tm_min; + + char timeday[24]={0}; + sprintf_s(timeday,24,"%d_%02d_%02d",y,m,d); + + printf("%s\r\n",timeday); + + while(data=read_Trainingdata_data(timeday, i)) + { + if(data!=NULL) + { + printf("%d,%d\r\n",timetamp,data->st); + int time_error= timetamp>data->st ? timetamp-data->st:data->st-timetamp; + if(time_error<=2) + { + cJSON* itemJSON = cJSON_CreateObject(); + + cJSON_AddNumberToObject(itemJSON,"src",data->src); + cJSON_AddNumberToObject(itemJSON,"ty",data->ty); + cJSON_AddNumberToObject(itemJSON,"st",data->st); + cJSON_AddNumberToObject(itemJSON,"sp",data->sp); + cJSON_AddNumberToObject(itemJSON,"tgt",data->tgt); + cJSON_AddNumberToObject(itemJSON,"tg",data->tg); + cJSON_AddNumberToObject(itemJSON,"pg",data->pg); + cJSON_AddNumberToObject(itemJSON,"du",data->du); + cJSON_AddNumberToObject(itemJSON,"ca",data->ca); + cJSON_AddNumberToObject(itemJSON,"di",data->di); + cJSON_AddNumberToObject(itemJSON,"hr",data->hr); + cJSON_AddNumberToObject(itemJSON,"stp",data->stp); + cJSON_AddNumberToObject(itemJSON,"ti",data->ti); + cJSON_AddNumberToObject(itemJSON,"cir",data->cir); + cJSON_AddNumberToObject(itemJSON,"alt",data->alt); + cJSON_AddNumberToObject(itemJSON,"fpc",data->fpc); + cJSON_AddNumberToObject(itemJSON,"spc",data->spc); + cJSON_AddNumberToObject(itemJSON,"std",data->std); + cJSON_AddNumberToObject(itemJSON,"cdc",data->cdc); + free(data); + return itemJSON; + } + + free(data); + data=NULL; + } + else{ + break; + } + i++; + } + return NULL; +} Tag_Trailer_t Mp3Trailer; Tag_ID3V2_TAG_T TAG_T; 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 9cf6cdb92..c3297fbc6 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -376,6 +376,8 @@ bool ble_add_sos_number(uint8_t sex,char *name,char *number); uint8_t* ble_get_sos_all_data_malloc(uint32_t*); +cJSON* ble_get_Trainingdata_by_timetamp(uint32_t timetamp); + #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 5e3553aab..20c133904 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -707,12 +707,16 @@ void getPhoneNameLen(uint8_t *data,uint8_t *datalen,uint8_t *type)//获取手机 if(root != NULL) { cJSON* pn = cJSON_GetObjectItem(root, "pn"); - if (cJSON_IsString(pn)) { + if (pn && cJSON_IsString(pn)) { len = strlen(pn->valuestring)+1; printf("设备名称: %s len:%d\n", pn->valuestring,len); } cJSON* tp = cJSON_GetObjectItem(root, "tp"); - *type=tp->valueint; + if(tp && cJSON_IsNumber(pn)) + { + *type=tp->valueint; + } + cJSON* bond=cJSON_GetObjectItem(root, "bond"); if(bond) { @@ -734,7 +738,7 @@ static uint8_t *getPhoneName(uint8_t *data)//获取手机设备名称 if(root != NULL) { cJSON* pn = cJSON_GetObjectItem(root, "pn"); - if (cJSON_IsString(pn)) { + if (pn && cJSON_IsString(pn)) { uint8_t datalen = strlen(pn->valuestring)+1; if(datalen > PHONE_NAME_MAX_LEN) // { @@ -775,7 +779,7 @@ void getPhoneMac(uint8_t *data,uint8_t *phoneMac)//获取手机设备mac这个 if(root != NULL) { cJSON* mac = cJSON_GetObjectItem(root, "mac"); - if (cJSON_IsArray(mac)) { + if (mac && cJSON_IsArray(mac)) { printf("MAC地址: "); cJSON* macElement = NULL; cJSON_ArrayForEach(macElement, mac) { @@ -1244,8 +1248,16 @@ void sendParieSuccess(uint8_t flag,bd_addr_t *addr)//发送配对成功指令to if(flag == 1)//配对成功 { cJSON *dataJSON = cJSON_CreateObject(); + if(dataJSON==NULL) + { + return; + } cJSON* arrayJSON = cJSON_CreateArray(); + if(arrayJSON==NULL) + { + return; + } for(uint8_t id = 0;id<6;id++) { cJSON_AddNumberToObject(arrayJSON,"id",addr->addr[id]); @@ -1359,48 +1371,48 @@ static uint8_t jsonCheck_time(uint8_t *buf)//json 格式解析 uint8_t second = 0; uint32_t timestamp; cJSON* time = cJSON_GetObjectItem(root, "time"); - if (cJSON_IsNumber(time)) { + if (time && cJSON_IsNumber(time)) { printf("time: %d\n", time->valueint); timestamp = time->valueint; // printf("time: %d\n", time->valueint); } cJSON* jsweek = cJSON_GetObjectItem(root, "week"); - if (cJSON_IsNumber(jsweek)) { + if (jsweek && cJSON_IsNumber(jsweek)) { printf("week: %d\n", jsweek->valueint); week = jsweek->valueint; } cJSON* jsyear = cJSON_GetObjectItem(root, "year"); - if (cJSON_IsNumber(jsyear)) { + if (jsyear && cJSON_IsNumber(jsyear)) { printf("year: %d\n", jsyear->valueint); year = jsyear->valueint; } cJSON* jsmonth = cJSON_GetObjectItem(root, "month"); - if (cJSON_IsNumber(jsmonth)) { + if (jsmonth && cJSON_IsNumber(jsmonth)) { printf("month: %d\n", jsmonth->valueint); month = jsmonth->valueint; } cJSON* jsday = cJSON_GetObjectItem(root, "day"); - if (cJSON_IsNumber(jsday)) { + if (jsday && cJSON_IsNumber(jsday)) { printf("day: %d\n", jsday->valueint); day = jsday->valueint; } cJSON* jshour = cJSON_GetObjectItem(root, "hour"); - if (cJSON_IsNumber(jshour)) { + if (jshour && cJSON_IsNumber(jshour)) { printf("hour: %d\n", jshour->valueint); hour = jshour->valueint; } cJSON* jsminute = cJSON_GetObjectItem(root, "minute"); - if (cJSON_IsNumber(jsminute)) { + if (jsminute && cJSON_IsNumber(jsminute)) { printf("minute: %d\n", jsminute->valueint); minute = jsminute->valueint; } cJSON* jssecond = cJSON_GetObjectItem(root, "second"); - if (cJSON_IsNumber(jssecond)) { + if (jssecond && cJSON_IsNumber(jssecond)) { printf("second: %d\n", jssecond->valueint); second = jssecond->valueint; } cJSON* location = cJSON_GetObjectItem(root, "location"); - if (cJSON_IsString(location)) { + if (location && cJSON_IsString(location)) { printf("location: %s\n", location->valuestring); locations = location->valuestring; } @@ -1579,7 +1591,7 @@ static void SetOtherTarget(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota set_goal_durationcount(target_fattime); set_goal_caloriescount(target_kcal); - + set_SilentMode(ring); set_vibrationremiander(vibratior); @@ -1613,15 +1625,30 @@ static void jsonCheck_alarm(uint8_t *buf)//json 解析闹钟数据 ble_delet_all_AlarmInfo(); cJSON* alarms = cJSON_GetObjectItem(root, "alarms"); + if(alarms==NULL) + { + return; + } int alarmCount = cJSON_GetArraySize(alarms); for(int i=0;ivalueint; - int id=cJSON_GetObjectItem(data,"id")->valueint; cJSON* repeat=cJSON_GetObjectItem(data,"repeat"); + if(repeat==NULL) + return; + int array_size = cJSON_GetArraySize(repeat); for(int j=0;jvalueint; - int minute=cJSON_GetObjectItem(data,"minute")->valueint; - int enable=cJSON_GetObjectItem(data,"enable")->valueint; - ble_SetAlarmInfo(hour, minute,week,i,enable); + + cJSON* hour_data=cJSON_GetObjectItem(data,"hour"); + if(hour_data==NULL) + { + return; + } + int hour=hour_data->valueint; + cJSON* minute_data=cJSON_GetObjectItem(data,"minute"); + if(minute_data==NULL) + { + return; + } + int minute=minute_data ->valueint; + cJSON* enable_data=cJSON_GetObjectItem(data,"enable"); + if(enable_data==NULL) + { + return; + } + int enable=enable_data ->valueint; + + ble_SetAlarmInfo(hour, minute,week,i,enable); } cJSON_Delete(root); @@ -2093,8 +2137,120 @@ void SetmsgfiltrationCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalD } +//通过时间戳来获取训练数据 + +void SYN_train_datatCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//同步训练数据 +{ + + if(Check_CRC(data,len,crcvalue)) + { + if(len==4) + { + uint32_t timetamp=0; + memcpy_s((void*)&timetamp,4,data,4); + cJSON *json_data = ble_get_Trainingdata_by_timetamp(timetamp); + if(json_data==NULL) + { + ble_data_type type_={0x02,0x19,0,1,1}; + send_big_data(type_,NULL,0); + return; + } + char *json_str=cJSON_PrintUnformatted(json_data); + uint32_t json_len= strlen(json_str); + cJSON_Delete(json_data); + + + uint32_t surplus_len=json_len; + uint32_t offset=0; + + uint32_t pack; + uint16_t pack_size=(ble_nus_max_data_len-18); + if(pack_size>482)pack_size=482; + if(json_len%pack_size==0) + { + pack=json_len/pack_size; + } + else + { + pack=json_len/pack_size+1; + } + uint32_t pack_id=1; + while (surplus_len!=0) + { + if(surplus_len>=pack_size) + { + surplus_len=surplus_len-pack_size; + ble_data_type type_={0x02,0x19,json_len,pack,pack_id}; + send_big_data(type_,(char *)json_str+offset,pack_size); + offset+=pack_size; + } + else + { + + printf("%d %d %d %d\r\n",json_len,surplus_len,pack_id,pack); + ble_data_type type_={0x02,0x19,json_len,pack,pack_id}; + send_big_data(type_,(char *)json_str+offset,surplus_len); + break; + } + pack_id++; + } + + cJSON_free(json_str); + + } + + } + else + { + ble_data_type type_={0x02,0x19,0,1,1}; + send_big_data(type_,NULL,0); + } +} + + +void SYN_train_heart_datatCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//同步训练数据 +{ + + if(Check_CRC(data,len,crcvalue)) + { + if(len==4) + { + uint32_t timetamp=0; + memcpy_s((void*)&timetamp,4,data,4); + ble_data_type type_={0x02,0x4B,0,1,1}; + send_big_data(type_,NULL,0); + } + + } + else + { + ble_data_type type_={0x02,0x4B,0,1,1}; + send_big_data(type_,NULL,0); + } +} + +void SYN_train_speed_datatCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//同步训练数据 +{ + + if(Check_CRC(data,len,crcvalue)) + { + if(len==4) + { + uint32_t timetamp=0; + memcpy_s((void*)&timetamp,4,data,4); + ble_data_type type_={0x02,0x18,0,1,1}; + send_big_data(type_,NULL,0); + } + + } + else + { + ble_data_type type_={0x02,0x18,0,1,1}; + send_big_data(type_,NULL,0); + } +} //APP设置步数目标 void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) @@ -2308,19 +2464,18 @@ uint8_t parse_jsonCheck_weather(uint8_t *buf,uint8_t *check)//json 格式解析 } - if( cm_custom_ble_service_on_flag() && cm_get_HFP_switch()) + if( uapi_dev_runtime_get_bt_powerstat() && cm_get_HFP_switch()) uapi_pbap_cmd_start_client(); bd_addr_t bdaddr={0}; uapi_get_br_address(&bdaddr); - if( cm_custom_ble_service_on_flag() && (cm_get_HFP_switch()||cm_get_A2DP_switch())) + if( uapi_dev_runtime_get_bt_powerstat() && (cm_get_HFP_switch()||cm_get_A2DP_switch())) { if (false==bt_is_acl_connected(&bdaddr)) { int ret = gap_reconnect_media_device(&bdaddr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " gap_reconnect_media_device ret = %u", ret); } - } @@ -3130,7 +3285,15 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui case DELETE_FILE_CMD: break; case SYN_BASIC_REAL_HEATR_CMD: + SYN_train_heart_datatCmd(typeID,data,datalen,totalData,crcvalue); break; + case SYN_TRAIN_DATA_CMD: + SYN_train_datatCmd(typeID,data,datalen,totalData,crcvalue); + break; + case SYN_TRAIN_SPEED_CMD: + SYN_train_speed_datatCmd(typeID,data,datalen,totalData,crcvalue); + break; + case SYN_TODAY_BASIC_TRAIN_TXT_CMD: break; case SYN_WATCH_LCD_PARAM_CMD://app下发的同步屏幕参数到手表 @@ -3226,89 +3389,6 @@ static void switchDialCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total } } -//获取闹钟数据 -static void GetAlarmDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) -{ - - uint32_t tmp = 1; - uint32_t data_len = 1; - uint16_t tmp_data = 1; - if(Check_CRC(data,len,crcvalue)) - { - - cJSON *dataJSON = cJSON_CreateObject(); - cJSON* data_arryJSON = cJSON_CreateArray(); - cJSON_AddNumberToObject(dataJSON,"code",1); - - for(uint8_t i =0;i<2;i++) - { - cJSON* itemJSON = cJSON_CreateObject(); - cJSON* arrayJSON = cJSON_CreateArray(); - for(uint8_t id = 0;id<7;id++) - { - cJSON_AddNumberToObject(arrayJSON,"id",id); - } - - cJSON_AddNumberToObject(itemJSON,"id",i); - cJSON_AddItemToObject(itemJSON,"repeat",arrayJSON); - cJSON_AddNumberToObject(itemJSON,"hour",2+20*i); - cJSON_AddNumberToObject(itemJSON,"minute",30+i*0); - cJSON_AddNumberToObject(itemJSON,"enable",1); - cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON); - } - cJSON_AddItemToObject(dataJSON,"alarms",data_arryJSON); - - char *json_format = cJSON_PrintUnformatted(dataJSON); - printf("%d\n",strlen(json_format)); - cJSON_Delete(dataJSON); - printf("phone %s",json_format); - char *new_json; - - uint32_t len = strlen(json_format); - uint8_t value[len+17+1]; - memset(value,0,len+17+1); - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x01; - data_len = len; - tmp_data = len; - memcpy(value+3,&tmp,4); - memcpy(value+7,&data_len,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - if((data_len+18) > ble_nus_max_data_len && data_len > 0) - { - - }else{ - if(data_len != 0){ - memcpy(value+17,json_format,data_len); - cJSON_free(json_format); - } - - } - value[data_len+17] = Calculate_CRC(value,data_len+17); - sendBleData(value,data_len+17+1); - - }else - { - uint8_t value[19]; - memset(value,0,19); - value[0] = 0x72; - value[1] = 0x01; - value[2] = 0x01; - uint32_t tmp = 1; - uint16_t tmp_data = 1; - memcpy(value+3,&tmp,4); - memcpy(value+7,&tmp,4); - memcpy(value+11,&tmp,4); - memcpy(value+15,&tmp_data,2); - value[17] = 0;//校验失败 - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); - } -} - - //关于本机内容 static void aboutDeviceCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) @@ -3483,6 +3563,10 @@ void GetCurDataCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,ui for(uint8_t i = 0;i<7;i++) { cJSON* data_arryJSON = cJSON_CreateObject(); + if(data_arryJSON==NULL) + { + return; + } uint32_t value=0; if(i==0) { @@ -3756,6 +3840,17 @@ static void OpenSportModeCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to sendBleData(value,19); } } + +void reply_APP_StopSportModeCmd(uint16_t time) +{ + char data[3]={0}; + uint32_t data_len=3; + data[0]=1; + memcpy(&data[1],&time,2); + printf("发送训练状态数据%d %d\r\n",data[0],time); + ble_data_type type={0x01,0x0B,data_len,1,1}; + send_big_data(type,data,data_len); +} //结束运动模式 static void StopSportModeCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -3778,9 +3873,9 @@ static void StopSportModeCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to printf("结束运动\r\n"); CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); - value[17] = 1; //1 操作成功 2 操作失败 - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); + // value[17] = 1; //1 操作成功 2 操作失败 + // value[18] = Calculate_CRC(value,18); + // sendBleData(value,19); }else { value[17] = 0; @@ -3960,6 +4055,19 @@ static void SetMaxHrRemindCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *t } } + +void reply_APP_SportPasueResetCmd(uint16_t time) +{ + char data[3]={0}; + uint32_t data_len=3; + data[0]=1; + memcpy(&data[1],&time,2); + printf("发送训练状态数据%d %d\r\n",data[0],time); + ble_data_type type={0x01,0x16,data_len,1,1}; + send_big_data(type,data,data_len); +} + + //训练暂停/恢复 static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -3994,9 +4102,9 @@ static void GetSportPasueResetCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_ CustomEventPublish(TOPIC_EVENT_BLE_TRAINING,(uint8_t*)&training_ble_data,sizeof(training_ble)); } - value[17] = 1; - value[18] = Calculate_CRC(value,18); - sendBleData(value,19); + // value[17] = 1; + // value[18] = Calculate_CRC(value,18); + // sendBleData(value,19); }else { value[17] = 0; @@ -6170,17 +6278,17 @@ uint8_t jscheck_ancs(uint8_t *data) memset(titleBuf,0,TITLE_BUF_LEN); memset(msgBuf,0,MSG_BUF_LEN); cJSON* uid = cJSON_GetObjectItem(root, "uid"); - if (cJSON_IsNumber(uid)) { + if (uid && cJSON_IsNumber(uid)) { printf("uid_t: %d\n", uid->valueint); uid_t = uid->valueint; } cJSON* appid = cJSON_GetObjectItem(root, "appid"); - if (cJSON_IsNumber(appid)) { + if (appid && cJSON_IsNumber(appid)) { printf("appid_t: %d\n", appid->valueint); appid_t = appid->valueint; } cJSON* title_c = cJSON_GetObjectItem(root, "title"); - if (cJSON_IsString(title_c)) { + if (title_c && cJSON_IsString(title_c)) { printf("titleBuf: %s\n", title_c->valuestring); int len = strlen(title_c->valuestring); if(len >= TITLE_BUF_LEN){ @@ -6193,7 +6301,7 @@ uint8_t jscheck_ancs(uint8_t *data) memcpy(titleBuf,(uint8_t *)title_c->valuestring,len); } cJSON* msg = cJSON_GetObjectItem(root, "msg"); - if (cJSON_IsString(msg)) { + if (msg && cJSON_IsString(msg)) { int len = strlen(msg->valuestring); if(len >= MSG_BUF_LEN-4){ len = uft8_check(msg->valuestring,MSG_BUF_LEN-4); @@ -6206,12 +6314,12 @@ uint8_t jscheck_ancs(uint8_t *data) printf("msgBuf: %s\n",msgBuf); } cJSON* time = cJSON_GetObjectItem(root, "time"); - if (cJSON_IsString(time)) { + if (time && cJSON_IsString(time)) { printf("time: %s\n", time->valuestring); // timeBuf = time->valueint; } cJSON* hasCode = cJSON_GetObjectItem(root, "hasCode"); - if (cJSON_IsNumber(hasCode)) { + if (hasCode && cJSON_IsNumber(hasCode)) { printf("hasCode_t: %d\n", hasCode->valueint); hasCode_t = hasCode->valueint; } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 0304681ee..0afd573dd 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -636,6 +636,8 @@ TYPE:02 #define SET_SEDENTARINESS_PARAM_CMD 0x021D //APP设置久坐提醒 #define SET_ANCS_MSG_FILTRATION_CMD 0x021e //APP设置消息过滤处理 #define SET_APP_AI_TXT_CMD 0x021F //设置AI返回的文本 +#define SYN_TRAIN_SPEED_CMD 0x0218 //同步某次基础训练配速(02,18) +#define SYN_TRAIN_DATA_CMD 0x0219 // 同步某次基础训练汇总记录(02,19) #define SET_WEATHER_DATA_CMD 0x0220 //发送天气数据 #define SET_ALARM_DATA_CMD 0x0221 //发送闹钟数据 #define DELETE_FILE_CMD 0x0222 //删除指定文件 @@ -823,6 +825,11 @@ 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); + +void reply_APP_SportPasueResetCmd(uint16_t time); + +void reply_APP_StopSportModeCmd(uint16_t time); + ///////////////////////////自定义文件传输协议///////////////////////////// #define OTA_FILE_MSG_CMD 0x0601 #define OTA_FILE_DATA_CMD 0x0602 diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index d0a0e2d57..f00e31764 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -326,7 +326,7 @@ void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_bl // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status()); // if(AdverFlag == true){ free_ble_data(); - if(uapi_dev_runtime_get_bt_powerstat()) + //if(uapi_dev_runtime_get_bt_powerstat()) { svr_ble_adv_start(); //gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); @@ -337,7 +337,7 @@ void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_bl devpair_state = 0;// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "exit_alipay_gui !!! %d",exit_alipay_gui); - if(!exit_alipay_gui)//如果进入了绑定二维码界面 正在连接app 不需要停止广播数据 + //if(!exit_alipay_gui)//如果进入了绑定二维码界面 正在连接app 不需要停止广播数据 { svr_ble_adv_stop(); } @@ -366,11 +366,9 @@ void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_bl void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t status) { devpair_state = 1;//代表配对成功了 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_pair_result_cbt_cb!!! addr 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x status:0x%x\r\n",addr->addr[0],addr->addr[1], addr->addr[2],addr->addr[3],addr->addr[4],addr->addr[5],status); - //if(get_notify_switch()) if(status==ERRCODE_SUCC) { if(get_ble_pair()) @@ -379,15 +377,11 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s if(get_ctkd_flag() && uapi_dev_runtime_get_bt_powerstat()) { gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 20); - if(get_ble_pair()&&( cm_get_A2DP_switch() || cm_get_HFP_switch())) { int ret=gap_reconnect_media_device(&phone_addr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! %X\r\n",ret); - //uapi_a2dp_snk_connect(); - - - }else{ + }else{ if(get_br_is_pair()) { @@ -400,10 +394,7 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s int ret=gap_reconnect_media_device(&bdaddr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! %X\r\n",ret); } - // if(cm_get_A2DP_switch() || cm_get_HFP_switch()) - // uapi_a2dp_snk_connect(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! \r\n"); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! \r\n"); } else { @@ -411,16 +402,10 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s uapi_a2dp_snk_connect(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n"); } - } - int ret = gap_connect_remote_device(addr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_connect_remote_device!!! %X\r\n",ret); - - - } - //uapi_a2dp_snk_connect(); - + } } hand_watch_first_time_Paired(); svr_ble_adv_stop(); @@ -434,11 +419,6 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s errcode_t ret = gap_ble_connect_param_update(&conn_param); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap ble update connection parameters ret: %u\n", ret); } - - - //if(!uapi_a2dp_snk_get_device_connect_state() || !uapi_hfp_connect_state()) - - } //添加ota特征值 @@ -776,64 +756,8 @@ void alipay_add_chart_decr_cb(uint8_t server_id,uint16_t srv_handle) if (ret != ERRCODE_SUCC) { // ALIPAY_PRINT_ERR(0, "gatts_add_descriptor fail, ret:%u.\r\n", ret); } - // errcode_t ret = 0; - // // uint16_t id = ALIPAYY_CHARACTERISTIC_ID; - // gatts_add_chara_info_t character; - // uint16_t value = 0; - // bt_uuid_t alipay_service_uuid = {0}; - // bts_data_to_uuid_len2(0x4a02, &alipay_service_uuid); - // memset_s(&character, sizeof(gatts_add_chara_info_t), 0, sizeof(gatts_add_chara_info_t)); - // // character.chara_uuid.uuid_len = sizeof(id); - // // memcpy_s(character.chara_uuid.uuid, sizeof (character.chara_uuid.uuid), (char *)&id, sizeof(id)); - // character.chara_uuid = alipay_service_uuid; - // character.permissions = GATT_ATTRIBUTE_PERMISSION_READ | GATT_ATTRIBUTE_PERMISSION_WRITE; - // character.properties = - // GATT_CHARACTER_PROPERTY_BIT_READ | GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_NOTIFY; - // character.value_len = 256; - // character.value = g_alipay_character_buf; - - // ret = gatts_add_characteristic(server_id, srv_handle, &character); - // if (ret != ERRCODE_SUCC) { - // ALIPAY_PRINT_ERR(0, "gatts_add_characteristic fail, ret:%u.\r\n", ret); - // } - - // uint8_t bas_ccc_val[] = { - // 0x01, - // 0x00 - // }; - // bt_uuid_t ccc_uuid = { 0 }; - // bts_data_to_uuid_len2(0x2902, &ccc_uuid); - // // bts_data_to_uuid_len2(0x2902, &ccc_uuid); - // gatts_add_desc_info_t descriptor; - // descriptor.desc_uuid = ccc_uuid; - // descriptor.permissions = GATT_ATTRIBUTE_PERMISSION_READ | GATT_ATTRIBUTE_PERMISSION_WRITE; - // descriptor.value_len = (uint16_t)sizeof(bas_ccc_val); - // descriptor.value = bas_ccc_val; - - // ret = gatts_add_descriptor(server_id, srv_handle, &descriptor); - // if (ret != ERRCODE_SUCC) { - // ALIPAY_PRINT_ERR(0, "gatts_add_descriptor fail, ret:%u.\r\n", ret); - // } - // bd_addr_t addr_info; - // gatts_add_desc_info_t descriptor_ap; - // gap_ble_get_local_addr(&addr_info); - // bts_data_to_uuid_len2(0x4b02, &ccc_uuid); - // descriptor_ap.desc_uuid = ccc_uuid; - // descriptor_ap.permissions = GATT_ATTRIBUTE_PERMISSION_READ | GATT_ATTRIBUTE_PERMISSION_WRITE; - // descriptor_ap.value_len = BD_ADDR_LEN; - // uint8_t ble_data_mac_switch[BD_ADDR_LEN] = {0}; - // int k = BD_ADDR_LEN; - // for (int i = 0; i < BD_ADDR_LEN; i++) { - // ble_data_mac_switch[--k] = addr_info.addr[i]; - // } - // descriptor_ap.value = ble_data_mac_switch; - // ret = gatts_add_descriptor(server_id, srv_handle, &descriptor_ap); - // if (ret != ERRCODE_SUCC) { - // ALIPAY_PRINT_ERR(0, "gatts_add_descriptor second fail, ret:%u.\r\n", ret); - // } - + } -} //这个回调函数添加新的服务UUID static void svr_ble_bt_gatts_service_add_cb(uint8_t server_id, bt_uuid_t *uuid, uint16_t srv_handle, errcode_t status) @@ -1202,24 +1126,8 @@ static void svr_ble_bt_gatts_req_read_cb(uint8_t server_id, uint16_t conn_id, ga WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_req_read_cb ret:is_long:%d",read_cb_para->is_long); //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_req_read_cb ret:is_long:%d 2ae2 %d read_cb_para->handle :%d",read_cb_para->is_long,data2ae2Cmd,read_cb_para->handle); - if(read_cb_para->handle!=data2ae2Cmd) - return; - - // if(flag==0) - // ble_ancs_client_cmd_setup_and_subscribe(g_ble_conn_id); - // else if(flag==1) - // a2dp_snk_connect(&disconect_addr);//ble_ancs_client_subscribe_notify(g_ble_conn_id,1); - // else if(flag==2) - // ble_ancs_client_subscribe_data(g_ble_conn_id,1); - // else if (flag==3) - // ble_ancs_client_subscribe_notify(g_ble_conn_id,0); - - // flag++; - // if(flag==4) - // { - // flag=1; - // } - + if(read_cb_para->handle==data2ae2Cmd) + { static uint8_t battery_point_val[20] = {0}; // 获取电池电压值 float voltage = 0.0F; @@ -1263,6 +1171,7 @@ static void svr_ble_bt_gatts_req_read_cb(uint8_t server_id, uint16_t conn_id, ga //read_cb_para->need_rsp=0; gatts_notify_indicate(server_id,conn_id,&gatts_ntf_ind); } +} static uint8_t falg = 0; @@ -1435,21 +1344,7 @@ void ble_unregist_server(void) void svr_ble_bluetooth_init(void) { memset(&phone_addr,0,sizeof(bd_addr_t)); - // bool ret = enable_bt_stack(); - // // bool ret = enable_ble(); - // if (ret != ERRCODE_SUCC) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bluetooth_init enable_bt_stack ret:%u.\r\n", ret); - // } - - // if (g_custom_ble_init_flag) - // { - // return ; - // } - - //清除上次内容r - - - // osDelay(100); + srv_ble_server_register_gap_ble_callbacks(); srv_ble_server_register_gatt_callbacks(); @@ -1470,8 +1365,6 @@ void svr_ble_bluetooth_init(void) #endif gattc_reg_id(); - - g_custom_ble_init_flag = true; return; } @@ -1502,13 +1395,8 @@ void uapi_ble_disconnect_device() //开启蓝牙 void custom_ble_service_start(void) { - AdverFlag = true; svr_ble_adv_start_param(); - gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); - // gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 0); - //gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE, 0); - } void custom_ble_service_start_(uint8_t data) diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 3973e4f5c..1fe6facd4 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -815,14 +815,25 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) // Prevent this from happening: // When the incoming call view is displayed, the calling number is not set in CallerLogModel. //uapi_hfp_disconnect(); + if(NotificationManager::GetInstance()->GetWatchCallStatus() && + (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_REJECT %s!=%s??",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + CallerLogModel::GetInstance()->tempSetoperateNumberCAT1END(call_data,req->len); + cat1_phone_state_change_cb(OPERATE_WATCH_REJECT); + free(call_data); + return; + } + if((NotificationManager::GetInstance()->GetWatchCallStatus() && (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) || uapi_dev_runtime_get_train_status()) { CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len); + NotificationManager::GetInstance()->SetWatchCallStatus(true); cat1_phone_state_change_cb(OPERATE_WAITING); free(call_data); - + return; } else @@ -843,12 +854,12 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3"); } - CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); + CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data)); CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - + NotificationManager::GetInstance()->SetWatchCallStatus(true); NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); cat1_phone_state_change_cb(OPERATE_INCOMING); - NotificationManager::GetInstance()->SetWatchCallStatus(true); + } free(call_data); @@ -913,6 +924,7 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) { unused(topic); unused(req); + // just stop the notify AlarmClockModel::GetInstance()->AlarmPlayerStop(); // AlarmViewEventListener::GetInstance()->CancelAlarmRing(); @@ -920,8 +932,23 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) { return; } - cat1_phone_state_change_cb(OPERATE_WATCH_FINISH); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetWatchCallStatus false"); + + if (req == NULL) return ; + char* call_data = (char*)malloc(req->len); + int32 ret = memcpy_s(call_data, req->len, req->data, req->len); + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),call_data)!=0 && + CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1) + { + + + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_FINISH"); + cat1_phone_state_change_cb(OPERATE_WATCH_FINISH); + } + //free(call_data); + } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 13da94aad..66ba68590 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -47,7 +47,6 @@ // #define NOTIFY_ONE_MINUTE 60000 // #define NOTOFY_NO_OPERATE_TIME 35000 static uint8_t sos_dail_falg=0; -static char*sos_dail_buf[]={"10085","10086","10084"}; #define SOS_TEST_FLAG 0 @@ -55,39 +54,6 @@ static char*sos_dail_buf[]={"10085","10086","10084"}; #define DIAL_TIME 30 -#define SOS_NUMBER_PATH "user/userdata/sos_number.bin" - -void SOS_number_save(void) -{ - FILE *fp=fopen(SOS_NUMBER_PATH,"wb+"); - if(fp) - { - for(int i=0;i<3;i++) - { - char W_buf[20]={0}; - memcpy_s(W_buf,20,sos_dail_buf[i],osal_strlen((const char*)sos_dail_buf[i])); - fwrite(W_buf,1,20,fp); - } - fclose(fp); - } -} - -void SOS_number_init(void) -{ - FILE *fp=fopen(SOS_NUMBER_PATH,"rb+"); - if(fp) - { - for(int i=0;i<3;i++) - { - char r_buf[20]={0}; - fread(r_buf,1,20,fp); - sos_dail_buf[i]=(char *)malloc(osal_strlen((const char*)r_buf)); - memcpy_s(sos_dail_buf[i],20,r_buf,osal_strlen((const char*)r_buf)); - } - fclose(fp); - } -} - @@ -107,12 +73,12 @@ void sos_falg_add(void) if(uapi_cat1_get_power_stat() && uapi_dev_runtime_get_cat1_simstat()) #endif { - calldial_event_sendmsg_toUI(sos_dail_buf[(sos_dail_falg)%3]); + calldial_event_sendmsg_toUI(OHOS:: get_sos_number(sos_dail_falg)); } #if SOS_HFP_FALG else if(uapi_hfp_connect_state()) { - DialCall((unsigned char *)sos_dail_buf[sos_dail_falg],osal_strlen((const char*)sos_dail_buf[sos_dail_falg])); + DialCall((unsigned char *)OHOS::get_sos_number(sos_dail_falg),osal_strlen((const char*)OHOS::get_sos_number(sos_dail_falg))); } #endif else @@ -140,7 +106,7 @@ void start_SOS_phone_dail(void) if(uapi_cat1_get_power_stat()|| uapi_dev_runtime_get_cat1_simstat()) #endif { - calldial_event_sendmsg_toUI(sos_dail_buf[0]); + calldial_event_sendmsg_toUI(OHOS::get_sos_number(0)); sos_dail_falg=1; } #if SOS_HFP_FALG @@ -459,6 +425,7 @@ UIViewGroup* SOS_cant_dial(void) } CallLogInfo info; + void calllog_info_init(uint8_t type) { strcpy(info.name,"xxx"); @@ -469,7 +436,7 @@ void calllog_info_init(uint8_t type) len=strlen(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),len+1); } - else + else if(type==1) { len=strlen(CallerLogModel::GetInstance()->GettempPhoneNumber().c_str()); memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GettempPhoneNumber().c_str(),len+1); @@ -500,6 +467,25 @@ void addcalllog() } } +void addcalllogend() +{ + CallLogInfo info; + strcpy(info.name,"xxx"); + info.nameLen=3; + int len; + len=strlen(CallerLogModel::GetInstance()->GettempPhoneendNumber().c_str()); + memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GettempPhoneendNumber().c_str(),len+1); + uint32_t tmptime=0; + uapi_get_timestampe_ss(&tmptime); + info.creationTime = tmptime; + info.callDurTime=0; + info.telLen=len; + info.calllogtype=CALL_CAT1; + info.status=CALL_MISSED; + AddToCallLog_CAT1(&info); + + return; +} static int g_callOperate = OPERATE_NO_OPE; @@ -557,8 +543,7 @@ static void WatchActiveHandle() static void WatchFinishHandle(void) { - if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL || - CallerLogModel::GetInstance()->GetNotifyFlag()) + if (NotificationManager::GetInstance()->GetWatchCallStatus()) { if(get_falg_SOS()) { @@ -574,10 +559,11 @@ static void WatchFinishHandle(void) else if(uapi_dev_runtime_get_train_status()) { addcalllog(); + StatusReset(); } else { - PhoneServiceScreenCtr(false); + uapi_cat1_stop_volte_voice(); addcalllog(); StatusReset(); @@ -610,6 +596,7 @@ void cat1_phone_state_change_cb(uint8_t state) PhoneServiceScreenCtr(true); IncomingHandle(); calllog_info_init(0); + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); @@ -637,7 +624,12 @@ void cat1_phone_state_change_cb(uint8_t state) WatchFinishHandle(); return; + //手表不做任何处理仅记录 case OPERATE_WATCH_REJECT: + CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0); + + addcalllogend(); + return; default: break; } @@ -703,7 +695,7 @@ void CalldialTimerCallBackProc(int data) if(dail_falg>=DIAL_TIME) { cat1_call_hungup(); - cat1_handle_call_disconnected("callnumb"); + cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); } } @@ -1153,7 +1145,7 @@ static bool DrawPhoneCallViewLabel(void) // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CreatePhoneCallView phonenum:%s!", // CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); const char *number=CallerLogModel::GetInstance()->GetPhoneNumber().c_str(); - char name[32]={0}; + char name[NAME_LEN+1]={0}; #ifdef FD230 get_phone_addrss_name(name,number,NULL); #endif @@ -1301,7 +1293,7 @@ UIViewGroup* CreateCalldialView(void) Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT); diallabl2->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - char name_buf[30]={0}; + char name_buf[NAME_LEN+1]={0}; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) { diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp index e614e0213..3e18da354 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp @@ -158,10 +158,21 @@ namespace OHOS } static uint8_t timer_falg_low_power=5; + static uint8_t test_flag=0; + + static void OTATimerCallBackProc(int data) + { + #if 0 + updatasider->SetValue(test_flag++); + #else + updatasider->SetValue(get_OTA_recv_value()); + #endif + updatasider->Invalidate(); + } + void OTATimerCallBack(int data) { - updatasider->SetValue(get_OTA_recv_value()); - RootView::GetInstance()->Invalidate(); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(OTATimerCallBackProc, data)); } void dialtimerCallBack(int data) diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 2ab86e783..a16907955 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -1000,7 +1000,7 @@ int cat1_handle_call_connected(char* phonenum) WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1 call connected %s\n",phonenum); //声音处理 incomedcall_event_sendmsg_toUI(phonenum); - uapi_cat1_start_volte_voice(); + //uapi_cat1_start_volte_voice(); return 1; } @@ -1010,7 +1010,6 @@ int cat1_handle_call_disconnected(char* phonenum) WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1 call disconnected %s\n",phonenum); //TODO: 关闭声音 callend_event_sendmsg_toUI(phonenum); - uapi_cat1_stop_volte_voice(); return 1; } void get_software_version_toCat1(void)//发送固件版本到cat1 -- 2.17.1