adding BLEGapConnection

- getHvnPacket()
- getWriteCmdPacket()
- getMTU()
This commit is contained in:
hathach committed 2019-01-17 20:00:08 +07:00
1 parent 45129ea425
commit a9ac9d994e
8 files changed
+80 -64

No files matched your search

@@ -195,11 +195,13 @@ uint16_t HAPCharacteristic::writeHapValue(uint32_t num)
void HAPCharacteristic::createHapResponse(uint16_t conn_hdl, uint8_t status, TLV8_t tlv_para[], uint8_t count)
{
BLEGapConnection* conn = Bluefruit.Gap.getConnection( conn_hdl );
// Determine body len (not including 2 byte length itself)
uint16_t body_len = tlv8_encode_calculate_len(tlv_para, count);
// Determine the response length including fragmentation scheme
uint16_t const gatt_mtu = Bluefruit.Gap.getMTU(conn_hdl) - 3;
uint16_t const gatt_mtu = conn->getMTU() - 3;
uint16_t resp_len = sizeof(HAPResponseHeader_t) + 2 + body_len;
uint16_t nfrag = 0; // number of fragments (excluding the first)
@@ -356,7 +358,8 @@ void HAPCharacteristic::processGattWrite(uint16_t conn_hdl, ble_gatts_evt_write_
LOG_LV2("GATTS", "Write Op = %d, len = %d, offset = %d, uuid = 0x%04X", gatt_req->op, gatt_req->len, gatt_req->offset, gatt_req->uuid.uuid);
LOG_LV2_BUFFER(NULL, gatt_req->data, gatt_req->len);
uint16_t const gatt_mtu = Bluefruit.Gap.getMTU(conn_hdl) - 3;
BLEGapConnection* conn = Bluefruit.Gap.getConnection( conn_hdl );
uint16_t const gatt_mtu = conn->getMTU() - 3;
ble_gatts_rw_authorize_reply_params_t reply =
{
@@ -459,7 +462,8 @@ void HAPCharacteristic::processGattWrite(uint16_t conn_hdl, ble_gatts_evt_write_
void HAPCharacteristic::processGattRead(uint16_t conn_hdl, ble_gatts_evt_read_t* gatt_req)
{
uint16_t const gatt_mtu = Bluefruit.Gap.getMTU(conn_hdl) - 3;
BLEGapConnection* conn = Bluefruit.Gap.getConnection( conn_hdl );
uint16_t const gatt_mtu = conn->getMTU() - 3;
LOG_LV2("GATTS", "Read uuid = 0x%04X, offset = %d", gatt_req->uuid.uuid, gatt_req->offset);