@@ -593,8 +593,10 @@ void BLEProfileManager::handleDisconnectedPutOffEvent()
593593 }
594594}
595595
596- bool BLEProfileManager::discoverAllAttributes (BLEDevice* device)
596+ bool BLEProfileManager::discoverAllAttributes (BLEDevice* device,
597+ bool discoverGapGatt)
597598{
599+ _discover_gap_gatt = discoverGapGatt;
598600 return discoverAttributes (device, NULL );
599601}
600602
@@ -692,7 +694,7 @@ void BLEProfileManager::setDiscovering(bool discover)
692694void BLEProfileManager::singleServiceDiscoverResponseProc (BLEDevice &device,
693695 BLEServiceImp* service)
694696{
695- bool result = service->discoverAttributes (&device);
697+ bool result = service->discoverAttributes (&device, true );
696698 if (result == true )
697699 {
698700 // Record the current discovering service
@@ -786,7 +788,8 @@ bool BLEProfileManager::discoverNextService(BLEDevice &device)
786788
787789 if (NULL == _cur_discover_service)
788790 {
789- bool result = serviceCurImp->discoverAttributes (&device);
791+ bool result = serviceCurImp->discoverAttributes (&device,
792+ _discover_gap_gatt);
790793 if (result == true )
791794 {
792795 // Record the current discovering service
@@ -890,17 +893,19 @@ void BLEProfileManager::serviceDiscoverComplete(const BLEDevice &bledevice)
890893 serviceCurImp = node->value ;
891894 if (NULL != serviceCurImp)
892895 {
893- if (servicePrevImp) // KW issue: Chk for NULL.
896+ if (servicePrevImp)
897+ {
894898 servicePrevImp->setEndHandle (serviceCurImp->startHandle () - 1 );
899+ pr_debug (LOG_MODULE_BLE, " Pre: start-%d, end-%d" ,
900+ servicePrevImp->startHandle (),
901+ servicePrevImp->endHandle ());
902+ pr_debug (LOG_MODULE_BLE, " Curr: start-%d, end-%d" ,
903+ serviceCurImp->startHandle (),
904+ serviceCurImp->endHandle ());
905+ }
895906 }
896907
897- if (servicePrevImp)
898- {
899- pr_debug (LOG_MODULE_BLE, " Curr: start-%d, end-%d" , servicePrevImp->startHandle (), servicePrevImp->endHandle ());
900- }
901908 servicePrevImp = serviceCurImp;
902- if (servicePrevImp) // KW issue: Chk for NULL.
903- pr_debug (LOG_MODULE_BLE, " Curr: start-%d, end-%d" , servicePrevImp->startHandle (), servicePrevImp->endHandle ());
904909 node = node->next ;
905910 }
906911 return ;
@@ -1059,3 +1064,33 @@ unsigned short BLEProfileManager::getAppearance()
10591064 return appearenceChrc.value ();
10601065}
10611066
1067+ String BLEProfileManager::getDeviceName (const BLEDevice* device)
1068+ {
1069+ String temp (" " );
1070+ char device_name_buff[BLE_MAX_DEVICE_NAME];
1071+ unsigned short device_name_len;
1072+
1073+ BLEServiceImp* gap_service = service (*device, " 1800" );
1074+ if (NULL == gap_service)
1075+ {
1076+ return temp;
1077+ }
1078+ BLECharacteristicImp* devicename_chrc = gap_service->characteristic (" 2a00" );
1079+ if (NULL == devicename_chrc)
1080+ {
1081+ return temp;
1082+ }
1083+
1084+ // Read device name
1085+ if (false == devicename_chrc->read (true ))
1086+ {
1087+ return temp;
1088+ }
1089+ device_name_len = devicename_chrc->valueLength ();
1090+ memcpy (device_name_buff, devicename_chrc->value (), device_name_len);
1091+ device_name_buff[device_name_len] = ' \0 ' ;
1092+ temp = device_name_buff;
1093+
1094+ return temp;
1095+ }
1096+
0 commit comments