Skip to content

Commit 33df47d

Browse files
sgbihuSidLeung
authored andcommitted
Implement the block call for descriptor read method
1 parent 07fce54 commit 33df47d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libraries/CurieBLE/src/internal/BLEDescriptorImp.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ bool BLEDescriptorImp::read()
172172
{
173173
int retval = 0;
174174
bt_conn_t* conn = NULL;
175+
bool ret_bool = true;
175176

176177
if (true == BLEUtils::isLocalBLE(_bledev))
177178
{
@@ -209,6 +210,13 @@ bool BLEDescriptorImp::read()
209210
{
210211
_reading = true;
211212
}
213+
214+
// Block the read
215+
while (_reading == true && ret_bool)
216+
{
217+
delay(5);
218+
ret_bool = _bledev.connected();
219+
}
212220
return _reading;
213221
}
214222

@@ -219,6 +227,12 @@ bool BLEDescriptorImp::writeValue(const byte value[],
219227
bool ret = true;
220228
int total_length = length + offset;
221229
int write_len = length;
230+
231+
if (_reading)
232+
{
233+
_reading = false;
234+
}
235+
222236
if (total_length > BLE_MAX_ATTR_DATA_LEN)
223237
{
224238
return false;

0 commit comments

Comments
 (0)