How to set custom APN?

Hi, I am working with RC7620. I am trying to set APN using at+cgdcont. The command seems to work as such, in terms of allowing me to set APN of choice, but when I set a wrong APN also, I seem to get a valid IP and data connection, which seems strange. I tried at!reset afterwards, but it still works. Am I missing something for APN setting? I have a ‘tre’ SIM whose APN is data.tre.se.

at+cgdcont?

+CGDCONT: 1,“IP”,“WRONGAPN”,“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

ati

Manufacturer: Sierra Wireless, Incorporated

Model: RC7620

Revision: SWI9X07H_00.08.19.00 725c0e jenkins 2021/09/08 14:36:45

IMEI: 353634110232963

IMEI SV: 18

FSN: 7Q1376000302B0

+GCAP: +CGSM

OK

echo at+cops? | socat - /dev/ttyUSB2,raw,echo=0,crnl,b115200

at+cops?

+cops: 0,0,“3”,7

OK

/ # ip a show wwan0
4: wwan0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq state UNKNOWN group default qlen 1000
link/none
inet 79.138.249.44/29 brd 79.138.249.47 scope global wwan0
valid_lft forever preferred_lft forever
/ # ping -c 4 www.google.com
PING www.google.com (142.250.74.132): 56 data bytes
64 bytes from 142.250.74.132: seq=0 ttl=57 time=38.938 ms
64 bytes from 142.250.74.132: seq=1 ttl=57 time=38.603 ms
64 bytes from 142.250.74.132: seq=2 ttl=57 time=31.227 ms
64 bytes from 142.250.74.132: seq=3 ttl=57 time=38.115 ms
www.google.com ping statistics —
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 31.227/36.720/38.938 ms

this may depend on the network operator whether wrong APN can establish data connection

Ok, but is this the right way to set APN in RC76xx ?

at+cgdcont=1,“IPV4V6”,“data.tre.se”

And does it require a modem reboot after setting APN?

yes.
Normally I will do a reboot after setting APN.

OK. When we don’t set any APN (leave it empty), how to know which APN is being used by the modem? Is there a way to query what APN is configured? If nothing is set using at+cgdcont, it shows empty when queried also. So it is not clear where the configuration is stored in the modem and how to retrieve that information.

I think it would use empty APN to communicate with network

Hi @saim,
in that particular context you can query the APN with AT+CGCONTRDP=1.

Regards,
Reinhard

Thank you for your quick response. What I set with at+cgdcont is being read by at+cgcontrdp. When I set it to empty with at+cgdcont, I can now read the actual APN being configured. But when I set it to anything else, a different valid IP is assigned and the data connection still works, though the APN is wrong. This is a bit confusing.

/ # echo at+cgdcont=1,"IP","WRONGAPN" | socat - /dev/ttyUSB2,raw,echo=0,crnl,b115200
at+cgdcont=1,“IP”,“WRONGAPN”
OK
/ # echo at+cgdcont? | socat - /dev/ttyUSB2,raw,echo=0,crnl,b115200
at+cgdcont?
+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
+CGDCONT: 1,“IP”,“WRONGAPN”,“0.0.0.0”,0,0,0,0
OK
/ # echo AT+CGCONTRDP=1 | socat - /dev/ttyUSB2,raw,echo=0,crnl,b115200
AT+CGCONTRDP=1
+CGCONTRDP: 1,5,WRONGAPN,2.71.21.117,80.251.201.177,80.251.201.178
OK
/ # ip a show wwan0
4: wwan0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq state UNKNOWN group default qlen 1000
link/none
inet 2.71.21.117/30 brd 2.71.21.119 scope global wwan0
/ # ping -c 4 www.google.com
PING www.google.com (216.58.211.4): 56 data bytes
64 bytes from 216.58.211.4: seq=0 ttl=60 time=40.920 ms
64 bytes from 216.58.211.4: seq=1 ttl=60 time=38.455 ms
64 bytes from 216.58.211.4: seq=2 ttl=60 time=38.206 ms
64 bytes from 216.58.211.4: seq=3 ttl=60 time=37.820 ms
www.google.com ping statistics —
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 37.820/38.850/40.920 ms