How is the APN set?

electron
Tags: #<Tag:0x00007fe21ead7548>

#1

I’ve got a few Electron’s that are being used in Malawi and couldn’t connect to the internet using the Particle SIM. I used the clouddebug program to check for cell towers and every one of them was “unrecognized”. So, I bought a 3rd-party Airtel SIM card, set the APN, and everything worked immediately. Then, I put the Particle SIM back in and it continued to work just fine for a little while.

I know that airtel is one of Particle’s providers in Malawi, so I was wondering if I just happened to set the correct APN? Anywho, this got me to thinking: how does the Electron know which APN to use by default? Is it based on the towers (finds location and tries the different providers in the area?)? Is there a way to tell the Electron which provider to try first in hopes of connecting more quickly? The airtel APN is “internet”, which I see is the default.


#2

You should always set the APN in all user firmware using cellular_credentials_set for the Electron and E Series.

The APN setting is not saved in configuration flash, and will go away if not always set. You can be lulled into a false sense of it being saved because it’s stored in the modem and will survive a reboot and code flash, but as soon as you completely power down the modem the setting will be lost.

You also need to be a little careful when swapping SIM cards. It’s best to completely power down the Electron because otherwise the SIM might not be read at boot so it will use the old SIM card, not the one that’s currently installed.

I believe you were lucky in that “internet” is a default APN, so that works without setting it. It might be a good idea to set it explicitly anyway just to be safe.

You will also almost certainly need to change the keep-alive setting when using a 3rd-party SIM card.

https://docs.particle.io/support/particle-devices-faq/electron-3rdparty-sims/#about-keep-alive

(It’s different for the Boron and B Series SoM, the APN setting is saved in configuration flash, though the keep-alive is not so you still need to set that.)


#3

Yea, I am setting the APN explicitly when using the third-party SIM as you suggested. I was more curious if there is an advantage to setting it even when using a Particle SIM? How does it know which APN to use when it is powered on in a new location with new networks?


#4

The APNs for Particle-branded SIMs come from a different location, cellular_hal_constants.h. There is one APN for each class of SIM card, regardless of the carrier in the country. In some cases, we can change the carriers from the MVNO side without requiring any changes on the device side at all.