drivers: allow setting BlueNRG public address
The zephyr bluetooth stack expects the controller to know its public address, if any. At least for BlueNRG, the public address is forgotten with every reset/power cycle, so there needs to be a way to set it from within zephyr. This is accomplished using the `Aci_Hal_Write_Config_Data` HCI command, as described in PM0237. Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This commit is contained in:
parent
57b04c1eb0
commit
4321f86f1e
2 changed files with 25 additions and 0 deletions
|
@ -120,6 +120,7 @@ config BT_SPI_INIT_PRIORITY
|
|||
|
||||
config BT_BLUENRG_ACI
|
||||
bool "ACI message with with BlueNRG-based devices"
|
||||
select BT_HCI_SET_PUBLIC_ADDR
|
||||
help
|
||||
Enable support for devices compatible with the BlueNRG Bluetooth
|
||||
Stack. Current driver supports: ST BLUENRG-MS.
|
||||
|
|
|
@ -95,6 +95,8 @@ static uint8_t attempts;
|
|||
|
||||
#if defined(CONFIG_BT_BLUENRG_ACI)
|
||||
#define BLUENRG_ACI_WRITE_CONFIG_DATA BT_OP(BT_OGF_VS, 0x000C)
|
||||
#define BLUENRG_CONFIG_PUBADDR_OFFSET 0x00
|
||||
#define BLUENRG_CONFIG_PUBADDR_LEN 0x06
|
||||
#define BLUENRG_CONFIG_LL_ONLY_OFFSET 0x2C
|
||||
#define BLUENRG_CONFIG_LL_ONLY_LEN 0x01
|
||||
|
||||
|
@ -240,6 +242,27 @@ static int bt_spi_send_aci_config(uint8_t offset, const uint8_t *value, size_t v
|
|||
|
||||
return bt_hci_cmd_send(BLUENRG_ACI_WRITE_CONFIG_DATA, buf);
|
||||
}
|
||||
|
||||
int bt_spi_bluenrg_setup(const struct bt_hci_setup_params *params)
|
||||
{
|
||||
int ret;
|
||||
const bt_addr_t addr = params->public_addr;
|
||||
|
||||
if (bt_addr_eq(&addr, BT_ADDR_NONE) || bt_addr_eq(&addr, BT_ADDR_ANY)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = bt_spi_send_aci_config(
|
||||
BLUENRG_CONFIG_PUBADDR_OFFSET,
|
||||
addr.val, sizeof(addr.val));
|
||||
|
||||
if (ret != 0) {
|
||||
LOG_ERR("Failed to set BlueNRG public address (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_BLUENRG_ACI */
|
||||
|
||||
static struct net_buf *bt_spi_rx_buf_construct(uint8_t *msg)
|
||||
|
@ -516,6 +539,7 @@ static const struct bt_hci_driver drv = {
|
|||
.bus = BT_HCI_DRIVER_BUS_SPI,
|
||||
#if defined(CONFIG_BT_BLUENRG_ACI)
|
||||
.quirks = BT_QUIRK_NO_RESET,
|
||||
.setup = bt_spi_bluenrg_setup,
|
||||
#endif /* CONFIG_BT_BLUENRG_ACI */
|
||||
.open = bt_spi_open,
|
||||
.send = bt_spi_send,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue