I am new to iOS development, and study about Bluetooth Low Energy (BLE, Bluetooth 4.0)
for IOS.
I studied the sample code of this link BTLE Central Peripheral Transfer.
And there is another similar sample in this link iOS 7 SDK: Core Bluetooth - Practical Lesson
The applications on the above two links talk about send and receive the text data
between two IOS device base on BLE
.
The App can select to be a central
or Peripheral
, and the central
will receive the text data send from the Peripheral
.
It define the UUID
like the following code in header file
.
#define TRANSFER_CHARACTERISTIC_UUID @"08590F7E-DB05-467E-8757-72F6FAEB13D4"
And after the Central
connect to the Peripheral
, it discover the characteristic from Peripheral
.
If the UUID
is equal to TRANSFER_CHARACTERISTIC_UUID
,then subscribe it by using setNotifyValue:YES
like the following code.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
// Again, we loop through the array, just in case.
for (CBCharacteristic *characteristic in service.characteristics) {
// And check if it's the right one
if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:TRANSFER_CHARACTERISTIC_UUID]]) {
// If it is, subscribe to it
[peripheral setNotifyValue:YES forCharacteristic:characteristic];
}
}
// Once this is complete, we just need to wait for the data to come in.
}
The question is like the following:
First Question:
I can not find this UUID:@"08590F7E-DB05-467E-8757-72F6FAEB13D4"
in Bluetooth Development Portal.
Is that create by uuidgen
in terminal
?
The second Question:
If I am Central
,and I have subscribe the characteristic
by using setNotifyValue:YES
like the above code.
The BLE will tell the Central
there has new data send from Peripheral
by following code , is the concept correct ?
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
I am new in IOS development and BLE.
Thanks in advance.