简体   繁体   中英

Writing and notifying from the same characteristic

Is there a problem with writing-to and notifying-from the same characteristic? Or is it recommended that one create two characteristics, one for receiving data, and the other for transmitting? Is this less of a concern for Android then the NRF52 series?

Thanks

There is no problem with a Characteristic having both Write and Notify properties. I would use a single Characteristic if the writing and notifying is associated with the same data.

As far as I know, this should not be a concern with any BLE device.

Having two characteristics does not eliminate the "race condition" on Android devices. The GATT API is synchronous, ie you cannot read or write on more than one characteristic at a time.

Generally there is no such issue but you shouldn't do it if you intend to communicate with an Android phone since there is a race condition in the API itself you can read about here How could i achieve maximum thread safety with a read/write BLE Gatt Characteristic?

So I would definitely recommend you to have two characteristics.

The officially approved Current Time Service contains the Current Time characteristics that allows for both writing and notifying. So I assume that there is no fundamental problem with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM