UniPRT SDK v2.0.0.0
 
Loading...
Searching...
No Matches
BleComm.h
1#import <Foundation/Foundation.h>
2#import <CoreBluetooth/CoreBluetooth.h>
3#import <UniPRT/AComm.h>
4NS_ASSUME_NONNULL_BEGIN
5
34@interface BleComm : AComm <CBCentralManagerDelegate, CBPeripheralDelegate>
35
39@property (nonatomic, strong) CBCentralManager *centralManager;
40
44@property (nonatomic, strong) NSMutableArray<NSString *> *discoveredDevices;
45
49@property (nonatomic, strong) NSMutableArray<CBPeripheral *> *foundPeripherals;
50
54@property (nonatomic, strong) CBPeripheral *connectedPeripheral;
55
59@property (nonatomic, strong) NSMutableArray<CBCharacteristic *> *writeCharacteristics;
60
64@property (nonatomic, strong) NSMutableArray<CBCharacteristic *> *readCharacteristics;
65
69@property (nonatomic, strong) NSMutableData *receivedData;
70
87- (NSArray<NSString *> *)availableDevices;
88
105- (void)open:(NSString *)deviceName;
106
120@property (nonatomic, copy) void (^ _Nullable characteristicsReadyCallback)(void);
121
139
150- (void)close;
151
168- (void)write:(NSData *)text;
169
186- (NSData *)read;
187
204- (void)waitForDataWithTimeout:(NSTimeInterval)msTimeOut;
205
234- (NSData *)writeAndWaitForResponse:(NSData *)text
235 responseStartTimeOut:(NSTimeInterval)responseStartTimeOut
236 responseEndTimeOut:(NSTimeInterval)responseEndTimeOut
237 completionToken:(NSString *)completionToken;
238
267- (NSData *)writeAndWaitForResponseJson:(NSData *)text
268 responseStartTimeOut:(NSTimeInterval)responseStartTimeOut
269 responseEndTimeOut:(NSTimeInterval)responseEndTimeOut
270 completionToken:(NSString *)completionToken;
271
272@end
273
274NS_ASSUME_NONNULL_END
A base class for communication interfaces, conforming to the IComm protocol.
Definition AComm.h:29
void open()
Opens the communication interface.
A communication class for handling Bluetooth Low Energy (BLE) connections.
Definition BleComm.h:34
NSData * read()
Reads the data received from the BLE device.
NSArray< NSString * > * availableDevices()
Retrieves a list of available BLE devices.
void close()
Disconnects the current BLE connection.
NSMutableArray< CBCharacteristic * > * readCharacteristics
Definition BleComm.h:64
NSMutableArray< CBPeripheral * > * foundPeripherals
Definition BleComm.h:49
void(^ _Nullable)(void)
Callback triggered after all required BLE characteristics are discovered and ready to use....
CBCentralManager * centralManager
Definition BleComm.h:39
NSMutableArray< CBCharacteristic * > * writeCharacteristics
Definition BleComm.h:59
bool isConnected()
Checks if the BLE connection is currently active.
NSMutableData * receivedData
Definition BleComm.h:69
CBPeripheral * connectedPeripheral
Definition BleComm.h:54
NSMutableArray< NSString * > * discoveredDevices
Definition BleComm.h:44