migrate BLE_EVT_TX_COMPLETE to HVN & WRITE_CMD.

TODO still need to seperate WRITE_CMD from HVN
This commit is contained in:
hathach committed 2017-10-05 17:22:37 +07:00
1 parent 9421a43b80
commit 5701e5944a
2 files changed
+32

No files matched your search

+29
View File
@@ -144,9 +144,14 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
peer->addr = para->peer_addr;
// Init transmission buffer for notification
#if SD_VER < 500
uint8_t txbuf_max;
(void) sd_ble_tx_packet_count_get(conn_handle, &txbuf_max);
peer->txpacket_sem = xSemaphoreCreateCounting(txbuf_max, txbuf_max);
#else
peer->txpacket_sem = xSemaphoreCreateCounting(BLEGAP_HVN_TX_QUEUE_SIZE, BLEGAP_HVN_TX_QUEUE_SIZE);
// TODO BLEGAP_WRITECMD_TX_QUEUE_SIZE
#endif
}
break;
@@ -162,6 +167,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
}
break;
#if SD_VER < 500
case BLE_EVT_TX_COMPLETE:
if ( peer->txpacket_sem )
{
@@ -172,6 +178,29 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
}
break;
#else
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
if ( peer->txpacket_sem )
{
for(uint8_t i=0; i<evt->evt.gatts_evt.params.hvn_tx_complete.count; i++)
{
xSemaphoreGive(peer->txpacket_sem);
}
}
break;
case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE:
if ( peer->txpacket_sem )
{
for(uint8_t i=0; i<evt->evt.gattc_evt.params.write_cmd_tx_complete.count; i++)
{
// TODO BLEGAP_WRITECMD_TX_QUEUE_SIZE
xSemaphoreGive(peer->txpacket_sem);
}
}
break;
#endif
default: break;
}
}
+3
View File
@@ -40,6 +40,9 @@
#include "bluefruit_common.h"
#include "BLEUuid.h"
#define BLEGAP_HVN_TX_QUEUE_SIZE 7 // BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT
#define BLEGAP_WRITECMD_TX_QUEUE_SIZE BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT
class BLEGap
{
public: