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

[Infineon] Update BLE Char C2 to Indicate instead of Notify #21652

Merged
Merged
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
45 changes: 31 additions & 14 deletions src/platform/P6/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
PacketBufferHandle::Adopt(event->CHIPoBLEWriteReceived.Data));
break;

case DeviceEventType::kCHIPoBLENotifyConfirm:
HandleIndicationConfirmation(event->CHIPoBLENotifyConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
case DeviceEventType::kCHIPoBLEIndicateConfirm:
HandleIndicationConfirmation(event->CHIPoBLEIndicateConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
break;

case DeviceEventType::kCHIPoBLEConnectionError:
Expand Down Expand Up @@ -331,27 +331,19 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
VerifyOrExit(conState != NULL, err = CHIP_ERROR_INVALID_ARGUMENT);

#ifdef BLE_DEBUG
ChipLogDetail(DeviceLayer, "Sending notification for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen);
ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen);
#endif

// Send a notification for the CHIPoBLE TX characteristic to the client containing the supplied data.
// Send a indication for the CHIPoBLE TX characteristic to the client containing the supplied data.
gatt_err =
wiced_bt_gatt_server_send_notification((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start(), NULL);
wiced_bt_gatt_server_send_indication((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start(), NULL);

exit:
if (gatt_err != WICED_BT_GATT_SUCCESS)
{
ChipLogError(DeviceLayer, "BLEManagerImpl::SendNotification() failed: %d", gatt_err);
ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %d", gatt_err);
return false;
}
else
{
// Post an event to the CHIP queue.
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLENotifyConfirm;
event.CHIPoBLENotifyConfirm.ConId = conId;
err = PlatformMgr().PostEvent(&event);
}
return err == CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -661,6 +653,27 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceMtuReq(uint16_t conn_id,
return WICED_BT_GATT_SUCCESS;
}

/*
* Process GATT Indication Confirm from the client
*/
wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceIndCfm(uint16_t conn_id, uint16_t handle)
{
#ifdef BLE_DEBUG
ChipLogDetail(DeviceLayer, "GATT Ind Cfm received con:%04x handle:%d", conn_id, handle);
#endif
if (handle == HDLC_CHIP_SERVICE_CHAR_C2_VALUE)
{
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = conn_id;
if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR)
{
return WICED_BT_GATT_INTERNAL_ERROR;
}
}
return WICED_BT_GATT_SUCCESS;
}

/*
* Process GATT attribute requests
*/
Expand Down Expand Up @@ -693,6 +706,10 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceRequestEvent(wiced_bt_ga
result = HandleGattServiceMtuReq(p_request->conn_id, p_request->data.remote_mtu);
break;

case GATT_HANDLE_VALUE_CONF:
result = HandleGattServiceIndCfm(p_request->conn_id, p_request->data.confirm.handle);
break;

default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/P6/cycfg_gatt_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const uint8_t gatt_database[] = {
GATTDB_CHAR_PROP_WRITE, GATTDB_PERM_READABLE | GATTDB_PERM_WRITE_REQ),
/* Characteristic: C2 */
CHARACTERISTIC_UUID128_WRITABLE(HDLC_CHIP_SERVICE_CHAR_C2, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, __UUID128_CHIPoBLEChar_C2,
GATTDB_CHAR_PROP_READ | GATTDB_CHAR_PROP_NOTIFY,
GATTDB_CHAR_PROP_READ | GATTDB_CHAR_PROP_INDICATE,
GATTDB_PERM_RELIABLE_WRITE | GATTDB_PERM_READABLE | GATTDB_CHAR_PROP_WRITE),

/* Descriptor: Client Characteristic Configuration */
Expand Down