Using usb_modeswitch to enable 4G usb modem


#1

Hey,

for the last hours I’m trying to get a Huawei e3131 usb modem up and running on our container. We are using RPi3 as a hardware platform and running the resin/raspberrypi3-node base image.

With usb_modeswitch we were able to get the modem up and running on the RPi with a default Raspbian - no docker, no resinOS.

Back on our resin.io container, usb_modeswitch is working and showing the same results with lsusb. But the modem itself is not connecting to a cellular network. This is not happening on the default Raspbian.

I thing the problem is that the modem’s mode is not switched on the host OS itself or is now in an inconsistent state.

Is there a possibility to run the usb_modeswitch command on the host OS?

Cheers,

Matt


#2

I know @shaunmulligan had a lot more experience with 4G modems. I think it’s easier on resinOS 2.x, which uses NetworkManager (as opposed to Connman on resinOS 1.x) To test it out, create an account on our beta site, http://dashboard.resinstaging.io, start a new application, download the latest Resin OS 2.0.0-beta.7 image. Now to add your cellular connection info you need to mount the resin-boot partition and add in a simple network configuration file in system-connection/ directory, for example system-connection/resin-cellular In the file drop in the following, changing the APN, password, etc for your GSM provider (this below is just on example for one particular provicer we’ve tested):

[connection]
id=giffgaff Mobile Broadband
uuid=3b8f359e-4df2-4997-99d8-04e15742d38f
type=gsm
autoconnect=true
permissions=
secondaries=

[gsm]
apn=giffgaff.com
number=*99#
password=password
username=giffgaff

[serial]
baud=115200

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore

The current docs on cellular modems unfortunately still link to an old blogpost and a repo (that actually used usb_modeswitch, etc), but should not use that anymore, as noted in the blogpost too. Would highly recommend the resinOS 2.x approach. It is still in beta, but should be coming soon to the production service.

Let us know if this helps!


#3

Hi @matt and @imrehg .
I haven’t messed around with many modems that require the usb_modeswitch. However I know one or two of the other users in the gitter.im chat. Unfortunately I can’t find the reference for the conversation right now because it appears gitter.im is having major outages :angry: , but I will come back and update here when I finally am allowed to find it. Failing that, I will try find the users that had it working and ask them to comment here.


#4

Looks like someone tried the Huawei E3531i-2 modem that uses modeswitch and it works, though no specific details in that chat. Let’s see if they have more info, asked them on chat. :thought_balloon:


#5

Hi @imrehg @shaunmulligan thanks for your quick reply! Always a pleasure to ask the community here.

I tried several other Huawei sticks this night. They work on default Raspbian, but not in the docker container.

The behavior when the modem is used on a default Raspbian:

  • usb_modeswitch
  • Modem is switching mode to ppp
  • The indicator led is blinking blue and found a cellular network automatically
  • All working fine with sakis3g or wvdial or pppd

Behavior in the docker container:

  • usb_modeswitch
  • Modem is switching mode to ppp
  • Light is stuck in green blinking which indicates that there is no cellular network available
  • Wvdial or sakis3g connect the modem but there is no network found

When I switch mode in the docker container, I get some errors from usblib which could be the reason the modem is not reaching network connectivity.

I’ll keep up on that and report the state here.

Thanks for your help

Matt


#6

Thanks for keeping us informed of where you’re up to Matt.
We’ll continue our efforts to access prior community wisdom, and once the new week begins I’ll reach out to others on our team.


#7

From experience on my end, wvdial won’t work inside a container, this is because the container cannot access all ppp functions.

The best way to connect with a 3G/4G dialup based modem is to use ResinOS 2 together with a GSM configuration, here’s an example of working network configuration on my end:

[connection]
id=Soracom
type=gsm

[gsm]
apn=soracom.io
number=99**1#
password-flags=1

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

PS: ResinOS 2 automatically takes care of usb_modeswitch so no need to worry about it.
PS2: Otherwise, you can use a Huawei “HiLink” based modem which exposes a USB Ethernet interaface after usb_modeswitch > Which works in Resin OS 1 / containers


#8

Ok, here we go again.

I managed to get the Huawei E3131 running with sakis3g and wvdial. The trick was to use usb_modeswitch with the following mode ID:

sudo usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 1506 -M “55534243123456780000000000000011060000000000000000000000000000”

The modem is now switched to:

Bus 001 Device 005: ID 12d1:1c05 Huawei Technologies Co., Ltd. E173s 3G broadband stick (modem on)

It is up and running for the last 24h hours without any problems.

@eblex I think for the future we will run the modem with your solutions and the brand new resinOS 2 with NetworkManager

Thank you all for your great help! If someone is in trouble to get his modem running, just ask me.

Cheers,

Matt


#9

@matt That’s great, looking like a good solution

Could you post your Sakis3G install script and wvdial configuration?
Will be sure to try that out with other modems on Resin OS 1


#10

Hey @eblex,

sorry for the late reply. I primary use sakis3g to start and stop the connection. Here are the configurations:

sudo ./sakis3g/sakis3g connect --sudo --console --pppd USBINTERFACE=“1” OTHER=“USBMODEM” USBMODEM=“12d1:1506” APN=“CUSTOM_APN” CUSTOM_APN=“m2m-net.sa.t-mobile” APN_USER=“0” APN_PASS=“0”

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800

[Dialer provider]
Phone = 99**1#
Stupid Mode = 1
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,“IP”,“m2m-net.sa.t-mobile”

As mentioned above, wvdial is working but sakis3g is a bit more handy to configure on new devices.


#11

Hi folks,

I have been able to get a 4G USB Cellular Dongle from Verizon to work with resin 1.24 on rpi2. I am using this dongle (https://www.verizonwireless.com/internet-devices/verizon-mifi-4g-lte-global-usb-modem-u620l/). Verizon has a guide for how to connect on linux. I just followed it and it was up and running (https://www.verizonwireless.com/dam/support/pdf/user_guide/u620-linux-integration-guide-7-17-15.pdf). I was surprised that it worked.

i will try it with resinOS 2 and see if it still works.

Happy to help and join the resin community,
Sid


#12

Got some news from our lab here:

We now use the Huawei HiLink mode to enable a constant connection via 3G/4G. We use the Huawei E3372 wich provides antenna outputs and 4G ability.

To set the modem to HiLink we use this usb_modeswitch command:

usb_modeswitch -v 0x12d1 -p 0x15ca -V 0x12d1 -P 0x14dc -M “55534243123456780000000000000011063000000100010000000000000000”

Hope this helps

Cheers,

Matt


#13

did it work with resinOS 2?