A communication class for handling Bluetooth Low Energy (BLE) connections.
More...
#include <BleComm.h>
A communication class for handling Bluetooth Low Energy (BLE) connections.
This class extends AComm and implements the CBCentralManagerDelegate and CBPeripheralDelegate protocols. It provides methods to discover, connect, send, and receive data from BLE peripherals.
◆ availableDevices
| - (NSArray< NSString * > *) availableDevices |
|
|
|
Retrieves a list of available BLE devices.
- Returns
- An array of NSString objects representing device names.
◆ close
Disconnects the current BLE connection.
Reimplemented from AComm.
◆ isConnected
Checks if the BLE connection is currently active.
- Returns
- true if connected, false otherwise.
Reimplemented from <IComm>.
◆ open:
| - (void) open: |
|
(NSString *) | deviceName |
|
Connects to the specified BLE device by name.
- Parameters
-
| deviceName | The name of the device to connect to. |
◆ read
Reads the data received from the BLE device.
- Returns
- An NSData object containing the received data.
Reimplemented from AComm.
◆ waitForDataWithTimeout:
| - (void) waitForDataWithTimeout: |
|
(NSTimeInterval) | msTimeOut |
|
Waits for data from the BLE device within a timeout period.
- Parameters
-
| msTimeOut | The maximum time to wait in milliseconds. |
Reimplemented from AComm.
◆ write:
| - (void) write: |
|
(NSData *) | text |
|
Writes data to the connected BLE device.
- Parameters
-
| text | The data to be written. |
Reimplemented from AComm.
◆ writeAndWaitForResponse:responseStartTimeOut:responseEndTimeOut:completionToken:
| - (NSData *) writeAndWaitForResponse: |
|
(NSData *) | text |
| responseStartTimeOut: |
|
(NSTimeInterval) | responseStartTimeOut |
| responseEndTimeOut: |
|
(NSTimeInterval) | responseEndTimeOut |
| completionToken: |
|
(NSString *) | completionToken |
Sends data to the BLE device and waits for a response.
- Parameters
-
| text | The data to send. |
| responseStartTimeOut | The maximum time to wait for the response to start. |
| responseEndTimeOut | The maximum time to wait for the response to finish. |
| completionToken | A string token indicating response completion. |
- Returns
- An NSData object containing the response.
Reimplemented from AComm.
◆ writeAndWaitForResponseJson:responseStartTimeOut:responseEndTimeOut:completionToken:
| - (NSData *) writeAndWaitForResponseJson: |
|
(NSData *) | text |
| responseStartTimeOut: |
|
(NSTimeInterval) | responseStartTimeOut |
| responseEndTimeOut: |
|
(NSTimeInterval) | responseEndTimeOut |
| completionToken: |
|
(NSString *) | completionToken |
Sends JSON data to the BLE device and waits for a response.
- Parameters
-
| text | The JSON data to send. |
| responseStartTimeOut | The maximum time to wait for the response to start. |
| responseEndTimeOut | The maximum time to wait for the response to finish. |
| completionToken | A string token indicating response completion. |
- Returns
- An NSData object containing the response.
◆ _Nullable
| - (void(^ _Nullable) (void)) |
|
readwritenonatomiccopy |
Callback triggered after all required BLE characteristics are discovered and ready to use. Set this before calling open: to know when it's safe to proceed with data operations.
◆ centralManager
| - (CBCentralManager*) centralManager |
|
readwritenonatomicstrong |
Central manager for BLE operations.
◆ connectedPeripheral
| - (CBPeripheral*) connectedPeripheral |
|
readwritenonatomicstrong |
Currently connected peripheral.
◆ discoveredDevices
| - (NSMutableArray<NSString *>*) discoveredDevices |
|
readwritenonatomicstrong |
List of discovered device names.
◆ foundPeripherals
| - (NSMutableArray<CBPeripheral *>*) foundPeripherals |
|
readwritenonatomicstrong |
List of found peripherals.
◆ readCharacteristics
| - (NSMutableArray<CBCharacteristic *>*) readCharacteristics |
|
readwritenonatomicstrong |
BLE characteristics available for reading.
◆ receivedData
| - (NSMutableData*) receivedData |
|
readwritenonatomicstrong |
Accumulated received data from the BLE device.
◆ writeCharacteristics
| - (NSMutableArray<CBCharacteristic *>*) writeCharacteristics |
|
readwritenonatomicstrong |
BLE characteristics available for writing.
The documentation for this class was generated from the following file:
- /Users/bob_huang/Documents/Project/sdk_json_Objective-C/AutoIdSDK/Comm/BleComm.h