This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to set APN in SDK v1.9.1 "https_client" sample project on nrf9160.

Hi all,

In my SIM, I need to set the APN name, username and password. They are not written to the SIM, so I need to set them.

With the at_client App provided by Nordic, I have already been able to connect to LTE using AT commands.

I think I can connect to LTE if I can set it correctly in the code, but I don't know where to set the APN information in sample project.

1,

I referred to the following thread.

devzone.nordicsemi.com/.../343313

And I added the following to the prj.conf file, but it failed with LTE connect.

# PDN library

CONFIG_PDN=y

CONFIG_PDN_DEFAULTS_OVERRIDE=y

CONFIG_PDN_SYS_INIT=y

CONFIG_PDN_DEFAULT_FAM_IPV4V6=y

CONFIG_PDN_DEFAULT_APN=”APN name

CONFIG_PDN_DEFAULT_USERNAME=”user name

CONFIG_PDN_DEFAULT_PASSWORD=”password

Am I missing something? Or do I need additional Including within the main?

2,(Another way)

I referred to the thread below and thought I could use AT commands in my code.

https://devzone.nordicsemi.com/f/nordic-q-a/70961/set-apn

Do I need to write additional code to use AT commands?

Seems like I need to include <modem/at_cmd.h>.  but can't find <modem/at_cmd.h> .

Is my guess correct that there are two different approaches to setting the APN?

Which is the best way? Is there another way?

My HW : nRF9160DK

MFW : v1.3.1

SDK : v1.9.1

Best regards,

Yukio Oyama

Parents
  • Hello, 

    First of all could you please provide the log output from your device ? What error do you receive? What SIM and network are you on?

    And I added the following to the prj.conf file, but it failed with LTE connect.

    This looks correct from what I can see. Note that our PDN library and nRF9160: PDN sample can also be used to configure APN. 

    Thanks. 

    Kind regards,
    Øyvind

  • Hello,

    About # 2
    Now in SDK v1.9.1, the function to execute the AT command seems to be nrf_modem_at_cmd (), not at_cmd_write().
    I have confirmed that "AT + CGDCONT" can be executed. Although I haven't tried setting the APN from the AT command.


    Is there a library reference manual for each SDK version? Searching from the code is not efficient. If it is not used in the sample project, I would not be aware of its existence.

    Best regards,

    Yukio Oyama

  • Yukio-san, 

    OYAMA YUKIO said:
    Is there a library reference manual for each SDK version? Searching from the code is not efficient. If it is not used in the sample project, I would not be aware of its existence.

    Yes, our documentation includes a dropdown menu to choose correct version:

    After selecting correct SDK version, you can navigate to e.g. PDN library (under libraries - modem libraries - PDN). This should provide information about PDN. 

    In regards to at_cmd_write changing to nrf_modem_at_cmd, this is a change in nrfxlib. Moving fra bsdlib to nrf_modem. 

    Not sure if that answers your question. 

    Let me know if you need any more.

    Kind regards,
    Øyvind
     

  • Hello Øyvind-san,

    When I checked last month, the page didn't exist when I selected the older version. Only the latest v1.9.1 had contents. But now there is information even in older versions.

    In the changelog, if a function is deleted, I would like you to be guided to a new function with the same function, but it seems that it is not. I'm disappointed.
    But the old version of the information helps me. thank you.

    At final, please tell me about Kconfig.
    Kconfig also changes depending on the version, but there are a lot of Kconfig items.


    There is a Kconfig list.

    developer.nordicsemi.com/.../index-nrf.html

    However, It's hard to find what I want because there are too many items on the list.

    Is there a way to search systematically? It would be very helpful if it was linked to the argument of the AT command.

    Best regards, 

    Yukio Oyama

  • Hi Yukio-san, 

    OYAMA YUKIO said:
    When I checked last month, the page didn't exist when I selected the older version. Only the latest v1.9.1 had contents. But now there is information even in older versions

    The information from all previous versions of nRF Connect SDK (NCS) has been available and are available through the dropdown menu in the nRF Connect SDK part of our documentation. In the bottom left hand side of the documentation page, you will find links to the other repositories included in our SDK

    Do you have an example of what you mean with "the page didn't exist"? This is valuable feedback to our technical publication team.

    Please note that from one version to another there might have been changes to the location of our documentation.

    OYAMA YUKIO said:
    In the changelog, if a function is deleted, I would like you to be guided to a new function with the same function, but it seems that it is not. I'm disappointed.
    But the old version of the information helps me. thank you.

    Yes, I agree. Missing documentation is not good, and could be handled better. 

    In the changelog of version 1.5.0 of NCS we have the following modem library changelog:

    • BSD library has been renamed to nrf_modem (Modem library) and nrf_modem_lib (glue).

    • Updated to version 1.0.1. See the Changelog for detailed information.

    I agree that there is lacking a link from old to new function. I will forward this to our team. 

    OYAMA YUKIO said:
    At final, please tell me about Kconfig.
    Kconfig also changes depending on the version, but there are a lot of Kconfig items.

    There is a search field in the top left corner on this page. Depending on what you are looking for, you can search e.g. in your case PDN or PDN APN. This will give all Kconfig configurations including the words PDN or PDN APN available in the SDK. 

    The Kconfig definition of these config options include information on what library they belong in, e.g. 

    <nRF>/lib/pdn/Kconfig:50 refers to nrf\lib\pdn\Kconfig. The functions are found in nrf\lib\pdn\pdn.c. 

    int pdn_default_apn_get(char *buf, size_t len)
    {
    	int err;
    	char apn[64] = {0};
    
    	/* +CGDCONT: 0,"family","apn.name" */
    	err = nrf_modem_at_scanf("AT+CGDCONT?",
    		"+CGDCONT: 0,\"%*[^\"]\",\"%64[^\"]\"", apn);
    	if (err < 0) {
    		LOG_ERR("Failed to read PDP contexts, err %d", err);
    		return err;
    	}
    
    	if (strlen(apn) + 1 > len) {
    		return -E2BIG;
    	}
    
    	strcpy(buf, apn);
    	return 0;
    }

    From the function above, you can see what AT command (+CGDCONT) is used to configure APN which is also described in the PDN library documentation. All AT commands are documented in our AT command reference guide, which is also linked to in the PDN documentation.

    Kind regards,
    Øyvind

  • Hello Øyvind-san,

    Thank you for your suggestion. But I think your suggestion is based on the premise that I know the libraries.

    When I check the network connection, I first try the AT command using SLM-App.
    Because the commands are executed step by step, they are easy to check and correct.


    For example, the APN settings for the AT command are "AT + CGDCONT" and "AT + CGAUTH".


    (Before I know they are in the PDN library)
    To set the APN information in the sample program, I would only search for "APN" in the Kconfig search.

    As a result, I never get to "CONFIG_PDN_DEFAULT_USERNAME" and "CONFIG_PDN_DEFAULT_PASSWORD".


    Of course, if I change the search term, it will hit someday.
    However, I thought it would be nice if there was a way to change the sample program from the result of the AT command with the minimum steps.

    I hope I don't miss something the important Kconfig settings.

    Older versions of the reference site seem to work. If "Not Found" appears, I'll let you know.

    thank you.

    BR,

    Yukio Oyama

Reply
  • Hello Øyvind-san,

    Thank you for your suggestion. But I think your suggestion is based on the premise that I know the libraries.

    When I check the network connection, I first try the AT command using SLM-App.
    Because the commands are executed step by step, they are easy to check and correct.


    For example, the APN settings for the AT command are "AT + CGDCONT" and "AT + CGAUTH".


    (Before I know they are in the PDN library)
    To set the APN information in the sample program, I would only search for "APN" in the Kconfig search.

    As a result, I never get to "CONFIG_PDN_DEFAULT_USERNAME" and "CONFIG_PDN_DEFAULT_PASSWORD".


    Of course, if I change the search term, it will hit someday.
    However, I thought it would be nice if there was a way to change the sample program from the result of the AT command with the minimum steps.

    I hope I don't miss something the important Kconfig settings.

    Older versions of the reference site seem to work. If "Not Found" appears, I'll let you know.

    thank you.

    BR,

    Yukio Oyama

Children
  • Hello Øyvind-san,

    It seems that older versions of reference sites do not contain content before v1.3.2.
    I used to misunderstand that Modem and SDK versions would be the same. (If MFW is v1.3.1, SDK also uses v1.3.1). Therefore, I found that there is no content on the reference site of v1.3.1.

    However, it doesn't matter because the content is present in the SDK version I want to use.
    I attach an image that does not contain content.

    My question is over. I close the case.

    I digressed from my posting question, but thank you for telling me about updating the reference site.

    Best Regards,

    Yukio Oyama

Related