how to change Esim profile for nbiot fall back

Hi,

I'm using nrf9160custom board using sdk version 2.0.0
our Esim has 2 profiles one is for LTE and another one is for NB-IoT. Present i have tested tested LTE network and its working fine but i need to work on NB-IoT.

i have no idea how to do fallback for LTE to NB-IoT.

our Esim provider given fallback APDU command.

i have refered below document too but i don't have any how to send AT+CSIM command

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fref_at_commands%2FREF%2Fat_commands%2Faccess_uicc%2Faccess_uicc.html

Thank you

Parents
  • Hi,

    Which modem FW version are you using?

    Have you tried to just set the system modem to NB-IoT or LTE-M and NB-IoT, to see if the modem handles it automatically?

    You can find the documentation on how to send AT commands from the application here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/nrfxlib/nrf_modem/doc/at_interface.html

    Best regards,

    Didrik

  • Hi,

    Which modem FW version are you using?

    I'm using FW version 1.3.4 

    Have you tried to just set the system modem to NB-IoT or LTE-M and NB-IoT, to see if the modem handles it automatically?

    Before we using plastic sim card in that we have implemented he NB-IoT fallback and its working fine but now we are using ESIM instead of plastic sim .Now our ESIM have 2 profiles one is for LTE and another one is NB-IoT. 
    so if i need to using NB-IoT fallback first i have to change the profile. so how i can change the ESIM profile?

    our Esim providers proved APDU command for fallback. i have tried "AT+CSIMcommand for fallback but i don't either it changes or not. how i can i check either it change or not?

    if you need i can provide ESIM document for your reference.

    Thank you

  • > +CEREG: 2,"05D7","019C4600",7

    AFAIK the "7" means LTE-M/CAT-M1. A "9" would be NB-IoT.

  • Hi,

    In that case E-sim not switching the profile right ?

    whats may the solution to switch the e-sim profile or need to send any command  for NB-IoT after switching the e-sim profile?

    Thank you

  • Your previous log from yesterday contains:

    > +CEREG: 2,"C2F0","00273265",9

    with that your device was connecting to NB-IoT.

    I don't know, how you setup your device. Therefore I don't know, what goes wrong or not nor what is required.

    My comment was mainly, that AT+CSIM has documentation and you didn't comply with that.

  • Hi sir,

    +CEREG: 2,"C2F0","00273265",9

    This logs i got from my  code in code i have already written NB-IoT fallback for physical sim but now i'm trying same thing for E-sim.
    But now i'm trying in LTE link monitor.

    After sending AT+CSIM  command how i can could whether e-sim profile changed or not.

    if it changed, i need to send AT%XSYSTEMMODE=0,1,0,0 to enable the NB-IoT ?

    for more clarity im send my fallback function when im using physical sim card please check it.

    static void lteConnect(void)
    {
        int err = NBIOT_ERROR_OK;
    
        if ((err = lte_lc_connect_async(lte_handler)) != NBIOT_ERROR_OK)
        {
            printk("Modem could not be configured, error: %d\n", err);
            err = NBIOT_ERROR_MODEM_CONFIG;
            errorHandler_process(err);
        }
    
        err = k_sem_take(&lte_connected_sem, K_SECONDS(CONFIG_LTE_NETWORK_TIMEOUT));
        if (err == -EAGAIN)
        {
            printk("LTE connection could not be established within timeout. "
                   "Schedule another attempt after sleeping\n");
    
            scheduleLTEReconnect(
                lte_reconnection_delay_s[atomic_get(&lte_reconnection_attempts)]);
    
            /*  get the current sytem mode from api and fallback */
            int error = NBIOT_ERROR_OK;
            error     = lte_lc_system_mode_get(&get_sys_mode_current);
            printk("Got mode %d \n", get_sys_mode_current);
            if (!error)
            {
                if (get_sys_mode_current == LTE_LC_SYSTEM_MODE_NBIOT)
                {
                    /* increment atomic variable to get the retry count of lte */
                    atomic_inc(&lte_try_count);
                    /*  Set the values in data structure to send to aws with fw
                     * info*/
                    sensor_config.nbt_try_count = atomic_get(&nbt_try_count);
                    sensor_config.lte_try_count = atomic_get(&lte_try_count);
                    // sprintf(sensor_config.nw_mode, "lte");
                    sensor_config.network_mode = NETWORK_MODE_LTE;
                    printk("Current mode is NB-IoT and changing it to LTE-CAT1 : "
                           "count of LTE-M: %d\n",
                           atomic_get(&lte_try_count));
                    /*  Set the fallback MODE to LTE */
                    int result = lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
                    if (!result)
                    {
                        printk("Set mode done\n");
                        /*  Sleep for a while just to give some time to change mode
                         Not given in Documantation but trial and error  */
                        k_msleep(5000);
                    }
                }
    
                else if (get_sys_mode_current == LTE_LC_SYSTEM_MODE_LTEM)
                {
                    /* increment atomic variable to get the retry count of lte */
                    atomic_inc(&nbt_try_count);
                    sensor_config.nbt_try_count = atomic_get(&nbt_try_count);
                    sensor_config.lte_try_count = atomic_get(&lte_try_count);
                    // sprintf(sensor_config.nw_mode, "nbt");
                    sensor_config.network_mode = NETWORK_MODE_LTE;
                    printk("Current mode is LTE-CAT1 and changing it to NB-IoT : "
                           "count of nbiot %d\n",
                           atomic_get(&nbt_try_count));
                    /*  Set the fallback MODE to NB-IoT */
                    int result = lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_NBIOT);
                    if (!result)
                    {
                        printk("Set mode done\n");
                        /*  Sleep for a while just to give some time to change mode
                        Not given in Documantation but trial and error  */
                        k_msleep(5000);
                    }
                }
            }
    
            /* Switch off modem until next reconnection attempt */
            modem_offline();
            return;
        }
    
        /* Setup Power Saving Mode */
        if ((err = setup_psm()) != NBIOT_ERROR_OK)
        {
            errorHandler_process(err);
        }
    
        return;
    }
    

    now i have added AT+CSIM command in this function to switch the profile which fall back is happening

    char nb_iot[] = "AT+CSIM=28,\"80C2000009D3070202018110017D\"";
    int err =at_cmd_write(nb_iot,NULL,0,NULL);
    printf("err:%d\n",err);

    but still its not connecting to NB-IoT . let me if need anything to add in code or need to add any configuration 

    Thank you

  • , could you take a modem trace, where you try to change the SIM profile and connect to NB-IoT?

Reply Children
  • Hi,

    we are using nrf9160 custom board can you guide how to take modem trace logs in custom board.

    In my board UART0 has UART to USB cable to see logs. how can i take modem trace using UART0?

    i have enabled "CONFIG_BSD_LIBRARY_TRACE_ENABLED=y" in prj.config

    below is my uart .dts

    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <29>;
    	rx-pin = <28>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <13>;
    	rx-pin = <14>;
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

    char lte_m[] = "AT+CSIM=28,\"80C2000009D3070202018110017C\"";

    int err=at_cmd_write(lte_m,NULL,0,NULL);
    when i call this function im getting err=-8; may i know what it means?
     

    thank you

  • bhanu prakash said:
    i have enabled "CONFIG_BSD_LIBRARY_TRACE_ENABLED=y" in prj.config

    Note that for NCS v2.0.0, you should use CONFIG_NRF_MODEM_LIB_TRACE_ENABLED, not CONFIG_BSD_LIBRARY_TRACE_ENABLED.

    The trace backend is hardcoded to use UART1, so the easiest way to get the trace over UART is to just swap the pins between UART1 and UART0. That way, they trace will come over the correct pins, and you don't have to change anything else than the pin assignment in the device tree.

    bhanu prakash said:
    int err=at_cmd_write(lte_m,NULL,0,NULL);
    when i call this function im getting err=-8; may i know what it means?

    Which SDK version are you using?

    That function is deprecated, and had already been removed in NCS v2.0.0

  • Hi,

    sorry for the late reply

    based on the sim card providers i have done the sim profile switching.

    but i have facing the issue now when sim profile is nbiot its connecting to network even  nrf9160 system in LTE mode i don't know how its possible and when nrf9160 is in nbiot its not connecting to network also?

    below is the network switching code:

    char nbiot_connect[] ="AT+COPS=0,2,\"26203\",7";
    err =at_cmd_write(esim_fallback,NULL,0,NULL);
    
     
    above cops command is to switch network to NB-IoT.
    and below command is to switch network to LTE
    char lte_m[] = "AT+COPS=0,2,\"26201\",7";
    int err=at_cmd_write(lte_m,NULL,0,NULL);

    i have seen logs if network is in NB-IoT  its still connecting to network even System mode in LTE.

  • In both of those cases, you have automatic network selection enabled, so the modem will still try to select a network to connect to automatically.

    Besides, depending on how the SIM card works, the modem might be able to handle the profile switching itself. So it could be that the modem informs the SIM card about what networks are available, and then the SIM card changes profile so that the modem is able to connect to a network.

  • Hi

    the SIM card changes profile so that the modem is able to connect to a network.

    That fine but when sim card profile switches to NB-IoT profile then the modem also need to change to NB-IoT to connect with that but in my car modem is in still lte mode but some how it's connecting to NB-IoT profile network and it's sending data to aws also. Is it possible? 

Related