Is it possible to create profiles for SIM cards? (TRB500)

Hi, we’re using the TRB500 for our solution and we frequently switch SIM cards between providers.
Every provider has a few different settings, mainly it’s the APN which is always different. With this, we need to manually connect to the modem to be able to change the APN through the WebUI, since it can’t connect to RMS yet.
We’d love to do this via RMS, however manually changing settings every time we switch SIM cards is a hassle. Is there something like different profiles for different operators which we could configure? For example something like: for SIM from provider A the modem uses APN xyz.

Hello,

There are multiple ways of how this could be approached:

  • Crontab
    Create a Crontab script that checks the currently inserted SIM ICCID (if it is known what particular SIMs will be used). Alternatively, you could also check what operator the device is currently connected to, however, with wrong APN the device will not be able to establish mobile data connection, which could cause it to restart the modem, so checking ICCID would be a better approach.
    Once the ICCID is gathered, compare it to the predefined values. If it matches, use UCI to set a different APN:
#Assuming Auto APN is already off, these are the commands:
uci set network.mob1s1a1.apn='<APN>'
#If APN has additional authentication
uci set network.mob1s1a1.username='<username>'
uci set network.mob1s1a1.password='<password>'
uci set network.mob1s1a1.auth='<PAP or CHAP>'
#Commit the changes
uci commit network
#reload the network for the changes to take effect
/etc/init.d/network restart

So a pseudo-code could look like so:

#!/bin/sh

#Get ICCID of the current SIM
ICCID=$(gsmctl -J)

#List of pre-defines ICCIDs
SIM1=123456789456
SIM2=987654321789
SIM3=852741963741

#If statement to check if ICCIDs match
if [ $ICCID -eq $SIM1 ]
then
         uci set network.mob1s1a1.apn='test'
         uci set network.mob1s1a1.username='test'
         uci set network.mob1s1a1.password='test'
         uci set network.mob1s1a1.auth='PAP'
         uci commit network
         /etc/init.d/network restart
         logger "Changed the APN for $ICCID SIM"
fi
.
.
.

Save the script in /etc folder, and add it to the /etc/sysupgrade.conf file, so it does not get erased after an update. This script could be scheduled to run every 5 minutes using the following cron line:

*/5 * * * * /etc/script.sh >/dev/null 2>&1

Of course, other routes like profile switching and sending an SMS to change the APN could be used, but writing a short script might be the most-automated solution.

Best regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.