Skip to content

RDKEMW-15846 : Elite classic controller is not disconnect on standby - #52

Open
natrajmuthusamy wants to merge 13 commits into
developfrom
DELIA-68952
Open

RDKEMW-15846 : Elite classic controller is not disconnect on standby#52
natrajmuthusamy wants to merge 13 commits into
developfrom
DELIA-68952

Conversation

@natrajmuthusamy

Copy link
Copy Markdown
Contributor

No description provided.

Reason for change : Sets the operation to modify the device's blocked property, enabling dynamic block/unblock control via this function.

Priority: P1
Test Procedure: Follow the steps provided in description

Risks: High
Signed-off-by:Natraj Muthusamy <Natraj_Muthusamy@comcast.com>
@natrajmuthusamy
natrajmuthusamy requested a review from a team as a code owner March 23, 2026 10:38
Copilot AI review requested due to automatic review settings March 23, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new API intended to programmatically block/unblock a paired Bluetooth device (likely to address the Elite classic controller behavior around standby).

Changes:

  • Added btrCore_UpdateDeviceBlockState(...) implementation in src/btrCore.c to set enBTDevPropBlocked.
  • Exposed the new API in include/btrCore.h with Doxygen documentation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
src/btrCore.c Adds a helper to set the “Blocked” device property via BtrCore_BTSetProp.
include/btrCore.h Exposes/document the new API in the public header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/btrCore.h Outdated
Comment thread include/btrCore.h
Comment on lines +1351 to +1360
/**
* @brief Updates the block state (blocked/unblocked) of a Bluetooth device.
*
* This API sets the device block state for the specified Bluetooth device using its device ID and type.
* It may be used to block or unblock a device from interacting with the Bluetooth core.
*
* @param[in] pstlhBTRCore Pointer to the Bluetooth Core handle.
* @param[in] aBTRCoreDevId Device ID of the target Bluetooth device.
* @param[in] aenBTRCoreDevType Device type of the target Bluetooth device.
* @param[in] isBlocked Desired block state: 1 to block the device, 0 to unblock it.

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a new externally visible API, but there are no corresponding unit tests (the repo has extensive coverage in unitTest/test_btrCore.c for other BTRCore_* APIs). Please add tests that cover success/failure paths (e.g., device not found, BTSetProp failure, and block/unblock values).

Copilot uses AI. Check for mistakes.
Comment thread include/btrCore.h Outdated
Comment thread src/btrCore.c
Comment on lines +5138 to +5142
enBTRCoreRet btrCore_UpdateDeviceBlockState (
tBTRCoreHandle* pstlhBTRCore,
tBTRCoreDevId aBTRCoreDevId,
enBTRCoreDeviceType aenBTRCoreDevType,
int isBlocked

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function uses aenBTRCoreDevType in the signature but never references it, which will fail the build under -Wall -Werror due to -Wunused-parameter. Either use it (e.g., via btrCore_GetDeviceInfoKnown(...)) or explicitly mark it unused if it’s intentionally ignored.

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c Outdated
Comment thread src/btrCore.c
Comment on lines +5152 to +5157
enBTDeviceType enBTDevice = enBTDevUnknown;

for (i = 0; i < pstlhBTRCore->numOfPairedDevices; ++i) {
if (pstlhBTRCore->stKnownDevicesArr[i].tDeviceId == aBTRCoreDevId) {
pDeviceAddress = pstlhBTRCore->stKnownDevicesArr[i].pcDeviceAddress;
enBTDevice = pstlhBTRCore->stKnownDevicesArr[i].enDeviceType;

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enBTDevice is declared as enBTDeviceType, but it’s being assigned from stKnownDevicesArr[i].enDeviceType (type enBTRCoreDeviceClass). This mixes unrelated enums and will produce an invalid value for later calls; avoid deriving the BT interface type from the device class here.

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c Outdated
Comment thread src/btrCore.c Outdated
Copilot AI review requested due to automatic review settings March 23, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/btrCore.c
Comment on lines +5138 to +5179
enBTRCoreRet btrCore_UpdateDeviceBlockState (
tBTRCoreHandle* hBTRCore,
tBTRCoreDevId aBTRCoreDevId,
enBTRCoreDeviceType aenBTRCoreDevType,
int isBlocked
) {

if (!hBTRCore) {
BTRCORELOG_ERROR("Invalid BT Core Handle\n");
return enBTRCoreInvalidArg;
}

pstlhBTRCore = (stBTRCoreHdl*)hBTRCore;

const char *pDeviceAddress = NULL;
int i;
enBTDeviceType enBTDevice = enBTDevUnknown;

for (i = 0; i < pstlhBTRCore->numOfPairedDevices; ++i) {
if (pstlhBTRCore->stKnownDevicesArr[i].tDeviceId == aBTRCoreDevId) {
pDeviceAddress = pstlhBTRCore->stKnownDevicesArr[i].pcDeviceAddress;
enBTDevice = pstlhBTRCore->stKnownDevicesArr[i].enDeviceType;
break;
}
}

if (!pDeviceAddress) {
BTRCORELOG_ERROR("Device ID %lld not found\n", aBTRCoreDevId);
return enBTRCoreDeviceNotFound;
}

unBTOpIfceProp lunBtOpDevProp;
lunBtOpDevProp.enBtDeviceProp = enBTDevPropBlocked;
int BlockDevice = block ? 1 : 0;

if (BtrCore_BTSetProp(pstlhBTRCore->connHdl, pDeviceAddress, enBTDevice, lunBtOpDevProp, &BlockDevice)) {
BTRCORELOG_ERROR("Set Device Property enBTDevPropBlocked - FAILED\n");
return enBTRCoreFailure;
}

return enBTRCoreSuccess;
}

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing unit tests for btrCore.c logic in unitTest/test_btrCore.c, but no tests cover this newly introduced device-block/unblock API. Please add unit tests for at least: invalid handle, device-not-found, and successful blocked/unblocked property setting (with BtrCore_BTSetProp mocked).

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c Outdated
Comment thread src/btrCore.c
Comment on lines +5154 to +5174
enBTDeviceType enBTDevice = enBTDevUnknown;

for (i = 0; i < pstlhBTRCore->numOfPairedDevices; ++i) {
if (pstlhBTRCore->stKnownDevicesArr[i].tDeviceId == aBTRCoreDevId) {
pDeviceAddress = pstlhBTRCore->stKnownDevicesArr[i].pcDeviceAddress;
enBTDevice = pstlhBTRCore->stKnownDevicesArr[i].enDeviceType;
break;
}
}

if (!pDeviceAddress) {
BTRCORELOG_ERROR("Device ID %lld not found\n", aBTRCoreDevId);
return enBTRCoreDeviceNotFound;
}

unBTOpIfceProp lunBtOpDevProp;
lunBtOpDevProp.enBtDeviceProp = enBTDevPropBlocked;
int BlockDevice = block ? 1 : 0;

if (BtrCore_BTSetProp(pstlhBTRCore->connHdl, pDeviceAddress, enBTDevice, lunBtOpDevProp, &BlockDevice)) {
BTRCORELOG_ERROR("Set Device Property enBTDevPropBlocked - FAILED\n");

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third argument to BtrCore_BTSetProp is enBTOpIfceType (e.g., enBTDevice), but this function defines enBTDevice as an enBTDeviceType variable and passes it through. That’s a type/semantic mismatch and will either not compile cleanly or call the API with the wrong enum value. Pass the enBTDevice interface type constant here, and keep the device-type enum separate if needed.

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c
Comment on lines +5153 to +5168
int i;
enBTDeviceType enBTDevice = enBTDevUnknown;

for (i = 0; i < pstlhBTRCore->numOfPairedDevices; ++i) {
if (pstlhBTRCore->stKnownDevicesArr[i].tDeviceId == aBTRCoreDevId) {
pDeviceAddress = pstlhBTRCore->stKnownDevicesArr[i].pcDeviceAddress;
enBTDevice = pstlhBTRCore->stKnownDevicesArr[i].enDeviceType;
break;
}
}

if (!pDeviceAddress) {
BTRCORELOG_ERROR("Device ID %lld not found\n", aBTRCoreDevId);
return enBTRCoreDeviceNotFound;
}

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aenBTRCoreDevType is currently unused, and this function manually scans stKnownDevicesArr to find the MAC/type. Elsewhere (e.g., connect/disconnect/unpair) the code uses helpers like btrCore_GetDeviceInfoKnown / btrCore_GetDeviceInfo / btrCore_GetKnownDeviceMac, which also handle the aBTRCoreDevId < BTRCORE_MAX_NUM_BT_DEVICES case and keep the lookup logic consistent. Reuse the existing helper(s) here to avoid divergent device-ID resolution and to make use of the aenBTRCoreDevType parameter (or remove it if it’s not needed).

Suggested change
int i;
enBTDeviceType enBTDevice = enBTDevUnknown;
for (i = 0; i < pstlhBTRCore->numOfPairedDevices; ++i) {
if (pstlhBTRCore->stKnownDevicesArr[i].tDeviceId == aBTRCoreDevId) {
pDeviceAddress = pstlhBTRCore->stKnownDevicesArr[i].pcDeviceAddress;
enBTDevice = pstlhBTRCore->stKnownDevicesArr[i].enDeviceType;
break;
}
}
if (!pDeviceAddress) {
BTRCORELOG_ERROR("Device ID %lld not found\n", aBTRCoreDevId);
return enBTRCoreDeviceNotFound;
}
enBTDeviceType enBTDevice = enBTDevUnknown;
stBTRCoreBTDevice lstBTDeviceInfo;
memset(&lstBTDeviceInfo, 0, sizeof(lstBTDeviceInfo));
/* Use common helper to resolve device ID to address/type, so that
* aBTRCoreDevId and aenBTRCoreDevType are handled consistently with
* other operations (connect/disconnect/unpair, etc.).
*/
if (btrCore_GetDeviceInfo(pstlhBTRCore,
aBTRCoreDevId,
aenBTRCoreDevType,
&lstBTDeviceInfo) != enBTRCoreSuccess) {
BTRCORELOG_ERROR("Device ID %lld not found\n", aBTRCoreDevId);
return enBTRCoreDeviceNotFound;
}
pDeviceAddress = lstBTDeviceInfo.pcDeviceAddress;
enBTDevice = lstBTDeviceInfo.enDeviceType;

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c
Copilot AI review requested due to automatic review settings March 23, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/btrCore.c Outdated
Comment thread src/btrCore.c
Comment on lines +5138 to +5152
enBTRCoreRet btrCore_UpdateDeviceBlockState (
tBTRCoreHandle* hBTRCore,
tBTRCoreDevId aBTRCoreDevId,
enBTRCoreDeviceType aenBTRCoreDevType,
int isBlocked
) {

stBTRCoreHdl* pstlhBTRCore = NULL;
if (!hBTRCore) {
BTRCORELOG_ERROR("Invalid BT Core Handle\n");
return enBTRCoreInvalidArg;
}

pstlhBTRCore = (stBTRCoreHdl*)hBTRCore;

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new API takes tBTRCoreHandle* (i.e., void**) but the rest of BTRCore public APIs take tBTRCoreHandle (void*). The implementation then casts hBTRCore directly to stBTRCoreHdl*, which will be an invalid pointer if callers pass the handle by value like other APIs. Please change the signature to take tBTRCoreHandle hBTRCore and align the null-handle return code with the existing pattern (enBTRCoreNotInitialized).

Copilot uses AI. Check for mistakes.
Comment thread src/btrCore.c Outdated
Comment thread src/btrCore.c
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 15:40
natrajmuthusamy and others added 4 commits March 23, 2026 21:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants