Failed to activate PDN for CID

I'm having trouble activating a PDN on a running/connected device. Here's the code:

int set_apn(char *apn)
{
    int err = 0;
    int esm = 0;
    char current[128];

    /* Get the current default */
    err = pdn_default_apn_get(current, sizeof(current));
    if (err)
    {
        LOG_ERR("pdn_default_apn_get error: %i", err);
        return err;
    }

    /* Don't do anything if APN is the same */
    if (strcmp(current, apn) == 0)
    {
        LOG_INF("No update neded. APN matches: %s", log_strdup(apn));
        return 0;
    }

    /* Create a PDP context and assign an event handler to receive events */
    err = pdn_ctx_create(&cid, pdn_event_handler);
    if (err)
    {
        LOG_ERR("pdn_ctx_create() failed, err %i", err);
        pdn_ctx_destroy(cid);
        return err;
    }

    LOG_INF("Created new PDP context %d", cid);

    /* Configure a PDP context with APN and Family */
    err = pdn_ctx_configure(cid, apn, PDN_FAM_IPV4V6, NULL);
    if (err)
    {
        LOG_ERR("pdn_ctx_configure() failed, err %i", err);
        pdn_ctx_destroy(cid);
        return err;
    }

    LOG_INF("PDP context %i configured: APN %s", cid, log_strdup(apn));

    /* Activate a PDN connection */
    err = pdn_activate(cid, &esm, NULL);
    if (err < 0)
    {
        LOG_ERR("pdn_activate() failed, err %i esm %i",
                err, esm);
        pdn_ctx_destroy(cid);
        return err;
    }

    return 0;
}

Seems like I'm missing something here. pdn_init does get called on system setup. (using CONFIG_PDN_SYS_INIT=y)

[00:00:25.517,486] <inf> main: Evt: APP_EVENT_APN_UPDATE
[00:00:25.517,517] <inf> main: ------------------- POST status 43
[00:00:25.517,547] <inf> main: Set apn to: Att (len: 3)
[00:00:25.531,402] <inf> main: Created new PDP context 1
[00:00:25.531,890] <inf> main: PDP context 1 configured: APN Att
[00:00:25.772,003] <wrn> pdn: Failed to activate PDN for CID 1, err 65536
[00:00:26.772,125] <err> main: pdn_activate() failed, err -8 esm 0 <unknown>

Parents
  • Hi,

     

    What is the order of initialization here?

    If you are initializing the modem library in the application, you'd need to call pdn_init() after modem init, with CONFIG_PDN_SYS_INIT=n, but before AT+CFUN=1 is set (ie. lte_lc_connect() is called)

     

    Kind regards,

    Håkon

  •  CONFIG_PDN_SYS_INIT was set to 'y' by default. I've changed the order of operations to see if that makes a difference. No go.

    Does the modem need to be in a disconnected state when creating and applying a new PDN context?

    Here is a log below where the device inits the modem library, then PDN, connects and then later on sets the PDN as set by the user.

    [00:01:30.965,972] <inf> main: Set apn to: Att (len: 3)
    [00:01:30.973,846] <inf> main: Created new PDP context 1
    [00:01:30.974,334] <inf> main: PDP context 1 configured: APN Att
    [00:01:31.005,157] <inf> main: LTE_LC_EVT_MODEM_SLEEP_EXIT 1
    [00:01:31.433,197] <wrn> pdn: Failed to activate PDN for CID 1, err 65536
    [00:01:32.433,319] <err> main: pdn_activate() failed, err -8 esm 0

Reply
  •  CONFIG_PDN_SYS_INIT was set to 'y' by default. I've changed the order of operations to see if that makes a difference. No go.

    Does the modem need to be in a disconnected state when creating and applying a new PDN context?

    Here is a log below where the device inits the modem library, then PDN, connects and then later on sets the PDN as set by the user.

    [00:01:30.965,972] <inf> main: Set apn to: Att (len: 3)
    [00:01:30.973,846] <inf> main: Created new PDP context 1
    [00:01:30.974,334] <inf> main: PDP context 1 configured: APN Att
    [00:01:31.005,157] <inf> main: LTE_LC_EVT_MODEM_SLEEP_EXIT 1
    [00:01:31.433,197] <wrn> pdn: Failed to activate PDN for CID 1, err 65536
    [00:01:32.433,319] <err> main: pdn_activate() failed, err -8 esm 0

Children
No Data
Related