Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxBle.writeChar如何设置写入模式以及数据写入失败问题 #29

Open
yiguozhen0510 opened this issue Nov 13, 2019 · 4 comments

Comments

@yiguozhen0510
Copy link

1.在使用RxBle.writeChar方法时,Android在使用时可以设置写入的模式,“writeWithNoResponse” '"writeWithResponse",但是RxBle并没有找到这个方法,有哪位大神知道这个问题怎么解决吗?
2.在使用RxBle.writeChar写入数据时,数据一直写入不成功,同时也没有返回值,希望大神能提供一下思路,跪谢!!!

@Hu-Wentao
Copy link

作者跟我说,iOS是默认withOutRespone的,(我自己没试过)。

@yiguozhen0510
Copy link
Author

您那边有遇到数据一直写入失败的情况吗?

@Hu-Wentao
Copy link

Hu-Wentao commented Nov 14, 2019 via email

@oooooocean
Copy link

func writeChar(call: FlutterMethodCall, result: @escaping FlutterResult) throws {
let map = call.arguments as! [String: Any?]
let deviceId = map["deviceId"] as! String
let uuid = map["uuid"] as! String
let value = map["value"] as! FlutterStandardTypedData
let peripheral = try getPeripheral(deviceId)
let char = try getCharFromCache(deviceId, uuid)

    sendSingle(peripheral.writeValue(value.data, for: char, type: .withResponse), result) {
        FlutterStandardTypedData(bytes: $0.value ?? Data())
    }
}

源码中一直使用 withResponse 对于一些情况会会导致写入数据失败

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants