#include "bts_br_gap.h"
#include "bts_le_gap.h"
#include "bleService.h"
+#include "BluetoothModel.h"
+
namespace OHOS
{
// #define BLE_scan
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)
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)
{
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)
{
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
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;
}
}
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)
{
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++;
else
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no bt_discovering %d",number);
- }
+ }
+
+ std::list<BluetoothCaseInfo> btScansDevicesList_ =BluetoothModel::GetInstance()->GetCase();
+ std::list<BluetoothCaseInfo>::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;
}
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);
- 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");
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;