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

at command parser library use

Hi,

nRF9160 DK
I have a simple question regarding processing at command responses. I was hoping to extract the individual values from a at command response using the at command parser library
e.g. from the response "+CESQ: 99,99,255,255,11,49" obtain an array of ints 99,99,255 etc. Before I write code to extract sub strings using comma delimiters will the at command parser
library achieve this? I am struggling to find examples of how to use this library. Using the function "at_params_valid_count_get" on the above example string returns 1 and "at_parser_params_from_str" returns a single value of 99,99,255,255,11,49 so I suspect I am not understanding the purpose of the library or using it correctly. A example of how to use the library would be appreciated.

Thank you

Peter

  • Thanks Jan Tore,

    If the stack fix does not work I will get some test code to you.

    I tried enabling stack protection but the project fails to load with the error:

    prj.conf:68: warning: attempt to assign the value 'y' to the undefined symbol GW_STACK_PROTECTION

    Config file below, I am using my own broker so I have redacted the IP address.

    Any help will be appreciated.


    CONFIG_GPIO=y
    CONFIG_SERIAL=y
    CONFIG_MODEM_INFO=y

    # Networking
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    #CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y

    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

    # BSD library
    CONFIG_BSD_LIBRARY=y

    # enable modem trace
    #CONFIG_BSD_LIBRARY_TRACE_ENABLED=y <<<<<<<<<<<<<

    # logging
    CONFIG_LOG=y
    CONFIG_LOG_IMMEDIATE=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y

    # AT Host
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y

    CONFIG_NEWLIB_LIBC=y # need this for newlib time.h

    # MQTT

    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y # TLS enabled
    CONFIG_MQTT_BROKER_PORT=8884
    CONFIG_SEC_TAG=51966
    CONFIG_PEER_VERIFY=1

    CONFIG_MQTT_PUB_TOPIC="ptopic"
    CONFIG_MQTT_SUB_TOPIC="stopic"
    CONFIG_MQTT_CLIENT_ID="dk"
    CONFIG_MQTT_BROKER_HOSTNAME=XXXXXXXXXX

    CONFIG_MQTT_KEEPALIVE=60

    CONFIG_MQTT_MESSAGE_BUFFER_SIZE=1024
    CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=1024

    # Main thread
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_GW_STACK_PROTECTION=y

    CONFIG_HEAP_MEM_POOL_SIZE=2048

  • Hi Peter, 

    I had a typo in the original answer, it should be:

    CONFIG_HW_STACK_PROTECTION=y

    Sorry about that! 

    Regards, 

    Jan Tore 

  • No problem Jan Tore I did some searching and found the protection config.

    I have enabled the HW stack protection and also increased the stack size:

    CONFIG_MAIN_STACK_SIZE=8192

    CONFIG_HW_STACK_PROTECTION=y

    CONFIG_HEAP_MEM_POOL_SIZE=8192

    But I am getting a hard reset on the at callback with no more information showing. Are there any more steps I need to take? I am only monitoring the DK board with the LTE link monitor. I don't have any j-link hardware if that is required.

    the callback simply prints the response:

    void callback_handler(char * response)
    {
    LOG_DBG("Response: %s",response);
    }

  • That handler seems to be for the at_cmd module and not at_notif, is that correct?

    Ideally you should register the handler with the at_notif module (this is probably not clear from the docs), as that allows for multiple subscribers to URCs. I can see from your config file that the AT host is enabled, which relies on at_notif. If any other part of your app registers a new handler with at_notif, the AT host will also stop working properly.

    To register with the at_notif, you can use at_notif_register_handler(). Note that the callback has a slightly different signature:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/a947fc91e5ce4e478ef72a3062314b295ae26bde/include/modem/at_notif.h#L40

    Regarding J-Link, there's a debugger on the DK that allows standard debugging with for example GDB, SEGGER's tools and other debug solutions. You don't need an external J-Link for the basics.

  • Thank you Jan Tore,

    I was disabling the at host for these tests. I had registered the handler as a at_notif with a null context, but then copied an existing at_cmd handler which did not account for the context signature so changing the handler to:

    void callback_handler(void * context, char * response) fixed the problem...

    At least I have plenty of time at the moment to fix my mistakes!

    Cheers

    Peter

Related