<div dir="auto">To add, and in my experience, when changing the data format the assigned interface needs to be down. <div dir="auto">Also, i have sided not to use the `autoconnect` bc i have had intermittent issues with it.</div><div dir="auto"><br><div dir="auto">My method to startup is simple</div><div dir="auto">//</div><div dir="auto"><br></div><div dir="auto">#find your proper sleep time as modem and your system may vary</div><div dir="auto">Sleep 8s</div><div dir="auto">Ifconfig wwan0 down</div><div dir="auto">Sleep 1s</div><div dir="auto">Qmi-network /dev/cdc-wdm0 stop</div><div dir="auto">Qmicli -d /dev/cdc-wdm0 -E raw-ip</div><div dir="auto">Ifconfig wwan0 up</div><div dir="auto">Sleep 1s</div><div dir="auto"><span style="font-family:sans-serif">Qmi-network /dev/cdc-wdm0 start</span><br></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">#call for dhcp address, i use systemd</span></div><div dir="auto"><span style="font-family:sans-serif">Systemcli restart systemd-networkd</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">//</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">This method is used as i am not versed in coding. I also through in some 1s in case any delays in execution. There is also a if statement that shows the ip addresses and if there is no address it reruns the script 1 time(in case something failed)</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Alek is well versed in qmicli and can correct anything i suggest.</span></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 8, 2020, 8:46 AM Aleksander Morgado <<a href="mailto:aleksander@aleksander.es">aleksander@aleksander.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey,<br>
<br>
> tir. 7. apr. 2020 kl. 17:17 skrev Aleksander Morgado <<a href="mailto:aleksander@aleksander.es" target="_blank" rel="noreferrer">aleksander@aleksander.es</a>>:<br>
>><br>
>> > I have some further updates here. I read another thread about the '-p' option,<br>
>> > which, when added to all instances of qmicli invocation in the init.d file makes<br>
>> > the problem go away in at least more than 9 out of 10 cases. So it is<br>
>> > apparently a timing issue. Still have to test this on more than one<br>
>> > system, but I am optimistic. :)<br>
>><br>
>> The "-p" option, if used, must be used in ALL qmicli commands, so that<br>
>> all use the intermediate qmi-proxy.<br>
>> I wonder what init.d file you're talking about, though?<br>
><br>
><br>
> We initialise the modem with this routine (somewhat simplified to illustrate the points):<br>
><br>
> START_NETWORK_ARGS=apn="internet",ip-type=4,autoconnect=yes<br>
><br>
> #QMICMD='qmicli -p '<br>
> QMICMD='qmicli '<br>
><br>
> for DEV in $(find /dev -maxdepth 1 -name "cdc-wdm*" | sort)<br>
> do<br>
> WANIF=$($QMICMD -d "$DEV" -w)<br>
> if $QMICMD -d "$DEV" --wds-get-packet-service-status | grep -q status:..connected ; then<br>
> echo "Stopping as it was already connected $DEV $WANIF"<br>
> $QMICMD -d "$DEV" --wds-stop-network=disable-autoconnect<br>
<br>
That above is not a good way to disconnect if you're manually running<br>
Start Network, see other comments below.<br>
<br>
> ip link set "$WANIF" down 2>&1<br>
> ip addr flush dev "$WANIF" 2>&1<br>
> echo "Stopped broadband on $DEV $WANIF to restart connection"<br>
> fi<br>
><br>
> # Does it work at all....?<br>
> if ! $QMICMD -d "$DEV" --wda-get-data-format ; then<br>
> echo "Modem does not respond as expected - trying to reset it"<br>
> # Here we had some code to try various things to get it working, like resetting the usb port it is connected to.<br>
> # However, following commands could still fail<br>
> fi<br>
><br>
> # Change to 802-3<br>
> if $QMICMD -d "$DEV" --wda-get-data-format | grep -q 'raw-ip'; then<br>
> echo "Identified $DEV $WANIF as raw-ip, changing to 802-3"<br>
> if ! $QMICMD -d "$DEV" --wda-set-data-format=802-3 ; then<br>
> echo "wda-set-data-format=802-3 failed"<br>
<br>
You cannot change data format after having started the connection. In<br>
the logic below you're connecting in 2 different ways (start network<br>
with apn, and autoconnect), but you're only stopping in one way<br>
(autoconnect). It may happen that the set data format fails because<br>
the modem is already connected?<br>
<br>
> exit 1<br>
> fi<br>
> else<br>
> echo "Failed to set $DEV $WANIF data format to 802-3"<br>
> fi<br>
><br>
> # Set up if correct mode<br>
> if ! $QMICMD -d "$DEV" --wda-get-data-format | grep -q '802-3'; then<br>
> echo "Modem is not is correct data format mode"<br>
<br>
Don't rely on devices supporting all 802.3. All new QMI devices don't<br>
support 802.3, they only support raw-ip. If you're stuck with an older<br>
model, this may be enough though, so just a heads up.<br>
<br>
> exit 1<br>
> fi<br>
> echo "Starting broadband on $DEV $WANIF with args '$START_NETWORK_ARGS'"<br>
> $QMICMD -d "$DEV" --wds-start-network=${START_NETWORK_ARGS:-apn=\"internet\"} --client-no-release-cid<br>
> $QMICMD -d "$DEV" --wds-set-autoconnect-settings=enabled,roaming-allowed<br>
<br>
You're attempting to manually connect with start network and then<br>
enabling autoconnect, and that doesn't make sense, these are 2<br>
different things. Autoconnect will use the "default 3GPP" profile<br>
settings, and the manual start network will try to use whatever<br>
settings you're passing. You should either use one approach or the<br>
other, using both won't work properly I believe.<br>
<br>
Also, if you run start network manually, you need to keep track of the<br>
CID you used to connect, and also track of the "connection id"<br>
returned by the command, so that you can then perform the associated<br>
stop network passing the correct cid and the correct connection id.<br>
<br>
> echo "Started broadband on $DEV $WANIF"<br>
> killall -HUP dhcpcd<br>
> exit 0 # Done<br>
> done<br>
><br>
> einfo "Failed to set up broadband adapter"<br>
> exit 1 # Failed<br>
><br>
> If I use -p it seems to work close to 100% (maybe 100% of the times). Without the script fails too often on the first wda-get-data-format.<br>
><br>
> (Btw, --wds-start-network also gives an error, but it does not seem to affect anything:<br>
> qmicli -p -d /dev/cdc-wdm0 --wds-start-network=apn=internet,ip-type=4,autoconnect=yes --client-no-release-cid<br>
> error: couldn't start network: QMI protocol error (14): 'CallFailed'<br>
> call end reason (3): generic-no-service<br>
> verbose call end reason (2,210): [internal] pdn-ipv6-call-disallowed<br>
> [/dev/cdc-wdm0] Client ID not released:<br>
> Service: 'wds'<br>
> CID: '9')<br>
<br>
If start network fails, but anyway you're connected it means the modem<br>
may be setup to autoconnect using the default 3GPP profile (see qmicli<br>
--wds-get-profile-list=3gpp and qmicli<br>
--wds-get-default-profile-num=3gpp). So it is not that it doesn't<br>
affect anything, it's that you may be trying to connect with different<br>
settings to the default ones, and the settings you used explicitly are<br>
failing.<br>
<br>
><br>
> Actually, while writing this mail, I made a new discovery: It looks like if -wda-get-data-format fails once, for example when running it first without -p, it will keep on failing, even if run with -p later. However, a usb port reset (unbind/bind) will make it work again if I then run with -p directly afterwards.<br>
><br>
> I have very few clues on what is going on. It could very well be that we are doing something wrong....(?)<br>
><br>
<br>
The use of "-p" just makes all your qmicli requests be forwarded to<br>
the device through an intermediate qmi-proxy process. This is done so<br>
that multiple applications can use the port at the same time for<br>
different commands; either multiple qmicli calls or even different<br>
programs doing different QMI interactions. E.g. you can use the<br>
"Mobile Radio Monitor" program<br>
(<a href="https://sigquit.wordpress.com/2013/09/17/mobile-radio-monitor/" rel="noreferrer noreferrer" target="_blank">https://sigquit.wordpress.com/2013/09/17/mobile-radio-monitor/</a>) at<br>
the same time as ModemManager is managing the device because both<br>
programs use the intermediate proxy. If there is one program using the<br>
proxy, all programs must use it.<br>
<br>
If some programs use it and some others don't, the ones not using it<br>
will all fight each other with the qmi-proxy for the access to the QMI<br>
control port.<br>
<br>
If you're on doubt on what to do, just use the proxy always always,<br>
and never attempt a qmicli command without using the proxy, as that<br>
will break the comm between the device and the proxy. So, the tests<br>
sometimes trying with "-p" and sometimes without "-p" don't really<br>
make sense because the testing itself is breaking the flow.<br>
<br>
Also, a lot of this logic is already handled in the qmi-network<br>
script, I'd suggest you take a look at its source code, it's quite<br>
simple.<br>
<br>
Cheers!<br>
<br>
-- <br>
Aleksander<br>
<a href="https://aleksander.es" rel="noreferrer noreferrer" target="_blank">https://aleksander.es</a><br>
_______________________________________________<br>
libqmi-devel mailing list<br>
<a href="mailto:libqmi-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">libqmi-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/libqmi-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/libqmi-devel</a><br>
</blockquote></div>