
nRF52810
Shenzhen RF-star Technology Co., Ltd.
Page 39 of 50
8 iOS APP Programming Reference
The module is always to broadcast as slave, waiting for mobile phone to scan and connect as master. The scanning and
connection are usually completed by APP. Due to the particularity of BLE protocol, there is no need to scan and connect
Bluetooth LE devices in the system settings of the Smart phone. 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 channel)
to.
To read and write in the channel can realize the direct control on the direct-drive mode functions of
the module 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 BM-ND04C
Page 33: ...nRF52810 www szrfstar com V1 3 Sep 2020 Shenzhen RF star Technology Co Ltd Page 32 of 50...
Page 37: ...nRF52810 www szrfstar com V1 3 Sep 2020 Shenzhen RF star Technology Co Ltd Page 36 of 50...
Page 38: ...nRF52810 www szrfstar com V1 3 Sep 2020 Shenzhen RF star Technology Co Ltd Page 37 of 50...
Page 39: ...nRF52810 www szrfstar com V1 3 Sep 2020 Shenzhen RF star Technology Co Ltd Page 38 of 50...