Skip to content

Commit

Permalink
* Enabling TX complete handling (#4402)
Browse files Browse the repository at this point in the history
  • Loading branch information
tima-q authored Jan 19, 2021
1 parent 0261dd1 commit aca6540
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
64 changes: 37 additions & 27 deletions src/platform/qpg6100/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
PacketBufferHandle::Adopt(event->CHIPoBLEWriteReceived.Data));
}
break;
case DeviceEventType::kCHIPoBLETXCharWriteEvent:
HandleTXComplete(event);
break;

case DeviceEventType::kCHIPoBLEConnectionError: {
ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLEConnectionError");
Expand Down Expand Up @@ -224,6 +221,12 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)

break;

case DeviceEventType::kCHIPoBLEIndicateConfirm: {
ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLEIndicateConfirm");
HandleIndicationConfirmation(event->CHIPoBLEIndicateConfirm.ConId, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX);
}
break;

default:
ChipLogProgress(DeviceLayer, "_OnPlatformEvent default: event->Type = %d", event->Type);
break;
Expand Down Expand Up @@ -594,11 +597,6 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(qvCHIP_Ble_AttsCccEvt_t * pEvt)
}
}

void BLEManagerImpl::HandleTXComplete(const ChipDeviceEvent * event)
{
// TODO -
}

/* Process DM Messages */
void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt)
{
Expand Down Expand Up @@ -686,30 +684,34 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt)
ChipLogProgress(DeviceLayer, "BLE GATT connection closed (con %u, reason %u)", pDmEvt->connClose.hdr.param,
pDmEvt->connClose.reason);

// If this was a CHIPoBLE connection, release the associated connection state record
// and post an event to deliver a connection error to the CHIPoBLE layer.
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
event.CHIPoBLEConnectionError.ConId = pDmEvt->connClose.hdr.param;
switch (pDmEvt->connClose.reason)
{
case QVCHIP_HCI_ERR_REMOTE_TERMINATED:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED;
break;
case QVCHIP_HCI_ERR_LOCAL_TERMINATED:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_APP_CLOSED_CONNECTION;
break;
default:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
break;
}
PlatformMgr().PostEvent(&event);

// Force a refresh of the advertising state.
if (mNumGAPCons > 0)
{
mNumGAPCons--;
}

// If this was a CHIPoBLE connection, release the associated connection state record
// and post an event to deliver a connection error to the CHIPoBLE layer.
if (UnsetSubscribed(pDmEvt->connClose.hdr.param))
{
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEConnectionError;
event.CHIPoBLEConnectionError.ConId = pDmEvt->connClose.hdr.param;
switch (pDmEvt->connClose.reason)
{
case QVCHIP_HCI_ERR_REMOTE_TERMINATED:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED;
break;
case QVCHIP_HCI_ERR_LOCAL_TERMINATED:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_APP_CLOSED_CONNECTION;
break;
default:
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
break;
}
PlatformMgr().PostEvent(&event);
}

SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded);
PlatformMgr().ScheduleWork(DriveBLEState, 0);
break;
Expand All @@ -734,6 +736,14 @@ void BLEManagerImpl::HandleAttMsg(qvCHIP_Ble_AttEvt_t * pAttEvt)
case QVCHIP_ATT_MTU_UPDATE_IND: {
break;
}
case QVCHIP_ATTS_HANDLE_VALUE_CNF: {
ChipDeviceEvent event;

event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = pAttEvt->hdr.param;
PlatformMgr().PostEvent(&event);
break;
}
case QVCHIP_ATTC_FIND_BY_TYPE_VALUE_RSP:
case QVCHIP_ATTC_READ_BY_GROUP_TYPE_RSP:
case QVCHIP_ATTC_READ_BY_TYPE_RSP:
Expand Down
1 change: 0 additions & 1 deletion src/platform/qpg6100/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla

void HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt);
void HandleAttMsg(qvCHIP_Ble_AttEvt_t * pAttEvt);
void HandleTXComplete(const ChipDeviceEvent * event);

/* Callbacks from BLE stack*/
static void ExternalCbHandler(qvCHIP_Ble_MsgHdr_t * pMsg);
Expand Down

0 comments on commit aca6540

Please sign in to comment.