kumoh national institute of technology
Networked Systems Lab.

NUC Project Open Source

NSL > Researches> Industrial IoT> NUC Project Open Source
About Bluetooth connection
By :
Date : 2017-05-23
Views : 54

func startScan() {

guard centralManager.state == .poweredOn else { return }


let uuid = CBUUID(string: "FFE0")

centralManager.scanForPeripherals(withServices: [uuid], option: nil)


let peripherals = centralManager.retrieveConnetedPeripherals(withServices: [uuid])

for peripheral in peripherals {

delegate.serialDidDiscoverPeripheral(peripheral, RSSI: nil)

}

}



func stopScan() {

centralManager.stopScan()

}


func connectToPeripheral(_peripheral: CBPeripheral) {

pendingPeripheral = peripheral

centralManager.connect(peripheral, options: nil)

}


func disconnect() {

if let p = connectedPeripheral {

centralManager.cancelPeripheralConnection(p)

} else if let p = pendingPeripheral {

centralManager.cancelPeripheralConnection(p)

}

}



 
Ʒ ̺
     About Bluetooth data process
Ʒ