Fix sporadic hangup when stopping notifies

This commit is contained in:
Matthias Spiller committed 2020-02-21 08:17:13 +00:00
1 parent 7f96cc2ffc
commit 3bc73d5fb0
3 files changed
+12 -1

No files matched your search

@@ -682,7 +682,12 @@ bool BLECharacteristic::notify(uint16_t conn_hdl, const void* data, uint16_t len
};
LOG_LV2("CHR", "Notify %d bytes", packet_len);
VERIFY_STATUS( sd_ble_gatts_hvx(conn_hdl, &hvx_params), false );
uint32_t status = sd_ble_gatts_hvx(conn_hdl, &hvx_params);
if(NRF_SUCCESS != status)
{
conn->releaseHvnPacket();
}
VERIFY_STATUS(status, false );
remaining -= packet_len;
u8data += packet_len;
@@ -210,6 +210,11 @@ bool BLEConnection::getHvnPacket (void)
return xSemaphoreTake(_hvn_sem, ms2tick(BLE_GENERIC_TIMEOUT));
}
bool BLEConnection::releaseHvnPacket(void)
{
return xSemaphoreGive(_hvn_sem);
}
bool BLEConnection::getWriteCmdPacket (void)
{
return xSemaphoreTake(_wrcmd_sem, ms2tick(BLE_GENERIC_TIMEOUT));
@@ -100,6 +100,7 @@ class BLEConnection
void stopRssi(void);
bool getHvnPacket(void);
bool releaseHvnPacket(void);
bool getWriteCmdPacket(void);
bool waitForIndicateConfirm(void);