Skip to content

Commit

Permalink
Finished basic functionality, ready for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
EskelCz committed Dec 18, 2018
1 parent 9c2cc87 commit 02cb714
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions ios/RNBLEPeripheral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,35 @@ import CoreBluetooth
print("called addService")
}

@objc func addCharacteristicToService() {


/*
let characteristicUUID = CBUUID(string: kCharacteristicUUID)
let properties: CBCharacteristicProperties = [.Notify, .Read, .Write]
let permissions: CBAttributePermissions = [.Readable, .Writeable]
let characteristic = CBMutableCharacteristic(
type: characteristicUUID,
properties: properties,
value: nil,
permissions: permissions)

// add to service
// service.characteristics = @[characteristic, characteristic2];
service.characteristics = @[characteristic];
*/
@objc func addCharacteristicToService(_ serviceUUID: String, _ uuid: String, _ permissions: UInt, _ properties: UInt, _ data: String) {
let characteristicUUID = CBUUID(string: uuid)
let propertyValue = CBCharacteristicProperties(rawValue: properties)
let permissionValue = CBAttributePermissions(rawValue: permissions)
let byteData: Data = data.data(using: .utf8)!
let characteristic = CBMutableCharacteristic( type: characteristicUUID, properties: propertyValue, value: byteData, permissions: permissionValue)
servicesMap[serviceUUID]?.characteristics?.append(characteristic)
print("called addCharacteristicToService")
}

@objc func start() {
print("called start")
let advertisementData = [CBAdvertisementDataLocalNameKey: "Test Device"]
let advertisementData = [CBAdvertisementDataLocalNameKey: "Test data"]
peripheralManager.startAdvertising(advertisementData)
print("called start")
}

@objc func stop() {
print("called stop")
peripheralManager.stopAdvertising()
print("called stop")
}

@objc func sendNotificationToDevices() {
print("called stop")
}

@objc static func requiresMainQueueSetup() -> Bool {
return false
}

// Private functiomns
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
print("updated state: \(peripheral.state)")
Expand Down

0 comments on commit 02cb714

Please sign in to comment.