<?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>issues with nus uart service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30179/issues-with-nus-uart-service</link><description>Hi All, 
 Just wondering if i&amp;#39;m doing the right thing here. 
 So i am using the example of the central device to get started.The idea i&amp;#39;m trying to do is to use the central to connect to a peripheral based on the advertisement data. When certain flags</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Feb 2018 15:18:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30179/issues-with-nus-uart-service" /><item><title>RE: issues with nus uart service</title><link>https://devzone.nordicsemi.com/thread/120312?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2018 15:18:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4d43f4a-1c12-4640-9983-f31d3de58a88</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Ok. I&amp;#39;m glad to hear that you found the cause of your problems.&lt;/p&gt;
&lt;p&gt;Be sure to let me know if you still have any problems.&lt;/p&gt;
&lt;p&gt;Best of luck with your project.&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Joakim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with nus uart service</title><link>https://devzone.nordicsemi.com/thread/120189?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2018 00:37:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32cdeba3-8330-4bc2-b7fe-42bfe0e5d1de</guid><dc:creator>Grant</dc:creator><description>&lt;p&gt;Think that we&amp;#39;ve solved our problem, turns out the peripheral that i was connecting to had issues. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Grant&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with nus uart service</title><link>https://devzone.nordicsemi.com/thread/120016?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2018 20:21:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f446944-18f2-4489-bfbd-043300f9a414</guid><dc:creator>Grant</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Joakim,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So i&amp;#39;m on the latest SDK - 14.2.0 and the softdevice is a 132 version 5(?) i downloaded the latest stuff i guess as i only started on this project mid dec.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So in my ble_nus_c_evt_handler i wait until the discovery of the service is complete, then try and send a command to the peripheral and i start an app timer, and everytime i get new data it resets the timer so i can disconnect after a period of in-activity.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So once i call the sd_ble_gap_disconnect command i assume that the peripheral is now d/c from the central and i don&amp;#39;t have to do anything else? So when the central connects to the peripheral again its like starting fresh.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
{
    ret_code_t err_code;
    
    switch (p_ble_nus_evt-&amp;gt;evt_type)
    {
        case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
            printf(&amp;quot;Discovery complete.&amp;quot;);
            NRF_LOG_INFO(&amp;quot;Discovery complete.&amp;quot;);
            err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt-&amp;gt;conn_handle, &amp;amp;p_ble_nus_evt-&amp;gt;handles);
            APP_ERROR_CHECK(err_code);

            err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
            APP_ERROR_CHECK(err_code);
            
            printf(&amp;quot;handles %d, %d, %d\n&amp;quot;, 
                   p_ble_nus_c-&amp;gt;handles.nus_rx_handle,
                   p_ble_nus_c-&amp;gt;handles.nus_tx_cccd_handle,
                   p_ble_nus_c-&amp;gt;handles.nus_tx_handle);
            NRF_LOG_INFO(&amp;quot;Connected to device with Nordic UART Service.&amp;quot;);

              err_code = ble_nus_c_string_send(&amp;amp;m_ble_nus_c, command, sizeof(command));
              APP_ERROR_CHECK(err_code);      

              // Start our disconnection timer going
              uart_timer_restart(p_ble_nus_c);       
              
            } else {
              printf(&amp;quot;unknown channel flag - disconnecting\n&amp;quot;);
              sd_ble_gap_disconnect(p_ble_nus_evt-&amp;gt;conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            }            
            break;

        case BLE_NUS_C_EVT_NUS_TX_EVT:
            // Show to screen the rx&amp;#39;d data
            for(int i = 0; i &amp;lt; p_ble_nus_evt-&amp;gt;data_len; i++) { 
              printf(&amp;quot;%02X&amp;quot;, p_ble_nus_evt-&amp;gt;p_data[i]);
            }
            
            // Restart our timer for disconnection
            uart_timer_restart(p_ble_nus_c);       

            break;

        case BLE_NUS_C_EVT_DISCONNECTED:
            NRF_LOG_INFO(&amp;quot;Disconnected.&amp;quot;);
            printf(&amp;quot;Disconnected\n&amp;quot;);
            scan_start();
            break;
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i don&amp;#39;t think i&amp;#39;m doing anything strange,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Grant&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: issues with nus uart service</title><link>https://devzone.nordicsemi.com/thread/119784?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2018 15:09:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ebb9e79-2852-4ca4-b873-eea958efa7c9</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi Grant!&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if you are doing the right thing, but I&amp;#39;ll do my best to help you find out.&lt;/p&gt;
&lt;p&gt;First of all, could you provide some more information for me?&lt;/p&gt;
&lt;p&gt;- Which SDK and softdevice versions are you working with?&lt;br /&gt;- Which device are you working with?&lt;/p&gt;
&lt;p&gt;What do you mean by this:&lt;/p&gt;
[quote user=""]but after disconnecting it doesn&amp;#39;t seem to send the command rather from what i see - it just sends 0&amp;#39;s.[/quote]
&lt;p&gt;Which command are you expecting after the central being disconnected?&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt;Joakim.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>