<?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>Understanding the API calls.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/73525/understanding-the-api-calls</link><description>nRf Gurus, I need your help! It is very hard for me to understand top level configuration of the soft devices and overall mentality. I am sure it will be very easy and convenient as soon as I will understand how to interact with these soft-devices and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Apr 2021 11:17:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/73525/understanding-the-api-calls" /><item><title>RE: Understanding the API calls.</title><link>https://devzone.nordicsemi.com/thread/304781?ContentTypeID=1</link><pubDate>Wed, 14 Apr 2021 11:17:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26f67eb8-023a-402f-aa4d-9c9bafa62fe6</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;You can try changing the priority of the at cmd thread. You can do that by setting CONFIG_AT_CMD_THREAD_PRIO in prj.conf.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the API calls.</title><link>https://devzone.nordicsemi.com/thread/304128?ContentTypeID=1</link><pubDate>Sun, 11 Apr 2021 00:12:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:754916a7-c747-48aa-9132-a4ce093aa490</guid><dc:creator>SamIam</dc:creator><description>&lt;p&gt;Thank you for your support. &lt;br /&gt;I got over the AT_Library and modified the sample to check both, &amp;quot;at_cmd_write&amp;quot; and &amp;quot;at_cmd_write_with_callback&amp;quot; functions. For the debugging convenience i used &amp;quot;spagetti&amp;quot; style instead of looping and still need a small help with callbacks. While &amp;quot;at_cmd_write&amp;quot; is working great, it looks like handler routine for &amp;quot;at_cmd_write_with_callback&amp;quot; (&amp;quot;responce_handler&amp;quot; in this case) does not have IRQ priority and not getting called while code is running. &lt;br /&gt;As you can see on the terminal, &amp;quot;at_cmd_write&amp;quot; replied right back, but handler of &amp;quot;at_cmd_write_with_callback&amp;quot; waited until &amp;quot;main&amp;quot; got through and only then kicked in. It is really important for me to properly arrange the sequence of the logging in to the server, what am I doing wrong? &lt;br /&gt;How can I get the handler to be a priority interrupt?&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;drivers/uart.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;drivers/clock_control.h&amp;gt;
#include &amp;lt;drivers/clock_control/nrf_clock_control.h&amp;gt;

//enum at_cmd_state at_state;

/**@brief Recoverable modem library error. */




void nrf_modem_recoverable_error_handler(uint32_t err)
{
	printk(&amp;quot;Modem library recoverable error: %u\n&amp;quot;, err);
}

/* To strictly comply with UART timing, enable external XTAL oscillator */
void enable_xtal(void)
{
	struct onoff_manager *clk_mgr;
	static struct onoff_client cli = {};

	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
	sys_notify_init_spinwait(&amp;amp;cli.notify);
	(void)onoff_request(clk_mgr, &amp;amp;cli);
}

static void responce_handler(const char* response){
    if(strlen(response) &amp;gt; 0){
        printk(&amp;quot;AT recv:\t%s&amp;quot;,response);}
}

void main(void)
{
        int err;
        char rback[20];
	enable_xtal();
        nrfx_systick_init();//Sam
	printk(&amp;quot;The AT host sample started\n&amp;quot;);
        nrfx_systick_delay_ms(1000);  
           
        printk(&amp;quot;Sending AT+CFUN=1\n&amp;quot;);
        if((err = at_cmd_write_with_callback(&amp;quot;AT+CFUN=1&amp;quot;,&amp;amp;responce_handler)) !=0)
        { printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(10);
        printk(&amp;quot;Sending AT+CFUN?\n&amp;quot;);
        //if((err = at_cmd_write_with_callback(&amp;quot;AT+CFUN?&amp;quot;,&amp;amp;responce_handler)) !=0)
        if((err = at_cmd_write(&amp;quot;AT+CFUN?&amp;quot;,&amp;amp;rback,sizeof(rback),NULL) !=0))
          {printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(rback,&amp;quot;\n&amp;quot;);
            printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(1000); 
        /*******************************************/
        printk(&amp;quot;Requesting MFG ID\n&amp;quot;);
        if((err = at_cmd_write_with_callback(&amp;quot;AT+CGMI?&amp;quot;,&amp;amp;responce_handler)) !=0)
        { printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(10);
        /*******************************************/
        printk(&amp;quot;Requesting Temp\n&amp;quot;);
        if((err = at_cmd_write_with_callback(&amp;quot;AT%XTEMP?&amp;quot;,&amp;amp;responce_handler)) !=0)
        { printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(1000);
        /*******************************************/
        printk(&amp;quot;Sending AT+CFUN=0\n&amp;quot;);
        if((err = at_cmd_write_with_callback(&amp;quot;AT+CFUN=0&amp;quot;,&amp;amp;responce_handler)) !=0)
        { printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(10);
                printk(&amp;quot;Sending AT+CFUN?\n&amp;quot;);
        if((err = at_cmd_write_with_callback(&amp;quot;AT+CFUN?&amp;quot;,&amp;amp;responce_handler)) !=0)
        { printk(&amp;quot;Return: Error\n&amp;quot;, err);}
        else 
          {printk(&amp;quot;Return: OK\n&amp;quot;, err);}
        nrfx_systick_delay_ms(10);
              
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;The AT host sample started
Sending AT+CFUN=1
Return: OK
Sending AT+CFUN?
+CFUN: 1
Return: OK
Requesting MFG ID
Return: OK
Requesting Temp
Return: OK
Sending AT+CFUN=0
Return: OK
Sending AT+CFUN?
Return: OK
AT recv:%XTEMP: 27
AT recv:+CFUN: 0&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the API calls.</title><link>https://devzone.nordicsemi.com/thread/303787?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 13:13:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6630dee-1432-4d1f-8256-96acbac59770</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]The goal is to start the device, send &amp;quot;AT+CFUN?&amp;quot; and read the result back into variable with API or using AT-library.[/quote]
&lt;p&gt;&amp;nbsp;You can use the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/modem/at_cmd.html#c.at_cmd_write"&gt;at_cmd_write()&lt;/a&gt; function for that. The result will be read back into a buffer that you pass to the function.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Can anyone PLEASE(!) present a bare code in a single &amp;quot;main&amp;quot; function and &amp;quot;includes&amp;#39;&amp;#39;, if any needed. [/quote]
&lt;p&gt;&amp;nbsp;You can use most samples in the SDK. &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/master/samples/nrf9160/at_client"&gt;This one&lt;/a&gt; is quite simple.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>