Bluetooth: controller: Settings for company_id and subversion_number.
Enable use of settings system in controller and introduce settings for company_id and subversion_number. Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
This commit is contained in:
parent
f89cc6130e
commit
c5c3a46824
7 changed files with 121 additions and 8 deletions
|
@ -140,6 +140,11 @@ if(CONFIG_BT_LL_SW_SPLIT)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_CTLR_SETTINGS
|
||||
ll_sw/ll_settings.c
|
||||
)
|
||||
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_SOC_COMPATIBLE_NRF
|
||||
ll_sw/nordic/hal/nrf5/cntr.c
|
||||
|
|
|
@ -201,6 +201,19 @@ config BT_CTLR_TX_PWR_MINUS_40
|
|||
|
||||
endchoice
|
||||
|
||||
config BT_CTLR_SETTINGS
|
||||
bool "Settings System"
|
||||
depends on BT_SETTINGS
|
||||
help
|
||||
Enable use of settings system in controller.
|
||||
|
||||
config BT_CTLR_VERSION_SETTINGS
|
||||
bool "Version Settings"
|
||||
depends on BT_CTLR_SETTINGS
|
||||
help
|
||||
Make Company Id and Subversion Number configurable through
|
||||
settings system.
|
||||
|
||||
config BT_CTLR_COMPANY_ID
|
||||
hex "Company Id"
|
||||
default 0x05F1
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "ll_sw/ull_conn_types.h"
|
||||
#include "ll.h"
|
||||
#include "ll_feat.h"
|
||||
#include "ll_settings.h"
|
||||
#include "hci_internal.h"
|
||||
#include "hci_vendor.h"
|
||||
|
||||
|
@ -518,8 +519,8 @@ static void read_local_version_info(struct net_buf *buf, struct net_buf **evt)
|
|||
rp->hci_version = LL_VERSION_NUMBER;
|
||||
rp->hci_revision = sys_cpu_to_le16(0);
|
||||
rp->lmp_version = LL_VERSION_NUMBER;
|
||||
rp->manufacturer = sys_cpu_to_le16(CONFIG_BT_CTLR_COMPANY_ID);
|
||||
rp->lmp_subversion = sys_cpu_to_le16(CONFIG_BT_CTLR_SUBVERSION_NUMBER);
|
||||
rp->manufacturer = sys_cpu_to_le16(ll_settings_company_id());
|
||||
rp->lmp_subversion = sys_cpu_to_le16(ll_settings_subversion_number());
|
||||
}
|
||||
|
||||
static void read_supported_commands(struct net_buf *buf, struct net_buf **evt)
|
||||
|
|
23
subsys/bluetooth/controller/include/ll_settings.h
Normal file
23
subsys/bluetooth/controller/include/ll_settings.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Oticon A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_VERSION_SETTINGS)
|
||||
|
||||
u16_t ll_settings_company_id(void);
|
||||
u16_t ll_settings_subversion_number(void);
|
||||
|
||||
#else
|
||||
|
||||
static inline u16_t ll_settings_company_id(void)
|
||||
{
|
||||
return CONFIG_BT_CTLR_COMPANY_ID;
|
||||
}
|
||||
static inline u16_t ll_settings_subversion_number(void)
|
||||
{
|
||||
return CONFIG_BT_CTLR_SUBVERSION_NUMBER;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_CTLR_VERSION_SETTINGS */
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "ll.h"
|
||||
#include "ll_feat.h"
|
||||
#include "ll_settings.h"
|
||||
|
||||
#if defined(CONFIG_SOC_COMPATIBLE_NRF)
|
||||
#include <drivers/clock_control/nrf_clock_control.h>
|
||||
|
@ -7815,9 +7816,9 @@ static inline void event_vex_prep(struct connection *conn)
|
|||
pdu_ctrl_tx->llctrl.version_ind.version_number =
|
||||
LL_VERSION_NUMBER;
|
||||
pdu_ctrl_tx->llctrl.version_ind.company_id =
|
||||
CONFIG_BT_CTLR_COMPANY_ID;
|
||||
ll_settings_company_id();
|
||||
pdu_ctrl_tx->llctrl.version_ind.sub_version_number =
|
||||
CONFIG_BT_CTLR_SUBVERSION_NUMBER;
|
||||
ll_settings_subversion_number();
|
||||
|
||||
ctrl_tx_enqueue(conn, node_tx);
|
||||
|
||||
|
|
69
subsys/bluetooth/controller/ll_sw/ll_settings.c
Normal file
69
subsys/bluetooth/controller/ll_sw/ll_settings.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Oticon A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <settings/settings.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include "ll_settings.h"
|
||||
|
||||
#define LOG_MODULE_NAME bt_ctlr_ll_settings
|
||||
#include "common/log.h"
|
||||
#include "hal/debug.h"
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_VERSION_SETTINGS)
|
||||
|
||||
static u16_t company_id = CONFIG_BT_CTLR_COMPANY_ID;
|
||||
static u16_t subversion = CONFIG_BT_CTLR_SUBVERSION_NUMBER;
|
||||
|
||||
u16_t ll_settings_company_id(void)
|
||||
{
|
||||
return company_id;
|
||||
}
|
||||
u16_t ll_settings_subversion_number(void)
|
||||
{
|
||||
return subversion;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_CTLR_VERSION_SETTINGS */
|
||||
|
||||
static int ctlr_set(const char *name, size_t len_rd,
|
||||
settings_read_cb read_cb, void *store)
|
||||
{
|
||||
int len, nlen;
|
||||
const char *next;
|
||||
|
||||
nlen = settings_name_next(name, &next);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_VERSION_SETTINGS)
|
||||
if (!strncmp(name, "company", nlen)) {
|
||||
len = read_cb(store, &company_id, sizeof(company_id));
|
||||
if (len < 0) {
|
||||
BT_ERR("Failed to read Company Id from storage"
|
||||
" (err %d)", len);
|
||||
} else {
|
||||
BT_DBG("Company Id set to %04x", company_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!strncmp(name, "subver", nlen)) {
|
||||
len = read_cb(store, &subversion, sizeof(subversion));
|
||||
if (len < 0) {
|
||||
BT_ERR("Failed to read Subversion from storage"
|
||||
" (err %d)", len);
|
||||
} else {
|
||||
BT_DBG("Subversion set to %04x", subversion);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_VERSION_SETTINGS */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SETTINGS_STATIC_HANDLER_DEFINE(bt_ctlr, "bt/ctlr", NULL, ctlr_set, NULL, NULL);
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "ll.h"
|
||||
#include "ll_feat.h"
|
||||
#include "ll_settings.h"
|
||||
|
||||
#define LOG_MODULE_NAME bt_ctlr_llsw_ull_conn
|
||||
#include "common/log.h"
|
||||
|
@ -2377,8 +2378,8 @@ static inline void event_vex_prep(struct ll_conn *conn)
|
|||
PDU_DATA_LLCTRL_TYPE_VERSION_IND;
|
||||
pdu->llctrl.version_ind.version_number =
|
||||
LL_VERSION_NUMBER;
|
||||
cid = sys_cpu_to_le16(CONFIG_BT_CTLR_COMPANY_ID);
|
||||
svn = sys_cpu_to_le16(CONFIG_BT_CTLR_SUBVERSION_NUMBER);
|
||||
cid = sys_cpu_to_le16(ll_settings_company_id());
|
||||
svn = sys_cpu_to_le16(ll_settings_subversion_number());
|
||||
pdu->llctrl.version_ind.company_id = cid;
|
||||
pdu->llctrl.version_ind.sub_version_number = svn;
|
||||
|
||||
|
@ -3530,9 +3531,9 @@ static int version_ind_send(struct ll_conn *conn, struct node_rx_pdu *rx,
|
|||
pdu_tx->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_VERSION_IND;
|
||||
v = &pdu_tx->llctrl.version_ind;
|
||||
v->version_number = LL_VERSION_NUMBER;
|
||||
v->company_id = sys_cpu_to_le16(CONFIG_BT_CTLR_COMPANY_ID);
|
||||
v->company_id = sys_cpu_to_le16(ll_settings_company_id());
|
||||
v->sub_version_number =
|
||||
sys_cpu_to_le16(CONFIG_BT_CTLR_SUBVERSION_NUMBER);
|
||||
sys_cpu_to_le16(ll_settings_subversion_number());
|
||||
|
||||
ctrl_tx_sec_enqueue(conn, tx);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue