Skip to content

Conversation

estutzenberger
Copy link

This fixes #12.

@moogle19
Copy link

@estutzenberger
Value is used for static read-only characteristics (see here)
Your implementation could be problematic, if a characteristic can be read from and written to, because if a Value is not nil, the Handler would not be called (see here).
Why do we need to buffer the Value and should the library do this or would it be better if it is handled in the program?

@estutzenberger
Copy link
Author

estutzenberger commented Mar 16, 2018

Thanks for reviewing this PR!

The links provided reference the server side. I'm not sure I see how client side characteristics are connected to the server side characteristics. Is there a sort of relay service where the client characteristics are then reused as the service characteristics? Maybe I'm missing something else. It seems like handleReadRequest is not going to be called for a client side characteristic. Is that correct?

Some BLE libraries that I have worked with (including CoreBluetooth and Android) buffer a characteristic's value after it has been read once. They do not update the local buffer for read/write situations. In that case, you would need to send another read request after performing the write.

Noble (nodejs ble library) on the other hand, does not buffer the read value and, for the client, it does not have a value property for the characteristic. They also have a separate project for the server side which DOES have a value property because it must.

Why do we need to buffer the Value and should the library do this or would it be better if it is handled in the program?

I suppose the main point for me is this: On the client side, the characteristic struct contains a Value property that isn't used. The server side does use it. If the value is property is going to exist on the client side within the characteristic struct, it seems like it should (could) be used to buffer the value read from the peripheral server. The reason I like to have it buffered is that I do not have to re-read the data every time my application needs to present characteristic information to the user. I could create my own buffer of the data, but that seems redundant and creates additional places for errors to creep in.

Thoughts?

@moogle19 moogle19 merged commit 582be3b into go-ble:master Apr 4, 2018
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

Successfully merging this pull request may close these issues.

Reading a characteristic or descriptor value returns the value but does not update the object
2 participants