Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read information from core bluetooth device

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 ;

  1. How can I read characteristic from Bluetooth device?
  2. How can I read other information of Bluetooth device?

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?

like image 363
Lalit Paliwal Avatar asked Jul 18 '12 11:07

Lalit Paliwal


People also ask

What is core Bluetooth?

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.

What is Cbuuid?

A universally unique identifier, as defined by Bluetooth standards.

What is CBPeripheral?

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.

What is ble in iOS?

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.


1 Answers

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

like image 148
chwi Avatar answered Nov 14 '22 10:11

chwi