-
-
Notifications
You must be signed in to change notification settings - Fork 284
Jira 794 Inconsistent writeInt() result with different Peripherals, g… #414
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
@bigdinotech @eriknyquist , please review the code change. @noelpaz @russmcinnis , this PR originates from Flex PR #400. Please sign off if you use that PR for system verification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 but needs to be tested by someone else
@SidLeung please fill in "reviewers" field in future... makes it much easier to track all the reviews :) |
@@ -223,4 +223,8 @@ void ble_central_device_found(const bt_addr_le_t *addr, | |||
ad, len); | |||
} | |||
|
|||
void ble_on_write_no_rsp_complete(struct bt_conn *conn, uint8_t err, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the empty function? Let's delete it, if not need, or add a comment explaining WHY there is an empty function (e.g. a TODO or something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that empty function neither. Let me check it out more. It should be made better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see those two functions _bt_gatt_write and bt_gatt_write in the gatt.c. This try to schedule the write request with response.
The code looks fine. I'd just like an explanation for the empty function |
@sgbihu , I would suggest, at least for the Deneb release, the CB function, ble_on_write_no_rsp_complete, should not be left empty. I propose, based on the same logic as read, this routine should reset a flag that indicates the stack is in writing (eg. bool _inWriting). For write that requires no response, no checking of the _inWriting flag prior to the write() call. Otherwise, check for clearing of _inWriting flag before calling write(). |
This blank function want stack can send out write with response. If we are not define a function, the stack always schedule the write without command. |
Let me capture our discussion on how to make use of this call back function, ble_on_write_no_rsp_complete, here:
|
Updated the code. Please rebase it. |
…it 385 Root cause: - As a Central, the write() operation can produce two different commands to a Peripheral depending on the Characteristic. - One command is a simple write without aknowledgement from Peripheral and the other requires a complete handshake for each write operation. - Root cause of the issue was that the function, BLECharacteristicImp::write(), did not check the characteristic property to determine if the caller requires a response. It just treats all calls do not require a response. Feature added: - For write with respond from Peripheral, it is now a blocking call (it also satisfied Arduino's request). Modifications: 1. libraries/CurieBLE/src/internal/BLECallbacks.cpp: - ble_on_write_no_rsp_complete: CB to process Peripheral Response to complete a write operation. 2. libraries/CurieBLE/src/internal/BLECallbacks.h: - Function definition added. 3. libraries/CurieBLE/src/internal/BLECharacteristicImp.cpp: - In function write(), check the characteristic property to determine whether the call requires a response. - Added a flag to signal the waiting on Peripheral Response for a write operation. - Write with response is now a blocking call. 4. BLECharacteristicImp.h: - Prototyping.
For a Central, a write with response from the Peripheral is now made as a blocking call. The Characteristic is used to determine if a write operation require a full handshake. @bigdinotech @eriknyquist , please review the addition code change. @noelpaz @russmcinnis , please perform system verification with the change. Unit testing has been performed. |
We are currently running tests |
BAT test -- no impact on corelib all test passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA team has verified the fix and also verified that it has not broken anything by running BAT
@yashaswini-hanji Would you please emerge this PR to main trunk? |
Changes merged. |
Root cause:
characteristic property to determine if the caller requires
a response. It just treats all calls do not require a
response.
Modifications:
determine whether the call requires a response.