This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

in \connect SDK\v1.5.0\nrf\samples\bluetooth\peripheral_uart,data number is limited 20 bytes, more than 20bytes BLE will part data in two or more packs to send or receive

in \connect SDK\v1.5.0\nrf\samples\bluetooth\peripheral_uart,data number is limited 20 bytes, more than 20bytes BLE will part data in two or more packs to send or receive .how can i chang to data number to more bytes. for example , i want to send 200 bytes through COM  in one time and BLE receive 200bytes i one time , relatively HOW to send 200bytes data in one time  through BLE ,not separate 200bytes data in many pack to send

  • Hi,

    You can call bt_conn_le_data_len_update() after a connection has been established. As you are using the nrf/samples/bluetooth/peripheral_uart sample there is allready a callback function called connected(). Here you get a handle to the current connection - current_conn. Once you have that you can call bt_conn_le_data_len_update(). Please refer to nrf\samples\bluetooth\throughput\src\main.c for an example.

  • in prj.conf ,I add below:

    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_L2CAP_RX_MTU=247
    CONFIG_BT_MAX_CONN=2

    in main.c , bt_callback function  connect ,I add below:

    static void connected(struct bt_conn *conn, uint8_t err)
    {
    ......

    current_conn = bt_conn_ref(conn);
    err2 = bt_conn_le_data_len_update(current_conn, 80);
    if (err2)
    printk( "LE data length update failed: %d", err2);

    ......
    }

    all other not changed,but build\debug\go ,the board always reset,can not run, ,ble app cannot connect board ,is there other place need to be modified in program,

  • thank you

       I konw you ar very busy ,could you take some time to test peripheral_uart in NCS v1.5.0 with a nrf5340_dk kit ,increase the number of ble that could send to a connected APP in a phone . in this nordic community ,few people know the answer。could you spend some time to reprogram the peripheral_uart example . could you accept my mailbox and mail with me?

  • Hi,

    You have some issues in your code, and I suspect you did not configure the stack on the network core. The following quick and dirty changes to the peripheral_uart sample does what you want and I tested to verify that the data length is updated to 80 upon establishing the connection:

    diff --git a/samples/bluetooth/peripheral_uart/src/main.c b/samples/bluetooth/peripheral_uart/src/main.c
    index f8d886d6b..b6f04aedc 100644
    --- a/samples/bluetooth/peripheral_uart/src/main.c
    +++ b/samples/bluetooth/peripheral_uart/src/main.c
    @@ -237,6 +237,7 @@ static int uart_init(void)
     static void connected(struct bt_conn *conn, uint8_t err)
     {
     	char addr[BT_ADDR_LE_STR_LEN];
    +	printk("Connected\n");
     
     	if (err) {
     		LOG_ERR("Connection failed (err %u)", err);
    @@ -249,6 +250,19 @@ static void connected(struct bt_conn *conn, uint8_t err)
     	current_conn = bt_conn_ref(conn);
     
     	dk_set_led_on(CON_STATUS_LED);
    +
    +
    +	printk("Start DLE...\n");
    +	struct bt_conn_le_data_len_param data_len_param;
    +
    +	data_len_param.tx_max_len = 80; // byte
    +	data_len_param.tx_max_time = 3750; // us
    +
    +	err = bt_conn_le_data_len_update(current_conn, &data_len_param);
    +	if (err)
    +	{
    +		printk("LE data length update failed: %d\n", err);
    +	}
     }
     
     static void disconnected(struct bt_conn *conn, uint8_t reason)
    

    diff --git a/samples/bluetooth/peripheral_uart/prj.conf b/samples/bluetooth/peripheral_uart/prj.conf
    index cd6df0664..8571bed92 100644
    --- a/samples/bluetooth/peripheral_uart/prj.conf
    +++ b/samples/bluetooth/peripheral_uart/prj.conf
    @@ -48,3 +48,16 @@ CONFIG_LOG_BACKEND_RTT=y
     CONFIG_LOG_BACKEND_UART=n
     
     CONFIG_ASSERT=y
    +
    +# Added
    +CONFIG_BT_USER_DATA_LEN_UPDATE=y
    +CONFIG_BT_RX_BUF_LEN=255
    +CONFIG_BT_GATT_CLIENT=y
    +CONFIG_BT_ATT_TX_MAX=10
    +CONFIG_BT_ATT_PREPARE_COUNT=2
    +CONFIG_BT_CONN_TX_MAX=10
    +CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    +CONFIG_BT_L2CAP_TX_MTU=247
    +CONFIG_BT_L2CAP_RX_MTU=247
    +CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    

    Here is update for the network core by changing zephyr\samples\bluetooth\hci_rpmsg\prj.conf (note that I also reduced CONFIG_BT_MAX_CONN in order to make this fit in RAM):

    diff --git a/samples/bluetooth/hci_rpmsg/prj.conf b/samples/bluetooth/hci_rpmsg/prj.conf
    index 46a1992edc..032fdbf54a 100644
    --- a/samples/bluetooth/hci_rpmsg/prj.conf
    +++ b/samples/bluetooth/hci_rpmsg/prj.conf
    @@ -9,10 +9,21 @@ CONFIG_MAIN_STACK_SIZE=512
     CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
     CONFIG_BT=y
     CONFIG_BT_HCI_RAW=y
    -CONFIG_BT_MAX_CONN=16
    +CONFIG_BT_MAX_CONN=4
     CONFIG_BT_CTLR_ASSERT_HANDLER=y
     CONFIG_BT_HCI_RAW_RESERVE=1
     
     CONFIG_ASSERT=y
     CONFIG_DEBUG_INFO=y
     CONFIG_EXCEPTION_STACK_TRACE=y
    +
    +# Added
    +#CONFIG_BT_USER_DATA_LEN_UPDATE=y
    +CONFIG_BT_RX_BUF_LEN=255
    +CONFIG_BT_L2CAP_TX_MTU=247
    +CONFIG_BT_L2CAP_RX_MTU=247
    +CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    +
    +
    +
    

Related