我正在尝试更改BlueCapKit的PeripheralManager类对象中的广告费率,我不知道如何更改它。
我已经与外围设备成功通信,但是有时设备一次发送多个数据包,最好是在不到一秒钟的时间内接收它们,而不是等待几秒钟才能接收所有数据包。
我创建了经理类,以将所有通信保持在一个单例对象下(这只是其中的一小段)
import BlueCapKit
import CoreBluetooth
class BluetoothConnectionManager {
// Object constructor
private init() {
manager = PeripheralManager(options: [CBPeripheralManagerOptionShowPowerAlertKey: true])
service = MutableService(uuid: serviceUUID)
characteristic = MutableCharacteristic(UUID: characteristicUUID, properties: [.read, .notify, .writeWithoutResponse, .write, .indicate, .authenticatedSignedWrites], permissions: [.readable, .writeable], value: nil)
service.characteristics = [characteristic]
}
// Function that starts advertising
func initService() {
let startAdvertiseFuture = manager.whenStateChanges().flatMap { state -> Future<Void> in
switch state {
case .poweredOn:
self.manager.removeAllServices()
self.manager.add(self.service)
self.didRequestStatusSentToDevice = false
return self.manager.stopAdvertising().flatMap { _ in
return self.manager.startAdvertising("test", uuids: [CBUUID(string: self.serviceUUID)])
}
}
}
有没有办法动态更改它?(在服务积极投放广告期间)