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

TinyPilot WiFi access point scripts #1778

Merged
merged 20 commits into from
Apr 15, 2024
Merged

TinyPilot WiFi access point scripts #1778

merged 20 commits into from
Apr 15, 2024

Conversation

jdeanwallace
Copy link
Contributor

@jdeanwallace jdeanwallace commented Apr 10, 2024

Related #1711

This PR converts the individual code snippets from our blog post on how to host a WiFi access point on your TinyPilot device, into less intimidating scripts:

  • enable-wifi-ap
  • disable-wifi-ap

Notes:

  1. Most of the code is copy-pasted from the blog post with minor enhancements made.
  2. All the default settings have been preserved.

Review on CodeApprove

@jdeanwallace jdeanwallace changed the title TinyPilot Access Point scripts TinyPilot WiFi Access Point scripts Apr 10, 2024
@jdeanwallace jdeanwallace changed the title TinyPilot WiFi Access Point scripts TinyPilot WiFi access point scripts Apr 10, 2024
@jdeanwallace jdeanwallace marked this pull request as ready for review April 10, 2024 13:12
Copy link
Contributor Author

Automated comment from CodeApprove ➜

@jotaen4tinypilot please review this Pull Request

Copy link
Contributor

@mtlynch mtlynch left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 48
      ;;

We want defaults for SSID and country, but we should provide flags that allow the user to override them.


👀 @jdeanwallace, @jotaen4tinypilot it's your turn please take a look

Copy link
Contributor Author

@jdeanwallace jdeanwallace left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 55
      ;;

Oh right, I forgot about that. Thanks.


👀 @jotaen4tinypilot, @mtlynch it's your turn please take a look

Copy link
Contributor

@jotaen4tinypilot jotaen4tinypilot left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

In: Discussion
Could we add a little more commentary to the scripts? Especially for enable-wifi-ap, I think that might help to follow the structure and purpose of the code sections.


In: debian-pkg/opt/tinypilot-privileged/scripts/disable-wifi-ap:
Should we provide help output for this script as well?


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 31
  --ssid NETWORK_NAME         The network name. Defaults to: ${NETWORK_NAME}

Shall we say Optional. here at the beginning of the description text?


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:
Is the blank line after this comment on purpose? (ditto below)


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 82
# Validate command-line arguments.

Do we need to add a check here for the NETWORK_COUNTRY value? (E.g., whether it’s set, or whether it’s two letters.)


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 95
NETWORK_AP_IP_ADDRESS='192.168.50.1'

Is it possible to make these readonly?


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 106
"${SCRIPT_DIR}/strip-marker-sections" /etc/dhcpcd.conf

Would this clear any potential static IP setting that might be present in the config file? If so, would this be something we should account for in some way? (I’m thinking, in the most simple case, we could point it out in the help output or in a code comment, just to “document” that we have considered this case.)


👀 @jdeanwallace, @mtlynch it's your turn please take a look

Copy link
Contributor Author

@jdeanwallace jdeanwallace left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

In: Discussion
I'm actually not 100% sure what's going on in these scripts... but I can find out and add comments.


In: debian-pkg/opt/tinypilot-privileged/scripts/disable-wifi-ap:
Done.


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:
Done.


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:
Done.


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:
Yes it was, with the intention of it being a section divider (because the comment applies to the next several lines of code).

But if it sparks slight confusion, I would rather default to a normal comment instead. Fixed.


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 88
# Validate command-line arguments.

Done.


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 118
"${SCRIPT_DIR}/strip-marker-sections" /etc/dhcpcd.conf

Yes, that's correct. I've added a note to the help output. Thanks!


👀 @jotaen4tinypilot, @mtlynch it's your turn please take a look

Copy link
Contributor

@jotaen4tinypilot jotaen4tinypilot left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

⏳ Approval Pending (2 unresolved comments)
Approval will be granted automatically when all comments are resolved

Cool, this looks good. I also tested on device.


In: Discussion
Ah alright. I think it would be cool to eventually have more commentary in both scripts, to make it easier to understand what’s happening, and also to make them match our usual commenting style in bash scripts. Considering that the code was already there before, though, would it make sense to merge this PR as is for now, and to create a separate follow-up ticket where we loop in Dave to help us with adding good comments? (Dave appears to have written the FAQ page.)


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:

> Line 94
if [[ -z "${NETWORK_PASSWORD}" ]]; then

It seems that the hostapd service requires the WPA passphrase to be 8–63 characters in length, at least it appears to fail to restart otherwise: (from the systemd logs, after trying asdf as password)

tinypilot hostapd[2170]: Configuration file: /etc/hostapd/hostapd.conf
tinypilot hostapd[2170]: Line 10: invalid WPA passphrase length 4 (expected 8..63)

Shall we validate the password against this rule?


👀 @jdeanwallace, @mtlynch it's your turn please take a look

Copy link
Contributor Author

@jdeanwallace jdeanwallace left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

In: Discussion
Good idea! Tracking in #1784


In: debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi-ap:
Ah good catch, thanks.


👀 @mtlynch it's your turn please take a look

@jotaen4tinypilot jotaen4tinypilot dismissed their stale review April 12, 2024 14:37

Review approved on CodeApprove

@jotaen4tinypilot jotaen4tinypilot dismissed their stale review April 15, 2024 12:17

Review approved on CodeApprove

Copy link
Contributor

@jotaen4tinypilot jotaen4tinypilot left a comment

Choose a reason for hiding this comment

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

Automated comment from CodeApprove ➜

Approved: I have approved this change on CodeApprove and all of my comments have been resolved.

@mtlynch mtlynch dismissed their stale review April 15, 2024 12:17

Review approved on CodeApprove

@jdeanwallace jdeanwallace merged commit dcff0fe into master Apr 15, 2024
14 checks passed
@jdeanwallace jdeanwallace deleted the wifi-ap-script branch April 15, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants