tinypilot icon indicating copy to clipboard operation
tinypilot copied to clipboard

WiFi dialog: add backend endpoints and logic

Open jotaen4tinypilot opened this issue 7 months ago • 2 comments

Related https://github.com/tiny-pilot/tinypilot/issues/131, part (c). Stacked on https://github.com/tiny-pilot/tinypilot/pull/1811.

This PR adds the backend logic and endpoints that we need for the WiFi dialog.

  • There are endpoints for reading, writing, and deleting the WiFi configuration. There is also one endpoint for checking the status of the network connectivity, which allows us to display warnings or status indicators in the frontend.
  • As mentioned in the code comment, we cannot read the wpa_supplicant.conf file directly due to file ownership. Therefore, we use the new print-marker-sections privileged script from the previous PR.
  • The scripts for enabling and disabling are executed in a “fire and forget” manner, otherwise it may happen that the frontend requests hang due to e.g. a change/interruption in the network (which would result in an eternal loading spinner). As we only write a config file and trigger service/daemon restarts, we wouldn’t get direct feedback about errors anyway, but we’d have to poll for the resulting status, which can take quite long, though.
    • Note that we also can’t really verify the WiFi credentials, because the desired WiFi might not be reachable at the time where the user wants to enter the settings (e.g., because they want to enter the config ahead of time).
  • The validation of the incoming request data is relatively important, because we will show the error messages in the frontend for input validation. So we need to make sure that we detect all relevant potential issues. The validation errors would be user-facing.

This PR can probably be tested best via the subsequent frontend PR – that one isn’t 100% code-complete yet, but it’s pretty close in terms of functionality. Review on CodeApprove

jotaen4tinypilot avatar Jul 01 '24 21:07 jotaen4tinypilot