Skip to content

refactor: connection check & reconnection handling#36

Merged
zehnm merged 4 commits into
mainfrom
fix/28_lost-connection
Apr 1, 2024
Merged

refactor: connection check & reconnection handling#36
zehnm merged 4 commits into
mainfrom
fix/28_lost-connection

Conversation

@zehnm

@zehnm zehnm commented Mar 30, 2024

Copy link
Copy Markdown
Contributor

Improved Android TV device connection & reconnection logic with various fixes.

  • Check internal AndroidTV protocol state before sending a command.
  • Force a reconnect if the internal state indicates a broken connection.
  • Use a decorator to handle connection check and error handling.
  • Handle auth errors and allow to pair again in the setup flow.
    • Devices with auth error are prefixes with "!" in the device dropdown.
  • Increase connection timeout to 10 seconds.

Fixes #28

Other fixes:

- Check internal AndroidTV protocol state before sending a command.
- Force a reconnect if the internal state indicates a broken connection.
- Use a decorator to handle connection check and error handling.
- Handle auth errors and allow to pair again in the setup flow.
  - Devices with auth error are prefixes with ! in the device dropdown.
- Increase connection timeout to 10 seconds.
@zehnm zehnm force-pushed the fix/28_lost-connection branch from af3c2db to b9e6d9e Compare March 31, 2024 23:03
Centralize certificate handling and migration in Devices configuration
class.
Introduce more device states and error checks.

Fixes #37
@zehnm zehnm self-assigned this Apr 1, 2024
@zehnm zehnm marked this pull request as ready for review April 1, 2024 12:58
zehnm added 2 commits April 1, 2024 15:12
If a device requires pairing, the setup flow creates a new client
certificate and reconnects the configured device.
The same Android TV device can only be controlled by multiple clients if
their client name is different. Otherwise, the old client certificate is
no longer valid and only the last paired client can control the device!

Instead of using a hardcoded client name, use the hostname with an
optional override with ENV variable `UC_CLIENT_NAME`.

Fixes #39
@zehnm zehnm force-pushed the fix/28_lost-connection branch from 53f7d23 to be38d8b Compare April 1, 2024 13:16

@zehnm zehnm left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tested with Google Chromecast HD and NVIDIA Shield 2017 & 2019

@zehnm zehnm merged commit 1e6e3f2 into main Apr 1, 2024
@zehnm zehnm deleted the fix/28_lost-connection branch April 1, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant