From: hcj <1224667075@qq.com> Date: Tue, 18 Jun 2024 07:35:28 +0000 (+0800) Subject: BR扫描测试 X-Git-Tag: release_V1.2.70_20241020_135402~978^2~10 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d5aaf1681640284ade6ab47e272b35a02e11bb31;p=mirrors%2FFD230.git BR扫描测试 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h index c183d82ff..93764dc20 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testbt.h @@ -51,23 +51,6 @@ namespace OHOS 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(); @@ -78,22 +61,22 @@ namespace OHOS UIScrollView *testBTInitIView(void); void ClearAll(void); void set_BR_connect(char *); - void setcat1vermsg(cat1_Ver); + bool br_scan_set_text(unsigned char *name ,unsigned char *addr,int16_t rssi,int i); + UILabelButtonExt* button{NULL}; + 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}; + UILabel *label_BR_SCAN[5]{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/testbt.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp index cc3543720..faf54d392 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp @@ -11,6 +11,8 @@ #include "bts_br_gap.h" #include "bts_le_gap.h" #include "bleService.h" +#include "BluetoothModel.h" + namespace OHOS { // #define BLE_scan @@ -34,17 +36,19 @@ namespace OHOS return g_pSystemAboutTheWatchView; } - static osTimerId_t Gsenson_TEST_timer=NULL; + static osTimerId_t BR_TEST_timer=NULL; void testBTView::ClearAll() { if(testBTScrollView) { + BluetoothModel::GetInstance()->SetCaseListClear(); + testBTScrollView->RemoveAll(); - if (Gsenson_TEST_timer != NULL) { - osTimerStop(Gsenson_TEST_timer); - osTimerDelete(Gsenson_TEST_timer); - Gsenson_TEST_timer = NULL; + if (BR_TEST_timer != NULL) { + osTimerStop(BR_TEST_timer); + osTimerDelete(BR_TEST_timer); + BR_TEST_timer = NULL; return ; } if(button) @@ -52,28 +56,13 @@ namespace OHOS 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) { @@ -81,33 +70,21 @@ namespace OHOS Title=nullptr; } + for(int i=0;i<5;i++) + { + if(label_BR_SCAN[i]) + { + delete label_BR_SCAN[i]; + label_BR_SCAN[i]=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) { @@ -160,7 +137,8 @@ namespace OHOS bool ret = gap_br_start_discovery(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap_br_start_discovery bool %d!\n",ret); #endif - + button->SetText("scaning"); + button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); discovery_falg=true; } else @@ -171,7 +149,11 @@ namespace OHOS bool ret = gap_br_cancel_discovery(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap_br_cancel_discovery bool %d!\n",ret); - #endif + #endif + + button->SetText("discovery"); + button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + discovery_falg=false; } } @@ -198,7 +180,8 @@ namespace OHOS static bd_addr_t bd_addr; static unsigned char addr[6] = {0}; - static uint8_t number =0; + static uint8_t number =0; + static uint8_t scan_i=0; static void sample_gap_discovery_result_callback(const bd_addr_t *bd_addr) { @@ -209,11 +192,6 @@ namespace OHOS 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++; @@ -244,7 +222,40 @@ namespace OHOS else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no bt_discovering %d",number); - } + } + + std::list btScansDevicesList_ =BluetoothModel::GetInstance()->GetCase(); + std::list::iterator node = btScansDevicesList_.begin(); + if (btScansDevicesList_.empty()) { + return; + } + int i=0; + while (node != btScansDevicesList_.end()) { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " name %s %d %d",node->deviceName,node->index,node->temp); + + BluetoothModel::GetInstance()->SortScansCaseRssi(); + + testBTView::GetInstance()->br_scan_set_text(node->deviceName,node->addr,node->temp,i); + i++; + node++; + } + + } + + bool testBTView::br_scan_set_text(unsigned char *name ,unsigned char *addr,int16_t rssi,int i) + { + if(i>=5) + { + return false; + } + char buf[128]={0}; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rssi %d",rssi); + + sprintf_s(buf,128,"name:%s\naddr:%02X%02X%02X%02X%02X%02X\nRssi:%d",name,addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],rssi); + label_BR_SCAN[i]->SetText(buf); + RootView::GetInstance()->Invalidate(); + return true; } @@ -262,56 +273,42 @@ namespace OHOS testBTScrollView->SetStyle(STYLE_BORDER_RADIUS, 0); testBTScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); testBTScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue); + testBTScrollView->SetScrollBlankSize(50); + testBTScrollView->SetReboundSize(50); + testBTScrollView->SetDirection(1); + LabelConfig Config = { - .left = 50, - .top = 70, - .width = 60, - .height = 35, + .left = 33, + .top = 80, + .width = 400, + .height = 44, .fontSize = 30, .lineHeigh = 35, .text = "", - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + .lineBreakMode = UILabel::LINE_BREAK_WRAP, }; - label_BR_connect= InitLabel(Config); - if (label_BR_connect == nullptr) + + for(int i=0 ;i<5;i++) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); - return false; + Config.top+=120; + label_BR_SCAN[i]= InitLabel(Config); + testBTScrollView->Add(label_BR_SCAN[i]); } - testBTScrollView->Add(label_BR_connect); - - bluetooth_get_local_addr(addr,BD_ADDR_LEN); - memcpy(bd_addr.addr,addr,6); - - - // 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.x = 55; + buttonconfig.y = 80; buttonconfig.w = 180; - buttonconfig.h = 96; + buttonconfig.h = 88; 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); @@ -326,7 +323,7 @@ namespace OHOS - labelButton_next= testAboutView::GetInstance()->init_button_next(267,278,"buttonbutton_next"); + labelButton_next= testAboutView::GetInstance()->init_button_next(270,80,"buttonbutton_next"); testBTScrollView->Add(labelButton_next); Title= testAboutView::GetInstance()->init_title(165,45,"BT_TEST"); @@ -337,13 +334,13 @@ namespace OHOS 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) { + BR_TEST_timer = osTimerNew((osTimerFunc_t)mgdataTimerCallBack, osTimerPeriodic, NULL, NULL); + tick =5000;// osMs2Tick(1000); + retTimer = osTimerStart(BR_TEST_timer, tick); + if (retTimer != osOK && BR_TEST_timer != NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); - osTimerDelete(Gsenson_TEST_timer); - Gsenson_TEST_timer = NULL; + osTimerDelete(BR_TEST_timer); + BR_TEST_timer = NULL; return false; } return true;