#include "SettingModel.h"\r
#include "common/image_cache_manager.h"\r
#include "graphic_service.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "uiservice/include/ui_service.h"\r
\r
-namespace OHOS {\r
-static BluetoothEarPhoneView *g_pBluetoothEarPhoneView{nullptr};\r
+namespace OHOS\r
+{\r
+ static BluetoothEarPhoneView *g_pBluetoothEarPhoneView{nullptr};\r
#define BLUETOOTH_IMAGE_X 175\r
#define BLUETOOTH_IMAGE_Y 175\r
#define BLUETOOTH_IMAGE_WIDTH 104\r
#define BLUETOOTH_IMAGE_HEIGHT 104\r
#define BLUETOOTH_DELAY 200\r
\r
-osTimerId_t g_stopScanHandle = nullptr;\r
-static constexpr uint64_t MS_SCAN_TIME = 25000;\r
-\r
-BluetoothEarPhoneView::BluetoothEarPhoneView()\r
-{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BluetoothEarPhoneView");\r
- g_pBluetoothEarPhoneView = this;\r
-}\r
+ osTimerId_t g_stopScanHandle = nullptr;\r
+ static constexpr uint64_t MS_SCAN_TIME = 25000;\r
\r
-BluetoothEarPhoneView::~BluetoothEarPhoneView()\r
-{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::~BluetoothEarPhoneView");\r
- group->RemoveAll();\r
- delete titleLabel;\r
- titleLabel = nullptr;\r
- delete imageAnimator;\r
- imageAnimator = nullptr;\r
- delete group;\r
- group = nullptr;\r
- g_pBluetoothEarPhoneView = nullptr;\r
-}\r
+ static constexpr int16_t CONNECTING_IMAGE_ANIMATOR_VIEW_X = 183;\r
+ static constexpr int16_t CONNECTING_IMAGE_ANIMATOR_VIEW_Y = 153;\r
+ static constexpr int16_t CONNECTING_IMAGE_ANIMATOR_VIEW_W = 100;\r
+ static constexpr int16_t CONNECTING_IMAGE_ANIMATOR_VIEW_H = 120;\r
+ static constexpr int16_t CONNECTING_IMAGE_ANIMATOR_DELAY = 50; // 图片更新间隔\r
+ static constexpr const char *connectImagePaths = "/user/res/connect/";\r
+ BluetoothEarPhoneView::BluetoothEarPhoneView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BluetoothEarPhoneView");\r
+ g_pBluetoothEarPhoneView = this;\r
+ }\r
\r
-BluetoothEarPhoneView *BluetoothEarPhoneView::GetInstance()\r
-{\r
- return g_pBluetoothEarPhoneView;\r
-}\r
+ BluetoothEarPhoneView::~BluetoothEarPhoneView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::~BluetoothEarPhoneView");\r
+ if (group)\r
+ {\r
+ group->RemoveAll();\r
+ if (imageAnimator)\r
+ {\r
+ imageAnimator->Stop();\r
+ delete imageAnimator;\r
+ imageAnimator = nullptr;\r
+ FreeImageInfoArray(connectPathsArray, connectImagePaths, CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
+ }\r
+ delete group;\r
+ group = nullptr;\r
+ }\r
+ g_pBluetoothEarPhoneView = nullptr;\r
+ }\r
\r
-void BluetoothEarPhoneView::BtScanImageAnimator()\r
-{\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtScanImageAnimator init");\r
- const char *searchImagePath[BLUETOOTH_SEARCH_IMAGE_NUM] = {\r
- PNG_A019_080_IMAGE_PATH,\r
- PNG_A019_081_IMAGE_PATH,\r
- PNG_A019_082_IMAGE_PATH,\r
- PNG_A019_083_IMAGE_PATH,\r
- PNG_A019_084_IMAGE_PATH,\r
- PNG_A019_085_IMAGE_PATH,\r
- PNG_A019_086_IMAGE_PATH,\r
- PNG_A019_087_IMAGE_PATH,\r
- };\r
+ BluetoothEarPhoneView *BluetoothEarPhoneView::GetInstance()\r
+ {\r
+ return g_pBluetoothEarPhoneView;\r
+ }\r
\r
- if (imageAnimator == nullptr) {\r
- imageAnimator = new UIImageAnimatorView();\r
- if (imageAnimator == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new imageAnimator fail");\r
- return;\r
- }\r
- for (uint8_t i = 0; i < BLUETOOTH_SEARCH_IMAGE_NUM; i++) {\r
- searchImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(searchImagePath[i]);\r
- searchImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
- searchImageInfo[i].pos.x = BLUETOOTH_IMAGE_X;\r
- searchImageInfo[i].pos.y = BLUETOOTH_IMAGE_Y;\r
- searchImageInfo[i].width = BLUETOOTH_IMAGE_WIDTH;\r
- searchImageInfo[i].height = BLUETOOTH_IMAGE_HEIGHT;\r
+ // 扫描动画创建\r
+ void BluetoothEarPhoneView::BtScanImageAnimator()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtScanImageAnimator init");\r
+ connectPathsArray = CreateImageInfoArray(connectImagePaths, CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
+ if (imageAnimator == nullptr)\r
+ {\r
+ imageAnimator = new UIImageAnimatorView();\r
+ if (imageAnimator == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView]imageAnimator new fail");\r
+ return;\r
+ }\r
+ for (uint8_t i = 0; i < CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)\r
+ {\r
+ connectImageInfo[i].imageInfo = (connectPathsArray[i]);\r
+ connectImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+ connectImageInfo[i].pos.x = CONNECTING_IMAGE_ANIMATOR_VIEW_X;\r
+ connectImageInfo[i].pos.y = CONNECTING_IMAGE_ANIMATOR_VIEW_Y;\r
+ connectImageInfo[i].width = CONNECTING_IMAGE_ANIMATOR_VIEW_W;\r
+ connectImageInfo[i].height = CONNECTING_IMAGE_ANIMATOR_VIEW_H;\r
+ }\r
+ imageAnimator->SetPosition(CONNECTING_IMAGE_ANIMATOR_VIEW_X, CONNECTING_IMAGE_ANIMATOR_VIEW_Y, CONNECTING_IMAGE_ANIMATOR_VIEW_W, CONNECTING_IMAGE_ANIMATOR_VIEW_H);\r
+ imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+ imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+ imageAnimator->SetImageAnimatorSrc(connectImageInfo, CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, CONNECTING_IMAGE_ANIMATOR_DELAY);\r
+ imageAnimator->SetRepeat(true);\r
+ imageAnimator->SetSizeFixed(true);\r
+ group->Add(imageAnimator);\r
}\r
- imageAnimator->SetPosition(175, 175, 104, 104); // 175:x 175:y 104:width 104:height\r
- imageAnimator->SetImageAnimatorSrc(searchImageInfo, BLUETOOTH_SEARCH_IMAGE_NUM, BLUETOOTH_DELAY);\r
- imageAnimator->SetRepeat(true);\r
- group->Add(imageAnimator);\r
}\r
-}\r
\r
-void BluetoothEarPhoneView::BtAnimatorStart(void)\r
-{\r
- imageAnimator->Start();\r
-}\r
+ // 动画开始\r
+ void BluetoothEarPhoneView::BtAnimatorStart(void)\r
+ {\r
+ imageAnimator->Start();\r
+ }\r
\r
-void BluetoothEarPhoneView::BtAnimatorStop(void)\r
-{\r
- imageAnimator->Stop();\r
-}\r
+ // 动画停止\r
+ void BluetoothEarPhoneView::BtAnimatorStop(void)\r
+ {\r
+ imageAnimator->Stop();\r
+ }\r
\r
-UIViewGroup *BluetoothEarPhoneView::InitShowUpView()\r
-{\r
- // 获取currentBdAddr db值 待开发\r
- if (group == nullptr) {\r
- group = new UIViewGroup();\r
- if (group == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");\r
- return nullptr;\r
+ UIViewGroup *BluetoothEarPhoneView::InitShowUpView()\r
+ {\r
+ // 获取currentBdAddr db值 待开发\r
+ if (group == nullptr)\r
+ {\r
+ group = new UIViewGroup();\r
+ if (group == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");\r
+ return nullptr;\r
+ }\r
}\r
- }\r
- group->SetPosition(0, 0);\r
- group->SetWidth(HORIZONTAL_RESOLUTION);\r
- group->SetHeight(VERTICAL_RESOLUTION);\r
- if (titleLabel == nullptr) {\r
- titleLabel = new UILabel();\r
- if (titleLabel == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView titleLabel new fail");\r
+ group->SetPosition(0, 0);\r
+ group->SetWidth(HORIZONTAL_RESOLUTION);\r
+ group->SetHeight(VERTICAL_RESOLUTION);\r
+\r
+ UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance();\r
+ UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance();\r
+ if ((earDragListener == nullptr) && (earDragListener2 == nullptr))\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail");\r
return nullptr;\r
}\r
- titleLabel->SetPosition(135, 35, 183, 53); // 135:x 35:y 183:width 53:height\r
- titleLabel->SetText("正在搜索");\r
- titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
- titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
- titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
- UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
- group->Add(titleLabel);\r
- }\r
- UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance();\r
- UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance();\r
- if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail");\r
- return nullptr;\r
- }\r
- if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
- group->SetOnDragListener(earDragListener);\r
- } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
- group->SetOnDragListener(earDragListener2);\r
+ if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS)\r
+ {\r
+ group->SetOnDragListener(earDragListener);\r
+ }\r
+ else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+ {\r
+ group->SetOnDragListener(earDragListener2);\r
+ }\r
+ group->SetViewId(BLUETOOTH_EAR_PHONE_VIEW);\r
+ // 动画\r
+ BtScanImageAnimator();\r
+ group->SetDraggable(true);\r
+ group->SetTouchable(true);\r
+ return group;\r
}\r
- group->SetViewId(BLUETOOTH_EAR_PHONE_VIEW);\r
- // 动画\r
- BtScanImageAnimator();\r
- group->SetDraggable(true);\r
- group->SetTouchable(true);\r
- return group;\r
-}\r
\r
-static void CancelBrScanHandle(void)\r
-{\r
- if (g_stopScanHandle != nullptr) {\r
- osStatus_t ret = osTimerDelete(g_stopScanHandle);\r
- if (ret != osOK) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);\r
- return;\r
+ // 取消br扫描处理\r
+ static void CancelBrScanHandle(void)\r
+ {\r
+ /* ---------------------------------- 取消定时器 --------------------------------- */\r
+ if (g_stopScanHandle != nullptr)\r
+ {\r
+ osStatus_t ret = osTimerDelete(g_stopScanHandle);\r
+ if (ret != osOK)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);\r
+ return;\r
+ }\r
+ g_stopScanHandle = nullptr;\r
}\r
- g_stopScanHandle = nullptr;\r
+ /* -------------------------------------------------------------------------- */\r
+ bool results = gap_br_cancel_discovery();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results);\r
}\r
- bool results = gap_br_cancel_discovery();\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results);\r
-}\r
\r
-static void EndScanHandle(void)\r
-{\r
- if (BluetoothModel::GetInstance()->GetCase().size() == 0) {\r
- BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance();\r
- if (bluetoothEarPhoneView == nullptr) { // 暂停动画\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView nullptr");\r
- return;\r
- }\r
- bluetoothEarPhoneView->BtAnimatorStop();\r
- if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
- JumpView *jumpView = JumpView::GetInstance();\r
- if (jumpView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail");\r
+ // 结束扫描处理\r
+ static void EndScanHandle(void)\r
+ {\r
+ if (BluetoothModel::GetInstance()->GetCase().size() == 0)\r
+ {\r
+ BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance();\r
+ if (bluetoothEarPhoneView == nullptr)\r
+ { // 暂停动画\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarPhoneView nullptr");\r
return;\r
}\r
- jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHEARPHONEVIEW,\r
- JumpView::BluetoothJumpViewNum::TIPSFAILMESSAGEVIEW);\r
- } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
- MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance();\r
- if (mainBluetoothView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail");\r
- return;\r
+ bluetoothEarPhoneView->BtAnimatorStop();\r
+ if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS)\r
+ {\r
+ JumpView *jumpView = JumpView::GetInstance();\r
+ if (jumpView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jumpView GetInstance fail");\r
+ return;\r
}\r
- mainBluetoothView->ChangeView(BLUETOOTHEARPHONEVIEW, TIPSFAILMESSAGEVIEW);\r
- }\r
- } else {\r
- // 按rssi信息重新排序\r
- BluetoothModel::GetInstance()->SortScansCaseRssi();\r
- // 刷新\r
- BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance();\r
- if (bluetoothEarListView == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarListView nullptr");\r
- return;\r
+ jumpView->ChangeView(JumpView::BluetoothJumpViewNum::BLUETOOTHEARPHONEVIEW,\r
+ JumpView::BluetoothJumpViewNum::TIPSFAILMESSAGEVIEW);\r
+ }\r
+ else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+ {\r
+ MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance();\r
+ if (mainBluetoothView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail");\r
+ return;\r
+ }\r
+ mainBluetoothView->ChangeView(BLUETOOTHEARPHONEVIEW, TIPSFAILMESSAGEVIEW);\r
+ }\r
}\r
- if (bluetoothEarListView->GetScanUIList() == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetScanUIList nullptr");\r
- return;\r
+ else\r
+ {\r
+ // 按rssi信息重新排序\r
+ BluetoothModel::GetInstance()->SortScansCaseRssi();\r
+ // 刷新\r
+ BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance();\r
+ if (bluetoothEarListView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothEarListView nullptr");\r
+ return;\r
+ }\r
+ if (bluetoothEarListView->GetScanUIList() == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetScanUIList nullptr");\r
+ return;\r
+ }\r
+ bluetoothEarListView->GetScanUIList()->RefreshList();\r
+ // 扫描完成\r
+ bluetoothEarListView->SetTitleLabel("扫描完成");\r
+ bluetoothEarListView->SetNewEquipmentButtonAdd();\r
+ RootView::GetInstance()->Invalidate();\r
}\r
- bluetoothEarListView->GetScanUIList()->RefreshList();\r
- // 扫描完成\r
- bluetoothEarListView->SetTitleLabel("扫描完成");\r
- bluetoothEarListView->SetNewEquipmentButtonAdd();\r
- RootView::GetInstance()->Invalidate();\r
}\r
-}\r
\r
-// 定时器回调函数\r
-static void ScanTimerCallbackProc(int data)\r
-{\r
- (void)data;\r
- CancelBrScanHandle();\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bt scan end jumpView");\r
- EndScanHandle();\r
-}\r
-\r
-static void ScanTimerCallback(int data)\r
-{\r
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(ScanTimerCallbackProc, data));\r
-}\r
-\r
-// 蓝牙start\r
-void BluetoothEarPhoneView::BtEnable()\r
-{\r
- bool ret;\r
- bool results;\r
- // 经典蓝牙扫描\r
- setScanStatus(true); // 开始扫描标记\r
- // BluetoothModel::GetInstance()->SetCaseListClear(); // 扫描list清空\r
- BluetoothModel::GetInstance()->Init(); //清空list,获取paired devicelist\r
- ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
- if (ret) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable Bt is Discovering");\r
- return;\r
- } else {\r
- results = gap_br_start_discovery();\r
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable StartBtDiscovery results %d", results);\r
+ // 定时器回调函数\r
+ static void ScanTimerCallbackProc(int data)\r
+ {\r
+ (void)data;\r
+ CancelBrScanHandle();\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bt scan end jumpView");\r
+ EndScanHandle();\r
}\r
- if (g_stopScanHandle != nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopScanHandle != nullptr");\r
- return;\r
- }\r
- g_stopScanHandle = osTimerNew((osTimerFunc_t)ScanTimerCallback, osTimerPeriodic, nullptr, nullptr);\r
- if (g_stopScanHandle == nullptr) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerNew failed!!");\r
- return;\r
+\r
+ static void ScanTimerCallback(int data)\r
+ {\r
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(ScanTimerCallbackProc, data));\r
}\r
- uint32 tick = osMs2Tick(MS_SCAN_TIME);\r
- osStatus_t retTimer = osTimerStart(g_stopScanHandle, tick);\r
- if (retTimer != osOK) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerStart failed, ret = %lx!!", retTimer);\r
- if (g_stopScanHandle != nullptr) {\r
- retTimer = osTimerDelete(g_stopScanHandle);\r
- if (retTimer != osOK) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerDelete ret = %lx!!", retTimer);\r
- return;\r
+\r
+ // 蓝牙start\r
+ void BluetoothEarPhoneView::BtEnable()\r
+ {\r
+ bool ret;\r
+ bool results;\r
+ // 经典蓝牙扫描\r
+ setScanStatus(true); // 开始扫描标记\r
+ // BluetoothModel::GetInstance()->SetCaseListClear(); // 扫描list清空\r
+ BluetoothModel::GetInstance()->Init(); // 清空list,获取paired devicelist\r
+ ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
+ if (ret)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable Bt is Discovering");\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ results = gap_br_start_discovery();\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable StartBtDiscovery results %d", results);\r
+ }\r
+ /* -------------------------------------------------------------------------- */\r
+ ScreenTurnOn(MS_SCAN_TIME);\r
+ /* -------------------------------------------------------------------------- */\r
+ /*开启定时器*/\r
+ if (g_stopScanHandle != nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopScanHandle != nullptr");\r
+ return;\r
+ }\r
+ g_stopScanHandle = osTimerNew((osTimerFunc_t)ScanTimerCallback, osTimerPeriodic, nullptr, nullptr);\r
+ if (g_stopScanHandle == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerNew failed!!");\r
+ return;\r
+ }\r
+ uint32 tick = osMs2Tick(MS_SCAN_TIME);\r
+ osStatus_t retTimer = osTimerStart(g_stopScanHandle, tick);\r
+ if (retTimer != osOK)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerStart failed, ret = %lx!!", retTimer);\r
+ if (g_stopScanHandle != nullptr)\r
+ {\r
+ retTimer = osTimerDelete(g_stopScanHandle);\r
+ if (retTimer != osOK)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerDelete ret = %lx!!", retTimer);\r
+ return;\r
+ }\r
+ g_stopScanHandle = nullptr;\r
}\r
- g_stopScanHandle = nullptr;\r
+ return;\r
}\r
return;\r
}\r
- return;\r
-}\r
\r
-void BluetoothEarPhoneView::StopBtDiscovery(void)\r
-{\r
- bool ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
- if (!ret) {\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Bt is not Discovering");\r
+ void BluetoothEarPhoneView::StopBtDiscovery(void)\r
+ {\r
+ bool ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
+ if (!ret)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Bt is not Discovering");\r
+ return;\r
+ }\r
+ CancelBrScanHandle();\r
return;\r
}\r
- CancelBrScanHandle();\r
- return;\r
-}\r
\r
-void BluetoothEarPhoneView::setScanStatus(bool value)\r
-{\r
- scanStart = value;\r
-}\r
-bool BluetoothEarPhoneView::getScanStatus(void)\r
-{\r
- return scanStart;\r
-}\r
+ void BluetoothEarPhoneView::setScanStatus(bool value)\r
+ {\r
+ scanStart = value;\r
+ }\r
+ bool BluetoothEarPhoneView::getScanStatus(void)\r
+ {\r
+ return scanStart;\r
+ }\r
}
\ No newline at end of file