I am working on an iOS core Bluetooth application, I am able to connect with the BLE device using iPad3. I am able to reach to the block didDiscoverServices
, but unable to proceed from here.
My questions are ;
Help me on this or provide any suggestion.
Thanks Wilhelmsen for reply.
I got the following from the mentioned block :
[0] - Service : <CBConcreteService: 0x1769a0> UUID: Generic Attribute Profile
[1] - Service : <CBConcreteService: 0x174470> UUID: Generic Access Profile
[2] - Service : <CBConcreteService: 0x1744e0> UUID: Unknown (<00005301 00000041 4c505749 53450000>)
Characteristic
[0] - Characteristic : <CBConcreteCharacteristic: 0x15d410> UUID: Service Changed
[0] - Characteristic : <CBConcreteCharacteristic: 0x1805b0> UUID: Device Name
[1] - Characteristic : <CBConcreteCharacteristic: 0x1806a0> UUID: Appearence
[0] - Characteristic : <CBConcreteCharacteristic: 0x183810> UUID: Unknown (<00004301 00000041 4c505749 53450000>)
[1] - Characteristic : <CBConcreteCharacteristic: 0x1838a0> UUID: Unknown (<00004302 00000041 4c505749 53450000>)
Now how to get the exact values from this Characteristic in didUpdateValueForCharacteristic block?
The Core Bluetooth framework provides the classes needed for your apps to communicate with Bluetooth-equipped low energy (LE) and Basic Rate / Enhanced Data Rate (BR/EDR) wireless technology.
A universally unique identifier, as defined by Bluetooth standards.
The CBPeripheral class represents remote peripheral devices that your app discovers with a central manager (an instance of CBCentralManager ). Peripherals use universally unique identifiers (UUIDs), represented by NSUUID objects, to identify themselves.
Create an engaging and connected user experience by integrating Bluetooth® wireless technology in your apps and hardware accessories. And with Core Bluetooth framework, it's easy for your apps to interact with the growing number of Bluetooth Low Energy (BLE) devices.
Take a nice good read through the framework. if you have come this far you shouldn't have any problem finding 'discoverCharacteristics' and the peripheral delegate callback 'didDiscoverCharacteristic'. You need to know the UUID of the services and characteristics you want to discover and apply it to those methods.
Then you can read with 'readValueForCharacteristic' and the delegate callback 'didUpdateValueForCharacteristic'.
This is sent from my phone, so I will maybe edit a bit when I get to a computer. Hope it helps
New question:
[connectedPeripheral readValueForCharacteristic:wantedCharacteristic]
and at peripheral delegate
- (void) peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error{
NSLog(@"Characteristic value : %@ with ID %@", characteristic.value, characteristic.UUID);
[delegate characteristicValueRead:characteristic.value];
}
works for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With