# Unable to Restart Network/Wifi/Modem/Data connection

**URL:** <https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294>\
**Category:** Legato Application Framework\
**Created:** [May 23, 2018, 3:40pm UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294 "2018-05-23T15:40:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [May 23, 2018, 3:40pm UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294/1 "2018-05-23T15:40:42Z")

</div>

So I’m testing my legato device wp85 for situations when Connection is lost. I have it on a Cellular Network with Sim inserted unlocked ready and such. I have a list of checks I go through every second to see my Connection status:

- Check SIM: if present/ready/state/
- check modem: if le\_data\_RequestObjRef\_t is NULL or not
- check network/radio: state/radio power/signal strength  
-ping check: where i try to ping [www.sierrawireless.com](http://www.sierrawireless.com) with a socket connection

Now when I have the SIM is activated, all stages are checked and all is well. When I go deactivate the SIM, it quickly changes and catches this change of state but it never fails till it gets to the last stage: ping in my App. On the outside I have it failing at WifiService && modemDaemon && dcsDaemon/dataConnectionServices with following repeating errors:

```auto
INFO | wifiService[556] | WIFICLIENT_DISCONNECT
=ERR= | wifiService[556] | Failed to connect to non-global ctrl_ifname: wlan0 error: No such file or directory
=ERR= | wifiService[556]/daemon T=main | pa_wifi_client_ti.c pa_wifiClient_Disconnect() 1041 | WiFi Client Command Failed: (24832)wlan0 WIFICLIENT_DISCONNECT
DBUG | wifiService[556]/framework T=main | le_wifiClient_server.c Handle_le_wifiClient_Disconnect() 1228 | Sending response to client session 0x27dcc : 4 bytes sent
=ERR= | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c TryStopWifiSession() 1851 | Impossible to disconnect wifi client
INFO | modemDaemon[550]/le_pa T=main | pa_mrc_qmi.c pa_mrc_GetNetworkRegState() 2040 | called
=ERR= | modemDaemon[550]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 781 | Sending QMI_WDS_START_NETWORK_INTERFACE_REQ_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=14.[0x0e]
=ERR= | modemDaemon[550]/le_pa T=main | pa_mdc_qmi.c StartSession() 1690 | Data connection failure Call End provided 44, Code 12
=ERR= | modemDaemon[550]/le_pa T=main | pa_mdc_qmi.c StartSession() 1701 | Data connection failure Verbose Call End provided Type 2, Verbose 201
=ERR= | modemDaemon[550]/modemDaemon T=main | le_mdc.c le_mdc_StartSession() 919 | Get Connection failure 44, 12, 2, 201
=ERR= | modemDaemon[550]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 781 | Sending QMI_WDS_GET_RUNTIME_SETTINGS_REQ_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=15.[0x0f]
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c SetDefaultGateway() 1010 | Default gateway or interface is empty
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c LoadSelectedTechProfile() 786 | No value set for 'SSID'!
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c TryStartWifiSession() 1633 | Impossible to use Wifi profile, result -1 (LE_NOT_FOUND)
DBUG | wifiService[556]/daemon T=main | le_wifiClient.c le_wifiClient_Disconnect() 1198 | Disconnect
INFO | wifiService[556] | WIFICLIENT_DISCONNECT
=ERR= | wifiService[556] | Failed to connect to non-global ctrl_ifname: wlan0 error: No such file or directory
=ERR= | wifiService[556]/daemon T=main | pa_wifi_client_ti.c pa_wifiClient_Disconnect() 1041 | WiFi Client Command Failed: (24832)wlan0 WIFICLIENT_DISCONNECT
DBUG | wifiService[556]/framework T=main | le_wifiClient_server.c Handle_le_wifiClient_Disconnect() 1228 | Sending response to client session 0x27dcc : 4 bytes sent
=ERR= | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c TryStopWifiSession() 1851 | Impossible to disconnect wifi client
INFO | modemDaemon[550]/le_pa T=main | pa_mrc_qmi.c pa_mrc_GetNetworkRegState() 2040 | called
=ERR= | modemDaemon[550]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 781 | Sending QMI_WDS_START_NETWORK_INTERFACE_REQ_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=14.[0x0e]
=ERR= | modemDaemon[550]/le_pa T=main | pa_mdc_qmi.c StartSession() 1690 | Data connection failure Call End provided 44, Code 12
=ERR= | modemDaemon[550]/le_pa T=main | pa_mdc_qmi.c StartSession() 1701 | Data connection failure Verbose Call End provided Type 2, Verbose 201
=ERR= | modemDaemon[550]/modemDaemon T=main | le_mdc.c le_mdc_StartSession() 919 | Get Connection failure 44, 12, 2, 201
=ERR= | modemDaemon[550]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 781 | Sending QMI_WDS_GET_RUNTIME_SETTINGS_REQ_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=15.[0x0f]
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c SetDefaultGateway() 1010 | Default gateway or interface is empty
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c LoadSelectedTechProfile() 786 | No value set for 'SSID'!
-WRN- | dcsDaemon[546]/dataConnectionService T=main | dcsServer.c TryStartWifiSession() 1633 | Impossible to use Wifi profile, result -1 (LE_NOT_FOUND)
DBUG | wifiService[556]/daemon T=main | le_wifiClient.c le_wifiClient_Disconnect() 1198 | Disconnect
INFO | wifiService[556] | WIFICLIENT_DISCONNECT

```

Next I Activate the SIM but what I have noticed is that it never changes its behavior: i still fails on all the apps above and in my own App it fails at ping still. Even if I go to the command line and try to ping 8.8.8.8 it fails giving me no Network connection error. The only way I can get it back working is by resetting the whole device (HARD RESET) or reboot via command line.

Any ideas on how to solve this? I want my device to be able to catch the fact that the Connection is back without having to reset it manually?

Thanks,  
MG

---

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [May 23, 2018, 10:35pm UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294/2 "2018-05-23T22:35:20Z")

</div>

@jyijyi Any suggestions? 🙂

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [May 23, 2018, 10:43pm UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294/3 "2018-05-23T22:43:34Z")

</div>

How about checking the data connection status by “cm data”?  
You can also check the sim status by AT command AT+CPIN? and also the signal strength by AT+CSQ and AT!GSTATUS?

---

<div class="post-metadata">

**Author:** ![mg\_bg](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@mg\_bg](https://forum.legato.io/u/mg_bg)\
**Post date:** [May 24, 2018, 6:38pm UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294/4 "2018-05-24T18:38:32Z")

</div>

@jyijyi I found the AT command to reset modem: AT!RESET. Trying it via command line works BUT:

1. I found out that every time I enter it to reset the modem, my process ends exiting with code 1 and causes an entire system reboot. How can I stop that?
2. How can I execute the AT commands from within my code? There has to be a way to do that. Using system() calls to execute anything in the terminal tends to not work. Any ideas?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [May 25, 2018, 1:26am UTC](https://forum.legato.io/t/unable-to-restart-network-wifi-modem-data-connection/3294/5 "2018-05-25T01:26:21Z")

</div>

AT!RESET will reset the system actually.  
Even you don’t run your application, AT!RESET will always reboot the whole system.

Please note that according to the link below, AT command is not quite recommended:

> **[AT Commands - Legato Docs](https://docs.legato.io/latest/legatoAtServices.html)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

But if you just want to do some testing, you can try my application attached here.

[Sending AT command in Legato application.docx](https://forum.legato.io/uploads/short-url/eeW5rtumfl90F32V8TMBOXcoVFp.docx) (215.2 KB)
