<?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>Standalone L2CAP Example, Since Apple Core Bluetooth doesn&amp;#39;t support  OTS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52204/standalone-l2cap-example-since-apple-core-bluetooth-doesn-t-support-ots</link><description>Hi 
 We want to open L2CAP channel to stream data between nRF52840 and iOS, We cant use OTS example since there is no OTS support from Apple core bluetooth framework. 
 So we thought to open a raw L2CAP channel on PSM (either hard-coded or from GATT Characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Sep 2019 09:03:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52204/standalone-l2cap-example-since-apple-core-bluetooth-doesn-t-support-ots" /><item><title>RE: Standalone L2CAP Example, Since Apple Core Bluetooth doesn't support  OTS</title><link>https://devzone.nordicsemi.com/thread/212215?ContentTypeID=1</link><pubDate>Fri, 27 Sep 2019 09:03:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:848bf7ca-a853-4830-a4ac-ae84fd9714b8</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;The most important parameters are connection interval, GAP event length, and GAP data length.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;GAP data length&lt;/strong&gt; tells you how many bytes you can transmit per BLE packet, or the Link Layer PDU. It defaults to 27 bytes. A BLE packet contains lots of overhead data, like access address, LL header, L2CAP header etc. So you should increase this to more than 27 bytes. The maximum supported by the BLE spec is 251 bytes.&lt;/p&gt;
&lt;p&gt;The data length update is performed by using this function: &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html?cp=3_4_3_1_2_1_2_14#gac4a6ef5c106107eb2a1707bb26f3245c"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html?cp=3_4_3_1_2_1_2_14#gac4a6ef5c106107eb2a1707bb26f3245c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It needs to be responded to by the peer. The flow chart is here: &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___d_a_t_a___l_e_n_g_t_h___u_p_d_a_t_e___p_r_o_c_e_d_u_r_e___m_s_c.html?cp=3_4_3_1_2_1_3_6"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_p___d_a_t_a___l_e_n_g_t_h___u_p_d_a_t_e___p_r_o_c_e_d_u_r_e___m_s_c.html?cp=3_4_3_1_2_1_3_6&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also send several packets per connection interval. So the &lt;strong&gt;GAP event length&lt;/strong&gt; is how much time is set aside for transmitting packets within one connection interval. In theory it can be as long as the connection interval.&lt;/p&gt;
&lt;p&gt;This is usually set in the sdk_config.h file and is called NRF_SDH_BLE_GAP_EVENT_LENGTH. Which is then passed to the softdevice when you call the nrf_sdh_ble_default_cfg_set() function.&lt;/p&gt;
&lt;p&gt;The softdevice will continue to transmit packets as long as there is time left within the connection interval.&lt;/p&gt;
&lt;p&gt;The, you have the &lt;strong&gt;connection interval&lt;/strong&gt;. You can set a long connection interval, and send many packets per connection interval, which will probably give you the highest throughput. The drawback is that when you get a packet loss, which happens from time to time, depending on the connection quality, you will have to wait until the next connection interval to re-transmit the packets.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can&amp;nbsp; have a look at the throughput example in the SDK to see how these parameters are tweaked to get the highest throughput:&amp;nbsp; &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_att_mtu.html?cp=5_1_4_2_1_0"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_att_mtu.html?cp=5_1_4_2_1_0&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Standalone L2CAP Example, Since Apple Core Bluetooth doesn't support  OTS</title><link>https://devzone.nordicsemi.com/thread/210589?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2019 06:23:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30827770-a0e0-465e-8615-48b126d64476</guid><dc:creator>ERobotics</dc:creator><description>&lt;p&gt;Hi Stian,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It was RAM&amp;nbsp; SIZE Issue,Now built the L2CAP Feature over ble_app_template (took reference from OTS), i used UART for printing debug messages, Able to&amp;nbsp; Receive the L2CAP packets from&amp;nbsp; TAB, assigned methods to all the events of L2CAP.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Last time, Issues due to lack of understanding about events and rules of L2CAP.&lt;/p&gt;
&lt;p&gt;1. Currently its speed is 8kbps, rx_mtu is 1000bytes, rx_mtu is 100 bytes.&amp;nbsp; To use the max possible speed what all parameters needs to be configured.&lt;/p&gt;
&lt;p&gt;2. Documentation says there is no upper limit for MTU i.e. 64KB since type is uint16_t, what about MPU&lt;/p&gt;
&lt;p&gt;3. Are there any other parameters&amp;nbsp; like connection length, connection size to be configured ?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Some references and points on increasing the channel speed is highly appreciated.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks a lot for your &amp;nbsp; reply&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Standalone L2CAP Example, Since Apple Core Bluetooth doesn't support  OTS</title><link>https://devzone.nordicsemi.com/thread/210458?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2019 14:09:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8fd86d2-cb5c-4519-b54d-7342f18bc170</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;So after the connection the nRF52840 needs to setup the L2CAP channel. The procedure is described here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___l2_c_a_p___c_h___s_e_t_u_p___m_s_c.html?cp=3_4_3_1_2_5_3_3"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___l2_c_a_p___c_h___s_e_t_u_p___m_s_c.html?cp=3_4_3_1_2_5_3_3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also look at the ble_central OTS example, in the main file in the ots_c_evt_handler you see how the channel is initialized using the sd_ble_l2cap_ch_setup function. It&amp;#39;s documented here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___l2_c_a_p___f_u_n_c_t_i_o_n_s.html?cp=3_4_3_1_2_5_2_3#ga69199818fd81b20baf5c7db0656962c9"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___l2_c_a_p___f_u_n_c_t_i_o_n_s.html?cp=3_4_3_1_2_5_2_3#ga69199818fd81b20baf5c7db0656962c9&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ble_l2cap_ch_setup_params_t params;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.rx_params.rx_mps = L2CAP_RX_MPS;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.rx_params.rx_mtu = L2CAP_RX_MTU;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.rx_params.sdu_buf.p_data = NULL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.le_psm = BLE_OTS_PSM;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Used when requesting setup of an L2CAP channel, ignored otherwise.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.status = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Used when requesting setup of an L2CAP channel, ignored otherwise.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16_t cid&amp;nbsp; = BLE_L2CAP_CID_INVALID;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = sd_ble_l2cap_ch_setup(m_ots_c.conn_handle, &amp;amp;cid, &amp;amp;params);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/pre&gt;
&lt;p&gt;You have to make sure that you are responding to the events in the ble_evt_handler according to the flow chart.&lt;/p&gt;
&lt;p&gt;You must also have a way to debug the code. Why can&amp;#39;t you use UART? It&amp;#39;s integrated into the nRF52840 DK, you just need the UART terminal, like Putty. You should also use the debugging functionality in the IDE you are using, stepping through the code, catching the error codes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Standalone L2CAP Example, Since Apple Core Bluetooth doesn't support  OTS</title><link>https://devzone.nordicsemi.com/thread/210146?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2019 13:25:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2aca01dd-8fb6-4de6-94fb-58af8bd7ed65</guid><dc:creator>ERobotics</dc:creator><description>&lt;p&gt;Hello Stian,&lt;/p&gt;
&lt;p&gt;Test scenario iPAD and nRF52840DK&lt;/p&gt;
&lt;p&gt;1. iPAD has custom developed application which reads the psm over gatt characteristic and tries to connect on using that psm.&lt;/p&gt;
&lt;p&gt;2. nRF52840 should setup L2CAP channel as soon as it receives connected event and update the PSM on gatt characteristic.&lt;/p&gt;
&lt;p&gt;Is there any design conflict in our procedure.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am initializing the stack with below snippet but app is crashing, i cannot see the error code, since uart is not available.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;To enable L2CAP do i need to create any instance or enable any macro.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    
    // Overwrite some of the default configurations for the BLE stack.
    ble_cfg_t ble_cfg;

    // Configure the number of custom UUIDS.
    memset(&amp;amp;ble_cfg, 0x00, sizeof(ble_cfg));
    ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = 0;


    // Set l2cap channel configuration
    ble_cfg.conn_cfg.conn_cfg_tag                        = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.rx_mps        = BLE_L2CAP_MPS_MIN;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.rx_queue_size = 1;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.tx_mps        = BLE_L2CAP_MPS_MIN;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.tx_queue_size = 1;
    ble_cfg.conn_cfg.params.l2cap_conn_cfg.ch_count      = BLE_L2CAP_CH_COUNT_MAX;

    err_code = sd_ble_cfg_set(BLE_CONN_CFG_L2CAP, &amp;amp;ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Standalone L2CAP Example, Since Apple Core Bluetooth doesn't support  OTS</title><link>https://devzone.nordicsemi.com/thread/210125?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2019 12:34:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fbcaa7e7-1ffe-4a0f-b942-2c3c27648ae1</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What are you using for testing? An iPhone? Did you develop your own app which is reading the L2CAP stream, or are you using some sort of testing app?&lt;/p&gt;
&lt;p&gt;If you can send a sniffer log that would be great. Then we can see what is going on.&lt;/p&gt;
&lt;p&gt;What is the reason you want to use a raw L2CAP channel? With connection event length extension and long MTU, you should be able to get almost same throughput using GATT.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>