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 dialout permissions instructions to no-port #427

Merged
merged 4 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/no-port-picked/no-port-picked-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { customElement } from "lit/decorators.js";
import "../components/ewt-dialog";
import "../components/ewt-button";
import { dialogStyles } from "../styles";
import { getOperatingSystem } from "../util/get-operating-system";

const cloudDownload = svg`
<svg
Expand Down Expand Up @@ -30,6 +31,8 @@ class EwtNoPortPickedDialog extends LitElement {
public doTryAgain?: () => void;

public render() {
const OS = getOperatingSystem();

return html`
<ewt-dialog
open
Expand All @@ -54,6 +57,20 @@ class EwtNoPortPickedDialog extends LitElement {
Make sure that the USB cable you use can be used for data and is not
a power-only cable.
</li>
${OS === "Linux"
? html`
<li>
If you are using a Linux flavor, make sure that your user is
part of the <code>dialout</code> group so it has permission to
access the device.
<code class="block"
>sudo usermod -a -G dialout YourUserName</code
>
You may need to log out & back in or reboot to activate the
new group access.
</li>
`
: ""}
<li>
Make sure you have the right drivers installed. Below are the
drivers for common chips used in ESP devices:
Expand Down Expand Up @@ -147,6 +164,10 @@ class EwtNoPortPickedDialog extends LitElement {
margin-bottom: 0;
padding-left: 1.5em;
}
li code.block {
display: block;
margin: 0.5em 0;
}
`,
];
}
Expand Down
24 changes: 24 additions & 0 deletions src/util/get-operating-system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// From https://stackoverflow.com/a/38241481
export const getOperatingSystem = () => {
const userAgent = window.navigator.userAgent;
const platform =
// @ts-expect-error
window.navigator?.userAgentData?.platform || window.navigator.platform;
const macosPlatforms = ["macOS", "Macintosh", "MacIntel", "MacPPC", "Mac68K"];
const windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"];
const iosPlatforms = ["iPhone", "iPad", "iPod"];

if (macosPlatforms.indexOf(platform) !== -1) {
return "Mac OS";
} else if (iosPlatforms.indexOf(platform) !== -1) {
return "iOS";
} else if (windowsPlatforms.indexOf(platform) !== -1) {
return "Windows";
} else if (/Android/.test(userAgent)) {
return "Android";
} else if (/Linux/.test(platform)) {
return "Linux";
}

return null;
};