<?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>How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36821/how-to-run-proxy-and-nus-at-the-same-time</link><description>Hi all, 
 when I insert ble_nus into mesh_gatt . I realized there are two pulse functions with the same function: 
 
 and 
 
 if they let them coexist , when I use nrf_connect connect and use mesh_app connect , It jump to 2 function , and I only want</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Aug 2018 10:12:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36821/how-to-run-proxy-and-nus-at-the-same-time" /><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/142772?ContentTypeID=1</link><pubDate>Fri, 03 Aug 2018 10:12:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee78533-2941-4fba-a7aa-4fdc1c24d64e</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Sorry for the delayed response. Which errors are you receiving? Could you upload the log? Which mesh sdk example &amp;amp; version are you using (proxy client or proxy server, mesh sdk v2.1.1). Are you using the uart ble_peripheral example from sdk 15?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141708?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 13:30:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ffd25e9-92a6-4664-938e-e23205f2f171</guid><dc:creator>Giang</dc:creator><description>&lt;p&gt;My problem is in case&amp;nbsp;&lt;/p&gt;
&lt;p&gt;case BLE_GATTS_EVT_HVN_TX_COMPLETE:&lt;br /&gt; &lt;br /&gt; on_hvx_tx_complete(p_nus, p_ble_evt);&lt;br /&gt; tx_complete_handle(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;two handle&amp;nbsp;&amp;nbsp;&lt;span&gt;on_hvx_tx_complete and&amp;nbsp;tx_complete_handle can&amp;#39;t run at the same time , when nus run&amp;nbsp;tx_complete_handle , it&amp;nbsp;produces errors&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141703?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 13:27:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0140c325-c6d1-4f44-9449-037aa13ef06d</guid><dc:creator>Giang</dc:creator><description>&lt;p&gt;yes , I set it = 1 . Can you send me an simple example run proxy and nus at the same time or I will send my project for you ? Thank very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141665?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 11:45:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd37a3c6-c2b1-4e4a-ba91-224700868d70</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;See file &amp;quot;app_config.h&amp;quot;, as it overrides some settings in &amp;quot;sdk_config.h&amp;quot;. In &amp;quot;app_config.h&amp;quot;,&amp;nbsp;NRF_SDH_BLE_PERIPHERAL_LINK_COUNT is set to 1, this value should be increased to allow for the NUS connection.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141648?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 09:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39eaf109-86dc-4ef5-bc82-c2ada95e0ca0</guid><dc:creator>Giang</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void initialize(void)
{
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_DBG3, LOG_CALLBACK_DEFAULT);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- BLE Mesh Light Switch Proxy Server Demo -----\n&amp;quot;);

    hal_leds_init();

    uart_init();
    log_info_init();
    timers_init();

#if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif
    uint32_t err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    uint32_t ram_start = 0;
    /* Set the default configuration (as defined through sdk_config.h). */
    err_code = nrf_sdh_ble_default_cfg_set(MESH_SOFTDEVICE_CONN_CFG_TAG, &amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_sdh_ble_enable(&amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    gap_params_init();

//    gatt_init();
    services_init();
    conn_params_init();

    mesh_init();
}

static void start(void)
{
//    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    ERROR_CHECK(mesh_stack_start());

    if (!m_device_provisioned)
    {
        static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
        mesh_provisionee_start_params_t prov_start_params =
        {
            .p_static_data    = static_auth_data,
            .prov_complete_cb = provisioning_complete_cb
        };
        ERROR_CHECK(mesh_provisionee_prov_start(&amp;amp;prov_start_params));
    }

    const uint8_t *p_uuid = nrf_mesh_configure_device_uuid_get();
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Device UUID &amp;quot;, p_uuid, NRF_MESH_UUID_SIZE);
}

int main(void)
{
    initialize();
    execution_start(start);

    for (;;)
    {
        (void)sd_app_evt_wait();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is an part of my main . I call nus init() in service_init() function&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141640?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2018 08:59:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f96748f0-0228-4b51-8978-fce3f25ded73</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;DId you initialise the nus? Call&amp;nbsp;nus_init(); after&amp;nbsp;initialize(); in the main(); function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141436?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 02:31:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a2e74ce-a33b-4a37-b827-e32f771b70bc</guid><dc:creator>Giang</dc:creator><description>&lt;p&gt;Thank for help !!!&lt;/p&gt;
&lt;p&gt;This my code modified :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void mesh_gatt_on_ble_evt(const ble_evt_t * p_ble_evt, void * p_context)
{
    if ((p_context == NULL) || (p_ble_evt == NULL))
    {
        return;
    }

    ble_nus_t * p_nus = (ble_nus_t *)p_context;
    ble_nus_on_ble_evt(p_ble_evt, &amp;amp;p_nus);

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
//            connect_evt_handle(p_ble_evt);

//            on_connect(p_nus, p_ble_evt);
            connect_evt_handle(p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            disconnect_evt_handle(p_ble_evt);
            break;

        case BLE_GATTS_EVT_WRITE:
            
            on_write(p_nus, p_ble_evt);
            write_evt_handle(p_ble_evt);
            break;

        case BLE_GATTS_EVT_HVN_TX_COMPLETE:
            
            on_hvx_tx_complete(p_nus, p_ble_evt);
            tx_complete_handle(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);
            break;  


        /* TODO: The following events should be handled by an SDK module/the application. */
        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
        {
//            uint32_t err_code = sd_ble_gatts_service_changed(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle,
//                                                             m_gatt.handles.service,
//                                                             m_gatt.handles.service);
//
//            /* Those errors can be expected when sending trying to send Service Changed indication
//             * if the CCCD is not set to indicate. Thus set the returning error code to success. */
//            NRF_MESH_ASSERT((err_code == NRF_SUCCESS) ||
//                            (err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
//                            (err_code == NRF_ERROR_INVALID_STATE) ||
//                            (err_code == NRF_ERROR_BUSY));
            NRF_MESH_ERROR_CHECK(sd_ble_gatts_sys_attr_set(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle, NULL, 0, 0));
            break;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it still error . If I run NUS service , it jump mesh handle and error ?&lt;/p&gt;
&lt;p&gt;NUS part will run correct if I only use :&lt;/p&gt;
&lt;p&gt;case BLE_GATTS_EVT_WRITE:&lt;br /&gt; on_write(p_nus, p_ble_evt);&lt;br /&gt;// write_evt_handle(p_ble_evt);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;case BLE_GATTS_EVT_HVN_TX_COMPLETE:&lt;br /&gt; on_hvx_tx_complete(p_nus, p_ble_evt);&lt;br /&gt;// tx_complete_handle(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;and error if use :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;case BLE_GATTS_EVT_WRITE:&lt;br /&gt; on_write(p_nus, p_ble_evt);&lt;br /&gt; write_evt_handle(p_ble_evt);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;case BLE_GATTS_EVT_HVN_TX_COMPLETE:&lt;br /&gt; on_hvx_tx_complete(p_nus, p_ble_evt);&lt;br /&gt; tx_complete_handle(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;can you help me ,&amp;nbsp;I really need this ! Thank very much !!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141416?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 18:50:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5baa38f8-d5b2-48f1-99b0-a5a849fd540d</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;I have this example, which I am still working on. It&amp;#39;s not &amp;quot;clean&amp;quot; as I cann the nus event handler from the mesh gatt event handler in stead of making a dispatcher. But it&amp;#39;s a part of a project I&amp;#39;ve been working on myself.&lt;/p&gt;
&lt;p&gt;At least this code gets into the nus data handler with the data I sent to it. That&amp;#39;s as far as I have tested this code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void mesh_gatt_on_ble_evt(const ble_evt_t * p_ble_evt, void * p_context)
{

	/// we need to put in this NUS this somewhere... this not not neat
	// to do it here... but until I find a better structure to support this
	// within the mesh sdk.
    ble_nus_on_ble_evt(p_ble_evt, &amp;amp;g_nus); // curious, did the parameters swap on this SDK version?
	///!!!

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:

        	// added for nus support


        	//

            connect_evt_handle(p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            disconnect_evt_handle(p_ble_evt);
            break;

        case BLE_GATTS_EVT_WRITE:
            write_evt_handle(p_ble_evt);
            break;

        case BLE_GATTS_EVT_HVN_TX_COMPLETE:
            tx_complete_handle(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle);
            break;


        /* TODO: The following events should be handled by an SDK module/the application. */
        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
        {
        	/*
            uint32_t err_code = sd_ble_gatts_service_changed(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle,
                                                             m_gatt.handles.service,
                                                             m_gatt.handles.service);

            // Those errors can be expected when sending trying to send Service Changed indication
            // if the CCCD is not set to indicate. Thus set the returning error code to success.
            NRF_MESH_ASSERT((err_code == NRF_SUCCESS) ||
                            (err_code == BLE_ERROR_INVALID_CONN_HANDLE) ||
                            (err_code == NRF_ERROR_INVALID_STATE) ||
                            (err_code == NRF_ERROR_BUSY));
            NRF_MESH_ERROR_CHECK(sd_ble_gatts_sys_attr_set(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle, NULL, 0, 0));
            break;
            */

        	// Well... the original code above crashes when adding the NUS. I&amp;#39;ve used the following
        	// code to handle BLE_GATTS_EVT_SYS_ATTR_MISSING in another NUS based project.
        	// I&amp;#39;d say gatts_service_changes ain&amp;#39;t a mesh thing thus this should pose no problem.
        	uint32_t err_code = sd_ble_gatts_sys_attr_set(p_ble_evt-&amp;gt;evt.gatts_evt.conn_handle, NULL, 0, 0);
        	break;
        }

        case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
        {
            ble_gap_data_length_params_t dl_params;
            memset(&amp;amp;dl_params, BLE_GAP_DATA_LENGTH_AUTO, sizeof(dl_params));
            NRF_MESH_ERROR_CHECK(sd_ble_gap_data_length_update(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle,
                                                               &amp;amp;dl_params,
                                                               NULL));
            break;
        }

        case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            NRF_MESH_ERROR_CHECK(sd_ble_gap_sec_params_reply(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle,
                                                             BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
                                                             NULL,
                                                             NULL));
            break;

        case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
        {
            ble_gap_phys_t const phys =
            {
                .rx_phys = BLE_GAP_PHY_AUTO,
                .tx_phys = BLE_GAP_PHY_AUTO,
            };
            NRF_MESH_ERROR_CHECK(sd_ble_gap_phy_update(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, &amp;amp;phys));
            break;
        }

        case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
            exchange_mtu_req_handle(p_ble_evt);
            break;

        case BLE_GATTS_EVT_SC_CONFIRM:
            break;

        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141381?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 15:16:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39540761-ca83-4c31-b699-21ff5cfa382d</guid><dc:creator>Giang</dc:creator><description>&lt;pre class="tw-data-text tw-ta tw-text-medium" id="tw-target-text" dir="ltr"&gt;&lt;span lang="en"&gt;Can you give me an example? Thank !!!&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141354?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 14:26:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ba6db63-f018-46f6-84c7-907edbb97c1e</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;At the point of the&amp;nbsp;BLE_GAP_EVT_CONNECTED, there is no distinction yet. The differences are only on&amp;nbsp;events like BLE_GATTS_EVT_WRITE and&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE. It&amp;#39;s the same connection, but one reads/writes to different characteristics. Ones accessing a characteristic, one compares the handle in the p_ble_evt with the handle of the characteristic of the NUS or Proxy to determine if it is being addressed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141349?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 14:03:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:239d90fe-f00e-4132-9ea9-cf0a7a575eca</guid><dc:creator>Giang</dc:creator><description>&lt;p&gt;In&amp;nbsp;BLE_GAP_EVT_CONNECTED ,&lt;span&gt;&amp;nbsp;how to know the connection of nus or proxy ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run proxy and Nus at the same time</title><link>https://devzone.nordicsemi.com/thread/141347?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 13:49:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08288e7f-f900-423b-8431-2e15fea012b1</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;In the regular ble examples there is a dispatch function that calls all *_ble_evt functions for the project. I suggest to take the same approach. All the individual handlers ( on_disconnect/ disconnect_evt_handle etc.) should check if the message is for them, and if not, ignore it. Therefore, writing a dispatch function and calling both should work.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>