Skip to content

Unblock device status callback with threaded authentication#71

Draft
Copilot wants to merge 6 commits intodevelopfrom
copilot/run-incoming-connection-authentication
Draft

Unblock device status callback with threaded authentication#71
Copilot wants to merge 6 commits intodevelopfrom
copilot/run-incoming-connection-authentication

Conversation

Copy link

Copilot AI commented Feb 19, 2026

btrMgr_IncomingConnectionAuthentication blocks the device status callback for up to 20 seconds polling for UI response. This delays processing of subsequent device events.

Changes

Threading infrastructure

  • Added thread context structure btrMgr_AuthThreadContext_t to safely pass device status info
  • Implemented btrMgr_IncomingConnectionAuthenticationAsync() spawning detached pthread
  • Thread handles authentication and cleanup, disconnects device on auth failure

Updated call sites
Replaced synchronous calls in btrMgr_DeviceStatusCb with async version at:

  • AUTO_CONNECT_ENABLED path for LE HID gamepads (Lost/Paired → Connected)
  • Disconnected → Connected transition
  • Connecting → Connected transition

Kept synchronous call in BTRMGR_ConnectGamepads_StartUp (initialization context, not a callback).

Example

Before:

int auth = 0;
btrMgr_IncomingConnectionAuthentication(p_StatusCB, &auth);
if (!auth)
    break;
// Callback blocked for up to 20s

After:

btrMgr_IncomingConnectionAuthenticationAsync(p_StatusCB);
// Callback returns immediately, auth happens in background thread
break;

Deliverable

Patch file: btrMgr_IncomingConnectionAuthentication_threading.patch


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 19, 2026 13:01
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Co-authored-by: natrajmuthusamy <52849136+natrajmuthusamy@users.noreply.github.com>
Copilot AI changed the title [WIP] Run btrMgr_IncomingConnectionAuthentication in a separate thread Unblock device status callback with threaded authentication Feb 19, 2026
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.

2 participants