-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,18 +146,18 @@ class BLECharacteristicImp: public BLEAttribute{ | |
/** | ||
* @brief Schedule the read request to read the characteristic in peripheral | ||
* | ||
* @param[in] none | ||
* @param[in] blocked Flag the call is blocked or un-blocked | ||
* | ||
* @return bool Indicate the success or error | ||
* | ||
* @note Only for central device | ||
* @note Only for GATT client | ||
* Default it is block call as per Arduino request | ||
*/ | ||
bool read(); | ||
bool read(bool blocked = true); | ||
|
||
/** | ||
* @brief Schedule the write request to update the characteristic in peripheral | ||
* | ||
* @param[in] peripheral The peripheral device that want to be updated | ||
* @param[in] value New value to set, as a byte array. Data is stored in internal copy. | ||
* @param[in] length Length, in bytes, of valid data in the array to write. | ||
* Must not exceed maxLength set for this characteristic. | ||
|
@@ -328,7 +328,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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
static volatile bool _gattc_writing; | ||
bt_gatt_read_params_t _read_params; // GATT read parameter | ||
|
||
|
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.