Skip to content

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

Open
natrajmuthusamy wants to merge 6 commits intodevelopfrom
DELIA-68952
Open

RDKEMW-15846 : Elite classic controller is not disconnect on standby.#87
natrajmuthusamy wants to merge 6 commits intodevelopfrom
DELIA-68952

Conversation

@natrajmuthusamy
Copy link
Copy Markdown
Contributor

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

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 14:35
Copilot AI review requested due to automatic review settings March 23, 2026 14:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates Bluetooth Manager’s gamepad startup/standby handling to dynamically toggle the “blocked” state for a specific Xbox Elite controller variant, aiming to prevent reconnect/disconnect issues across standby transitions.

Changes:

  • Unblocks a targeted Xbox Elite HID device during gamepad startup processing.
  • Blocks the same targeted device when entering standby/light-sleep in the SysDiag power-state callback.
  • Adds a new firmware/device-id constant used to identify the targeted controller variant.

Reviewed changes

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

File Description
src/ifce/btrMgr.c Adds block/unblock state updates around startup and standby transitions; adjusts recreated event fields.
include/btmgr.h Adds a constant for an additional Xbox Elite “default firmware/device id” value.

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

Comment thread src/ifce/btrMgr.c Outdated
Comment thread src/ifce/btrMgr.c Outdated
Comment thread src/ifce/btrMgr.c Outdated
Comment thread src/ifce/btrMgr.c Outdated
Comment thread src/ifce/btrMgr.c
Comment on lines 9482 to +9510
BTRMGRLOG_INFO("Entered standby mode, disconnecting gamepads\n");
gbGamepadStandbyMode = TRUE;
//stop any gamepads from connecting whilst in standby mode
BTRCore_clearLEActionListForGamepads(ghBTRCoreHdl);
//Disconnect all connected gamepads
lstConnectedDevices = malloc(sizeof(BTRMGR_ConnectedDevicesList_t));
if (!lstConnectedDevices)
{
BTRMGRLOG_ERROR("Run out memory for connected devices list\n");
return eBTRMgrFailure;
}
if ((lenBtrMgrResult = BTRMGR_GetConnectedDevices(0, lstConnectedDevices)) == BTRMGR_RESULT_SUCCESS) {
BTRMGRLOG_DEBUG ("Connected Devices = %d\n", lstConnectedDevices->m_numOfDevices);

for (ui16LoopIdx = 0; ui16LoopIdx < lstConnectedDevices->m_numOfDevices; ui16LoopIdx++) {
unsigned int ui32confirmIdx = 2;
enBTRCoreDeviceType lenBtrCoreDevTy = enBTRCoreUnknown;
enBTRCoreDeviceClass lenBtrCoreDevCl = enBTRCore_DC_Unknown;
stBTRCoreBTDevice stDeviceInfo = {0};

btrMgr_GetDeviceDetails(lstConnectedDevices->m_deviceProperty[ui16LoopIdx].m_deviceHandle,&stDeviceInfo);
if ((stDeviceInfo.enDeviceType == BTRMGR_DEVICE_TYPE_HID ||
stDeviceInfo.enDeviceType == BTRMGR_DEVICE_TYPE_HID_GAMEPAD) &&
(stDeviceInfo.ui16DevAppearanceBleSpec != BTRMGR_HID_GAMEPAD_LE_APPEARANCE) &&
(stDeviceInfo.ui32ModaliasVendorId == BTRMGR_XBOX_ELITE_VENDOR_ID) &&
(stDeviceInfo.ui32ModaliasProductId == BTRMGR_XBOX_ELITE_PRODUCT_ID) &&
(stDeviceInfo.ui32ModaliasDeviceId == BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2)) {
lenBtrCoreRet = btrCore_UpdateDeviceBlockState (ghBTRCoreHdl, stDeviceInfo.tDeviceId, stDeviceInfo.enDeviceType,1);
if (lenBtrCoreRet != enBTRCoreSuccess) {
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

New standby-mode behavior adds device blocking/unblocking for a specific controller variant, but existing unit tests for btrMgr_SDStatusCb only cover ON/OFF paths and do not exercise the standby/light-sleep branch or the btrCore_UpdateDeviceBlockState call. Please add/extend tests to cover entering standby (block + disconnect) and exiting standby (unblock on next startup/power-on) for both matching and non-matching devices.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 16:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
natrajmuthusamy and others added 2 commits March 23, 2026 22:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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/ifce/btrMgr.c Outdated
strncpy(stRecreatedEvent.deviceAddress, stDeviceInfo.pcDeviceAddress, BTRMGR_NAME_LEN_MAX - 1);
stRecreatedEvent.deviceId = stDeviceInfo.tDeviceId;
stRecreatedEvent.eDeviceClass = stDeviceInfo.enDeviceType;
stRecreatedEvent.eDeviceClass = stDeviceInfo.enDeviceClass;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

stRecreatedEvent.eDeviceClass is later consumed as an enBTRCoreDeviceClass (e.g., mapped via btrMgr_MapDeviceTypeFromCore(p_StatusCB->eDeviceClass) in btrMgr_MapDevstatusInfoToEventInfo). Assigning stDeviceInfo.ui32DevClassBtSpec here changes the meaning/type to a Bluetooth class-of-device bitfield, which will cause incorrect device-type mapping (likely UNKNOWN) for the recreated DEVICE_FOUND flow at startup. Set eDeviceClass back to the core device class (the same value previously used, i.e., stDeviceInfo.enDeviceType) and keep the BT-spec class in ui32DevClassBtSpec (already set elsewhere on the struct).

Suggested change
stRecreatedEvent.eDeviceClass = stDeviceInfo.enDeviceClass;
stRecreatedEvent.eDeviceClass = stDeviceInfo.enDeviceType;

Copilot uses AI. Check for mistakes.
Comment thread src/ifce/btrMgr.c
Comment on lines +9504 to +9511
if (btrMgr_GetDeviceDetails(lstConnectedDevices->m_deviceProperty[ui16LoopIdx].m_deviceHandle, &stDeviceInfo) != 0) {
BTRMGRLOG_ERROR ("btrMgr_GetDeviceDetails failed for device handle %llu\n",
lstConnectedDevices->m_deviceProperty[ui16LoopIdx].m_deviceHandle);
continue;
}
/* Map BTRCore device type to BTRMGR device type before comparison */
BTRMGR_DeviceType_t enMgrDevType = btrMgr_MapDeviceTypeFromCore(stDeviceInfo.enDeviceType);

Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

This standby-path block-state update likely never triggers: stDeviceInfo.enDeviceType is a core device class (it is mapped elsewhere via btrMgr_MapDeviceTypeFromCore(stDeviceInfo.enDeviceType)), but here it's compared directly against BTRMGR_DEVICE_TYPE_* values. Use the mapped BTRMGR device type (or compare against the corresponding core enum) to ensure the HID/gamepad check works.

Also, btrMgr_GetDeviceDetails(...) return value is ignored; on failure stDeviceInfo remains zeroed and the block/unblock logic silently skips. Check the return and log/continue on failure (as done in BTRMGR_ConnectGamepads_StartUp).

Copilot uses AI. Check for mistakes.
Comment thread src/ifce/btrMgr.c Outdated
Comment on lines +6133 to +6146
BTRMGR_DeviceType mappedDevType = btrMgr_MapDeviceTypeFromCore(stDeviceInfo.enDeviceType);

if ((mappedDevType == BTRMGR_DEVICE_TYPE_HID ||
mappedDevType == BTRMGR_DEVICE_TYPE_HID_GAMEPAD) &&
(stDeviceInfo.ui16DevAppearanceBleSpec != BTRMGR_HID_GAMEPAD_LE_APPEARANCE) &&
(stDeviceInfo.ui32ModaliasVendorId == BTRMGR_XBOX_ELITE_VENDOR_ID) &&
(stDeviceInfo.ui32ModaliasProductId == BTRMGR_XBOX_ELITE_PRODUCT_ID) &&
(stDeviceInfo.ui32ModaliasDeviceId == BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2)) {
lenBtrCoreRet = btrCore_UpdateDeviceBlockState(ghBTRCoreHdl,stDeviceInfo.tDeviceId,stDeviceInfo.enDeviceType,0);
if (lenBtrCoreRet != enBTRCoreSuccess) {
BTRMGRLOG_INFO("Failed to update the block state of the device ...\n");
} else {
BTRMGRLOG_INFO("Updated the block state of the device successfully ...\n");
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The Xbox Elite "classic" identification + block/unblock logic is duplicated in both the startup connect loop and the standby disconnect loop. Consider extracting a small helper (e.g., btrMgr_IsXboxEliteClassic(...) and/or btrMgr_UpdateBlockStateIfXboxEliteClassic(...)) to keep the device-match criteria consistent and reduce the risk of future divergence.

Copilot uses AI. Check for mistakes.
Comment thread include/btmgr.h
#define BTRMGR_NINTENDO_GAMESIR_VENDOR_ID 0x057E
#define BTRMGR_HID_GAMEPAD_LE_APPEARANCE 0x3C4
#define BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE 0x0407
#define BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2 0x0903
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2 doesn’t indicate what the value represents (it’s compared to ui32ModaliasDeviceId, which is typically a device/revision id rather than firmware). Consider renaming this macro to reflect the field it matches (e.g., ..._DEVICE_ID_0903 / ..._REVISION_0903) or adding a short comment describing what 0x0903 corresponds to, to avoid confusion with actual firmware versions.

Suggested change
#define BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2 0x0903
#define BTRMGR_XBOX_ELITE_DEFAULT_FIRMWARE2 0x0903 /* used as Xbox Elite modalias device/revision ID, not a firmware version */

Copilot uses AI. Check for mistakes.
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