* fix: 优化界面

* fix: 修复已知问题

* fix: 代码优化

* fix: 修复已知问题

* fix: 优化 getMaximumWriteLength 方法

* fix: 修改版本号

* fix: 修改版本号

* fix: 修改 CHANGELOG
This commit is contained in:
iAMD
2023-10-18 17:26:24 +08:00
committed by GitHub
parent 4bec1c9f3a
commit 728402ac16
26 changed files with 872 additions and 413 deletions

View File

@ -154,7 +154,7 @@ class MyCentralManager: MyCentralManagerHostApi {
throw MyError.illegalArgument
}
let type = typeArgs.toWriteType()
let maximumWriteLength = peripheral.maximumWriteValueLength(for: type)
let maximumWriteLength = try peripheral.maximumWriteValueLength(for: type).coerceIn(20, 512)
let maximumWriteLengthArgs = Int64(maximumWriteLength)
return maximumWriteLengthArgs
}
@ -310,7 +310,6 @@ class MyCentralManager: MyCentralManagerHostApi {
api.onStateChanged(stateNumberArgs: stateNumberArgs) {}
}
func didDiscover(_ peripheral: CBPeripheral, _ advertisementData: [String : Any], _ rssi: NSNumber) {
let peripheralArgs = peripheral.toArgs()
let peripheralHashCode = peripheral.hash
@ -329,10 +328,12 @@ class MyCentralManager: MyCentralManagerHostApi {
return
}
let peripheralHashCodeArgs = peripheralArgs.hashCodeArgs
let completion = connectCompletions.removeValue(forKey: peripheralHashCodeArgs)
completion?(.success(()))
let stateArgs = true
api.onPeripheralStateChanged(peripheralArgs: peripheralArgs, stateArgs: stateArgs) {}
guard let completion = connectCompletions.removeValue(forKey: peripheralHashCodeArgs) else {
return
}
completion(.success(()))
}
func didFailToConnect(_ peripheral: CBPeripheral, _ error: Error?) {