问题点: IOS设备对BLE peripheral端发送广播的支持,似乎不允许进行Manufaturer定制广播(central端接受是可以的)。如何在IOS设备上进行Manufaturer Data的广播?
1. 官网对cbperipheral.startAdvertising(_:)描述:
An optional dictionary containing the data you want to advertise. The possible keys of anadvertisementDatadictionary are detailed inCBCentralManagerDelegate. That said, only two of the keys are supported for peripheral manager objects:CBAdvertisementDataLocalNameKeyandCBAdvertisementDataServiceUUIDsKey.
是不可以指定CBAdvertisementDataManufacturerDataKey关键字的。
2. central设备discover扫描到的数据:
centralManager didDiscover
name: nil
UUID: EC2FB599-DCBC-4954-89CB-D579D8DB762A
advertisementData: ["kCBAdvDataIsConnectable": 1, "kCBAdvDataManufacturerData": <0000c0ff 08b31500 0016aba2 699500bf 55343483 60>]
RSSI: -83
central可以扫描出peripheral广播的Manfacturer Data
3. IOS提供的iBeacon是以Manafacturer Data形式向外广播信息
kCBAdvDataAppleBeaconKey =<........>;
用peripheral.strartAdvertising广播CLBeaconRegion应该可以实现广播Manufacturer Data
DataFormat:
1A # AD Structure の長さ(bytes)
FF # AD type
4C 00 # Company identifier code (0x004C は Apple を示す)
02 # Byte 0 of iBeacon advertisement indicator
15 # Byte 1 of iBeacon advertisement indicator
XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX # iBeacon の proximity uuid
XX XX # major
XX XX # minor
XX # Tx Power