From 28a5a8261318ef2970352ecf731ead44e4d5230b Mon Sep 17 00:00:00 2001 From: sommermorgentraum <24917424+zxkmm@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:24:01 +0800 Subject: [PATCH] linux permission guide (#67) * linux permission guide * import order try 1, idk if it's the case * remove {} * hide linux guide when not linux * fix li and remove bull * Remove console log --------- Co-authored-by: jLynx --- .gitignore | 5 +- src/components/SerialLoader/SerialLoader.tsx | 112 +++++++++++++------ 2 files changed, 84 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 24caa3f..3024496 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,7 @@ next-env.d.ts .wrangler # pnpm -pnpm-lock.yaml \ No newline at end of file +pnpm-lock.yaml + +# JetBrains +.idea \ No newline at end of file diff --git a/src/components/SerialLoader/SerialLoader.tsx b/src/components/SerialLoader/SerialLoader.tsx index e3d9ec8..427c333 100644 --- a/src/components/SerialLoader/SerialLoader.tsx +++ b/src/components/SerialLoader/SerialLoader.tsx @@ -6,6 +6,7 @@ import { useRef, useState, } from "react"; +import Modal from "../Modal/Modal"; import useWebSerial, { UseWebSerialReturn, } from "../SerialProvider/SerialProvider"; @@ -27,6 +28,8 @@ export const useSerial = () => useContext(SerialContext); const SerialLoader = ({ children }: PropsWithChildren) => { const pairButtonRef = useRef(null); const [consoleMessage, setConsoleMessage] = useState(); + const [isLinuxUserModalOpen, setIsLinuxUserModalOpen] = + useState(false); const serial: UseWebSerialReturn = useWebSerial({ onConnect: (data: any) => { @@ -42,6 +45,10 @@ const SerialLoader = ({ children }: PropsWithChildren) => { }, }); + const toggleLinuxUserModal = () => { + setIsLinuxUserModalOpen(!isLinuxUserModalOpen); + }; + const onPairButtonClick = async () => { // Can identify the vendor and product IDs by plugging in the device and visiting: chrome://device-log/ // the IDs will be labeled `vid` and `pid`, respectively @@ -83,40 +90,53 @@ const SerialLoader = ({ children }: PropsWithChildren) => { ); - const ConnectScreen = () => ( -
-
- {/*

Get Started

*/} - -

- Connect your HackRF/Portapack via USB to get started. -

- - -
- No device found or cannot connect? -
    -
  • - • Keep your PortaPack in normal mode (instead of HackRF mode) -
  • -
  • - • Make sure you are running at least stable v2.0.0, nightly - n_240114 or newer. -
  • -
+ const ConnectScreen = () => { + const isLinux = /linux/i.test(navigator.userAgent); + + return ( +
+
+

+ Connect your HackRF/Portapack via USB to get started. +

+ + +
+ No device found or cannot connect? +
    +
  • + Keep your PortaPack in normal mode (instead of HackRF mode) +
  • +
  • + Make sure you are running at least stable v2.0.0, nightly + n_240114 or newer. +
  • + {isLinux && ( +
  • + Linux user?{" "} + + Permission help + +
  • + )} +
+
-
- ); + ); + }; const TitleMessage = () => (
@@ -192,6 +212,34 @@ const SerialLoader = ({ children }: PropsWithChildren) => { {!serial.canUseSerial ? : } + +
+
    + Method 1: +
      +
    1. Plug in your PortaPack.
    2. +
    3. + Find the specific name of your Portapack device, it usually + is /dev/ttyUSBx or /dev/ttyACMx. +
    4. +
    5. + Run the following command: sudo chmod a+rw YOUR_DEVICE_NAME +
    6. +
    + Method 2: +
      +
    1. Plug in your PortaPack.
    2. +
    3. + Run the following command: sudo usermod -a -G dialout $USER +
    4. +
    +
+
+
)}