Problems in iOS Bluetooth development

The problem of inconsistency between the iOS device Bluetooth name and the kCBAdvDataLocalName field in the broadcast

This problem only occurs on iOS devices due to caching issues with device names.
It is consistent on the android phone and is consistent with the kCBAdvDataLocalName field on the iOS device. When there is a difference, the Bluetooth debugging app displays the kCBAdvDataLocalName in the broadcast when searching, but the Bluetooth in the iPhone settings displays the Bluetooth name.
Here is the official description of the Bluetooth name
Insert image description here

Bluetooth has a modification channel set up. After connecting to Bluetooth once, the modified device name will change.

Fields that can be obtained in iOS Bluetooth broadcast

Field name Corresponding string meaning Broadcast Type describe
CBAdvertisementDataLocalNameKey kCBAdvDataLocalName The corresponding value is a string describing the name of the peripheral 0x09 Complete local name
CBAdvertisementDataManufacturerDataKey kCBAdvDataManufacturerData The corresponding value is an NSData object, containing the data generated by the peripheral. 0xFF Manufacturer Specific Data: first 2 octets contain the Company Identifier Code followed by the additional manufacturer specific data
CBAdvertisementDataServiceDataKey kCBAdvDataServiceData Contains distribution data for a specific service. The key of the dictionary is the CBUUID object representing the service. The value is the NSData object. 0x06 Service: More 128-bit UUIDs available
CBAdvertisementDataServiceUUIDsKey kCBAdvDataServiceUUIDs UUIDArray of services to be published 0x07 Service: Complete list of 128-bit UUIDs
CBAdvertisementDataOverflowServiceUUIDsKey kCBAdvDataHashedServiceUUIDs An array representing the UUIDs of services that can be discovered in the "overflow" area of ​​published data, as the UUIDlist stored in this is 最大努力的not always accurate. These properties may not be published if the device has insufficient resources. 0x15 Service Solicitation: list of 128-bit Service UUIDs
CBAdvertisementDataTxPowerLevelKey kCBAdvDataTxPowerLevel TxA number NSNumber containing the transmit power of the peripheral. This property is available if the peripheral provides its power level in the broadcast packet. Using this RSSIvalue and the station power, it is possible to calculate the path loss. 0x0A TX Power Level: -127 to +127 dBm
CBAdvertisementDataIsConnectable kCBAdvDataIsConnectable A Boolean value indicating whether the published event type is connectable. The corresponding Key is an NSNumber object. You can use this value to check whether a peripheral is currently connected.
CBAdvertisementDataSolicitedServiceUUIDsKey kCBAdvDataSolicitedServiceUUIDs A representation of one or more servicesUUID

Guess you like

Origin blog.csdn.net/guoxulieying/article/details/133316627