-
Notifications
You must be signed in to change notification settings - Fork 222
Write method for returning the number of bytes transferred #371
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
e358f2d
to
ac8ab19
Compare
This comment was marked as outdated.
This comment was marked as outdated.
ac8ab19
to
c81df43
Compare
This comment was marked as outdated.
This comment was marked as outdated.
517881c
to
166debb
Compare
Memory usage change @ 166debb
Click for full report table
Click for full report CSV
|
I would like to open a discussion about changing the behaviour of the function writeValue
instead of writing a new one I would still use the same and return the length instead of 1 or 0.
The reason is if there is an error we can return 0 and there is no breaking change in that, if there is no error we return the length which can be evaluated to true in a boolean expression. The only case where this could not work is if someone is directly comparing the result of write with 1, in which the expected behaviour is not preserved.
I would also like to open the same discussion for handleInd
and handleInd
which can be changed to the definition I put below. The behaviour is changed in the sense that the length is returned (which cannot be higher than a 16 bit, if I recall correctly). For the same reasons I described above I don't see a reason why this cannot work in the same way.
virtual bool handleNotify(uint16_t handle, const uint8_t* value, int length);
virtual bool handleInd(uint16_t handle, const uint8_t* value, int length);
virtual uint16_t handleNotify(uint16_t handle, const uint8_t* value, uint16_t length);
virtual uint16_t handleInd(uint16_t handle, const uint8_t* value, uint16_t length);
This will help us shrink the code size and avoid repeating the definition of functions that are performing the same operation but slightly different.
handleNotify
and handleInd
are returning a bool value that is not strictly related to the length, respectively
return (numNotifications > 0);
and return (numIndications > 0);
returning the length would change how the function is working
@pennam Then we can exclude these functions from the discussion
superseded by #392
Uh oh!
There was an error while loading. Please reload this page.
The current
writeValue
method, used for writing the value of a characteristic, returns an integer value.This value is used as a Boolean to indicate the success or the failure of the writing operation, without giving any indication about the amount of bytes actually transferred (in case of subscription) or "loaded" into the characteristic (in case of a readable characteristic).
Considering that the MTU, the amount of transferable data, is decided by the central and varies device by device, it is impossible for the user to determinate how many bytes are transferred and upon that to take an action.
In this PR a
write
method is added for the genericBLECharacteristic
returning the number of bytes transferred.It works both when the device is in peripheral and central mode.