@@ -593,8 +593,10 @@ void BLEProfileManager::handleDisconnectedPutOffEvent()
593
593
}
594
594
}
595
595
596
- bool BLEProfileManager::discoverAllAttributes (BLEDevice* device)
596
+ bool BLEProfileManager::discoverAllAttributes (BLEDevice* device,
597
+ bool discoverGapGatt)
597
598
{
599
+ _discover_gap_gatt = discoverGapGatt;
598
600
return discoverAttributes (device, NULL );
599
601
}
600
602
@@ -692,7 +694,7 @@ void BLEProfileManager::setDiscovering(bool discover)
692
694
void BLEProfileManager::singleServiceDiscoverResponseProc (BLEDevice &device,
693
695
BLEServiceImp* service)
694
696
{
695
- bool result = service->discoverAttributes (&device);
697
+ bool result = service->discoverAttributes (&device, true );
696
698
if (result == true )
697
699
{
698
700
// Record the current discovering service
@@ -786,7 +788,8 @@ bool BLEProfileManager::discoverNextService(BLEDevice &device)
786
788
787
789
if (NULL == _cur_discover_service)
788
790
{
789
- bool result = serviceCurImp->discoverAttributes (&device);
791
+ bool result = serviceCurImp->discoverAttributes (&device,
792
+ _discover_gap_gatt);
790
793
if (result == true )
791
794
{
792
795
// Record the current discovering service
@@ -890,17 +893,19 @@ void BLEProfileManager::serviceDiscoverComplete(const BLEDevice &bledevice)
890
893
serviceCurImp = node->value ;
891
894
if (NULL != serviceCurImp)
892
895
{
893
- if (servicePrevImp) // KW issue: Chk for NULL.
896
+ if (servicePrevImp)
897
+ {
894
898
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
+ }
895
906
}
896
907
897
- if (servicePrevImp)
898
- {
899
- pr_debug (LOG_MODULE_BLE, " Curr: start-%d, end-%d" , servicePrevImp->startHandle (), servicePrevImp->endHandle ());
900
- }
901
908
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 ());
904
909
node = node->next ;
905
910
}
906
911
return ;
@@ -1059,3 +1064,33 @@ unsigned short BLEProfileManager::getAppearance()
1059
1064
return appearenceChrc.value ();
1060
1065
}
1061
1066
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