YMSCBPeripheral Class Reference
| Inherits from | NSObject |
|---|---|
| Conforms to | CBPeripheralDelegate |
| Declared in | YMSCBPeripheral.h YMSCBPeripheral.m |
Overview
Base class for defining a Bluetooth LE peripheral.
YMSCBPeripheral holds an instance of CBPeripheral (cbPeripheral) and implements the CBPeripheralDelegate messages sent by cbPeripheral.
The BLE services discovered by cbPeripheral are encapulated in instances of YMSCBService and contained in the dictionary serviceDict.
Properties
base
128 bit address base
@property (nonatomic, assign) yms_u128_t baseDiscussion
128 bit address base
Declared In
YMSCBPeripheral.h
name
Convenience accessor for cbPeripheral.name.
@property (nonatomic, readonly) NSString *nameDiscussion
Convenience accessor for cbPeripheral.name.
Declared In
YMSCBPeripheral.h
delegate
Pointer to delegate.
@property (nonatomic, weak) id<CBPeripheralDelegate> delegateDiscussion
Pointer to delegate.
The delegate object will be forwarded CBPeripheralDelegate messages sent by cbPeripheral.
Declared In
YMSCBPeripheral.h
watchdogRaised
Flag to indicate if the watchdog timer has expired and forced a disconnect.
@property (nonatomic, assign) BOOL watchdogRaisedDiscussion
Flag to indicate if the watchdog timer has expired and forced a disconnect.
Declared In
YMSCBPeripheral.h
serviceDict
Dictionary of (key, value) pairs of (NSString, YMSCBService) instances.
@property (nonatomic, strong) NSDictionary *serviceDictDiscussion
Dictionary of (key, value) pairs of (NSString, YMSCBService) instances.
The NSString key is typically a “human-readable” string to easily reference a YMSCBService.
Declared In
YMSCBPeripheral.h
cbPeripheral
The CBPeripheral instance.
@property (nonatomic, strong) CBPeripheral *cbPeripheralDiscussion
The CBPeripheral instance.
Declared In
YMSCBPeripheral.h
isConnected
A Boolean value indicating whether the peripheral is currently connected to the central manager. (read-only)
@property (readonly) BOOL isConnectedDiscussion
A Boolean value indicating whether the peripheral is currently connected to the central manager. (read-only)
This value is populated with cbPeripheral.isConnected.
Declared In
YMSCBPeripheral.h
rssiPingPeriod
Time period between RSSI pings. (Default: 2 seconds)
@property (nonatomic, assign) NSTimeInterval rssiPingPeriodDiscussion
Time period between RSSI pings. (Default: 2 seconds)
This is a convenience property to hold a ping period for RSSI updates. No policy or mechanism for invoking readRSSI is provided for by YMSCBPeripheral or YMSCoreBluetooth.
Declared In
YMSCBPeripheral.h
central
Pointer to an instance of YMSCBCentralManager.
@property (nonatomic, weak) YMSCBCentralManager *centralDiscussion
Pointer to an instance of YMSCBCentralManager.
Declared In
YMSCBPeripheral.h
watchdogTimer
Watchdog timer for connection.
@property (nonatomic, strong) NSTimer *watchdogTimerDiscussion
Watchdog timer for connection.
Declared In
YMSCBPeripheral.h
watchdogTimerInterval
Watchdog timer interval in seconds. Default is 5 seconds.
@property (nonatomic, assign) NSTimeInterval watchdogTimerIntervalDiscussion
Watchdog timer interval in seconds. Default is 5 seconds.
Declared In
YMSCBPeripheral.h
connectCallback
Holds callback for connection established.
@property (nonatomic, copy) YMSCBPeripheralConnectCallbackBlockType connectCallbackDiscussion
Holds callback for connection established.
Declared In
YMSCBPeripheral.h
isRenderedInViewCell
Helper flag to determine ViewCell updates.
@property (nonatomic, assign) BOOL isRenderedInViewCellDiscussion
Helper flag to determine ViewCell updates.
Declared In
YMSCBPeripheral.h
Initializing a YMSCBPeripheral
– initWithPeripheral:central:baseHi:baseLo:
Constructor.
- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral central:(YMSCBCentralManager *)owner baseHi:(int64_t)hi baseLo:(int64_t)loParameters
peripheral |
Pointer to CBPeripheral |
|---|---|
owner |
Pointer to YMSCBCentralManager |
hi |
Top 64 bits of 128-bit base address value |
lo |
Bottom 64 bits of 128-bit base address value |
Return Value
instance of this class
Discussion
Constructor.
This method must be called via super in any subclass implementation.
The implementation of this method in a subclass will populate serviceDict with (key, value) pairs of
(NSString, YMSCBService) instances, where key is typically a “human-readable” string to easily
reference a YMSCBService.
Declared In
YMSCBPeripheral.h
Get all CBService CBUUIDs for this peripheral
– services
Generate array of CBUUID for all CoreBluetooth services associated with this peripheral.
- (NSArray *)servicesReturn Value
array of CBUUID services
Discussion
Generate array of CBUUID for all CoreBluetooth services associated with this peripheral.
The output of this method is to be passed to the method discoverServices: in CBPeripheral:
Declared In
YMSCBPeripheral.h
– servicesSubset:
Return array of CBUUIDs for YMSCBService instances in serviceDict whose key is included in keys.
- (NSArray *)servicesSubset:(NSArray *)keysParameters
keys |
array of NSString keys, where each key must exist in serviceDict |
|---|
Return Value
array of CBUUIDs
Discussion
Return array of CBUUIDs for YMSCBService instances in serviceDict whose key is included in keys.
Declared In
YMSCBPeripheral.h
Find a YMSCBService
– findService:
Find YMSCBService given its corresponding CBService.
- (YMSCBService *)findService:(CBService *)serviceParameters
service |
CBService to search for in serviceDict. |
|---|
Return Value
YMSCBService instance which holds service.
Discussion
Find YMSCBService given its corresponding CBService.
Declared In
YMSCBPeripheral.h
– connect
Connect peripheral
- (void)connectDiscussion
Connect peripheral
Declared In
YMSCBPeripheral.h
– readRSSI
Invokes CBPeripheral.readRSSI method to retrieve current RSSI value for cbPeripheral.
- (void)readRSSIDiscussion
Invokes CBPeripheral.readRSSI method to retrieve current RSSI value for cbPeripheral.
Declared In
YMSCBPeripheral.h
– resetWatchdog
Initialize or reset watchdog timer.
- (void)resetWatchdogDiscussion
Initialize or reset watchdog timer.
Declared In
YMSCBPeripheral.h
– invalidateWatchdog
Invalidate watchdog timer.
- (void)invalidateWatchdogDiscussion
Invalidate watchdog timer.
Declared In
YMSCBPeripheral.h
– connectWithOptions:withBlock:
Establishes connection to peripheral with callback block.
- (void)connectWithOptions:(NSDictionary *)options withBlock:(void ( ^ ) ( YMSCBPeripheral *yp , NSError *error ))connectCallbackParameters
options |
A dictionary to customize the behavior of the connection. See “Peripheral Connection Options” for CBCentralManager. |
|---|---|
connectCallback |
Callback block to handle peripheral connection. |
Discussion
Establishes connection to peripheral with callback block.
Declared In
YMSCBPeripheral.h
– cancelConnection
Cancels an active or pending local connection to a peripheral.
- (void)cancelConnectionDiscussion
Cancels an active or pending local connection to a peripheral.
Declared In
YMSCBPeripheral.h
– defaultConnectionHandler
Default connection handler routine that is invoked only if connectCallback is nil.
- (void)defaultConnectionHandlerDiscussion
Default connection handler routine that is invoked only if connectCallback is nil.
This method is only invoked if a connection request to an instance of this peripheral is done without a callback block defined.
Declared In
YMSCBPeripheral.h
– discoverServices:withBlock:
Discover services using block.
- (void)discoverServices:(NSArray *)serviceUUIDs withBlock:(void ( ^ ) ( NSArray *services , NSError *error ))callbackParameters
serviceUUIDs |
An array of CBUUID objects that you are interested in. Here, each CBUUID object represents a UUID that identifies the type of service you want to discover. |
|---|---|
callback |
A |
Discussion
Discover services using block.
Declared In
YMSCBPeripheral.h
– objectForKeyedSubscript:
Add dictionary style subscripting to YMSCBPeripheral instance to access objects in serviceDict with key.
- (id)objectForKeyedSubscript:(id)keyParameters
key |
The key for which to return the corresponding value in serviceDict. |
|---|
Return Value
object in serviceDict.
Discussion
Add dictionary style subscripting to YMSCBPeripheral instance to access objects in serviceDict with key.
Declared In
YMSCBPeripheral.h
CBPeripheralDelegate Methods
– peripheral:didDiscoverServices:
CBPeripheralDelegate implementation.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)errorParameters
peripheral |
The peripheral that the services belong to. |
|---|---|
error |
If an error occurred, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation.
Declared In
YMSCBPeripheral.m
– peripheral:didDiscoverIncludedServicesForService:error:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
service |
The CBService object containing the included service. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation. Not yet supported.
Declared In
YMSCBPeripheral.m
– peripheral:didDiscoverCharacteristicsForService:error:
CBPeripheralDelegate implementation.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
service |
The service that the characteristics belong to. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation.
Declared In
YMSCBPeripheral.m
– peripheral:didDiscoverDescriptorsForCharacteristic:error:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
characteristic |
The characteristic that the characteristic descriptors belong to. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation. Not yet supported.
Declared In
YMSCBPeripheral.m
– peripheral:didUpdateValueForCharacteristic:error:
CBPeripheralDelegate implementation.
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
characteristic |
The characteristic whose value has been retrieved. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation.
Declared In
YMSCBPeripheral.m
– peripheral:didUpdateValueForDescriptor:error:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
descriptor |
The characteristic descriptor whose value has been retrieved. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation. Not yet supported.
Declared In
YMSCBPeripheral.m
– peripheral:didUpdateNotificationStateForCharacteristic:error:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
characteristic |
The characteristic whose value has been retrieved. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation. Not yet supported.
Declared In
YMSCBPeripheral.m
– peripheral:didWriteValueForCharacteristic:error:
CBPeripheralDelegate implementation.
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
characteristic |
The characteristic whose value has been retrieved. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation.
Declared In
YMSCBPeripheral.m
– peripheral:didWriteValueForDescriptor:error:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
descriptor |
The characteristic descriptor whose value has been retrieved. |
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation. Not yet supported.
Declared In
YMSCBPeripheral.m
– peripheralDidUpdateRSSI:error:
CBPeripheralDelegate implementation.
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(NSError *)errorParameters
peripheral |
The peripheral providing this information. |
|---|---|
error |
If an error occured, the cause of the failure. |
Discussion
CBPeripheralDelegate implementation.
Declared In
YMSCBPeripheral.m
– peripheralDidUpdateName:
CBPeripheralDelegate implementation. Not yet supported.
- (void)peripheralDidUpdateName:(CBPeripheral *)peripheralParameters
peripheral |
The peripheral providing this information. |
|---|
Discussion
CBPeripheralDelegate implementation. Not yet supported.
iOS only.
Declared In
YMSCBPeripheral.m