Problems with Core Bluetooth

I am making an application in which the iOS device must be peripheral and central at the same time. When it discovers a peripheral device, sometimes its name is the model (for example, iPhone), and not the actual name (for example, My iPhone). In this case, the UUID is used instead (usually this is (null) when the name is the actual name). I set the name correctly in startAdvertising: and when that happens, the real name will not be provided with the corresponding key in advertisementData

How can I make sure that the real name always exists?

This is how I set the name:

 [self.peripheralManager startAdvertising:@{ CBAdvertisementDataLocalNameKey : [[UIDevice currentDevice] name], CBAdvertisementDataServiceUUIDsKey : @[SERVICE_UUID] }]; 
+4
source share
1 answer

If the application, which is an advertisement, is constantly in the foreground, there is no guarantee that the advertising data (except for certain services that you are looking for) will be visible. The adv data is put into a hash when the application moves to the background to have the same experience while running multiple applications simultaneously using corebluetooth against one application (since the iPhone itself can only advertise a finite amount of data). However, I noticed that as soon as the device is seen in the foreground, if the application moves to the background, you can still see most of the adv data. Let me know if you have any questions.

+2
source

Source: https://habr.com/ru/post/1494786/


All Articles