Instantly share code, notes, and snippets.

Embed
What would you like to do?
Estimator: BLE를 사용한 Planning Poker 애플리케이션
import CoreBluetooth
let serviceUUID = CBUUID(string: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
let service = CBMutableService(type: serviceUUID, primary: true)
/// 1. `CBPeripheralManager`를 초기화하고,
self.peripheral = CBPeripheralManager(delegate: self, queue: nil)
/// 2. 사용가능한 상태가 되면 특정 UUID를 가진 서비스를 추가한 뒤에
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager) {
if peripheral.state == .PoweredOn {
self.peripheral.addService(service)
}
}
/// 3. 원하는 정보를 advertising합니다.
func peripheralManager(peripheral: CBPeripheralManager,
didAddService service: CBService,
error: NSError?) {
self.peripheral.startAdvertising([
CBAdvertisementDataLocalNameKey: "전수열",
CBAdvertisementDataServiceUUIDsKey: [serviceUUID],
])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment