Skip to content

Commit

Permalink
bluetooth: Extend array size for advertising data
Browse files Browse the repository at this point in the history
Array size for advertising data needs to be extended
when extended advertising data reception was supported.
  • Loading branch information
SPRESENSE committed Jun 26, 2023
1 parent 338c6b3 commit cf015e8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
7 changes: 7 additions & 0 deletions externals/nrf52/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,12 @@ config EXTERNALS_NRF52_SER_PHY_UART_LOG_LEVEL
Set log level of ser_phy_uart component.

endif # EXTERNALS_NRF52_OUTPUT_LOG_LEVEL > 0

config EXTERNALS_NRF52_EVTTASK_STACKSIZE
int "Event task stack size"
default 4096
---help---
Stack size of event task which calls callback functions to notify
asynchronous event from nRF52
endif # EXTERNALS_NRF52

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include <semaphore.h>
Expand Down Expand Up @@ -76,7 +77,6 @@ NRF_LOG_MODULE_REGISTER();
#define SD_BLE_RESPONSE_TIMEOUT_FLAG 0x01
#define SD_BLE_EVENT_FLAG 0x10
#define SD_BLE_EVTTASK_NAME "nrf52_sdevt_task"
#define SD_BLE_EVTTASK_STACKSIZE (2048)

static pid_t g_rcv_tid;
static int g_rcv_loop;
Expand Down Expand Up @@ -350,7 +350,7 @@ uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg,
sched_getparam(0, &param);
g_rcv_tid = task_create(SD_BLE_EVTTASK_NAME,
param.sched_priority,
SD_BLE_EVTTASK_STACKSIZE,
CONFIG_EXTERNALS_NRF52_EVTTASK_STACKSIZE,
(main_t)ble_rcv_evt_task,
NULL);
if (g_rcv_tid == ERROR)
Expand Down
7 changes: 7 additions & 0 deletions sdk/modules/bluetooth/bluetooth_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,13 @@ int ble_parse_advertising_data(BLE_AD_TYPE target,
type = adv[i++];
data = &adv[i];

if (len - 1 > BT_EIR_LEN)
{
/* Invalid advertising data(invalid length information) */

break;
}

if (type == target)
{
eir->len = len,
Expand Down
9 changes: 7 additions & 2 deletions sdk/modules/include/bluetooth/bt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@
#include <stdint.h>
#include <bluetooth/bluetooth.h>

#define BT_EIR_LEN (29)

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define BT_ADV_DATA_MAX_LEN (255)
#define BT_ADV_DATA_LEN_LEN (1)
#define BT_ADV_DATA_TYPE_LEN (1)
#define BT_EIR_LEN (BT_ADV_DATA_MAX_LEN \
- BT_ADV_DATA_LEN_LEN \
- BT_ADV_DATA_TYPE_LEN)

#define BLE_IRK_LEN (16)
#define BLE_CSRK_LEN (16)
#define BLE_LTK_LEN (16)
Expand Down
9 changes: 8 additions & 1 deletion sdk/modules/include/bluetooth/hal/bt_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@
#define BT_MAX_EVENT_DATA_LEN 1024
/** @} */

/**
*@name address type length of advertise data
*@{
*/
#define BT_ADV_DATA_ADDRTYPE_LEN (1)
/** @} */

/**
*@name Max ble advertise data length
*@{
*/
#define BLE_MAX_ADV_DATA_LEN 31
#define BLE_MAX_ADV_DATA_LEN (BT_ADV_DATA_MAX_LEN + BT_ADV_DATA_ADDRTYPE_LEN)
/** @} */

/**
Expand Down

0 comments on commit cf015e8

Please sign in to comment.