BG95M3 QuecPython GNSS and WWAN switching

Good afternoon.
I am trying to use the BG95M3 Quecpython board to initially get GPS data and then transmit it on an Internet IOT platform. However after getting GPS data and switching it off so that RF channel is used by WWAN, network registration is not happening correctly and I am getting a network connection failure as below.
Does anyone has experienced this problem please?

Function to Check SIM and Network

def check_network():

print("Checking SIM card and network connectivity...")

# Step 1: Check SIM Status
sim_status = sim.getStatus()        
if sim_status != 1:
    print("Error: SIM card not detected or not ready.")
    return False
print("SIM card detected and ready.")

utime.sleep(5)  # Allow time for signal to be received

print("Checking if network is ready...")
# Step 7: Check if Network is ready for GPRS connection
stage, state = checkNet.waitNetworkReady(60)    # 30 sec timeout
if stage == 3 and state == 1:
    print('Network connection successful. (PDP Context and SIM status OK)')
else:
    print('Network connection failed, stage={}, state={}'.format(stage, state))

# Step 2: Check Signal Quality
signal_strength = net.csqQueryPoll()
print("Signal Quality (CSQ):", signal_strength)
print("Range of the value of signal strength: 0–31. The higher the value, the better the signal strength.")

# Step 3: Check Network Configuration
network_config, roam_enable_status = net.getConfig()
print('Check Network configuration = {}, roaming = {}'.format(network_config, roam_enable_status))
print("Network configuration = 21 = CATNB and roaming enable/disable.")

# Step 4: Set Network Configuration
net.setConfig(21)

# Step 5: Check Operator Information
operator_full_name, operator_abbreviation, mob_country_code, mob_network_code = net.operatorName()
print('Operator full name = {}, Operator abbreviation = {}, Mobile country code = {}, Mobile network code = {}'.format(operator_full_name, operator_abbreviation, mob_country_code, mob_network_code))

# Step 6: Check PDP Context
ipType, apn, username, password, authType = dataCall.getPDPContext(1)
print('ipType={}, apn={}, username={}, password={}, authType={}'.format(ipType, apn, username, password, authType))

# Step 7: Check if Network is ready for GPRS connection
stage, state = checkNet.waitNetworkReady(30)    # 30 sec timeout
if stage == 3 and state == 1:
    print('Network connection successful. (PDP Context and SIM status OK)')
    return True
else:
    print('Network connection failed, stage={}, state={}'.format(stage, state))
    return False

def activate_wwan():
print(“Activating WWAN…”)
net.setModemFun(1) # Restore WWAN functionality
utime.sleep(5) # Allow time for modem initialization
print(‘Activating PDP Context…’)
if not dataCall.activate(1):
print(“PDP context activation failed!”)
else:
print(“PDP context activated.”)

def deactivate_wwan():
print(“Deactivating WWAN…”)
dataCall.deactivate(1) # Deactivate PDP context for context ID 1
utime.sleep(2) # Allow time for deactivation
print(‘Deactivating PDP Context’)
net.setModemFun(4) # Set to airplane mode (disables WWAN)
print(“WWAN deactivated.”)

def get_gnss_coordinates():
print(“Starting GNSS…”)
quecgnss.gnssEnable(1)
ret = quecgnss.init()
if ret != 0:
print(‘GNSS initilization failed’)
return None

print('Waiting for GNSS fix')
utime.sleep(10)     
data = quecgnss.read(1096)           
print(data[1].decode())
quecgnss.gnssEnable(0)
print("GNSS disabled.")

def main():

deactivate_wwan()
utime.sleep(10)
get_gnss_coordinates()
utime.sleep(10)
activate_wwan()
utime.sleep(10)

# Run Network Check
# Step 1: Check Network
if check_network():
    print("SIM and Network check passed successfully.")
# Step 2: Connect to MQTT Broker
    mqtt_client = connect_mqtt()
    if mqtt_client:
        print("Starting temperature data publishing...")
        try:
            for _ in range(1):   # Repeat num of times, adjust as needed
                publish_temperature(mqtt_client)
                utime.sleep(5)  # Adjust the interval (in seconds) as needed
            print("Publishing completed.")
        except KeyboardInterrupt:
            print("\nPublishing interrupted by user.")      
        finally:
            mqtt_client.disconnect()  # Disconnect after all transmissions  
   
    else:
        print("Unable to connect to MQTT Broker. Exiting.")
else:
    print("SIM or Network check failed.")


deactivate_wwan()
utime.sleep(5)
get_gnss_coordinates()

Main Execution

if name == “main”:
main()