2019-07-18 10:04:06 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <settings/settings.h>
|
|
|
|
|
|
|
|
#include <bluetooth/bluetooth.h>
|
2020-12-15 09:04:00 +05:30
|
|
|
|
2019-07-18 10:04:06 +02:00
|
|
|
#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)
|
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
static uint16_t company_id = CONFIG_BT_CTLR_COMPANY_ID;
|
|
|
|
static uint16_t subversion = CONFIG_BT_CTLR_SUBVERSION_NUMBER;
|
2019-07-18 10:04:06 +02:00
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t ll_settings_company_id(void)
|
2019-07-18 10:04:06 +02:00
|
|
|
{
|
|
|
|
return company_id;
|
|
|
|
}
|
2020-05-27 11:26:57 -05:00
|
|
|
uint16_t ll_settings_subversion_number(void)
|
2019-07-18 10:04:06 +02:00
|
|
|
{
|
|
|
|
return subversion;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_BT_CTLR_VERSION_SETTINGS */
|
|
|
|
|
2020-01-27 12:52:04 +01:00
|
|
|
#if defined(CONFIG_BT_CTLR_SMI_TX_SETTING)
|
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
static uint8_t smi_tx;
|
2020-01-27 12:52:04 +01:00
|
|
|
|
|
|
|
bool ll_settings_smi_tx(void)
|
|
|
|
{
|
|
|
|
return smi_tx;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_BT_CTLR_SMI_TX_SETTING */
|
|
|
|
|
2019-07-18 10:04:06 +02:00
|
|
|
static int ctlr_set(const char *name, size_t len_rd,
|
|
|
|
settings_read_cb read_cb, void *store)
|
|
|
|
{
|
2020-04-02 16:08:46 +02:00
|
|
|
ssize_t len;
|
|
|
|
int nlen;
|
2019-07-18 10:04:06 +02:00
|
|
|
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"
|
2020-04-03 16:55:52 +02:00
|
|
|
" (err %zd)", len);
|
2019-07-18 10:04:06 +02:00
|
|
|
} 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"
|
2020-04-03 16:55:52 +02:00
|
|
|
" (err %zd)", len);
|
2019-07-18 10:04:06 +02:00
|
|
|
} else {
|
|
|
|
BT_DBG("Subversion set to %04x", subversion);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BT_CTLR_VERSION_SETTINGS */
|
|
|
|
|
2020-01-27 12:52:04 +01:00
|
|
|
#if defined(CONFIG_BT_CTLR_SMI_TX_SETTING)
|
|
|
|
if (!strncmp(name, "smi_tx", nlen)) {
|
|
|
|
len = read_cb(store, &smi_tx, sizeof(smi_tx));
|
|
|
|
if (len < 0) {
|
|
|
|
BT_ERR("Failed to read SMI TX flag from storage"
|
2020-04-03 16:55:52 +02:00
|
|
|
" (err %zd)", len);
|
2020-01-27 12:52:04 +01:00
|
|
|
} else {
|
|
|
|
BT_DBG("SMI TX flag set to %04x", smi_tx);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BT_CTLR_SMI_TX_SETTING */
|
|
|
|
|
2019-07-18 10:04:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SETTINGS_STATIC_HANDLER_DEFINE(bt_ctlr, "bt/ctlr", NULL, ctlr_set, NULL, NULL);
|