6#ifndef SGBlePeripheralQueue_h
7#define SGBlePeripheralQueue_h
9#import <Foundation/Foundation.h>
10#import <CoreBluetooth/CoreBluetooth.h>
15NS_ASSUME_NONNULL_BEGIN
47 dispatch_queue_t _queue;
49 CBPeripheral *_peripheral;
52 NSArray<CBUUID *> *_requiredServices;
53 NSUInteger _discoveringServicesCounter;
54 SGBleConnectionEventReason _disconnectReason;
61 NSMutableArray<SGBleRequest *> *_pendingRequests;
65 NSMapTable<CBCharacteristic *, SGBleCharacteristicValueEventHandler> *_valueChangedHandlers;
69- (CBPeripheral *)peripheral;
77@property(readonly, getter=
peripheral) CBPeripheral *peripheral;
82@property(assign)
bool isReady;
87@property(readonly, getter=
rssi)
int rssi;
92@property(strong)
void (^ _Nullable connectionEventHandler)(
SGBlePeripheralQueue *peripheralQueue, SGBleConnectionEvent connectionEvent, SGBleConnectionEventReason reason);
105- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral
121- (void)queueConnectWithServices:(NSArray<CBUUID *> *)services
122 completionHandler:(
void (^)(NSError * _Nullable error))completionHandler;
132- (void)queueDisconnect:(
void (^)(NSError * _Nullable error))completionHandler;
144- (void)queueReadRssi:(
void (^)(NSError * _Nullable error))completionHandler;
159- (void)queueReadValueForCharacteristic:(CBCharacteristic *)characteristic
160 valueReadHandler:(
void (^)(
SGBlePeripheralQueue *peripheralQueue, CBCharacteristic *characteristic, NSError *_Nullable error))valueReadHandler;
172- (void)queueWriteValue:(NSData *)data
173 forCharacteristic:(CBCharacteristic *)characteristic
174 type:(CBCharacteristicWriteType)type
175 completionHandler:(
void (^)(NSError * _Nullable error))completionHandler;
187- (void)queueSetNotifyValueForCharacteristic:(CBCharacteristic *)characteristic
188 valueChangedHandler:(
void (^ _Nullable)(
SGBlePeripheralQueue *peripheralQueue, CBCharacteristic *characteristic, NSError * _Nullable error))valueChangedHandler
189 completionHandler:(
void (^)(NSError * _Nullable error))completionHandler;
Definition of the SGBleCentralManagerDelegate class.
Internal types for representing a BLE request.
Definition of SGBleConnectionEvent and SGBleConnectionEventReason enumerations.
void(^ SGBleCharacteristicValueEventHandler)(SGBlePeripheralQueue *_Nonnull peripheralQueue, CBCharacteristic *_Nonnull characteristic, NSError *_Nullable error)
Peripheral connection event handler.
Definition SGBleTypes.h:142
Implementation of CBCentralManagerDelegate protocol. Stores and notifies of discovered Bluetooth Low ...
Definition SGBleCentralManagerDelegate.h:29
Implementation of the CBPeripheralDelegate protocol. Queues up operations to be performed with a Blue...
Definition SGBlePeripheralQueue.h:44
int rssi
Gets the last read value of the Received Signal Strength Indicator (RSSI).
Definition SGBlePeripheralQueue.h:87
CBPeripheral * peripheral
Gets the CBPeripheral object for this peripheral.
Definition SGBlePeripheralQueue.h:77
Internal type, represents a Bluetooth operation to be performed on a peripheral. Used by SGBlePeriphe...
Definition SGBleRequest.h:47