-
-
Notifications
You must be signed in to change notification settings - Fork 283
Jira 795, read() is blocking selectable, git 383 #418
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 this code change. @noelpaz @russmcinnis , please verify this fix. Please use the example sketch, peripheral_explorer, as a guideline for testing the resolution. |
*/ | ||
bool read(); |
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.
So this doesn't change any existing code, right? i.e. if I call read()
with no arguments, it will block by default, yes?
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.
You are correct.
@@ -324,7 +324,7 @@ class BLECharacteristicImp: public BLEAttribute{ | |||
bt_gatt_subscribe_params_t _sub_params; | |||
bool _subscribed; | |||
|
|||
bool _reading; | |||
volatile bool _reading; |
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 does this need to be volatile?
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 note last two changes in BLECharacteristicImp.cpp. It need to make compiler not optimize the code.
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.
So we typing it as volatile so that it compile? Is this change temporary then? What is the penalty as far as code size?
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.
OK, so why do you need to force optimization off? Who is accessing this variable out of normal execution flow? Describe the situation that will occur if _reading
is not volatile
.
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.
When read response come back, the setValue will be called and clear the reading flag. Because the response is asynchronous. So the below code may optimized for the value was set true before call while.
_reading = true;
while(_reading)
{
......
}
@noelpaz , @russmcinnis , please provide feed back on this PR. |
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.
Talked with Sidney, who gave me a good explanation of the requirement for volatile use.
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 am starting BAT Test on this and then will discuss with @SidLeung for focused unit testing and will use analyzer if needed.
@@ -324,7 +324,7 @@ class BLECharacteristicImp: public BLEAttribute{ | |||
bt_gatt_subscribe_params_t _sub_params; | |||
bool _subscribed; | |||
|
|||
bool _reading; | |||
volatile bool _reading; |
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.
So we typing it as volatile so that it compile? Is this change temporary then? What is the penalty as far as code size?
@russmcinnis is testing this functionality. But we cannot do an end to end testing unless we resolve the conflicts. Pinging @SidLeung |
@noelpaz , @russmcinnis , conflict resolved, please proceed with system testing. Thanks. |
@noelpaz @russmcinnis , please retest this PR. It has resolved the hanging issue due to disconnection in the middle of reading. @bigdinotech @eriknyquist , please review the additional code change for disconnection detection. |
Mods: 1. Add an input parameter to BLECharacteristic::read() for blocking call selection. 2. By default, read() is a blocking call. File changes: 1. libraries/CurieBLE/src/BLECharacteristic.cpp: - Method read() added blocking selection. 2. libraries/CurieBLE/src/BLECharacteristic.h: - Prototype for read(), default is blocking. 3. libraries/CurieBLE/src/internal/BLECallbacks.cpp: - Added parameter checking in profile_read_rsp_process(). 4. libraries/CurieBLE/src/internal/BLECharacteristicImp.cpp - The implementation of read() added waiting for resp if blocking is selected. 5. libraries/CurieBLE/src/internal/BLECharacteristicImp.h: - prototyping.
@yashaswini-hanji , please merge the PR to main and close out Jira 795. |
PR merged and Jira 795 is closed |
Mods:
call selection.
File changes:
blocking is selected.