Hey,

>
> First what are the conditions where a cellular data connection will be 
> automatically disconnected due to bad signal/loss of network?  Also what 
> program handles the disconnect (NetworkManager, ModemManager, pppd)?
>

It's the modem firmware itself handling that, MM will just report
whatever the modem is reporting.

E.g. if the modem is registered and connected in LTE, and the LTE
network disappears (e.g. low signal quality, out of coverage) then the
modem will try to handover to 3G or 2G transparently if there is any
3G or 2G around. While this is happening, the modem will definitely
report that it's no longer registered in LTE (e.g. the CEREG:4 and
CEREG:0  you see in the logs), it will also probably say that it's
searching for some other non-LTE network via CREG/CGREG URCs, and
while all that is happening, the modem will still keep saying that
it's connected (the response to the periodic CGACT? states that the
PDP context / EPS bearer is still connected). ModemManager will say
that the modem is disconnected only when the CGACT? response reports
that our specific CID isn't active.

See below.

So signal quality is 0:
> May  6 18:31:25 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167485.896059] (ttyACM1): --> 'AT+CSQ<CR>'
> May  6 18:31:25 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167485.899223] (ttyACM1): <-- '<CR><LF>+CSQ: 
> 99,99<CR><LF><CR><LF>OK<CR><LF>'
> May  6 18:31:25 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167485.900293] Modem /org/freedesktop/ModemManager1/Modem/0: signal 
> quality updated (0)

But still CGACT? reports that context with CID #2 is ACTIVE:
> May  6 18:31:30 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167490.876303] (ttyACM1): --> 'AT+CGACT?<CR>'
> May  6 18:31:30 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167490.882310] (ttyACM1): <-- '<CR><LF>+CGACT: 
> 1,0<CR><LF><CR><LF>+CGACT: 2,1<CR><LF><CR><LF>+CGACT: 
> 3,0<CR><LF><CR><LF>+CGACT: 4,0<CR><LF><CR><LF>+CGACT: 
> 5,0<CR><LF><CR><LF>+CGACT: 6,0<CR><LF><CR><LF>+C
> May  6 18:31:30 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167490.883392] connection status loaded: connected

Now, no LTE, but registering in CS
> May  6 18:31:48 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167508.641702] (ttyACM1): <-- '<CR><LF>+CREG: 
> 1,"0000","0331E70C",7<CR><LF><CR><LF>+CGREG: 4<CR><LF><CR><LF>+CIEV: 
> 3,1<CR><LF><CR><LF>+CEREG: 0<CR><LF>'
> May  6 18:31:48 canect2 daemon.info ModemManager[304]: <info>  
> [1557167508.642347] Modem /org/freedesktop/ModemManager1/Modem/0: 3GPP 
> Registration state changed (searching -> registering)

Looks like pppd detects a disconnection itself here:
> May  6 18:31:48 canect2 daemon.notice pppd[540]: Modem hangup

Which is in line with the result of the next CGACT? check, where CID
#2 is now reported as INACTIVE:
> May  6 18:31:50 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167510.873812] (ttyACM1): --> 'AT+CGACT?<CR>'
> May  6 18:31:50 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167510.880002] (ttyACM1): <-- '<CR><LF>+CGACT: 
> 1,0<CR><LF><CR><LF>+CGACT: 2,0<CR><LF><CR><LF>+CGACT: 
> 3,0<CR><LF><CR><LF>+CGACT: 4,0<CR><LF><CR><LF>+CGACT: 
> 5,0<CR><LF><CR><LF>+CGACT: 6,0<CR><LF><CR><LF>+C
> May  6 18:31:50 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167510.881410] connection status loaded: disconnected
> May  6 18:31:50 canect2 daemon.warn ModemManager[304]: <warn>  
> [1557167510.882008] (ttyACM0): could not re-acquire serial port lock: (5) 
> Input/output error
> May  6 18:31:50 canect2 daemon.debug ModemManager[304]: <debug> 
> [1557167510.882435] (ttyACM0): port now disconnected

And modem is reported disconnected in MM now.
> May  6 18:31:50 canect2 daemon.info ModemManager[304]: <info>  
> [1557167510.882875] Modem /org/freedesktop/ModemManager1/Modem/0: state 
> changed (connected -> registered)

There's a thing here, though. For this kind of modems where PPP is
used, maybe we shouldn't be doing the periodic CGACT? checks through
the secondary TTY. This is an open point I have in mind to review,
because if we end up reporting the disconnection via MM (because CGACT
reports no active CIDs) then the pppd shutdown process may not be
happening properly in NM and the connected TTY may not go well back to
command mode. I think there was some open issue about this.

-- 
Aleksander
https://aleksander.es
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to