3

So i live in an area that doesn't have fiber but has decent 4G/LTE connection. The problem is we have one service with unlimited data between 11pm and 6pm the following day and another service thats pre-paid. I want to connect both dongles to my pi and have the pi connected via ehternet to a router. At a specific time I want one dongle to be disabled and have the other one enabled and vice versa. Is it possible to do this? I know I can route the 4g connection through my wifi router via wan, but can I disable one then enable the other after 6pm and after 11pm?

Thanks

  • How do you establish the 4G/LTE connection? Is there a service like sudo systemctl start wan-connection.service? Or does it start on boot up? How? – Ingo Nov 20 '19 at 10:40
  • Well I havent gotten my dongle just yet. Im currently using a samsung tablet to do it and with this I have to enable the hotspot everytime I want to connect to the internet – Zayd Bhyat Nov 20 '19 at 23:56
1

Find out the bus number and the device number of each dongle using lsusb:

$lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 003: ID 7392:7811 Wireless Adapter [Realtek RTL8188CUS]

Then schedule a cron job enabling and disabling the dongles with

# turn off bus 1 device 1
echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind
# turn on bus 1 device 2
echo '1-2' | sudo tee /sys/bus/usb/drivers/usb/bind
| improve this answer | |
  • Ok thanks. I will probably have to set cron jobs to connect the device after its switched on too correct? When I say connect I mean to establish a connection via the sim card – Zayd Bhyat Nov 19 '19 at 18:05
  • @ZaydBhyat Probably, yes. I don't own such a modem so I don't know what exactly it takes to connect. – Dmitry Grigoryev Nov 25 '19 at 7:50
  • Righto so i got my dongle connected and it seems to power on and connect automatically as soon as its plugged in. The command you gave me seems to kills all the usb devices, echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind. When I try: echo '1-5' | sudo tee /sys/bus/usb/drivers/usb/unbind, it says no device found. Do i need to specify which usb device to switch off somewhere in the tee command? EG tee /sys/bus/usb/drivers/usb5/unbind – Zayd Bhyat Nov 26 '19 at 10:38
  • Ok so I see that it does disable all the usb ports and then when the command is back it switches them all on. So it looks like i need another solution – Zayd Bhyat Nov 26 '19 at 10:49
  • @ZaydBhyat Perhaps. Just wanted to mention that that's exactly what would happen if you disable the root hub, so make sure you didn't do that. – Dmitry Grigoryev Nov 26 '19 at 11:46
0

So it seems as though I cant find a way to disable individual usb ports. Another problem is changing the ethernet interface that connects to the internet. My solution: Getting a router that can use a dongle backup. The pi is connected to the WAN of the router with the primary dongle plugged into it. A second dongle is connected to the router directly, this is the backup dongle and only runs when the primary dongle stops functioning. This is the best solution until I find a better way.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.