<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>at command parser library use</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59557/at-command-parser-library-use</link><description>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 &amp;quot;+CESQ: 99,99,255,255,11,49&amp;quot; obtain</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Apr 2020 20:51:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59557/at-command-parser-library-use" /><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244303?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 20:51:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f44641c-b205-480d-a251-5c8e4562c059</guid><dc:creator>PeterC</dc:creator><description>&lt;p&gt;Thank you Jan Tore,&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;void callback_handler(void * context, char * response) fixed the problem...&lt;/p&gt;
&lt;p&gt;At least I have plenty of time at the moment to fix my mistakes!&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244301?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 19:56:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f870bac-b866-4c57-9b37-f092956e52db</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;That handler seems to be for the at_cmd module and not at_notif, is that correct?&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;To register with the at_notif, you can use&amp;nbsp;&lt;span&gt;at_notif_register_handler(). Note that the callback has a slightly different signature:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/a947fc91e5ce4e478ef72a3062314b295ae26bde/include/modem/at_notif.h#L40"&gt;https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/a947fc91e5ce4e478ef72a3062314b295ae26bde/include/modem/at_notif.h#L40&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regarding J-Link, there&amp;#39;s a debugger on the DK that allows standard debugging with for example GDB, SEGGER&amp;#39;s tools and other debug solutions. You don&amp;#39;t need an external J-Link for the basics.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244300?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 19:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23326f12-65ae-4e1d-93df-657913343c1f</guid><dc:creator>PeterC</dc:creator><description>&lt;p&gt;No problem Jan Tore I did some searching and found the protection config.&lt;/p&gt;
&lt;p&gt;I have enabled the HW stack protection and also increased the stack size:&lt;/p&gt;
&lt;p&gt;CONFIG_MAIN_STACK_SIZE=8192&lt;/p&gt;
&lt;p&gt;CONFIG_HW_STACK_PROTECTION=y&lt;/p&gt;
&lt;p&gt;CONFIG_HEAP_MEM_POOL_SIZE=8192&lt;/p&gt;
&lt;p&gt;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&amp;#39;t have any j-link hardware if that is required.&lt;/p&gt;
&lt;p&gt;the callback simply prints the response:&lt;/p&gt;
&lt;p&gt;void callback_handler(char * response)&lt;br /&gt;{&lt;br /&gt; LOG_DBG(&amp;quot;Response: %s&amp;quot;,response);&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244293?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 17:05:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa7ed392-ac6e-43b4-b0ca-c31f50f8161f</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi Peter,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I had a typo in the original answer, it should be:&lt;/p&gt;
&lt;p&gt;CONFIG_HW_STACK_PROTECTION=y&lt;/p&gt;
&lt;p&gt;Sorry about that!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Jan Tore&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244290?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 16:52:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f77ca5a2-772f-4330-9990-6ad669c21b83</guid><dc:creator>PeterC</dc:creator><description>&lt;p&gt;Thanks Jan Tore,&lt;/p&gt;
&lt;p&gt;If the stack fix does not work I will get some test code to you.&lt;/p&gt;
&lt;p&gt;I tried enabling stack protection but the project fails to load with the error:&lt;/p&gt;
&lt;p&gt;prj.conf:68: warning: attempt to assign the value &amp;#39;y&amp;#39; to the undefined symbol GW_STACK_PROTECTION&lt;/p&gt;
&lt;p&gt;Config file below, I am using my own broker so I have redacted the IP address.&lt;/p&gt;
&lt;p&gt;Any help will be appreciated.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;CONFIG_GPIO=y&lt;br /&gt;CONFIG_SERIAL=y&lt;br /&gt;CONFIG_MODEM_INFO=y&lt;/p&gt;
&lt;p&gt;# Networking&lt;br /&gt;CONFIG_NETWORKING=y&lt;br /&gt;CONFIG_NET_NATIVE=n&lt;br /&gt;#CONFIG_NET_SOCKETS_OFFLOAD=y&lt;br /&gt;CONFIG_NET_SOCKETS=y&lt;br /&gt;CONFIG_NET_SOCKETS_POSIX_NAMES=y&lt;/p&gt;
&lt;p&gt;# LTE link control&lt;br /&gt;CONFIG_LTE_LINK_CONTROL=y&lt;br /&gt;CONFIG_LTE_AUTO_INIT_AND_CONNECT=n&lt;/p&gt;
&lt;p&gt;# BSD library&lt;br /&gt;CONFIG_BSD_LIBRARY=y&lt;/p&gt;
&lt;p&gt;# enable modem trace&lt;br /&gt;#CONFIG_BSD_LIBRARY_TRACE_ENABLED=y &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/p&gt;
&lt;p&gt;# logging &lt;br /&gt;CONFIG_LOG=y&lt;br /&gt;CONFIG_LOG_IMMEDIATE=y&lt;br /&gt;CONFIG_LOG_DEFAULT_LEVEL=4&lt;br /&gt;CONFIG_STDOUT_CONSOLE=y&lt;br /&gt;CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y&lt;/p&gt;
&lt;p&gt;# AT Host&lt;br /&gt;CONFIG_UART_INTERRUPT_DRIVEN=y&lt;br /&gt;CONFIG_AT_HOST_LIBRARY=y&lt;/p&gt;
&lt;p&gt;CONFIG_NEWLIB_LIBC=y # need this for newlib time.h&lt;/p&gt;
&lt;p&gt;# MQTT&lt;/p&gt;
&lt;p&gt;CONFIG_MQTT_LIB=y&lt;br /&gt;CONFIG_MQTT_LIB_TLS=y # TLS enabled&lt;br /&gt;CONFIG_MQTT_BROKER_PORT=8884 &lt;br /&gt;CONFIG_SEC_TAG=51966&lt;br /&gt;CONFIG_PEER_VERIFY=1&lt;/p&gt;
&lt;p&gt;CONFIG_MQTT_PUB_TOPIC=&amp;quot;ptopic&amp;quot;&lt;br /&gt;CONFIG_MQTT_SUB_TOPIC=&amp;quot;stopic&amp;quot;&lt;br /&gt;CONFIG_MQTT_CLIENT_ID=&amp;quot;dk&amp;quot;&lt;br /&gt;CONFIG_MQTT_BROKER_HOSTNAME=XXXXXXXXXX&lt;/p&gt;
&lt;p&gt;CONFIG_MQTT_KEEPALIVE=60&lt;/p&gt;
&lt;p&gt;CONFIG_MQTT_MESSAGE_BUFFER_SIZE=1024&lt;br /&gt;CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=1024&lt;/p&gt;
&lt;p&gt;# Main thread&lt;br /&gt;CONFIG_MAIN_STACK_SIZE=4096&lt;br /&gt;CONFIG_GW_STACK_PROTECTION=y&lt;/p&gt;
&lt;p&gt;CONFIG_HEAP_MEM_POOL_SIZE=2048&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244283?ContentTypeID=1</link><pubDate>Mon, 13 Apr 2020 13:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43797260-9a72-4dc6-aa69-39f201fb3552</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;Have you checked if this might be a stack overflowing?&lt;br /&gt;You can enable stack protection by setting CONFIG_HW_STACK_PROTECTION=y in prj.conf.&lt;/p&gt;
&lt;p&gt;If a stack overflows, you&amp;#39;ll get some useful debug information to check which instruction causes the error, and which stack is overflowing.&lt;/p&gt;
&lt;p&gt;If possible, you could share your code to make it easier for others to try to reproduce the issues locally and help out that way.&lt;/p&gt;
&lt;p&gt;Regarding the poll() issue, I can&amp;#39;t recall having seen similar issues, so I&amp;#39;ll have to check that.&amp;nbsp;&lt;br /&gt;Have you tried doing a blocking receive instead? If so, do you see the same issues?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jan Tore&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/244144?ContentTypeID=1</link><pubDate>Wed, 08 Apr 2020 22:44:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da0f3f86-065d-4c3b-9b56-12c532fde438</guid><dc:creator>PeterC</dc:creator><description>&lt;p&gt;Hi Jan Tore,&lt;/p&gt;
&lt;p&gt;When I enable a at_notif_register_handler for URC&amp;#39;s&amp;nbsp; I can see the handler being called when URC&amp;#39;s are received&amp;nbsp; but if I try to access the handler&amp;#39;s response buffer in any way, the device reset&amp;#39;s itself. The same handler used with at command send with callbacks works fine (the at_notif handler is not registered during those tests).&lt;/p&gt;
&lt;p&gt;Also if I setup a simple at socket and poll it I can use a button interrupt to send a at command and get a response but URC&amp;#39;s never trigger a POLLIN event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am unsure of what is happening here, any ideas?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/242255?ContentTypeID=1</link><pubDate>Sun, 29 Mar 2020 20:09:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33b8e9d9-83db-48ec-b001-6df9fa2bd86d</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, if you&amp;#39;re using the at_cmd library, the best way to go about it is to register an AT command handler with at_notif.&lt;br /&gt;Currently all handlers registered with at_notif will get all URCs, and you can&amp;#39;t register a handler for only certain response types.&lt;br /&gt;So you&amp;#39;ll need to have some logic in your handler to check the first parameter coming out of&amp;nbsp;&lt;span&gt;at_parser_max_params_from_str() and handle/ignore it accordingly.&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jan Tore&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/242228?ContentTypeID=1</link><pubDate>Sat, 28 Mar 2020 16:56:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0668e05a-f94b-42c1-8aaa-62b4534eeb3d</guid><dc:creator>PeterC</dc:creator><description>&lt;p&gt;Hi Jan Tore,&lt;/p&gt;
&lt;p&gt;Thanks for your quick response, I have some test parser code working now. I have enabled registration status URC&amp;#39;s using +CEREG=1. I take it that I would then need to enable a &amp;quot;global&amp;quot; URC handler using&amp;nbsp;&lt;span&gt;at_notif_register_handler which accepts all URC&amp;#39;s and inputs them to the at parser for processing. Since the register handler needs to accept all URC&amp;#39;s while the modem is on it never gets de-registered. Is this approach correct? Or can I assign handlers to particular URC&amp;#39;s?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Cheers&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Peter&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: at command parser library use</title><link>https://devzone.nordicsemi.com/thread/242182?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 20:38:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eae1ef49-65be-4a74-b2d5-3aef10711c8f</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi Peter,&lt;br /&gt;&lt;br /&gt;To better understand how to use the AT parser library, you can for example have a look at how CEREG responses are parsed in the LTE link controller:&lt;br /&gt;&lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/lib/lte_link_control/lte_lc.c#L528"&gt;https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/lib/lte_link_control/lte_lc.c#L528&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;What you need to do is:&lt;br /&gt;- Initialize a parameter list with the maximum number of parameters in the command response or notification that you wish to decode. So for +CESQ, that is 7, as &amp;quot;+CESQ&amp;quot; also counts as a paramter.&lt;br /&gt;- Input the response string to the parser using &lt;span&gt;at_parser_max_params_from_str&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;br /&gt;- Read out individual parameter using&amp;nbsp;&lt;span&gt;at_params_string_get() or&amp;nbsp;at_params_int_get() and similar helpper functions. &amp;quot;+CEREG&amp;quot; is the parameter in posiion 0 and can be used to check which response type you&amp;#39;re handling.&lt;br /&gt;&lt;/span&gt;- Free the list after you&amp;#39;re done with it using&amp;nbsp;&lt;span&gt;at_params_list_free()&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Best regards,&lt;br /&gt;Jan Tore&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>