Hello, We have an Quectel UC20 modem running with ModemManager. We are using the libmm python module (gi.repository.ModemManager) and no NetworkManager. This will be in hundreds of unattended embedded boxes, and losing the connection will require a site visit in many cases.
I have wwan0 set as dhcp, and dhclient is started automatically on "ifup wwan0". This kind of fits with what was said here: https://lists.freedesktop.org/archives/modemmanager-devel/2015-December/002419.html but much of the implementation has been guesswork and trial&error... Our main issues: Operstate seems to be always UNKNOWN "ip link set dev wwan0 up" and "ip link set dev wwan0 down" seem to do nothing. We need to reset the connection once a day (with mmcli --disable), because of external reasons. This mostly works, but sometimes we lose connectivity after the reconnect. In those cases I have 2 IP addresses in the interface, and ip route tells me that both of them are gateways. "ifup wwan0 && ifdown wwan0" fixes the connection again without any action from the python script (this automatically starts a new dhclient and updates ip route). This seems to be just a timing issue, or a question of doing things in the right order. My main questions: 1) what do I need to do to have a reliable connection? 2) when do I need to do those things? - in what state should I call ifup ? - in what state should I call connect_bearer()? Any exceptions? 3) I switch modem states really fast (from DISABLING to CONNECTING in under a second - see syslog below). Do some of these states need to wait a bit? 4) Is ModemManager 1.4.10 too old? Are there any major improvements I'm missing from staying on Ubuntu 12.04? NOTE: To find out the status of the connection, I check if the IfState is up or down (basically "grep wwan0 /run/network/ifstate"), instead of checking operstate (which is UNKNOWN no matter what I do). If ifstate is down I call "ifup wwan0" manually. When disconnecting (and on the pyhon startup), I call "ifdown wwan0" manually. Relevant python code: def handle_modem_state(self, oldState, state): logging.debug('Handle modem state, old: ' + self.modem_state_str(oldState) + ' new: ' + self.modem_state_str(state)) if state == ModemManager.ModemState.DISABLED: self.enable_modem() # calls modemProxy.Enable(1, ...) elif state == ModemManager.ModemState.ENABLED: self.register_modem() # calls modemProxy.Register(...) elif state == ModemManager.ModemState.SEARCHING: pass elif state == ModemManager.ModemState.REGISTERED: if oldState != ModemManager.ModemState.CONNECTING and oldState != ModemManager.ModemState.DISCONNECTING: self.connect_bearer() # get bearer from DBUS and connect elif state == ModemManager.ModemState.CONNECTED: self.triedPreferredOperator = False elif state == ModemManager.ModemState.CONNECTING: if not self.is_network_interface_up('wwan0'): # check operstate/ifstate self.set_network_state('wwan0', 'up') # calls ifup wwan0 in a new process elif state == ModemManager.ModemState.DISABLING: if self.is_network_interface_up('wwan0'): # check operstate/ifstate self.set_network_state('wwan0', 'down') # calls ifdown wwan0 in a new process result of: ip -4 a show dev wwan0 | grep -v forever 4: wwan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 inet XX.YY.197.125/30 brd XX.YY.197.127 scope global wwan0 inet XX.YY.80.188/30 brd XX.YY.80.191 scope global wwan0 /var/log/syslog with minor obfuscation - python script is "modemmonitor[1475]" # connection working before modem-reset Mar 19 06:35:51 ubuntu12 modem-reset: Performing daily modem reset: 'mmcli --disable --modem=0' Mar 19 06:35:51 ubuntu12 my_tunnel[3352]: AutoSSH2 stop Mar 19 06:35:51 ubuntu12 autossh[14671]: received signal to exit (15) Mar 19 06:35:51 ubuntu12 my_tunnel[3352]: AutoSSH2 stop: done Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Modem state: CONNECTED -> DISABLING Mar 19 06:35:52 ubuntu12 nslcd[1530]: [65b848] <passwd="*"> "*": name denied by validnames option Mar 19 06:35:52 ubuntu12 nslcd[1530]: [725ebb] <passwd="*"> "*": name denied by validnames option Mar 19 06:35:52 ubuntu12 my_tunnel[3396]: AutoSSH2 stop Mar 19 06:35:52 ubuntu12 my_tunnel[3396]: AutoSSH2 not running Mar 19 06:35:52 ubuntu12 my_tunnel[3396]: AutoSSH2 stop: done Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: ifdown wwan0 (for dchlient/ssh) returned my_tunnel[3396]: AutoSSH2 stop#012my_tunnel[3396]: AutoSSH2 not running#012my_tunnel[3396]: AutoSSH2 stop: done Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Operator Code: Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Operator Name: Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Registration State: UNKNOWN Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Modem state: DISABLING -> DISABLED Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Enabling modem... Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Modem state: DISABLED -> ENABLING Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Operator Code: 20404 Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Operator Name: DATA ONLY Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Registration State: HOME Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Modem state: ENABLING -> REGISTERED Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Current operator: 20404 Mar 19 06:35:52 ubuntu12 modemmonitor[1475]: Modem state: REGISTERED -> CONNECTING Mar 19 06:35:53 ubuntu12 dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 60 Mar 19 06:35:54 ubuntu12 nslcd[1530]: [87a0be] <passwd=-1> ldap_start_tls_s() failed: Can't contact LDAP server: Transport endpoint is not connected (uri="ldap://ssh.example.com:389") Mar 19 06:35:54 ubuntu12 nslcd[1530]: [87a0be] <passwd=-1> failed to bind to LDAP server ldap://ssh.example.com:389: Can't contact LDAP server: Transport endpoint is not connected Mar 19 06:35:54 ubuntu12 nslcd[1530]: [87a0be] <passwd=-1> no available LDAP server found: Can't contact LDAP server Mar 19 06:35:54 ubuntu12 logger: Unloading CAN driver Mar 19 06:35:54 ubuntu12 nslcd[1530]: [8e8cbc] <passwd="*"> "*": name denied by validnames option Mar 19 06:35:54 ubuntu12 nslcd[1530]: [91daaa] <passwd=-1> no available LDAP server found: Server is unavailable Mar 19 06:35:54 ubuntu12 logger: Loading CAN driver Mar 19 06:35:54 ubuntu12 kernel: [410151.671069] pch_can 0000:02:0c.3: irq 51 for MSI/MSI-X Mar 19 06:35:54 ubuntu12 kernel: [410151.671121] pch_can 0000:02:0c.3 (unregistered net_device): PCH CAN opened with MSI Mar 19 06:35:54 ubuntu12 nslcd[1530]: [66d378] <passwd="*"> "*": name denied by validnames option Mar 19 06:36:07 ubuntu12 ntpdate[3606]: adjust time server 46.243.26.34 offset 0.000085 sec Mar 19 06:36:11 ubuntu12 acpid: client 2632[0:0] has disconnected Mar 19 06:36:11 ubuntu12 acpid: client connected from 3986[0:0] Mar 19 06:36:11 ubuntu12 acpid: 1 client rule loaded Mar 19 06:36:53 ubuntu12 dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 1 Mar 19 06:36:53 ubuntu12 dhclient: DHCPREQUEST of XX.YY.197.125 on wwan0 to 255.255.255.255 port 67 Mar 19 06:36:53 ubuntu12 dhclient: DHCPOFFER of XX.YY.197.125 from XX.YY.197.126 Mar 19 06:36:53 ubuntu12 dhclient: DHCPACK of XX.YY.197.125 from XX.YY.197.126 Mar 19 06:36:53 ubuntu12 nslcd[1530]: [29fdc1] <passwd="*"> "*": name denied by validnames option Mar 19 06:36:54 ubuntu12 dhclient: bound to XX.YY.197.125 -- renewal in 2886 seconds. Mar 19 06:36:54 ubuntu12 my_tunnel[4118]: AutoSSH2 start Mar 19 06:37:04 ubuntu12 nslcd[1530]: [802c05] <passwd=-1> ldap_start_tls_s() failed: Can't contact LDAP server: Connection timed out (uri="ldap://ssh.example.com:389") Mar 19 06:37:04 ubuntu12 nslcd[1530]: [802c05] <passwd=-1> failed to bind to LDAP server ldap://ssh.example.com:389: Can't contact LDAP server: Connection timed out Mar 19 06:37:04 ubuntu12 nslcd[1530]: [802c05] <passwd=-1> no available LDAP server found: Can't contact LDAP server Mar 19 06:37:04 ubuntu12 autossh[4150]: port set to 0, monitoring disabled Mar 19 06:37:04 ubuntu12 autossh[4151]: starting ssh (count 1) Mar 19 06:37:04 ubuntu12 autossh[4151]: ssh child pid is 4152 Mar 19 06:37:04 ubuntu12 my_tunnel[4118]: AutoSSH2 start: done Mar 19 06:37:04 ubuntu12 nslcd[1530]: [2a1dc5] <passwd="*"> "*": name denied by validnames option Mar 19 06:37:16 ubuntu12 ntpdate[4201]: no server suitable for synchronization found Mar 19 06:37:16 ubuntu12 modemmonitor[1475]: ifup wwan0 (for dchlient/ssh) returned my_tunnel[4118]: AutoSSH2 start#012my_tunnel[4118]: AutoSSH2 start: done#012ssh stop/waiting#012ssh start/running, process 4209 Mar 19 06:37:17 ubuntu12 modemmonitor[1475]: Modem state: CONNECTING -> CONNECTED Mar 19 06:39:11 ubuntu12 /usr/bin/ssh[4152]: error: ssh: connect to host ssh.example.com port 22: Connection timed out Mar 19 06:39:11 ubuntu12 autossh[4151]: ssh exited with error status 255; restarting ssh Mar 19 06:39:11 ubuntu12 autossh[4151]: starting ssh (count 2) Mar 19 06:39:11 ubuntu12 autossh[4151]: ssh child pid is 4492 # connection broken from now on ---- Hardware/software Ubuntu 12.04 with kernel 3.13.0-57-generic CPU : Intel(R) Atom(TM) CPU E680 @ 1.60GHz using qmi_wwan, cdc_wdm kernel modules ModemManager 1.4.10 ---- $ mmcli -m 0 /org/freedesktop/ModemManager1/Modem/0 (device id '4dd8d723ec[...]') ------------------------- Hardware | manufacturer: 'QUALCOMM INCORPORATED' | model: '0' | revision: 'UC20GQBR03A10E1G 1 [2014/05/05 9:00:00]' | supported: 'gsm-umts' | current: 'gsm-umts' | equipment id: '861075023803802' Best regards Einar Jón Gunnarsson _______________________________________________ ModemManager-devel mailing list ModemManager-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel