Skip to content

nutc-imac-team/BKBluetooth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%