Best option for Ubuntu 20 CORE snap design, USB or I2C hardware?

We’re starting a new dev feature using our CORE snap on Ubuntu 20 LTS CORE. We are wanting to create a plug-n-play hardware ability for our snap to use either use I2C on a Raspberry p4 GPIO pins when external hardware is plugged into our device or use native USB with opens a serial port to communicate to our devices when plugged in.

I see there are issues with the security of CORE saps being locked down and this looks to be difficult. Does anyone have experience doing this and which option would be best for us to use for ease of programming design and allows us the ability to have our customers plugin as many external devices possible where we can auto-detect it in our software snap?

snaps have interfaces that you can connect to access certain bits of the system … for a snap that monitors plug events you can use the hardware-observe interface and ship the udevadm tool in your snap through the stage-packages option. you can then write a script to run something like udevadm monitor as a daemon in your snap and make it do things based on the output of the monitoring command (send messages on plug events, filter by hardware type, run an app for certain device types etc etc)

Hey Orga, thank you so much for the response and ideas on how to do this.

Would you say it’s easier talking to USB on core with snap, or would using I2C protocol be easier so we’re not having to look for serial ports opening and usb events?