Skip to content

Conversation

@mirkoCrobu
Copy link
Contributor

Motivation

A board connected via both USB and Network currently shows up as two separate devices in the board list. This makes it difficult for a client application to know it is the same physical board.

We need a way to "deduplicate" these entries by providing a common identifier, allowing the client to show just one entry for that board.

Change description

A simple approach is to add the board's serial number to its Avahi service file. This change will be made at runtime when the EnableNetworkMode function is executed.

Specifically, we will add a new containing the serial number (e.g., serial_number=YOUR_SERIAL) to the board's .service file.

Additional Notes

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@mirkoCrobu mirkoCrobu requested review from a team and lucarin91 November 5, 2025 16:14
@mirkoCrobu mirkoCrobu self-assigned this Nov 6, 2025
Copy link
Contributor

@lucarin91 lucarin91 left a comment

Choose a reason for hiding this comment

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

I didn't figure out that we needed to add another sudoers file for this feature, which I would avoid to do it. So I think we should change the approach here, and we could instead do that in a systemd unit that is triggered only on the first boot, e.g., https://github.com/arduino/arduino-app-cli/blob/main/debian/arduino-app-cli/etc/systemd/system/arduino-burn-bootloader.service.
The Serial number of the board should not change, so we can do it just the first time you flash the board, and in there, you have all the permission to patch the Avahi service.

@mirkoCrobu
Copy link
Contributor Author

How to test it

  1. Create the .deb and push it into the board
    On the board
  2. Be sure that /etc/avahi/services/arduino.service doesn't contain the serial number
  3. Reboot the board
  4. Check /etc/avahi/services/arduino.service: now you should see the serial number
  5. Check that the .flag file exists: ls -l /var/lib/arduino/avahi_serial_configured.flag
  6. Check the service status (should be active (exited)): systemctl status arduino-avahi-serial.service
  7. Enable network mode: arduino-app-cli system network-mode enable
    From your PC
  8. Check the board list configs(you should the network information with serial number:
    ): arduino-cli board list --json

@mirkoCrobu mirkoCrobu requested a review from lucarin91 November 7, 2025 14:27
Copy link
Contributor

@lucarin91 lucarin91 left a comment

Choose a reason for hiding this comment

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

I would also add the disable command in postrm as for the other services

Copy link
Contributor

@lucarin91 lucarin91 left a comment

Choose a reason for hiding this comment

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

LGTM, I would improve a little bit the schell script

Copy link
Contributor

@lucarin91 lucarin91 left a comment

Choose a reason for hiding this comment

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

@mirkoCrobu I think you need to update rebase main, I see changes not related to this PR

@mirkoCrobu
Copy link
Contributor Author

@lucarin91 I had to change a commit author already includedd in main to pass license/cla.
Let me check if I can fix it

Copy link
Contributor

@lucarin91 lucarin91 left a comment

Choose a reason for hiding this comment

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

I think it is safe to always return errors

@mirkoCrobu mirkoCrobu requested a review from lucarin91 November 11, 2025 10:54
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