Skip to content

Latest commit

 

History

History
62 lines (56 loc) · 1.58 KB

README.md

File metadata and controls

62 lines (56 loc) · 1.58 KB

BKBluetooth

CI Status License Platform

Requirements

XCode 9.0 iOS 10 ++

Installation

add following file to your project.

Useage

Start the BLEManger

let queue = DispatchQueue.global()
centralManager = CBCentralManager(delegate: self, queue: queue)

Send Data

func sendData(data: Data, uuidString: String) throws {
        guard let characteristic = charDictionary[uuidString] else {
            throw SendDataError.CharacteristicNotFound
        }
        connectPeripheral.writeValue(
            data,
            for: characteristic,
            type: .withResponse
        )
    }

Disconnect

	centralManager.cancelPeripheralConnection(connectPeripheral)

Reconnect

centralManager.retrievePeripherals(withIdentifiers: [uuid])

Subscribe

if let characteristic = charDictionary[uuid.uuidString] {
            connectPeripheral.setNotifyValue(true, for: characteristic)
}

Unsubscribe

if let characteristic = charDictionary[uuid.uuidString] {
            connectPeripheral.setNotifyValue(false, for: characteristic)
        }

ReadData

 if let characteristic = charDictionary[uuid.uuidString] {
            connectPeripheral.readValue(for: characteristic)
} 

Author

BookTw, [email protected]