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

Can't enable DLE

Hi

For a project I want to send acceleration data via BLE 4.2 (with DLE). An acceleration packet consists of 81 values (24 bits each, total 243 bytes). My goal is to send 18 packets (1458 acceleration packets or 4374 bytes). After all packets have been sent, the connection to the smartphone (Samsung Galaxy A3 2017 Edition) is terminated and new 1458 acceleration packets are recorded. After that, an RTC activates sleep mode for 1 minute. After this minute the nRF should begin advertising and reconnecting to the smartphone.
The following figure illustrates the problem:

 

I have used this tutorial as a basis. With this tutorial I can only send 20 bytes at once.

 

Question 1:

Why can't I send more than 20 bytes? Even if I set maximum length to 27, only 20 bytes will be sent:

 

Fullscreen
1
attr_char_value.max_len = 27;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

According to this thread you can enable DLE by using the function nrf_ble_gatt_data_length_set(). For the implementation of DLE I used the example ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput. The main.c contains the function data_len_set(). In it the DLE is enabled. Since there is no connection yet, BLE_CONN_HANDLE_INVALID is given as parameter:

 

Fullscreen
1
2
3
4
5
6
7
8
void data_len_set(uint8_t value)
{
ret_code_t err_code;
err_code = nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, value);
APP_ERROR_CHECK(err_code);
m_test_params.data_len = value;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the example, the two macros NRF_SDH_BLE_GAP_EVENT_LENGTH and NRF_SDH_BLE_GATT_MAX_MTU_SIZE are initialized as follows (sdk_config.h):

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
// <o> NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length.
// <i> The time set aside for this connection on every connection interval in 1.25 ms units.
#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 400
#endif
// <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size.
#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the example of the tutorial I have adapted the sdk_config.h and main.c as mentioned above.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Copyright (c) 2014 - 2018, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In my code, data_len_set() is called before advertising_start(). As soon as I call data_len_set(), there is no advertising anymore.

Question 2:

Why is there no advertising anymore? Have I set a parameter somewhere wrong, which causes a problem with the SoftDevice?

My Setup:

nrf52832 dk

sdk V15.0

SoftDevice s132