Skip to content

Commit 0c6742d

Browse files
Set wait timeout for indication
1 parent 0ed4d9f commit 0c6742d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

libraries/Bluefruit52Lib/src/BLEConnection.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ BLEConnection::BLEConnection(uint16_t conn_hdl, ble_gap_evt_connected_t const* e
6464
_hvc_received = false;
6565

6666
_ediv = 0xFFFF;
67+
68+
_waitForIndicateConfirmTimeout = portMAX_DELAY;
6769
}
6870

6971
BLEConnection::~BLEConnection()
@@ -285,13 +287,18 @@ bool BLEConnection::requestPairing(void)
285287
return Bluefruit.Security._authenticate(_conn_hdl);
286288
}
287289

290+
void BLEConnection::setWaitForIndicateConfirmTimeout(uint16_t timeOutMs)
291+
{
292+
_waitForIndicateConfirmTimeout = pdMS_TO_TICKS (timeOutMs);
293+
}
294+
288295
bool BLEConnection::waitForIndicateConfirm(void)
289296
{
290297
// on the fly semaphore
291298
_hvc_sem = xSemaphoreCreateBinary();
292299

293300
_hvc_received = false;
294-
xSemaphoreTake(_hvc_sem, portMAX_DELAY);
301+
xSemaphoreTake(_hvc_sem, _waitForIndicateConfirmTimeout);
295302

296303
vSemaphoreDelete(_hvc_sem);
297304
_hvc_sem = NULL;

libraries/Bluefruit52Lib/src/BLEConnection.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class BLEConnection
7070
// On-demand semaphore/data that are created on the fly
7171
SemaphoreHandle_t _hvc_sem;
7272

73+
TickType_t _waitForIndicateConfirmTimeout;
74+
7375
public:
7476
BLEConnection(uint16_t conn_hdl, ble_gap_evt_connected_t const * evt_connected, uint8_t hvn_qsize, uint8_t wrcmd_qsize);
7577
virtual ~BLEConnection();
@@ -95,6 +97,7 @@ class BLEConnection
9597
bool disconnect(void);
9698

9799
bool setTxPower(int8_t power); // set power for this connection
100+
void setWaitForIndicateConfirmTimeout(uint16_t timeOutMs);
98101

99102
bool requestDataLengthUpdate(ble_gap_data_length_params_t const *p_dl_params = NULL, ble_gap_data_length_limitation_t *p_dl_limitation = NULL);
100103
bool requestMtuExchange(uint16_t mtu);
@@ -116,8 +119,7 @@ class BLEConnection
116119
bool removeBondKey(void);
117120

118121
bool saveCccd(void);
119-
bool loadCccd(void);
120-
122+
bool loadCccd(void);
121123
/*------------------------------------------------------------------*/
122124
/* INTERNAL USAGE ONLY
123125
* Although declare as public, it is meant to be invoked by internal code.

0 commit comments

Comments
 (0)