diff --git a/assets/notes/notes.md b/assets/notes/notes.md index 977af73..0c434a9 100644 --- a/assets/notes/notes.md +++ b/assets/notes/notes.md @@ -1,6 +1,6 @@ # Notes ## To Do -1. [ ] define actions and plan +1. [x] define actions and plan 2. [ ] create simple web interface with flask and nginx 3. [ ] communicate with Meshtastic device via web interface @@ -18,4 +18,25 @@ ### Backend - Environment setup script in development -### Frontend \ No newline at end of file +### Frontend + +### Thoughts +- Play with usbip + +To establish a connection between a website and a USB device connected to a Linux server, you cannot directly connect a web application to a USB device over a network using standard web protocols. However, you can achieve this functionality by creating a bridge between the web application and the USB device using a local service on the Linux server. Here’s how: + +1. Use USB/IP to Share the USB Device Over the Network: The USB/IP project allows you to share a physical USB device connected to a Linux server over a TCP/IP network, making it appear as a local USB device on a client machine. This is the most direct method for network access. + - On the Server (where the USB device is physically connected): + - Install the usbip package. + - Load the required kernel modules: usbip_core and usbip_host by creating a `.conf` file in `/etc/modules-load.d/` and adding the modules. + - Start and enable the usbipd.service daemon. + - List the available USB devices using usbip list -l to find the device's bus ID. + - Bind the specific USB device to the USB/IP service using usbip bind -b . This makes the device available for remote access. + - On the Client (the machine running the web application): + - Ensure the vhci_hcd kernel module is loaded. + - List the available devices from the server using usbip list -r . + - Attach the device to the client using usbip attach -r -b . Once attached, the device will appear as a local USB device on the client machine. +2. Integrate the Attached Device with Your Web Application: Once the USB device is attached to the client machine via USB/IP, it will be accessible to any software running on that machine, including a web application. The web application can then communicate with the device using standard USB communication libraries (e.g., libusb for C/C++, pyusb for Python) just as if the device were directly connected to the client machine. The web server (e.g., Apache, Nginx) and the application framework (e.g., Node.js, Django) on the client machine handle the web interface, while the application code uses the local USB device. +3. Alternative: Use a Local Service (e.g., a Web API): Instead of attaching the device to the web server machine, you can create a separate local service (a daemon or a small application) on the server that communicates directly with the USB device. This service can then expose a simple HTTP API (e.g., using a lightweight framework like Flask or Express) that the web application can call to send commands to or receive data from the USB device. This approach keeps the USB device connection confined to the server and uses standard web protocols for communication. + +In summary, the most practical approach is to use USB/IP to make the USB device appear as a local device on the machine hosting the web application, allowing the application to interact with it directly through standard USB libraries. \ No newline at end of file diff --git a/dev_env_setup.sh b/dev_env_setup.sh index 15a5c1a..9dee2be 100755 --- a/dev_env_setup.sh +++ b/dev_env_setup.sh @@ -173,16 +173,15 @@ done sudo mv /var/www/html/index.* /var/www/html/index.html sudo nginx -t -sudo systemctl restart NetworkManager sudo nginx -s reload ###### STATUS - +echo -e "\n ${LGN}Mandatory packages have been installed ${LCY}$cert_name.crt ${GRN}and ${LCY}$cert_name.key ${GRN}created and stored in ${LCY}$cert_path${CRS}\n" ### DEV STATUS -echo -e "\n ${LGN}Script ran through...${CRS}" +#echo -e "\n ${LGN}Script ran through...${CRS}" ###### JEFF ###### #