This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

set APN

I'm new to develop firmware on nRF9160-DK, and my first target to add APN to use LTE-M.

For now, I'd like to do a simple way in the below even this is temporary.

=> Hard-code in code.  Have to re-build if APN needs tp be changed.

I've added the code to run the following at the beginning of main in 'mqtt_simple' to add APN.

>>if (at_cmd_write('AT+CGDCONT=1,"IP","isp.telus.com"', NULL, 0, NULL) != 0) {
>>    LOG_INF("Failed AT+CGDCONT");
>>}

But it looked failing somehow because I didn't see the following message without my code in mqtt_simple.

Could you let me know how to hard-code to add APN?

---------------------------------------

AT+CFUN?
ÂÅ0000 0x40000 Non-Secure rwxl
Peripheral Domain Status
00 NRF_P0 Non-Secure OK
01 NRF_CLOCK Non-Secure OK
02 NRF_RTC0 Non-Secure OK
03 NRF_RTC1 Non-Secure OK
04 NRF_NVMC Non-Secure OK
05 NRF_UARTE1 Non-Secure OK
06 NRF_UARTE2 Secure SKIP
07 NRF_TWIM2 Non-Secure OK
08 NRF_SPIM3 Non-Secure OK
09 NRF_TIMER0 Non-Secure OK
10 NRF_TIMER1 Non-Secure OK
11 NRF_TIMER2 Non-Secure OK
12 NRF_SAADC Non-Secure OK
13 NRF_PWM0 Non-Secure OK
14 NRF_PWM1 Non-Secure OK
15 NRF_PWM2 Non-Secure OK
16 NRF_PWM3 Non-Secure OK
17 NRF_WDT Non-Secure OK
18 NRF_IPC Non-Secure OK
19 NRF_VMC Non-Secure OK
20 NRF_FPU Non-Secure OK
21 NRF_EGU1 Non-Secure OK
22 NRF_EGU2 Non-Secure OK
23 NRF_DPPIC Non-Secure OK
24 NRF_GPIOTE1 Non-Secure OK
25 NRF_REGULATORS Non-Secure OK
SPM: NS image at 0xc000
SPM: NS MSP at 0x20025338
SPM: NS reset vector at 0xfcd9
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.4.0-ncs1-1710-g5a7b4eb71047 ***
[00:00:00.207,122] [0m<inf> at_host: UART check failed: 1. Dropping buffer and retrying.[0m
[00:00:00.217,254] [0m<inf> mqtt_simple: The MQTT simple sample started[0m
[00:00:00.217,254] [1;31m<err> os: ***** BUS FAULT *****[0m
[00:00:00.217,254] [1;31m<err> os: Precise data bus error[0m
[00:00:00.217,254] [1;31m<err> os: BFAR Address: 0x636f6d22[0m
[00:00:00.217,285] [1;31m<err> os: r0/a1: 0x636f6d22 r1/a2: 0x00000000 r2/a3: 0x00000000[0m
[00:00:00.217,285] [1;31m<err> os: r3/a4: 0x00000000 r12/ip: 0x20020104 r14/lr: 0x0000d465[0m
[00:00:00.217,285] [1;31m<err> os: xpsr: 0x21000000[0m
[00:00:00.217,285] [1;31m<err> os: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000[0m
[00:00:00.217,315] [1;31m<err> os: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000[0m
[00:00:00.217,315] [1;31m<err> os: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000[0m
[00:00:00.217,346] [1;31m<err> os: s[12]: 0x00000000 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x00000000[0m
[00:00:00.217,346] [1;31m<err> os: fpscr: 0x00000000[0m
[00:00:00.217,346] [1;31m<err> os: Faulting instruction address (r15/pc): 0x000124ec[0m
[00:00:00.217,346] [1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[0m
[00:00:00.217,346] [1;31m<err> os: Current thread: 0x200205a8 (unknown)[0m
[00:00:00.341,796] [1;31m<err> fatal_error: Resetting system[0m
*** Booting Zephyr OS build v2.4.0-ncs1-1710-g5a7b4eb71047 ***
Flash regions Domain Permissions
00 00 0x00000 0x08000 Secure rwxl
01 31 0x08000 0x100000 Non-Secure rwxl
Non-secure callable region 0 placed in flash region 0 with size 32.
SRAM region Domain Permissions
00 07 0x00000 0x10000 Secure rwxl
08 31 0x10000 0x40000 Non-Secure rwxl
---------------------------------------
  • Hi,

    From the log, I can see that your device is crashing shortly after startup.

    The reason for this is twofold:

    1.

     

    'AT+CGDCONT=1,"IP","isp.telus.com"'

     This is not a valid character. In C ' is used for char literals, while " is used for string literals. If you want to use " inside a string, it must be escaped with \.

    Your AT command string should therefore be: "AT+CGDCONT=1,\"IP\",\"isp.telus.com\"".

    2. This would normally be caught by the compiler, but it also doesn't seem like you have included <modem/at_cmd.h> in your .c file. Because of this, the compiler doesn't know what type you are intending to have, and only issues a warning.

    Finally, to set the APN used by the default bearer, you must use cid 0, not 1.

    Best regards,

    Didrik

Related