Skip to content
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

Set the wait timeout for missing indication acknowledgment #825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libraries/Bluefruit52Lib/src/BLEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ BLEConnection::BLEConnection(uint16_t conn_hdl, ble_gap_evt_connected_t const* e
_hvc_received = false;

_ediv = 0xFFFF;

_waitForIndicateConfirmTimeout = portMAX_DELAY;
}

BLEConnection::~BLEConnection()
Expand Down Expand Up @@ -285,13 +287,18 @@ bool BLEConnection::requestPairing(void)
return Bluefruit.Security._authenticate(_conn_hdl);
}

void BLEConnection::setWaitForIndicateConfirmTimeout(uint16_t timeOutMs)
{
_waitForIndicateConfirmTimeout = pdMS_TO_TICKS (timeOutMs);
}

bool BLEConnection::waitForIndicateConfirm(void)
{
// on the fly semaphore
_hvc_sem = xSemaphoreCreateBinary();

_hvc_received = false;
xSemaphoreTake(_hvc_sem, portMAX_DELAY);
xSemaphoreTake(_hvc_sem, _waitForIndicateConfirmTimeout);

vSemaphoreDelete(_hvc_sem);
_hvc_sem = NULL;
Expand Down
6 changes: 4 additions & 2 deletions libraries/Bluefruit52Lib/src/BLEConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class BLEConnection
// On-demand semaphore/data that are created on the fly
SemaphoreHandle_t _hvc_sem;

TickType_t _waitForIndicateConfirmTimeout;

public:
BLEConnection(uint16_t conn_hdl, ble_gap_evt_connected_t const * evt_connected, uint8_t hvn_qsize, uint8_t wrcmd_qsize);
virtual ~BLEConnection();
Expand All @@ -95,6 +97,7 @@ class BLEConnection
bool disconnect(void);

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

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

bool saveCccd(void);
bool loadCccd(void);

bool loadCccd(void);
/*------------------------------------------------------------------*/
/* INTERNAL USAGE ONLY
* Although declare as public, it is meant to be invoked by internal code.
Expand Down
Loading