<?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>Unable to receive UART response when combined the NUS example with custom service central example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45722/unable-to-receive-uart-response-when-combined-the-nus-example-with-custom-service-central-example</link><description>Hi, 
 I am using a central example to scan the peripheral and connects to it. I get data through notifications in bulk. That works fine. Then in order to add support to FONA808 module, I need to have UART communication which I have established using NUS</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Apr 2019 15:52:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45722/unable-to-receive-uart-response-when-combined-the-nus-example-with-custom-service-central-example" /><item><title>RE: Unable to receive UART response when combined the NUS example with custom service central example</title><link>https://devzone.nordicsemi.com/thread/180366?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2019 15:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4e39177-ee82-42b2-a5e7-4be358f53056</guid><dc:creator>Muhammad Akram Karimi</dc:creator><description>&lt;p&gt;UPDATE:&lt;br /&gt;I got the issue resolved. The exact reason, I am still unsure.&lt;/p&gt;
&lt;p&gt;The issue was that I was using app_uart.c in the project which was not working fine.&lt;/p&gt;
&lt;p&gt;While I was using app_uart_fifo.c in the project which was working fine.&lt;/p&gt;
&lt;p&gt;Since both of these files, I guess, uses same nomenclature of the APIs, so I could not point it out.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Once I started using app_uart_fifo.c and app_fifo.c in the combined project, the issue was resolved. NRF now can hear back on UART and the program is working as expected.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Still, I have one question in mind, why???&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive UART response when combined the NUS example with custom service central example</title><link>https://devzone.nordicsemi.com/thread/180364?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2019 15:36:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fce01002-7c2b-469d-a26f-06a343f337cf</guid><dc:creator>Muhammad Akram Karimi</dc:creator><description>&lt;p&gt;UPDATE: I have just checked on the oscilloscope that both Tx and Rx pins of nRF52 are getting data on them.&lt;/p&gt;
&lt;p&gt;Meaning UART is working fine while transmitting the data at least (UART of nRF sends data and gets the response back from FONA808).&lt;/p&gt;
&lt;p&gt;However, due to some reason the UART in nRF is not detecting the received response, because of which the application keeps on waiting for the response.&lt;/p&gt;
&lt;p&gt;Here is my code for the UART event handler which is supposed to handle the received packets from FONA808 module.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[FONA_CMD_RET_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;
		static char* http_read;

    switch (p_event-&amp;gt;evt_type)
    {
				//Test
				SEGGER_RTT_printf(0, &amp;quot;\nReceived some response from UART\n&amp;quot;);
        case APP_UART_DATA_READY:			//Gets the event at each byte receive
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;
						
            if (data_array[index - 1] == &amp;#39;\n&amp;#39;) 															//AK removed the the upper limit on BLE_NUS_MAX_DATA_LEN==20
																																						//FONA reply consists of at least 3 &amp;quot;\n&amp;quot; if SUCCESS
																																						// 1: Command repeats
																																						// 2: Command response
																																						// 3: OK etc. 
            {
						
								/*			AK47			*/
								// Data is ready to be displayed
								fona_cmd_t.ret_cr_cnt++;		//New CR &amp;#39;\n&amp;#39; found in the command
								uint8_t i=0;
								do{ 
								//	SEGGER_RTT_printf(0, &amp;quot;Rx[%d] = %c\n&amp;quot;,i,data_array[i]);
									 cmd_ret[fona_cmd_t.ret_cr_cnt][i]=data_array[i];
									//SEGGER_RTT_printf(0, &amp;quot;cmd_ret [%d] = %x\n&amp;quot;,i,cmd_ret[fona_cmd_t.ret_cr_cnt][i]);
									i++;
								}while(data_array[i] != &amp;#39;\n&amp;#39;);
								
								
								fona_cmd_t.ret_len=i-1;
								if(fona_cmd_t.ret_len == 0)
								{
									fona_cmd_t.ret_type		=	 CMD_NULL;
									fona_cmd_t.cmd_status =  CMD_PROCESS;
								}
								else
								{									
										//If command length is Non-Zero :: Characterizing the command return types (wnhich type of return code is it)
										char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],fona_cmd_t.cmd);		//Finding same command
										if(ret_type!=NULL)																	//Meaning &amp;quot;SAME&amp;quot; command found in return type
										{
											fona_cmd_t.ret_type		=	 CMD_REPEAT;
											fona_cmd_t.cmd_status =  CMD_PROCESS;
										}
										else		//Same command was not returned
										{
											char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;OK&amp;quot;);						//Finding OK in response
											if(ret_type!=NULL)																//Found OK
											{
												fona_cmd_t.ret_type=CMD_OK;
												if(strstr(fona_cmd_t.cmd,&amp;quot;AT+HTTPACTION=1&amp;quot;)!=NULL)		//If command is AT+HTTPACTION=1 ; in that case &amp;quot;OK&amp;quot; does not indicated the end of response
												{
													SEGGER_RTT_printf(0, &amp;quot;OK response of AT+HTTPACTION=1 does not mean EOC\n&amp;quot;);
													fona_cmd_t.cmd_status =  CMD_PROCESS;								
												}
												else
												{
													fona_cmd_t.cmd_status =  CMD_END;								//Nothing to expect after &amp;quot;OK&amp;quot;
													fona_cmd_t.ret_cr_cnt=0;													//Cleared
												}
											}
											else		// Response was not OK
											{
												char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;ERROR&amp;quot;);						//Finding ERROR in response
												if(ret_type!=NULL)																//Found ERROR
												{
													fona_cmd_t.ret_type=CMD_ERROR;
													fona_cmd_t.cmd_status =  CMD_END;								//Nothing to expect after &amp;quot;ERROR&amp;quot;
													fona_cmd_t.ret_cr_cnt=0;												//Cleared
												}
												else	//ERROR was not found in response
												{
													char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;0.0.0.0&amp;quot;);						//Finding GPRS network release
													if(ret_type!=NULL)																//Found ERROR
													{
														fona_cmd_t.ret_type=CMD_GPRS_INVALID_IP;
														fona_cmd_t.cmd_status =  CMD_END;								//Nothing to expect after &amp;quot;CMD_GPRS_DEACT&amp;quot;
														fona_cmd_t.ret_cr_cnt=0;												//Cleared
													}
													else		//NULL ip was not found in response
													{
														char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;DOWNLOAD&amp;quot;);						//Finding ERROR in response
														if(ret_type!=NULL)																//Found ERROR
														{
															fona_cmd_t.ret_type   =  CMD_DOWNLOAD;
															fona_cmd_t.cmd_status =  CMD_PROCESS;								//User needs to process (input data) further
														}
														else
														{
															char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;+HTTPACTION&amp;quot;); // Denotes that HTTP POST executed OK :: CMD_HTTP_POST_OK
															if(ret_type!=NULL)																//Found respose from server on +HTTPACTION:1
															{
																SEGGER_RTT_printf(0, &amp;quot;Response from server = %s \n&amp;quot;,cmd_ret[fona_cmd_t.ret_cr_cnt]);
																char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;200&amp;quot;);	//200 status code=SUCCESS
																if(ret_type!=NULL)																							//Found 200 in the response from server
																{
																	SEGGER_RTT_printf(0, &amp;quot;\n*** Data successfully uploaded to server ***\n&amp;quot;);
																	fona_cmd_t.cmd_repeat = 0;			//Don&amp;#39;t repeat cmd
																	fona_cmd_t.ret_type   =  CMD_HTTP_POST_OK;
																	fona_cmd_t.cmd_status =  CMD_END;								//Nothing to expect after this
																	fona_cmd_t.ret_cr_cnt=0;												//Cleared
																}
																else
																{
																	SEGGER_RTT_printf(0, &amp;quot;\n*** Some error in uploading data to server. Retry ***\n&amp;quot;);
																	fona_cmd_t.cmd_repeat = 1;			//cmd_repeat flag raised
																	fona_cmd_t.ret_type   =  CMD_HTTP_POST_REPEAT;
																	fona_cmd_t.cmd_status =  CMD_END;								//Ending the command with repeat type[CMD_HTTP_POST_REPEAT]: That will force to re-execute the command
																	fona_cmd_t.ret_cr_cnt=0;												//Cleared
																}
																//http_read = cmd_ret[fona_cmd_t.ret_cr_cnt];
															}
															else
															{
																char* ret_type = strstr(cmd_ret[fona_cmd_t.ret_cr_cnt],&amp;quot;+HTTPREAD&amp;quot;);	//Message from the server
																if(ret_type!=NULL)																//Found respose from server on +HTTPACTION:1
																{
																	SEGGER_RTT_printf(0, &amp;quot;Message from server = %s \n&amp;quot;,cmd_ret[fona_cmd_t.ret_cr_cnt]);
																	fona_cmd_t.ret_type   =  CMD_HTTP_POST_READ;
																	fona_cmd_t.cmd_status =  CMD_END;								//Nothing to expect after this
																	fona_cmd_t.ret_cr_cnt=0;												//Cleared
																}
																else
																{
																	fona_cmd_t.ret_type		=  CMD_RESPONSE;
																	fona_cmd_t.cmd_status =  CMD_PROCESS;						//Command return string : more to expect
																}
															}
														}
													}
												}
											}
										}
									}	
								/*			AK47			*/
                index = 0;
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;BTW, the same piece of code (UART event handler) is working fine (with the same hardware of FONA808) when I don&amp;#39;t combine it with central example. Any hints why nRF UART event handler is not being executed?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive UART response when combined the NUS example with custom service central example</title><link>https://devzone.nordicsemi.com/thread/180084?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 15:54:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb2fa4ee-3bdf-481e-8991-a1683ad0e02d</guid><dc:creator>Muhammad Akram Karimi</dc:creator><description>&lt;p&gt;I don&amp;#39;t think the above mentioned RAM usage messages have anything to do with UART problem. Because I have just checked that my other program (which is working fine and does not use central code) also gives the same messages on top of the log:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;0&amp;gt; RAM START ADDR 0x200025E0 should be adjusted to 0x20002418&lt;br /&gt;&amp;nbsp;0&amp;gt; RAM SIZE should be adjusted to 0xDBE8 &lt;br /&gt;&amp;nbsp;0&amp;gt; sd_ble_enable: RAM START at 0x200025E0&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But still works fine. Meaning UART operation has nothing to do with these messages. The problem is somewhere else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive UART response when combined the NUS example with custom service central example</title><link>https://devzone.nordicsemi.com/thread/180079?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 15:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63bd5a10-5e36-43a9-94e8-e11244f54d13</guid><dc:creator>Muhammad Akram Karimi</dc:creator><description>&lt;p&gt;I just want to add that I get the following on my log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;0&amp;gt; RAM START ADDR 0x200025E0 should be adjusted to 0x20002418
0&amp;gt; RAM SIZE should be adjusted to 0xDBE8 
0&amp;gt; sd_ble_enable: RAM START at 0x200025E0
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Currently the RAM start address is set at 0x200025E0.&lt;/p&gt;
&lt;p&gt;If I set the RAM Start address to be 0x20002418 (Meaning I am keeping less RAM for SD), then I get&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;0&amp;gt; sd_ble_enable: RAM START at 0x20002418
0&amp;gt; sd_ble_enable: app_ram_base should be adjusted to 0x200025E0
0&amp;gt; ram size should be adjusted to 0xDA20 
0&amp;gt; softdevice_enable ERROR code = 0x4
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Error code 0x04 means, I don&amp;#39;t have sufficient MEMORY for SD. So, I think setting the RAM starting point to 0x200025E0 keeps sufficient RAM for SD, but in that scenario I don&amp;#39;t understand why I get the 1st message of reducing the RAM start address to 0x20002418???&lt;/p&gt;
&lt;p&gt;Can there be some conflicting memory usage going inside the app?&lt;/p&gt;
&lt;p&gt;I am using CENTRAL_LINK_COUNT==1 &amp;amp; PERIPHERAL_LINK_COUNT==1. While I am using one service only, as mentioned above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>