EFR32BG22
Shenzhen RF-star Technology Co., Ltd.
Page 77 of 93
7 iOS APP Programming Reference
The module is always broadcast as a slave, waiting for the master device of the mobile phone to scan and connect. The
scanning and connection are usually completed by APP. Due to the particularity of the BLE protocol, there is no need to
scan and connect Bluetooth LE devices in the system settings of the Smartphone. Smart devices are responsible for
BLE connection, communication, disconnection, etc. And usually, it is implemented by the APP.
Regarding BLE programming in iOS, the key point is the
read
,
write
and
enable notify switch
to
Characteristic (or
called a channel)
.
To read and write in the channel can realize the direct control of the module direct-drive mode
functions and no extra MCU is needed.
Typical functions that are involved are as follows:
/*!
* @method writeValue:forCharacteristic:withResponse:
* @param data The value to write.
* @param characteristic The characteristic on which to perform the write operation.
* @param type The type of write to be executed.
* @discussion Write the value of a characteristic.
* The passed data is copied and can be disposed of after the call finishes.
* The relevant delegate callback will then be invoked with the status of the request.
* @see peripheral:didWriteValueForCharacteristic:error:
*/
-
(void)writeValue:(NSData
*)data
forCharacteristic:(CBCharacteristic
*)characteristic
type:(CBCharacteristicWriteType)type;
Note: to write to a characteristic.
NSData *d = [[NSData alloc] initWithBytes:&data length:mdata.length];
[p writeValue:d
forCharacteristic:c
type:CBCharacteristicWriteWithoutResponse];
/*!
* @method readValueForCharacteristic:
* @param characteristic The characteristic for which the value needs to be read.
* @discussion Fetch the value of a characteristic.
* The relevant delegate callback will then be invoked with the status of the request.
* @see peripheral:didUpdateValueForCharacteristic:error:
Summary of Contents for EFR32BG22
Page 71: ...EFR32BG22 www szrfstar com V1 6 Jun 2022 Shenzhen RF star Technology Co Ltd Page 70 of 93...
Page 75: ...EFR32BG22 www szrfstar com V1 6 Jun 2022 Shenzhen RF star Technology Co Ltd Page 74 of 93...
Page 76: ...EFR32BG22 www szrfstar com V1 6 Jun 2022 Shenzhen RF star Technology Co Ltd Page 75 of 93...
Page 77: ...EFR32BG22 www szrfstar com V1 6 Jun 2022 Shenzhen RF star Technology Co Ltd Page 76 of 93...
Page 91: ...EFR32BG22 www szrfstar com V1 6 Jun 2022 Shenzhen RF star Technology Co Ltd Page 90 of 93 CE...