Switching operators and RATs in Quectel EC21 and BG96

We are currently doing a project with the Quectel EC21 and BG96 to do iperf3 tests, ftp operations, pinging etc. with Windows 10, Python 3 and AT commands. We have two private APNs, one for 2G and 3G and another one for 4G. Below are some questions I had for the setup and switching between RATs and operators, and my setup so far is shown below the questions:

  • What are the AT command steps to switch between operators and switch between RATs? Do I have to switch operators to switch RATs?
  • Should I define multiple PDP contexts or should I just overwrite the current one each time?
  • Do I need to have chosen an operator to activate the PDP context to get an IP address?
  • Since I have multiple APNs, and Windows uses the current activated APN, is there a way to not use Windows’ APN settings and just rely on the modem’s APN setup?

Setup:

from AT import AT
from ftplib import FTP
import time
import subprocess
import iperf3

port = ‘COM15’

modem1 = AT(port)

def run_iperf_test(rat, options):

#print(modem1.send_AT_command("AT+CFUN=0"))
#print(modem1.send_AT_command("AT+CFUN=1"))
print(modem1.send_AT_command("AT+COPS=2"))
print(modem1.send_AT_command("AT+QIDEACT=1"))

if rat == "2G":
    print(modem1.send_AT_command("AT+COPS=0,,,0"))
    print(modem1.send_AT_command("AT+CREG?"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",1,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","ruskoap1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))

elif rat == "3G":
    print(modem1.send_AT_command("AT+COPS=0,,,2"))
    print(modem1.send_AT_command("AT+CREG?"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",2,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","ruskoap1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))
    
elif rat == "4G":
    print(modem1.send_AT_command("AT+COPS=0,,,7"))
    print(modem1.send_AT_command("AT+CREG?"))
    print(modem1.send_AT_command("AT+COPS?"))
    print(modem1.send_AT_command('AT+QCFG="nwscanmode",3,1'))
    print(modem1.send_AT_command('AT+CGDCONT=1,"IP","5gapn1"'))
    print(modem1.send_AT_command("AT+QIACT=1"))
    print(modem1.send_AT_command("AT+QIACT?"))
    
    

ip_address = modem1.get_ip_address()
print(ip_address)

command = f'iperf3 {options} -B {ip_address}'
print(command)
result = subprocess.run(command, shell=True,capture_output=True, text=True)
print("Output:", result.stdout)
print("Error:", result.stderr)

test changing RATs

run_iperf_test(‘2G’, ‘-c 10.33.92.47’)
#run_iperf_test(‘3G’, ‘-c 10.33.92.47’)
#run_iperf_test(‘4G’, ‘-c 10.33.92.47’)

modem1.close()