# IOT Sim-card integration

Source: https://forum.modalai.com/topic/185/iot-sim-card-integration
Category: ESCs, Sensors and Accessories (https://forum.modalai.com/category/15/escs-sensors-and-accessories)
Tags: cellular
Posted: 2021-04-06 14:16:27 UTC by Arrowtec
Replies: 13 · Views: 2651

## Arrowtec · 2021-04-06 14:16:27 UTC

Hey there,
we want to switch from using a normal sim-card to an IOT one which basically only means that certain IP-addresses are valid to connect to and receive a connection from.
I think that this is a problem since the Modem won't boot/show up unless the connection is valid and the means of confirming a valid connection probably have something to do with my issue of the Modem not starting properly.
Any Ideas?

~ # systemctl status -l voxl-modem
● voxl-modem.service - Modem Initialization
   Loaded: loaded (/etc/systemd/system/voxl-modem.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-04-06 13:43:08 UTC; 31min ago
  Process: 4223 ExecStartPre=/bin/sleep 2 (code=exited, status=0/SUCCESS)
 Main PID: 4225 (voxl-modem-star)
   CGroup: /system.slice/voxl-modem.service
           ├─4225 /bin/bash /usr/bin/voxl-modem-start.sh
           ├─7565 /usr/bin/python /usr/bin/sierra.py
           └─7636 uqmi -P -d /dev/cdc-wdm0 --get-msisdn

Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: "plmn_mnc": 2,
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: "plmn_description": "vodafone.de",
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: "roaming": true
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: }
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: ]
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: Successfully registered with the network
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: Starting network
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: Checking connection status
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: "disconnected"
Apr 06 14:14:29 apq8096 voxl-modem-start.sh[4225]: Connection failed

## Reply by tom (ModalAI staff) · 2021-04-06 16:31:37 UTC

Hi @Arrowtec ,

Just so I fully understand the situation:

You have a modem that you were able to connect to the network successfully with previously and now you want to use a different SIM card with the same modem?

If that is the case it is possible that the APN of the SIM has changed, especially if it is a different carrier. Have you ran through `voxl-configure-modem` again and entered the correct APN for this new SIM card?

## Reply by Arrowtec · 2021-04-06 19:19:42 UTC

@tom Yes exactly it is a new Sim and I went through the ```voxl-configure-modem``` setup.
The Problem that I think I am having is that in order to figure out if the connection works Voxl tries to ping a server and if it can't reach it it will say it is not connected. With the IOT-Sim it only allows to speak to certain predetermined IPs meaning it cant reach the IP to confirm the connection.

## Reply by tom (ModalAI staff) · 2021-04-06 20:09:11 UTC

Which modem are you using, the WP7610 or the WP7607 and where are you located? I want to make sure you're using the correct hardware.

## Reply by Arrowtec · 2021-04-06 20:28:13 UTC

I am using the WP7607. The carrier is Vodafone and I am located in Germany.
The APN I am using is: web.vodafone.de
It worked with another Sim-Card so the compatibility shouldn't be the issue here

## Reply by tom (ModalAI staff) · 2021-04-06 20:30:14 UTC

Got it, from the output you posted earlier it looks like the APN it is trying to use is `vodafone.de`. Is that the previous APN? The APN might not be setting properly in the setup script.

## Reply by Arrowtec · 2021-04-06 20:34:32 UTC

That should be the name of the Carrier and not the APN but I went through the ```
voxl-configure-modem``` multiple times and it should be set right.
As already mentioned here: 

> @tom Yes exactly it is a new Sim and I went through the ```voxl-configure-modem``` setup.
> The Problem that I think I am having is that in order to figure out if the connection works Voxl tries to ping a server and if it can't reach it it will say it is not connected. With the IOT-Sim it only allows to speak to certain predetermined IPs meaning it cant reach the IP to confirm the connection.

I am thinking the Problem is with the restricted access to certain IPs and the checking of one not in those in the startup process. Do you know what happens during the startup of the modem and how it checks to see if its connected to the internet?

## Reply by tom (ModalAI staff) · 2021-04-06 21:00:34 UTC

@Arrowtec I don't believe that it pings a specific address that your SIM cannot access, we use this same modem with our private LTE networks.

Can you run the following to check what APN is set on the modem?
`echo -ne "AT+CGDCONT?\r" | busybox microcom -t 1000 /dev/ttyUSB2`

I understand that you have run `voxl-configure-modem` multiple times but I have seen on rare occasion where the APN doesn't set correctly.

## Reply by tom (ModalAI staff) · 2021-04-06 21:08:18 UTC

And could you please post the contents of `/etc/modalai/voxl-modem.conf`? I want to make sure I'm not missing anything obvious.

## Reply by Arrowtec · 2021-04-06 21:21:34 UTC

Will do when I get in the office, thanks

## Reply by tom (ModalAI staff) · 2021-04-06 21:27:25 UTC (in reply to Arrowtec)

@Arrowtec Thanks :)

## Reply by Arrowtec · 2021-04-07 09:34:28 UTC

@tom 
The APN seems to default to "internet" but after the ```voxl-configure-modem``` its set correctly as seen below. After that it is still not working / showing up.

Here is ```echo -ne "AT+CGDCONT?\r" | busybox microcom -t 1000 /dev/ttyUSB2```:

```
~ # echo -ne "AT+CGDCONT?\r" | busybox microcom -t 1000 /dev/ttyUSB2
AT+CGDCONT?
+CGDCONT: 1,"IP","web.vodafone.de","0.0.0.0",0,0,0,0
+CGDCONT: 2,"IPV4V6","ims","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0
+CGDCONT: 3,"IPV4V6","sos","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,1

OK
```
Here is the content of ```/etc/modalai/voxl-modem.conf```:
```
~ # cat /etc/modalai/voxl-modem.conf
{
	"modem_type":	"v2",
	"apn":	"spe.inet4g.gdsp",
	"world":	"true",
	"microhard_ip": "192.168.168.100",
	"modallink":	"false",
	"placeholder": "hello world"
}
```
And here again the ```systemctl status -l voxl-modem```:
```
~ # systemctl status -l voxl-modem
● voxl-modem.service - Modem Initialization
   Loaded: loaded (/etc/systemd/system/voxl-modem.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-04-07 09:19:38 UTC; 11min ago
  Process: 4400 ExecStartPre=/bin/sleep 2 (code=exited, status=0/SUCCESS)
 Main PID: 4401 (voxl-modem-star)
   CGroup: /system.slice/voxl-modem.service
           ├─4401 /bin/bash /usr/bin/voxl-modem-start.sh
           └─5666 /usr/bin/python /usr/bin/sierra.py

Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: "plmn_mnc": 2,
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: "plmn_description": "vodafone.de",
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: "roaming": true
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: }
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: ]
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: Successfully registered with the network
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: Starting network
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: Checking connection status
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: "disconnected"
Apr 07 09:30:38 apq8096 voxl-modem-start.sh[4401]: Connection failed
```
Furthermore here is ```ifconfig``` if that helps:
```
~ # ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:DD:11:4A:98  
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:ddff:fe11:4a98/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:152 (152.0 B)  TX bytes:216 (216.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr EC:5C:68:CD:21:5B  
          inet addr:192.168.7.122  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::ee5c:68ff:fecd:215b/64 Scope:Link
          inet6 addr: fd48:4c86:10be:e600:ee5c:68ff:fecd:215b/64 Scope:Global
          inet6 addr: 2a01:598:b00c:e53c:ee5c:68ff:fecd:215b/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:110 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3000 
          RX bytes:11644 (11.3 KiB)  TX bytes:15615 (15.2 KiB)
```
Let me know if you can troubleshoot anything off the new information :)

## Reply by Arrowtec · 2021-04-07 10:46:36 UTC

The ```echo -ne "AT+CGDCONT?\r" | busybox microcom -t 1000 /dev/ttyUSB2``` is btw from when I was using the old APN so dont get confused by that, here is the new one: 
```
~ # echo -ne "AT+CGDCONT?\r" | busybox microcom -t 1000 /dev/ttyUSB2
AT+CGDCONT?
+CGDCONT: 1,"IP","spe.inet4g.gdsp","0.0.0.0",0,0,0,0
+CGDCONT: 2,"IPV4V6","ims","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0
+CGDCONT: 3,"IPV4V6","sos","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,1

OK
```

## Reply by tom (ModalAI staff) · 2021-04-07 16:36:18 UTC

@Arrowtec Okay this all looks normal, have you tested this SIM card in a different device to confirm that it is indeed functional?
