Obtaining the UUID of a connected BLE device
Obtaining the UUID of a connected BLE device
- Subject: Obtaining the UUID of a connected BLE device
- From: Carl Hoefs <email@hidden>
- Date: Wed, 17 Aug 2016 17:18:25 -0700
I must have overlooked the obvious, but how can I obtain the service UUID of a connected BLE device (without knowing it first)?
My iOS9 app uses CoreBluetooth to interface with BLE devices. My app scans for all visible BLE devices:
[cbCentralManager scanForPeripheralsWithServices:nil options:nil];
The user then selects the device to connect to from a tableview list, and my delegate callback gets invoked wherein I call CBCentralManager connectPeripheral:options:. This in turn causes -centralManager:didConnectPeripheral: to get invoked. So far, so good.
The problem is, in -centralManager:didConnectPeripheral:, I need to call CBPeripheral -discoverServices: with an array of CBUUID objects. Where do those come from? I don't see how to obtain the connected device's service UUID from a CBPeripheral object. There is a deprecated UUID property which Xcode won't allow me to use, so I'm guessing there must be a newer way to obtain it? I can get all the other data from -centralManager:didDiscoverPeripheral:advertisementData:RSSI:, just not the UUID!
Note: Everything works if I hard-code the foreknown UUID into a CBUUID and then call CBPeripheral -discoverServices: with it. But this isn't practical because I won't know it ahead of time, as there are potentially numerous devices that will be available for selection.
-Carl
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden