Due some mobile network roaming issues one of my test SIM Cards is not able to use the network of T-Mobile here properly. The SIM Cards get a network attach to T-Mobile but the GPRS Activation fails. As soon as the SIM card is using O2 it works just fine.

I use a RUT900 Router for this and this has a Network blacklist in the firmware. But this does not work as expected since this only works once and if the router reconnects for whatever reason it end up in the T-Mobile network again.

Luckily there is another solution to the problem: SIM Cards contains a list of forbidden networks(PLNMs) where the mobile equipment will not connect to.

This list can be manipulated by AT Commands and the RUT900 comes with the convenient commandline tool gsmctl to send AT Command to the gsm module.

To query the list of forbidden PLMNs:

gsmctl -A "AT+crsm=176,28539,0,0,12"
+CRSM: 144,0,"FFFFFFFFFFFFFFFFFFFFFFFF"

the response with all F tells us that this list is currently emtpy.

To set T-Mobile Germany to the list of forbidden PLMNs use

gsmctl -A "AT+crsm=214,28539,0,0,3,\"62F210\""
+CRSM: 144,0,""

this sets the first entry of the list to the mobile country code (MCC) of 262 (Germany) and the mobile network code to 01 (Telekom). As often in GSM the numbers are coded as 4 bit nibbles, high and low nibble are swapped, and unused digits are represented by F.

Therefore the MCC/MNC 26201 is obviously represented as 62F210, easy right?!?

This will be saved in the SIM Card and survives a Router reboot, equipment swap etc. Keep in mind that the forbidden PLMNs are not obvious from the WebUI of the router and you can shoot yourself in the foot…

Using

gsmctl -A "AT+cops=?"
+COPS: (1,"Vodafone.de","Vodafone","26202",0),(1,"Vodafone.de","Vodafone","26202",2),(1,"E-Plus","E-Plus","26203",0),(3,"Telekom.de","TDG","26201",0),(2,"o2 - de","o2 - de","26203",2),,(0-4),(0-2)

you can see the available mobile networks and the 3 at (3,"Telekom.de"[..] tells you that this network is forbidden.

Details are in the GSM Specs: