ESPBleTransport
class ESPBleTransport : NSObject, ESPCommunicable
extension ESPBleTransport: CBCentralManagerDelegate
extension ESPBleTransport: CBPeripheralDelegate
The ESPBleTransport
class conforms and implememnt methods of ESPCommunicable
protocol.
This class provides methods for sending configuration and session related data to ESPDevice
.
-
Instance of ‘ESPUtility’ class.
Declaration
Swift
var utility: ESPUtility
-
Stores Proof of Possesion for a device.
Declaration
Swift
var proofOfPossession: String?
-
Store username for device
Declaration
Swift
var username: String?
-
Undocumented
Declaration
Swift
var centralManager: CBCentralManager!
-
Undocumented
Declaration
Swift
var espressifPeripherals: [String : ESPDevice]
-
Undocumented
Declaration
Swift
var currentPeripheral: CBPeripheral?
-
Undocumented
Declaration
Swift
var currentService: CBService?
-
Undocumented
Declaration
Swift
var bleConnectTimer: Timer
-
Undocumented
Declaration
Swift
var bleScanTimer: Timer?
-
Undocumented
Declaration
Swift
var bleDeviceConnected: Bool
-
Undocumented
Declaration
Swift
var peripheralCanRead: Bool
-
Undocumented
Declaration
Swift
var peripheralCanWrite: Bool
-
Undocumented
Declaration
Swift
var currentRequestCompletionHandler: ((Data?, Error?) -> Void)?
-
Undocumented
Declaration
Swift
public var delegate: ESPBLETransportDelegate?
-
Undocumented
Declaration
Swift
var bleStatusDelegate: ESPBLEStatusDelegate?
-
Create BLETransport object.
Declaration
Swift
init(scanTimeout: TimeInterval, deviceNamePrefix: String, proofOfPossession: String? = nil, username: String? = nil)
Parameters
deviceNamePrefix
Device name prefix.
scanTimeout
Timeout in seconds for which BLE scan should happen.
-
BLE implementation of
ESPCommunicable
protocol.Declaration
Swift
func SendSessionData(data: Data, sessionPath: String?, completionHandler: @escaping (Data?, Error?) -> Void)
Parameters
data
Data to be sent.
sessionPath
Not required.
completionHandler
Handler called when data is sent.
-
BLE implemenation of the
ESPCommunicable
protocolDeclaration
Swift
func SendConfigData(path: String, data: Data, completionHandler: @escaping (Data?, Error?) -> Void)
Parameters
path
Path of the configuration endpoint.
data
Data to be sent.
completionHandler
Handler called when data is sent.
-
Connect to a BLE peripheral device.
Declaration
Swift
func connect(peripheral: CBPeripheral, withOptions options: [String : Any]?, delegate: ESPBLEStatusDelegate)
Parameters
peripheral
The peripheral device
options
An optional dictionary specifying connection behavior options. Sent as is to the CBCentralManager.connect function.
-
This method is invoked on timeout of connection with BLE device.
Declaration
Swift
@objc func bleConnectionTimeout()
-
Disconnect from the current connected peripheral.
Declaration
Swift
func disconnect()
-
Scan for BLE devices.
Declaration
Swift
func scan(delegate: ESPBLETransportDelegate)
Parameters
delegate
Delegate which will receive resulting events.
-
Stop scan when timer runs off.
Declaration
Swift
@objc func stopScan(timer: Timer)
-
Undocumented
Declaration
Swift
func stopSearch()
-
BLE implementation of
ESPCommunicable
protocol.Declaration
Swift
func isDeviceConfigured() -> Bool
-
Undocumented
Declaration
Swift
func centralManagerDidUpdateState(_ central: CBCentralManager)
-
Undocumented
Declaration
Swift
func centralManager(_: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData data: [String: Any], rssi _: NSNumber)
-
Undocumented
Declaration
Swift
func centralManager(_: CBCentralManager, didConnect _: CBPeripheral)
-
Undocumented
Declaration
Swift
func centralManager(_: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?)
-
Undocumented
Declaration
Swift
func centralManager(_: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices _: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error _: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error _: Error?)
-
Undocumented
Declaration
Swift
func peripheral(_: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error _: Error?)