https://dietpi.com/ | https://dietpi.com/phpbb/viewtopic.php?p=9#p9
───────────────────────────────────────────────────── DietPi v6.28.0 : 12:46 - Sa 18.01.2020 ───────────────────────────────────────────────────── - Device model : RPi Zero (armv6l) - CPU temp : 36'C : 96'F (Cool runnings) - LAN IP : 192.168.10.30 (eth0) ───────────────────────────────────────────────────── DietPi Team : MichaIng (lead), Daniel Knight (founder) Image : DietPi Core Team (pre-image: Raspbian Lite) Web : https://DietPi.com | https://twitter.com/dietpi_ Patreon Legends : PINE64 community | oct8l Donate : https://DietPi.com/#donate DietPi Hosting : Powered by https://MyVirtualServer.com dietpi-launcher : All the DietPi programs in one place. dietpi-config : Feature rich configuration tool for your device. dietpi-software : Select optimized software for installation. htop : Resource monitor. cpu : Shows CPU information and stats.Execute dietpi-launcher8 : Network Options: MiscNo-IP : [[Not Installed] Install No-IP now]New configuration file '/usr/local/etc/no-ip2.conf' created. lsusbBus 001 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet AdapterBus 001 Device 003: ID 05c6:1000 Qualcomm, Inc. Mass Storage DeviceBus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. HubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubsudo apt-get install ppp usb-modeswitch wvdialCreated symlink /etc/systemd/system/multi-user.target.wants/pppd-dns.service → /lib/systemd/system/pppd-dns.service.You can retry the autodetection at any time by running "wvdialconf". (Or you can create /etc/wvdial.conf yourself.)We need to get the codes of the USB device in USB storage mode and USB modem mode.
Connect your USB modem and reboot the Raspberry PI without LAN or Wifi connection
Once rebooted open a terminal window and enter:
lsusbBus 001 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet AdapterBus 001 Device 003: ID 05c6:1000 Qualcomm, Inc. Mass Storage DeviceBus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. HubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub05c6:1000sudo usb_modeswitch -W -v 05c6 -p 1000 -KTake all parameters from the command line * usb_modeswitch: handle USB devices with multiple modes * Version 2.5.2 (C) Josua Dietze 2017 * Based on libusb1/libusbx ! PLEASE REPORT NEW CONFIGURATIONS !DefaultVendor= 0x05c6DefaultProduct= 0x1000StandardEject=1Look for default devices ... found USB ID 0bda:8153 found USB ID 05c6:1000 vendor ID matched product ID matched found USB ID 1a40:0101 found USB ID 1d6b:0002 Found devices in default mode (1)Access device 003 on bus 001Get the current device configuration ...Current configuration number is 1Use interface number 0 with class 8Use endpoints 0x01 (out) and 0x81 (in)USB description data (for identification)-------------------------Manufacturer: USBModem Product: HSPA Data Card Serial No.: 1234567890ABCDEF-------------------------Sending standard EJECT sequenceLooking for active drivers ... OK, driver detachedSet up interface 0Use endpoint 0x01 for message sending ...Trying to send message 1 to endpoint 0x01 ... OK, message successfully sentRead the response to message 1 (CSW) ... Response successfully read (13 bytes), status 0Trying to send message 2 to endpoint 0x01 ... OK, message successfully sentRead the response to message 2 (CSW) ... Response successfully read (13 bytes), status 0Trying to send message 3 to endpoint 0x01 ... OK, message successfully sentRead the response to message 3 (CSW) ... Response successfully read (13 bytes), status 0Trying to send message 4 to endpoint 0x01 ... OK, message successfully sentRead the response to message 4 (CSW) ... Response successfully read (13 bytes), status 1Reset response endpoint 0x81Reset message endpoint 0x01-> Run lsusb to note any changes. Bye!lsusbBus 001 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet AdapterBus 001 Device 005: ID 05c6:6000 Qualcomm, Inc. Siemens SG75Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. HubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubCreate a rule
nano /etc/udev/rules.d/05c6\:1000.rulesPut the following line into the empty file; It says if you see this USB device with these properties run the command we used above to switch modes from USB to 3G Modem:
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="1000", RUN+="/usr/sbin/usb_modeswitch -W -v 05c6 -p 1000 -K"Save the file and reboot.
Subsequent hot plugs should see the device attached as a USB 3G modem
wvdial 3gA simple solution to this is CRON that runs the following script:
If WVDIAL is not running: Run WVDIAL 3gThe USB GSM modem does not always work properly. Sometimes it gets stuck. Sometimes on boot, usb_modswitch seems to just not get fired.
Create script
sudo nano
#! /bin/sh # /usr/sbin/resetdevicebyauthorizedecho "Searching for $1"devPath=`lsusb | grep $1 | sed -r 's/Bus ([0-9]{3}) Device ([0-9]{3}).*/bus\/usb\/\1\/\2/g;'`Bus 001 Device 007: ID 05c6:6000 Qualcomm, Inc. Siemens SG75echo "Found $1 @ $devPath"echo "Searching for sysPath"for sysPath in /sys/bus/usb/devices/*; do echo "$sysPath/uevent" devName=`cat "$sysPath/uevent" | grep $devPath` #echo devName=$devName if [ ! -z $devName ] then break fidoneif [ ! -z $devName ] then echo "Found $1 @ $sysPath, Resetting" echo "echo 0 > $sysPath/authorized" echo 0 > $sysPath/authorized echo "echo 1 > $sysPath/authorized" echo 1 > $sysPath/authorizedelse echo "Could not find $1"fiI want to change the script to be this:
If /dev/ttyUSB0 is not present: If DevicePresent(12d1:1446): ResetDevice(12d1:1446) ElseIs DevicePresemt(12d1:1506) ResetUSB(12d1:1506)If WVDIAL is not running: Run WVDIALlsusbObviously this is pseudo code, but I have the following lines that I need to string together but I can't figure out how:
This loads wvdial if it is not running:
#! /bin/sh # /etc/init.d/wvdial### BEGIN INIT INFO# Provides: TheInternet# Required-Start: $remote_fs $syslog# Required-Stop: $remote_fs $syslog# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: Simple script to start a program at boot# Description: A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.### END INIT INFO# If you want a command to always run, put it here# Carry out specific functions when asked to by the systemcase "$1" in start) echo "Starting GPRS Internet" # run application you want to start /sbin/start-stop-daemon --start --background --quiet --exec /usr/bin/wvdial internet ;; stop) echo "Stopping GPRS Internet" # kill application you want to stop /sbin/start-stop-daemon --stop --exec /usr/bin/wvdial ;; *) echo "Usage: /etc/init.d/noip {start|stop}" exit 1 ;;esacexit 0This lets me find the /sys path to a certain device:
for X in /sys/bus/usb/devices/*; do echo "$X" cat "$X/idVendor" 2>/dev/null cat "$X/idProduct" 2>/dev/null echodoneAnd this resets a USB device if you know the correct /sys path:
echo 0 > /sys/bus/usb/devices/1-1.2.1.1/authorizedecho 1 > /sys/bus/usb/devices/1-1.2.1.1/authorizedSo, I need to string the last 2 sections and a test to /dev/ttyUSB0 into a section that goes under the "If you want a command to always run. put it here" section
UPDATE 1
usbreset, although functioning, does not do the job. Only echo 0 the 1 into authroized correctly simulates a device disconnect/reconnect.
This is what does the trick of booting the device or usb_modeswitch back into life. As such I've managed to cobble together this:
echo "Searching for $1"devPath=`lsusb | grep $1 | sed -r 's/Bus ([0-9]{3}) Device ([0-9]{3}).*/bus\/usb\/\1\/\2/g;'`echo "Found $1 @ $devPath"echo "Searching for sysPath"for sysPath in /sys/bus/usb/devices/*; do echo "$sysPath/uevent" devName=`cat "$sysPath/uevent" | grep $devPath` #echo devName=$devName if [ ! -z $devName ] then break fidoneif [ ! -z $devName ] then echo "Found $1 @ $sysPath, Resetting" echo "echo 0 > $sysPath/authorized" echo 0 > $sysPath/authorized echo "echo 1 > $sysPath/authorized" echo 1 > $sysPath/authorizedelse echo "Could not find $1"fiI think therefore all I have to do now is put this in the init.d script:
if ttyUSB0 not present if 12d1:1446 present /usr/sbin/resetdevicebyauthorized 12d1:1446 else if 12d1:1506 present /usr/sbin/resetdevicebyauthorized 12d1:1506 fifiEver wanted to analyze the boot process? => "systemd-analyze -h"sudo chmod +x hello-world.sh