Hard coded context ID of 0 in the Serial LTE Modem application (nRF SDK 2.0.0)

Hi!

I am using the Serial LTE Modem application from the nRF Connect SDK v.2.0.0

In the source code for this app, every call to: 

int util_resolve_host(int cid, const char *host, uint16_t port, int family, struct sockaddr *sa)
has a hardcoded "cid" argument with the value 0. This is a problem where a preexisting default context can't be used. It isn't possible to deactivate the default context and any new context will have a non zero id.
Creating a new context with AT+CGDCONT, activating the this context and deactivating the default with AT+CGACT will result in a single remaining context with a cid of 1.
Attempting to use AT#XSENDTO with an active context with cid=1 will result in a call to util_resolve_host with a hard coded cid=0 and the AT command will fail.
I can always hard code a different cid and recompile the application, but somehow this feels like the wrong solution to the problem Slight smile
Any suggestions to how I can get around this using AT commands without having to patch the SLM source code ?
Regards
Hans Jørgen
Lab5e AS
Parents Reply Children
  • Hi !

    I am not trying to use multiple PDP contexts.

    I created a new one using +CGDCONT and then deactivated the default context with +CGACT. I then ended up with a single active context with a context id == 1. The non-zero id breaks any attempts to use the context to transfer data in the SLM code.

    The SLM code works just fine for AT#XSENDTO and AT#XRECVFROM if the correct (non-zero) cid is transferred in the calls to util_get_ip_addr and util_resolve_host, so I don't quite understand why it isn't supported.

    The source code documentation for these two functions is also clear about this:

     * @param[in] cid PDP Context ID as defined in "+CGDCONT" command (0~10).

    If it's the case that only a single context with an id of 0 is permitted in this version of SLM, maybe it would have been better to:

    • Explicitly include the CONFIG_PDN_DEFAULT_APN and CONFIG_PDN_DEFAULTS_OVERRIDE configs (along with maybe a comment or two) in the SLM prj.conf, since this would make it a bit more explicit (I guess that by using these I can specify my own default context that will end up with a cid == 0 ?)
    • Disallow creation of PDP contexts with a non-zero id in the +CGDCONT command, since being able to create a seemingly ok PDP context that can't be used for sending data is a somewhat confusing user experience.

    For socket send and receive, previously mentioned socket option can be used to bind secondary PDP context.

    Which socket option are you referring to ? 

    Best Regards

    Hans Jørgen

  • Hi Hans Jørgen,

    You could apply these changes. This should work regardless if your network allows non-zero primary context or not. Cid 0 is assumed as primary context (in init state), but it can be overridden with <cid> parameter in AT command.

    Best regards,
    Dejan

Related