From e213b385ad6f851b26926c4b8e6f16f444494b06 Mon Sep 17 00:00:00 2001 From: hcj_ <1224667075@qq.com> Date: Thu, 30 May 2024 00:09:57 +0800 Subject: [PATCH] =?utf8?q?=E6=95=B4=E6=9C=BA=E4=BA=A7=E6=B5=8B=E8=93=9D?= =?utf8?q?=E7=89=99=E9=83=A8=E5=88=86=EF=BC=88=E5=BE=97=E4=B8=8D=E5=88=B0?= =?utf8?q?=E6=89=AB=E6=8F=8F=E7=BB=93=E6=9E=9C=EF=BC=8C=E6=9C=AA=E8=83=BD?= =?utf8?q?=E7=A1=AE=E8=AE=A4=E9=97=AE=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 5 +- .../producttest/include/testPresenter.h | 1 + .../nativeui/producttest/include/testView.h | 5 + .../nativeui/producttest/include/testbt.h | 99 ++++ .../producttest/src/testPresenter.cpp | 7 + .../nativeui/producttest/src/testView.cpp | 28 ++ .../nativeui/producttest/src/testbt.cpp | 434 ++++++++++++++++++ 7 files changed, 578 insertions(+), 1 deletion(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 0703faae8..d1cd5a8d1 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -619,6 +619,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/DialingMethodView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/TelephonyInitInterface.cpp + #产测 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testabout.cpp @@ -634,7 +635,9 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testcat1.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testhrsenson.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testgsenson.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testold.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testold.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testbt.cpp + #${CMAKE_CURRENT_SOURCE_DIR} /service/acc_service.c ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h index c79d6a1f6..be9a3220f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h @@ -34,6 +34,7 @@ namespace OHOS MICROPHONE, HRSENSON, GSENSON, + BTTEST, OLDTEST, DEEPSLEEP, shutdown, diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h index 663ecfaa4..facb9a174 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h @@ -27,6 +27,8 @@ #include "producttest/include/testgsenson.h" #include "producttest/include/testold.h" +#include "producttest/include/testbt.h" + namespace OHOS { @@ -86,6 +88,8 @@ namespace OHOS bool ChangeGTESTView(int16_t thisView); bool ChangeoldTESTView(int16_t thisView); + bool ChangeBTTESTView(int16_t thisView); + bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetSystemScrollView(int ViewId); @@ -118,6 +122,7 @@ namespace OHOS testgsensonView *test_G_view{nullptr}; testoldView *test_old_view{nullptr}; + testBTView *test_BT_view{nullptr}; UILabelButtonExt *button[20]={NULL}; bool initViewStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h new file mode 100644 index 000000000..c183d82ff --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h @@ -0,0 +1,99 @@ +#ifndef TEST_BT_VIEW_H +#define TEST_BT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" + +//#include "cmsis_os.h" +#include +namespace OHOS +{ + + class testBTView + { + + public: + struct ButtonConfig_ext_t + { + int x; + int y; + int w; + int h; + const char *str; + const char *ViewId; + const char *ImageSrc; + + //label + int label_x; + int label_y; + uint8_t ALIGN; + int Fontsize; + + }; + + + + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + + + struct cat1_msg + { + char * imei; + int sim; + char * oper; + uint8_t signal; + }; + + struct cat1_Ver + { + char * modem_version; + char * cat1appver; + }; + + + + + testBTView(); + virtual ~testBTView(); + static testBTView *GetInstance(void); + void dial_112(bool); + void BT_discovery_callback(void); + + UIScrollView *testBTInitIView(void); + void ClearAll(void); + void set_BR_connect(char *); + void setcat1vermsg(cat1_Ver); + private: + UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener); + UILabel *InitLabel(LabelConfig &labelConfig); + bool testBTScrollViewcrollViewinit(void); + UIScrollView *testBTScrollView{nullptr}; + UILabel *label_1_cat1msg_1=NULL; + // UILabel *label_1_cat1msg_oper{nullptr}; + // UILabel *label_1_cat1msg_sim{nullptr}; + // UILabel *label_1_cat1msg_signal{nullptr}; + UILabelButtonExt* labelButton_next = nullptr; + UILabel *label_BR_connect{nullptr}; + UILabel *label_1_cat1vison_1{nullptr}; + bool initViewStatus{false}; + UILabel *Title{nullptr}; // 标题 + UILabelButtonExt* button{NULL}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp index 65ea32f5a..d2f747f09 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -51,6 +51,7 @@ namespace OHOS {MICROPHONE,"microphonebutton", "hrsensonbutton_next",true}, {HRSENSON,"hrsensonbutton", "gsensonbutton_next",true}, {GSENSON,"gsensonbutton","xxxx" ,true}, + {BTTEST,"BTbutton","xxxx",true}, {OLDTEST,"oldtestbutton","oldtestexit",true}, {DEEPSLEEP,"deepsleep","xxxxxxxxx",true}, {shutdown,"shutdown","xxxxxxxxx",true}, @@ -263,7 +264,13 @@ namespace OHOS testhrsenson1View::GetInstance()->leeklight_test(true); } + + if(strcmp(view.GetViewId(),"discovery") == 0) + { + testBTView::GetInstance()->BT_discovery_callback(); + } + return false; } 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 2f67db8ff..bdba67b04 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp @@ -31,8 +31,12 @@ namespace OHOS {MICROPHONE,"microphonebutton","microphone" ,&testView::ChangeMPTESTView}, {HRSENSON,"hrsensonbutton","hrsensor" ,&testView::ChangeHRTESTView}, {GSENSON,"gsensonbutton","gsensor" ,&testView::ChangeGTESTView}, + + {BTTEST,"BTbutton","BT" ,&testView::ChangeBTTESTView}, + {OLDTEST,"oldtestbutton","aging" ,&testView::ChangeoldTESTView}, {DEEPSLEEP,"deepsleep","CloseBTCat1&Sleep" ,&testView::ChangeoldTESTView}, + {shutdown,"shutdown","shutdown" ,&testView::ChangeoldTESTView}, // {FACTORYRESETVIEW,"FactoryResetButton","恢复出厂", &testView::ChangeSystemAboutView}, // {SYSTEMLUPGRADE,"systemupgread","系统升级",&testView::ChangeSystemAboutView}, @@ -544,6 +548,23 @@ namespace OHOS return true; } + bool testView::ChangeBTTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + test_BT_view = new testBTView(); + if (test_BT_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_BT_view->testBTInitIView(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); + } + return true; + } + UIScrollView *testView::GetSystemScrollView(int ViewId) { if (SystemScrollView[ViewId] == nullptr) @@ -676,6 +697,13 @@ namespace OHOS test_old_view = nullptr; SystemScrollView[hideView]=nullptr; break; + case BTTEST: + RootView::GetInstance()->Remove(SystemScrollView[hideView]); + delete test_BT_view; + test_BT_view = nullptr; + SystemScrollView[hideView]=nullptr; + break; + default: break; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp new file mode 100644 index 000000000..630fe5506 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp @@ -0,0 +1,434 @@ +#include "wearable_log.h" +#include "custom_utils.h" +#include "producttest/include/testPresenter.h" +#include "producttest/include/testbt.h" +#include "AlarmClockModel.h" +#include "cmsis_os2.h" +#include "cat1_server.h" +#include "cat1_ctl.h" +#include "cat1_server_hal.h" +#include "custom_runtime.h" +#include "bts_br_gap.h" +#include "bts_le_gap.h" + +namespace OHOS +{ + + static testBTView *g_pSystemAboutTheWatchView{nullptr}; + + testBTView::testBTView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + testBTView::~testBTView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testBTView::~testBTView"); + ClearAll(); + //g_pSystemAboutTheWatchView = nullptr; + } + + testBTView *testBTView::GetInstance() + { + + return g_pSystemAboutTheWatchView; + } + static osTimerId_t Gsenson_TEST_timer=NULL; + void testBTView::ClearAll() + { + if(testBTScrollView) + { + testBTScrollView->RemoveAll(); + + if (Gsenson_TEST_timer != NULL) { + osTimerStop(Gsenson_TEST_timer); + osTimerDelete(Gsenson_TEST_timer); + Gsenson_TEST_timer = NULL; + return ; + } + if(button) + { + delete button; + button=nullptr; + } + if(labelButton_next) + { + delete labelButton_next; + labelButton_next=nullptr; + } + if(label_1_cat1msg_1) + { + delete label_1_cat1msg_1; + label_1_cat1msg_1=nullptr; + } + + if(label_BR_connect) + { + delete label_BR_connect; + label_BR_connect=nullptr; + } + + if(label_1_cat1vison_1) + { + delete label_1_cat1vison_1; + label_1_cat1vison_1=nullptr; + } + + if(Title) + { + delete Title; + Title=nullptr; + } + + + delete testBTScrollView; + testBTScrollView=nullptr; + } + } + void testBTView:: set_BR_connect( char* buf) + { + if(label_BR_connect!=NULL) + { + label_BR_connect->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + + } + void testBTView:: setcat1vermsg(cat1_Ver t) + { + + if(label_BR_connect!=nullptr) + { + char buf[124]={0}; + sprintf(buf,"appver:%s\nmodem_ver:%s\n",t.cat1appver,t.modem_version); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); + label_BR_connect->SetText(buf); + RootView::GetInstance()->Invalidate(); + } + + } + + UILabelButtonExt *testBTView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig) + { + UILabelButtonExt *button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!"); + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + //button->SetStyle(STYLE_BORDER_RADIUS,0); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED); + //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED); + button->SetTouchable(true); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x80); + button->SetText(buttonconfig.str); + button->SetAlign(TEXT_ALIGNMENT_LEFT); + button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); + UIView:: OnClickListener *touchListener = static_cast(testPresenter::GetInstance()); + button->SetOnClickListener(touchListener); + + // UIView::OnDragListener *drgListener = static_cast(testPresenter::GetInstance()); + // button->SetOnDragListener(drgListener); + + // button->SetDraggable(false); + return button; + } + static bool speakfalg=false; + + static bool discovery_falg=false; + + void testBTView:: BT_discovery_callback( void) + { + + bool reT_gap; + if(discovery_falg==false) + { + // reT_gap = gap_br_start_discovery(); + #if BLE_scan + reT_gap=gap_ble_start_scan(); + #else + reT_gap = gap_br_start_discovery(); + #endif + + #if BLE_scan + if(reT_gap==ERRCODE_SUCC) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_start_scan %d !",reT_gap); + else + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_start_scan fail %d !",reT_gap); + #else + if(reT_gap==true) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_br_start_scan %d !",reT_gap); + else + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_br_start_scan fail %d !",reT_gap); + + #endif + + + discovery_falg=true; + } + else + { + //reT_gap = gap_br_cancel_discovery(); + #if BLE_scan + reT_gap=gap_ble_stop_scan(); + #else + reT_gap = gap_br_cancel_discovery(); + #endif + + + #if BLE_scan + if(reT_gap==ERRCODE_SUCC) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_stop_scan %d !",reT_gap); + else + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_stop_scan fail %d !",reT_gap); + #else + if(reT_gap==true) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_br_cancel_discovery %d !",reT_gap); + else + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_br_cancel_discovery fail %d !",reT_gap); + + + #endif + + discovery_falg=false; + } + } + + + UILabel *testBTView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + label->SetAlign(TEXT_ALIGNMENT_LEFT); + return label; + } + + + static bd_addr_t bd_addr; + static unsigned char addr[6] = {0}; + static uint8_t number =0; + + static void sample_gap_discovery_result_callback(const bd_addr_t *bd_addr) + { + unsigned char length = BD_NAME_LEN; + unsigned char *device_name = (unsigned char *)(void *)malloc(length); + if (device_name == NULL) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"gap_discovery_result_callback malloc error!\n"); + return; + } + (void)memset_s(device_name, length, 0, length); + + // bool ret1 = gap_get_device_name(scan_result_data->addr, device_name, &length); + // int cod = gap_get_device_class(bd_addr); + // bool ret2 = gap_read_remote_rssi_value(bd_addr); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RemovePair gap_get_paired_devices_list ret = %s %s", device_name,bd_addr); + number++; + + free(device_name); + } + + static void sample_gap_discovery_state_changed_callback(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ap_discovery_state_changed_callback status: %d\n", status); + } + + static char device_name_buf[64]; + static void mgdataTimerCallBack(int data) + { + + if(is_bt_discovering(BT_TRANSPORT_INVALID)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BT_TRANSPORT_INVALID is_bt_discovering %d",number); + } + else if(is_bt_discovering(BT_TRANSPORT_BR_EDR)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BT_TRANSPORT_BR_EDR is_bt_discovering %d",number); + } + else if(is_bt_discovering(BT_TRANSPORT_LE)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " BT_TRANSPORT_LE is_bt_discovering %d",number); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no bt_discovering %d",number); + } + + unsigned int connedDevicesNum = 0; + + bool ret = gap_get_paired_devices_num(&connedDevicesNum); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Setup GetPariedDevicesNum ret = %d, num = %d", ret, connedDevicesNum); + + if (connedDevicesNum != 0) + { + gap_paired_device_info_t *devInfo = (gap_paired_device_info_t *)malloc(sizeof(gap_paired_device_info_t) * connedDevicesNum); + if (devInfo == NULL) + { + return; + } + + ret = gap_get_paired_devices_list(devInfo, (int *)&connedDevicesNum); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RemovePair gap_get_paired_devices_list ret = %d", ret); + + + for (int i = 0; i < static_cast(connedDevicesNum); ++i) + { + + memcpy_s(device_name_buf,64,devInfo[i].device_name,strlen((const char*)devInfo[i].device_name)); + testBTView:: GetInstance()->set_BR_connect(device_name_buf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RemovePair gap_get_paired_devices_list ret = %s", devInfo[i].device_name); + } + free(devInfo); + } + + + } + + static void sample_gap_ble_set_scan_param_cbk(errcode_t status) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sample_gap_ble_set_scan_param_cbk%d", status); + } + + + + + bool testBTView::testBTScrollViewcrollViewinit(void) + { + + testBTScrollView = new UIScrollView(); + if (testBTScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testBTScrollView new fail!"); + return false; + } + testBTScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + testBTScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + testBTScrollView->SetStyle(STYLE_BORDER_RADIUS, 0); + testBTScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + testBTScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue); + + LabelConfig Config = { + .left = 50, + .top = 70, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + + label_BR_connect= InitLabel(Config); + if (label_BR_connect == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return false; + } + testBTScrollView->Add(label_BR_connect); + + bluetooth_get_local_addr(addr,BD_ADDR_LEN); + memcpy(bd_addr.addr,addr,6); + + + //enable_bt_stack(); + + static gap_call_backs_t cb = + { + .discovery_state_changed_callback=sample_gap_discovery_state_changed_callback, + .discovery_result_callback= sample_gap_discovery_result_callback, + }; + //gap_br_set_bt_scan_mode(GAP_SCAN_MODE_GENERAL_DISCOVERABLE,60); + // gap_ble_register_callbacks() + + //int ret = gap_ble_register_callbacks(&cb); + + int ret= gap_register_callbacks(&cb); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ":: %x !",ret); + // gap_ble_scan_params_t scan_param = { 0 }; + // scan_param.scan_interval = 1; + // scan_param.scan_window = 5; + // scan_param.scan_type = GAP_BLE_SCAN_TYPE_ACTIVE; + // scan_param.scan_phy = GAP_BLE_PHY_NO_PACKET; + // scan_param.scan_filter_policy = GAP_BLE_ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY; + // ret = gap_ble_set_scan_parameters(&scan_param); + //bts_sample_log("gap ble set scan parameters ret(errcode_t): %x\n", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ":: %x !",ret); + // bts_sample_log("gap reg cbk ret %x\n", ret); + + + + //清楚配对 + gap_remove_all_pairs(); + + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = 100; + buttonconfig.y = 350; + buttonconfig.w = 180; + buttonconfig.h = 96; + buttonconfig.label_x=40; + buttonconfig.label_y=0; + buttonconfig.Fontsize=30; + buttonconfig.ViewId="discovery"; + buttonconfig.str="discovery"; + buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + button=SetTheButton_ext(buttonconfig); + testBTScrollView->Add(button); + + + UIView::OnDragListener *draglistener = static_cast(testPresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + return false; + } + testBTScrollView->SetOnDragListener(draglistener); + + + + labelButton_next= testAboutView::GetInstance()->init_button_next(267,278,"buttonbutton_next"); + testBTScrollView->Add(labelButton_next); + + Title= testAboutView::GetInstance()->init_title(165,45,"BT_TEST"); + testBTScrollView->Add(Title); + + + testBTScrollView->SetTouchable(true); + testBTScrollView->SetDraggable(true); + uint32_t tick; + osStatus_t retTimer; + Gsenson_TEST_timer = osTimerNew((osTimerFunc_t)mgdataTimerCallBack, osTimerPeriodic, NULL, NULL); + tick =3000;// osMs2Tick(1000); + retTimer = osTimerStart(Gsenson_TEST_timer, tick); + if (retTimer != osOK && Gsenson_TEST_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(Gsenson_TEST_timer); + Gsenson_TEST_timer = NULL; + return false; + } + return true; + } + + UIScrollView *testBTView::testBTInitIView() + { + if (!testBTScrollViewcrollViewinit()) + { + return nullptr; + } + return testBTScrollView; + } +} \ No newline at end of file -- 2.17.1