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

Add new commands to support watching for port changes #904

Open
Xayton opened this issue Feb 23, 2024 · 0 comments
Open

Add new commands to support watching for port changes #904

Xayton opened this issue Feb 23, 2024 · 0 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@Xayton
Copy link
Contributor

Xayton commented Feb 23, 2024

Current problem

The front-end applications using the Agent, for example the Cloud Editor, have no way to be notified when a new board is connected (or in general when there are "port changes"). So the way it's done now is by polling: sending a LIST command every N seconds.

This is both inefficient (a lot of useless LIST commands) and slow (the user has to wait up to N seconds before they see the board they have just connected). It would be nice if the front-end could receive a notification when a new board is connected, without polling.

Describe the request

New commands:

  • startwatchports: starts watching and returns multiple add events (corresponding to all the known ports at that time)
  • stopwatchports

When the WebSocket connection is closed by the client, the agent will automatically stop sending events and eventually stop watching for port changes (this is an internal implementation detail).

At the start of the communication, the watch functionality is stopped, and has to be started manually with a startwatchports.

If the agent is already sending watchport events, a startwatchports will not do anything. Same for the other way around with stopwatchports.

Result message:

{
  "message_type": "watchportevent"
  "message_data": 
  {
    "eventType": "add",
    "port": {
      "address": "/dev/ttyACM0",
      "label": "/dev/ttyACM0",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x0070",
        "serialNumber": "3485187AA318",
        "vid": "0x2341"
      },
      "hardware_id": "3485187AA318"
    }
  }
}

Note: multiple port additions or removals would be sent using multiple watchportevent messages.

Describe the current behavior

Currently the Agent does not support watch functionality.

@Xayton Xayton added the type: enhancement Proposed improvement label Feb 23, 2024
@per1234 per1234 added the topic: code Related to content of the project itself label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants