How to auto connect to network by MC7304 in Linux

Hi guys,
I want to auto connect to network. I understand that can use “–wds-set-autoconnect-settings”, but this need set

/sys/class/net/wwan0/qmi/raw_ip

to Y before start network.

I hope can either default data format to 802-3 or auto set “/sys/class/net/wwan0/qmi/raw_ip”.

I tried to use networking to pre-up wwan0 set “/sys/class/net/wwan0/qmi/raw_ip” when hot plugging, but this not work when hot plugging.

auto lo
iface lo inet loopback



allow-hotplug wwan0
iface wwan0 inet dhcp
     pre-up for _ in $(seq 1 10); do /usr/bin/test -c /dev/cdc-wdm0 && break; /bin/sleep 1; done
     pre-up for _ in $(seq 1 10); do /usr/bin/qmicli -d /dev/cdc-wdm0 --nas-get-signal-strength && break; /bin/sleep 1; done
     pre-up /usr/bin/qmicli -d /dev/cdc-wdm0 --wda-set-data-format=802-3
     pre-up /usr/bin/qmi-network /dev/cdc-wdm0 start
     post-down /usr/bin/qmi-network /dev/cdc-wdm0 stop

Does anyone have any idea why? Thanks

Then use ModemManager + NetworkManager

Because qmi-network overrides it based on the value of /sys/class/net/wwan0/qmi/raw_ip

Note that qmi-network is mostly a test script, and not really suitable as a connection manager replacement.

I tried use ModemManager + NetworkManager.
But when run “nmcli con up id model” that get error “Error: Connection activation failed: No suitable device found for this connection (device wlan0 not available because device is not available).”

~ # nmcli connection show
NAME UUID TYPE DEVICE
model 9b088834-a18f-4355-b70c-ed472c5bf6f3 gsm –

~# nmcli device status
DEVICE TYPE STATE CONNECTION
wlan0 wifi unavailable –
ip6tnl0 iptunnel unmanaged –
sit0 iptunnel unmanaged –
lo loopback unmanaged –
wwan0 wwan unmanaged –

~# mmcli -m 0
/ --------------------------------
General | dbus path: /org/freedesktop/ModemManager1/Modem/0
| device id: 30f8b8836559dddabd53f024253691776a89a942
/ --------------------------------
Hardware | manufacturer: Sierra Wireless, Incorporated
| model: MC7304
| firmware revision: SWI9X15C_05.05.78.00
| h/w revision: MC7304
| supported: gsm-umts, lte
| current: gsm-umts, lte
| equipment id: 356853057744015
/ --------------------------------
System | device: /sys/devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.1.auto/usb1/1-1/1-1.1
| drivers: cdc_mbim, qcserial
| plugin: Sierra
| primary port: cdc-wdm0
| ports: cdc-wdm0 (mbim), ttyUSB0 (qcdm), ttyUSB2 (at), wwan0 (net)
/--------------------------------
Status | unlock retries: sim-pin2 (3)
| state: disabled
| power state: on
| signal quality: 0% (cached)
/ --------------------------------
Modes | supported: allowed: 2g; preferred: none
| allowed: 3g; preferred: none
| allowed: 4g; preferred: none
| allowed: 2g, 3g; preferred: 3g
| allowed: 2g, 3g; preferred: 2g
| allowed: 2g, 4g; preferred: 4g
| allowed: 2g, 4g; preferred: 2g
| allowed: 3g, 4g; preferred: 3g
| allowed: 3g, 4g; preferred: 4g
| allowed: 2g, 3g, 4g; preferred: 4g
| allowed: 2g, 3g, 4g; preferred: 3g
| allowed: 2g, 3g, 4g; preferred: 2g
| current: allowed: 2g, 3g, 4g; preferred: 4g
/ --------------------------------
Bands | supported: egsm, dcs, pcs, g850, utran-1, utran-6, utran-5, utran-8,
| utran-2, eutran-1, eutran-3, eutran-7, eutran-8, eutran-20
| current: egsm, dcs, pcs, g850, utran-1, utran-5, utran-8, utran-2,
| eutran-1, eutran-3, eutran-7, eutran-8, eutran-20
/ --------------------------------
IP | supported: ipv4, ipv6, ipv4v6
/--------------------------------
3GPP | imei: 356853057744015
| enabled locks: fixed-dialing
/--------------------------------
3GPP EPS | ue mode of operation: csps-2
/ --------------------------------
SIM | dbus path: /org/freedesktop/ModemManager1/SIM/0

~# mmcli -m 0 --enable
successfully enabled the modem
~# mmcli -m 0
/--------------------------------
General | dbus path: /org/freedesktop/ModemManager1/Modem/0
| device id: 30f8b8836559dddabd53f024253691776a89a942
/--------------------------------
Hardware | manufacturer: Sierra Wireless, Incorporated
| model: MC7304
| firmware revision: SWI9X15C_05.05.78.00
| h/w revision: MC7304
| supported: gsm-umts, lte
| current: gsm-umts, lte
| equipment id: 356853057744015
/--------------------------------
System | device: /sys/devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.1.auto/usb1/1-1/1-1.1
| drivers: cdc_mbim, qcserial
| plugin: Sierra
| primary port: cdc-wdm0
| ports: cdc-wdm0 (mbim), ttyUSB0 (qcdm), ttyUSB2 (at), wwan0 (net)
/--------------------------------
Status | unlock retries: sim-pin2 (3)
| state: registered
| power state: on
| access tech: lte
| signal quality: 0% (cached)
/--------------------------------
Modes | supported: allowed: 2g; preferred: none
| allowed: 3g; preferred: none
| allowed: 4g; preferred: none
| allowed: 2g, 3g; preferred: 3g
| allowed: 2g, 3g; preferred: 2g
| allowed: 2g, 4g; preferred: 4g
| allowed: 2g, 4g; preferred: 2g
| allowed: 3g, 4g; preferred: 3g
| allowed: 3g, 4g; preferred: 4g
| allowed: 2g, 3g, 4g; preferred: 4g
| allowed: 2g, 3g, 4g; preferred: 3g
| allowed: 2g, 3g, 4g; preferred: 2g
| current: allowed: 2g, 3g, 4g; preferred: 4g
/--------------------------------
Bands | supported: egsm, dcs, pcs, g850, utran-1, utran-6, utran-5, utran-8,
| utran-2, eutran-1, eutran-3, eutran-7, eutran-8, eutran-20
| current: egsm, dcs, pcs, g850, utran-1, utran-5, utran-8, utran-2,
| eutran-1, eutran-3, eutran-7, eutran-8, eutran-20
/--------------------------------
IP | supported: ipv4, ipv6, ipv4v6
/--------------------------------
3GPP | imei: 356853057744015
| enabled locks: fixed-dialing
| operator id: 46689
| operator name: 台灣之星
| registration: home
/--------------------------------
3GPP EPS | ue mode of operation: csps-2
/--------------------------------
SIM | dbus path: /org/freedesktop/ModemManager1/SIM/0

How to solve this?Thank

NM considers the wwan0 interface “unmanaged” because of the config you have in /etc/network/interfaces. Remove (or comment out) that, and NM should let you manage the wwan connection. You might have to restart NM and/or replug the interface to make it notice the difference. I’m not sure about that…

Ok,I removed config of wwan in /etc/network/interfaces,and restart NM and replug.But wwan still unmanage.

:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

~# nmcli d
DEVICE TYPE STATE CONNECTION
wlan0 wifi unavailable –
ip6tnl0 iptunnel unmanaged –
sit0 iptunnel unmanaged –
lo loopback unmanaged –
wwan0 wwan unmanaged –

Maybe do you know how to either auto set data format(802-3 or raw-ip) or use mbimcli auto connect?

Can’t explain that. There must be something else than the ifupdown plugin setting the unmanaged state on that device.

As for raw-ip: That’s always enabled for MBIM, but unfortunately the driver hides this so it looks like it is always 802.3. Either way it can’t be changed.

If you meant raw-ip in QMI mode, then the only prerequisite is that thendetdev isn’t running. You should be able to switch it by doing

ip link set wwan0 down
echo Y > /sys/class/net/wwan0/qmi/raw_ip
ip link set wwan0 up

Auto connect in the sense that you let the modem firmware manage the connection doesn’t really work. The firmware will reconnect as necessary, but has no way to signal this to the host. You may use it if you see the modem as a standalone router, managing the connection without any client (i.e host) intervention. But that’s not the way most users want to view an LTE modem.

1 Like

I don’t know what else I need to do.

Yes. If I use MBIM that don’t need to switch it, but mbimcil doesn’t seem to have auto connect feature, It not like QMI have the “–wds-set-autoconnect-settings”.

In QMI mode: I think model default set raw-ip, so I must be switch it, witch don’t switch it if model in the 802-3,but I need to set “–wda-set-data-format=802-3”,can I change this default for example using at command?

MBIM was made for managing USB connected Mobile Broadband devices from a host. Device firmware autoconnect is not compatible with that, and is therefore not part of the spec.

A vendor creating a self managing device can just use some other USB network protocol for the data plane, like ECM or NCM or whatever. They could obviously abuse MBIM too, but I just don’t see the point.

The qmi_wwan driver defaults to 802.3 for historical reasons. Most devices prior to the MC7455 generation also defaulted to 802.3. BUT: Some conditions will make a devce default to raw-ip instead. autoconnect is one of them. Persistent device config is another. The MC7304 generation was particularily cranky, and would often default for raw-ip on one RMNET function and 802.3 on the other. Newer devices defaults to raw-ip, since that’s the only mode they support.

To summarize: You should always explicitly set the mode on both host and device. raw-ip is the mode that’s most likely to work, regardless of modem generation.

I don’t know how to manage these devices using AT commands. I recommend using QMI or MBIM.

1 Like

Thank, I understand. But one thing I am confused, the MC7304 generation default for 802-3 in qmi_wwan driver, but witch default for raw-ip in qmi-cli tool? This is strange right?

Hi @dl5162 ,I follow your suggest. now I using the modemmanager auto control the data-format of host.
But I encounter some problem.

In addition, I using modemmanager and qmicli with “–wds-set-autoconnect-settings” connect network now.

  1. When qmocli autoconnect is enabled and wait for modemmanager set the data-format of host to Y, it can’t use dhcp get an IP address, must use “qmicli --device=/dev/cdc-wdm0 --device-open-proxy --wds-get-autoconnect-settings” to get an IP address.Do you know why it happend?

root@:~# udhcpc -i wwan0
udhcpc: started, v1.31.0
udhcpc: sending discover
udhcpc: sending discover
^C
root@:~# qmicli --device=/dev/cdc-wdm0 --device-open-proxy --wds-get-autoconnect-settings
Autoconnect settings retrieved:
Status: ‘enabled’
Roaming: ‘allowed’
root@:~# udhcpc -i wwan0
udhcpc: started, v1.31.0
udhcpc: sending discover
udhcpc: sending select for 100.70.245.152
udhcpc: lease of 100.70.245.152 obtained, lease time 7200
/etc/udhcpc.d/50default: Adding DNS 172.24.9.21
/etc/udhcpc.d/50default: Adding DNS 10.9.121.102

  1. I using systemd-networkd to auto get IP address.When the host does not get IP address, which will keep retry to get IP address. However, when the modemmanager try to set the data-format of host, the dhcp retry get IP address that will make it impossible set the data-format of host.Do you have any idea solve it? Thank you.

[ 592.153521] qmi_wwan 1-1.1:1.2 wwan0: Cannot change a running device

If I don’t use systemd-networkd, and only use udhcpc before the modemmanager to set the data-format of host. It likely below:

root@:~# udhcpc -i wwan0
udhcpc: started, v1.31.0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
[ 3108.153377] qmi_wwan 1-1.1:1.2 wwan0: Cannot change a running device
udhcpc: sending discover
^C
root@:~# cat /sys/class/net/wwan0/qmi/raw_ip
N

The DHCP server in the modem firmware is similar to autoconnect. It is a feature designed to let the host ignore the fact that this is a modem, and just treat it as any unmanaged ethernet link. That’s nice if you don’t want to manage the mobile network connection.

I recommend letting the host manage the IP configuration. That is: Use QMI or MBIM to retrieve the connection information from the modem and configure the IP interface on the host. based on this. No DHCP.

I believe this is what NM+MM will do.

You cannot do now, that will confuse ModemManager. If you want to use ModemManager you should first disable autoconnect. I believe a recent MM release already does this internally though.

yes, that is what MM+NM does if the network interface is raw-ip.

The process is a bit like this (some steps ignored for the purpose of the discussion):

  • NetworkManager asks ModemManager to start a data connection, using the DBus Simple.Connect()
  • MM uses WDA Get Data Format to check which is the link layer protocol configured by default in the network interface.
  • If the link layer protocol configured in the modem is raw-ip, it automatically switches the qmi_wwan net interface to raw-ip, so that kernel and modem both have the same protocol configured and both expect the same.
  • MM runs WDS Start network to initiate the data connection, and eventually it succeeds.
  • As soon as the network is started, MM queries IP settings to use in the network interface, using WDS Get Current Settings, and exposes them in the “bearer object” in DBus.
  • NetworkManager gets notified that the modem is connected, reads the IP settings from the “bearer object” in DBus, and applies them to the network interface.

There is absolutely no need to involve any qmicli call in this process.

Hi ,I solved “unmanaged” problem(pass --with-modem-manager-1 at configure time) and that can auto connect network by MN+NN now, Thank both of you

Excuse me. Hi guys, I have the new problem ,I use the MC7304 auto connect to network by NM, which get error.

root@:~# nmcli d
DEVICE TYPE STATE CONNECTION
cdc-wdm0 gsm disconnected –
wlan0 wifi unavailable –
ip6tnl0 iptunnel unmanaged –
sit0 iptunnel unmanaged –
lo loopback unmanaged –
root@:~# nmcli c
NAME UUID TYPE DEVICE
lte 557f6db4-26aa-407b-9e15-ddc31c6f9c3d gsm –
root@bovia-deb:~# nmcli con up lte
Error: Connection activation failed: The device could not be readied for configuration
Hint: use ‘journalctl -xe NM_CONNECTION=557f6db4-26aa-407b-9e15-ddc31c6f9c3d + NM_DEVICE=cdc-wdm0’ to get more details.

Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4237] device (cdc-wdm0): Activation: starting connection ‘lte’ (557f6db4-26aa-407b-9e15-ddc31c6f9c3d)
Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4255] device (cdc-wdm0): state change: disconnected -> prepare (reason ‘none’, sys-iface-state: ‘managed’)
Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4676] modem-broadband[cdc-wdm0]: failed to connect modem: invalid ip methods
Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4679] device (cdc-wdm0): state change: prepare -> failed (reason ‘config-failed’, sys-iface-state: ‘managed’)
Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4885] device (cdc-wdm0): Activation: failed for connection ‘lte’
Oct 21 16:37:06 -deb NetworkManager[576]: [1603269426.4975] device (cdc-wdm0): state change: failed -> disconnected (reason ‘none’, sys-iface-state: ‘managed’)

I don’t know why happen get this error, because I use other module(Telit LE910) that is not get this error.

And also this error is happen to the second time, this error is normal in first time.

Do you have any ideas? @dl5162 @aleksander0m
Thank

I disable IPV6 to solved this, Thank.