Bluetooth: Remove support for NBLE
NBLE has been deprecated for a few releases now and can be removed. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
cc47918166
commit
9516d63836
|
@ -77,13 +77,6 @@ config BLUETOOTH_UART_ON_DEV_NAME
|
|||
|
||||
endif
|
||||
|
||||
if NBLE
|
||||
|
||||
config NBLE_UART_ON_DEV_NAME
|
||||
default "UART_1"
|
||||
|
||||
endif
|
||||
|
||||
if UART_PIPE
|
||||
|
||||
config UART_PIPE_ON_DEV_NAME
|
||||
|
|
|
@ -192,7 +192,7 @@ config RTC_0_IRQ_PRI
|
|||
default 2
|
||||
endif # RTC
|
||||
|
||||
if BLUETOOTH_H4 || NBLE
|
||||
if BLUETOOTH_H4
|
||||
|
||||
config BLUETOOTH_UART_ON_DEV_NAME
|
||||
default UART_QMSI_0_NAME
|
||||
|
@ -206,7 +206,7 @@ config UART_QMSI_0_BAUDRATE
|
|||
config UART_QMSI_0_HW_FC
|
||||
def_bool y
|
||||
|
||||
endif # BLUETOOTH_H4 || NBLE
|
||||
endif # BLUETOOTH_H4
|
||||
|
||||
if UART_QMSI
|
||||
|
||||
|
|
|
@ -16,19 +16,6 @@ config ROM_SIZE
|
|||
config PHYS_LOAD_ADDR
|
||||
default 0x40010000
|
||||
|
||||
if NBLE
|
||||
|
||||
config GPIO
|
||||
def_bool y
|
||||
|
||||
config BLUETOOTH_NRF51_PM
|
||||
def_bool y
|
||||
|
||||
config NBLE_UART_ON_DEV_NAME
|
||||
default UART_QMSI_0_NAME
|
||||
|
||||
endif
|
||||
|
||||
if BLUETOOTH_H4
|
||||
|
||||
config BLUETOOTH_UART_ON_DEV_NAME
|
||||
|
|
|
@ -4,25 +4,6 @@ if BOARD_QUARK_SE_C1000_DEVBOARD
|
|||
config BOARD
|
||||
default "quark_se_c1000_devboard"
|
||||
|
||||
if NBLE
|
||||
|
||||
config GPIO
|
||||
def_bool y
|
||||
|
||||
config BLUETOOTH_NRF51_PM
|
||||
def_bool y
|
||||
|
||||
config NBLE_UART_ON_DEV_NAME
|
||||
default UART_QMSI_0_NAME
|
||||
|
||||
config UART_QMSI_0_BAUDRATE
|
||||
default 1000000
|
||||
|
||||
config UART_QMSI_0_HW_FC
|
||||
def_bool y
|
||||
|
||||
endif
|
||||
|
||||
if BLUETOOTH_H4
|
||||
|
||||
config BLUETOOTH_UART_ON_DEV_NAME
|
||||
|
|
|
@ -19,12 +19,12 @@ source "drivers/bluetooth/hci/Kconfig"
|
|||
endif
|
||||
|
||||
if BLUETOOTH_CUSTOM
|
||||
source "drivers/bluetooth/nble/Kconfig"
|
||||
# Insert here any custom (non-HCI) offload drives
|
||||
endif
|
||||
|
||||
config BLUETOOTH_NRF51_PM
|
||||
bool "nRF51 Power Management [EXPERIMENTAL]"
|
||||
depends on BLUETOOTH_H4 || NBLE
|
||||
depends on BLUETOOTH_H4
|
||||
help
|
||||
Power Management support for Nordic BLE nRF51 chip. Allows to enable,
|
||||
disable the chip and handle wakeups.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
ccflags-y += -I$(srctree)/subsys/bluetooth
|
||||
|
||||
obj-y += hci/
|
||||
obj-$(CONFIG_NBLE) += nble/
|
||||
obj-$(CONFIG_BLUETOOTH_NRF51_PM) += nrf51_pm.o
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
# Kconfig - NBLE configuration options
|
||||
|
||||
#
|
||||
# Copyright (c) 2016 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
config NBLE
|
||||
bool "Support for custom non-HCI nRF51 firmware [DEPRECATED]"
|
||||
select UART_INTERRUPT_DRIVEN
|
||||
select NET_BUF
|
||||
depends on SERIAL
|
||||
help
|
||||
Note: This feature is deprecated and will be removed in a
|
||||
future Zephyr version.
|
||||
|
||||
Enables support for using Nordic Semiconductor nRF51 Bluetooth
|
||||
LE chips with a custom firmware. The API for this is a subset of
|
||||
the normal Bluetooth API (include/bluetooth/). This driver can
|
||||
only be enabled if CONFIG_BLUETOOTH has not been enabled.
|
||||
|
||||
A fundamental assumption that the driver makes is that it is
|
||||
run on an architecture with the same ABI (e.g. struct packing
|
||||
& endianness) as the nRF51 chip. The driver cannot be used on
|
||||
any architecture that doesn't fulfill this requirement.
|
||||
|
||||
if NBLE
|
||||
config BLUETOOTH_PERIPHERAL
|
||||
bool
|
||||
default y
|
||||
|
||||
config BLUETOOTH_CENTRAL
|
||||
bool
|
||||
default y
|
||||
|
||||
config BLUETOOTH_ATT_PREPARE_COUNT
|
||||
int "Number of ATT prepare write buffers"
|
||||
default 2
|
||||
range 0 64
|
||||
help
|
||||
Number of buffers available for ATT prepare write, setting
|
||||
this to 0 disables GATT long/reliable writes.
|
||||
|
||||
config BLUETOOTH_GATT_CLIENT
|
||||
bool
|
||||
default y
|
||||
|
||||
config BLUETOOTH_SMP
|
||||
bool
|
||||
default y
|
||||
|
||||
config BLUETOOTH_MAX_CONN
|
||||
int
|
||||
default 6
|
||||
|
||||
config BLUETOOTH_MAX_PAIRED
|
||||
int
|
||||
default 7
|
||||
|
||||
config BLUETOOTH_RX_STACK_SIZE
|
||||
int "Size of the receiving thread stack"
|
||||
default 1024
|
||||
range 1024 65536
|
||||
help
|
||||
Size of the receiving thread stack. This is the context from
|
||||
which all event callbacks to the application occur. The
|
||||
default value is sufficient for basic operation, but if the
|
||||
application needs to do advanced things in its callbacks that
|
||||
require extra stack space, this value can be increased to
|
||||
accommodate for that.
|
||||
|
||||
config BLUETOOTH_DEVICE_NAME
|
||||
string "Bluetooth device name"
|
||||
default "Zephyr"
|
||||
help
|
||||
Bluetooth device name. Name can be up to 248 bytes long (excluding
|
||||
NULL termination). Can be empty string.
|
||||
|
||||
if BLUETOOTH_DEBUG
|
||||
|
||||
config BLUETOOTH_DEBUG_GATT
|
||||
bool "Bluetooth Generic Attribute Profile (GATT) debug"
|
||||
help
|
||||
This option enables debug support for the Bluetooth
|
||||
Generic Attribute Profile (GATT).
|
||||
|
||||
config NBLE_DEBUG_GAP
|
||||
bool "NBLE Generic Access Profile (GAP) debug"
|
||||
help
|
||||
This option enables debug support for the Bluetooth
|
||||
Generic Access Profile (GAP) in the interfaces to the
|
||||
Nordic chip.
|
||||
|
||||
config NBLE_DEBUG_CONN
|
||||
bool "NBLE connection debug"
|
||||
help
|
||||
This option enables debug support for Bluetooth
|
||||
connections in the nble driver.
|
||||
|
||||
config NBLE_DEBUG_RPC
|
||||
bool "NBLE RPC debug"
|
||||
help
|
||||
This option enables debug for RPC interface to the Nordic
|
||||
Bluetooth LE chip.
|
||||
|
||||
endif # BLUETOOTH_DEBUG
|
||||
|
||||
config NBLE_UART_ON_DEV_NAME
|
||||
string "Device Name of UART Device for Nordic BLE"
|
||||
default "UART_0"
|
||||
depends on NBLE
|
||||
help
|
||||
This option specifies the name of UART device to be used
|
||||
for Nordic BLE.
|
||||
|
||||
endif
|
|
@ -1,5 +0,0 @@
|
|||
ccflags-y += -I$(srctree)/subsys/bluetooth
|
||||
|
||||
obj-$(CONFIG_NBLE) += gap.o conn.o gatt.o uart.o rpc_serialize.o \
|
||||
rpc_deserialize.o stubs.o smp.o \
|
||||
../../../subsys/bluetooth/host/uuid.o
|
|
@ -1,535 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <atomic.h>
|
||||
#include <misc/util.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include <bluetooth/gatt.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_CONN)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "gap_internal.h"
|
||||
#include "gatt_internal.h"
|
||||
#include "conn_internal.h"
|
||||
#include "smp.h"
|
||||
|
||||
/* Peripheral timeout to initialize Connection Parameter Update procedure */
|
||||
#define CONN_UPDATE_TIMEOUT K_SECONDS(5)
|
||||
|
||||
static struct bt_conn conns[CONFIG_BLUETOOTH_MAX_CONN];
|
||||
static struct bt_conn_cb *callback_list;
|
||||
|
||||
static struct bt_conn *conn_new(void)
|
||||
{
|
||||
struct bt_conn *conn = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(conns); i++) {
|
||||
if (!atomic_get(&conns[i].ref)) {
|
||||
conn = &conns[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(conn, 0, sizeof(*conn));
|
||||
|
||||
atomic_set(&conn->ref, 1);
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
static struct bt_conn *conn_get(const bt_addr_le_t *peer)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
if (peer) {
|
||||
conn = bt_conn_lookup_addr_le(peer);
|
||||
if (conn) {
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
|
||||
return conn_new();
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_ref(struct bt_conn *conn)
|
||||
{
|
||||
atomic_inc(&conn->ref);
|
||||
|
||||
BT_DBG("handle %u ref %u", conn->handle, atomic_get(&conn->ref));
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
void bt_conn_unref(struct bt_conn *conn)
|
||||
{
|
||||
atomic_dec(&conn->ref);
|
||||
|
||||
BT_DBG("handle %u ref %u", conn->handle, atomic_get(&conn->ref));
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_lookup_handle(u16_t handle)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(conns); i++) {
|
||||
if (!atomic_get(&conns[i].ref)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (conns[i].handle == handle) {
|
||||
return bt_conn_ref(&conns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(conns); i++) {
|
||||
if (!atomic_get(&conns[i].ref)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bt_addr_le_cmp(peer, &conns[i].dst)) {
|
||||
return bt_conn_ref(&conns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn)
|
||||
{
|
||||
return &conn->dst;
|
||||
}
|
||||
|
||||
int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
info->type = BT_CONN_TYPE_LE;
|
||||
info->role = conn->role;
|
||||
info->le.dst = &conn->dst;
|
||||
info->le.src = &nble.addr;
|
||||
info->le.interval = conn->interval;
|
||||
info->le.latency = conn->latency;
|
||||
info->le.timeout = conn->timeout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool bt_le_conn_params_valid(u16_t min, u16_t max,
|
||||
u16_t latency, u16_t timeout)
|
||||
{
|
||||
if (min > max || min < 6 || max > 3200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Limits according to BT Core spec 4.2 [Vol 2, Part E, 7.8.12] */
|
||||
if (timeout < 10 || timeout > 3200 ||
|
||||
(2 * timeout) < ((1 + latency) * max * 5)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Limits according to BT Core spec 4.2 [Vol 6, Part B, 4.5.1] */
|
||||
if (latency > 499 || ((latency + 1) * max) > (timeout * 4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int bt_conn_le_param_update(struct bt_conn *conn,
|
||||
const struct bt_le_conn_param *param)
|
||||
{
|
||||
struct nble_gap_conn_update_req req;
|
||||
|
||||
/* Check if there's a need to update conn params */
|
||||
if (conn->interval >= param->interval_min &&
|
||||
conn->interval <= param->interval_max) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
/* Cancel any pending update */
|
||||
k_delayed_work_cancel(&conn->update_work);
|
||||
|
||||
if (!bt_le_conn_params_valid(param->interval_min, param->interval_max,
|
||||
param->latency, param->timeout)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
req.conn_handle = conn->handle;
|
||||
req.params.interval_min = param->interval_min;
|
||||
req.params.interval_max = param->interval_max;
|
||||
req.params.slave_latency = param->latency;
|
||||
req.params.link_sup_to = param->timeout;
|
||||
|
||||
nble_gap_conn_update_req(&req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_conn_disconnect(struct bt_conn *conn, u8_t reason)
|
||||
{
|
||||
struct nble_gap_disconnect_req req;
|
||||
|
||||
switch (conn->state) {
|
||||
case BT_CONN_CONNECT:
|
||||
nble_gap_cancel_connect_req(conn);
|
||||
return 0;
|
||||
case BT_CONN_CONNECTED:
|
||||
break;
|
||||
case BT_CONN_DISCONNECT:
|
||||
BT_ERR("Disconnecting already");
|
||||
return -EBUSY;
|
||||
default:
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* Handle disconnect */
|
||||
req.conn_handle = conn->handle;
|
||||
req.reason = reason;
|
||||
|
||||
conn->state = BT_CONN_DISCONNECT;
|
||||
|
||||
nble_gap_disconnect_req(&req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_gap_disconnect_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Disconnect failed, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p", rsp->user_data);
|
||||
}
|
||||
|
||||
void on_nble_gap_cancel_connect_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Cancel connect failed, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p", rsp->user_data);
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
||||
const struct bt_le_conn_param *param)
|
||||
{
|
||||
struct nble_gap_connect_req req;
|
||||
struct bt_conn *conn;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
if (!bt_le_conn_params_valid(param->interval_min, param->interval_max,
|
||||
param->latency, param->timeout)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conn = conn_get(peer);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to get bt_conn object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Update connection parameters */
|
||||
bt_addr_le_copy(&conn->dst, peer);
|
||||
conn->latency = param->latency;
|
||||
conn->timeout = param->timeout;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
/* Construct parameters to NBLE */
|
||||
bt_addr_le_copy(&req.bda, peer);
|
||||
|
||||
req.conn_params.interval_min = param->interval_min;
|
||||
req.conn_params.interval_max = param->interval_max;
|
||||
req.conn_params.slave_latency = param->latency;
|
||||
req.conn_params.link_sup_to = param->timeout;
|
||||
|
||||
req.scan_params.interval = BT_GAP_SCAN_FAST_INTERVAL;
|
||||
req.scan_params.window = BT_GAP_SCAN_FAST_WINDOW;
|
||||
|
||||
conn->state = BT_CONN_CONNECT;
|
||||
|
||||
nble_gap_connect_req(&req, conn);
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
void on_nble_gap_connect_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Connect failed, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p", rsp->user_data);
|
||||
}
|
||||
|
||||
static int start_security(struct bt_conn *conn)
|
||||
{
|
||||
switch (conn->role) {
|
||||
case BT_HCI_ROLE_MASTER:
|
||||
return bt_smp_send_pairing_req(conn);
|
||||
case BT_HCI_ROLE_SLAVE:
|
||||
return bt_smp_send_security_req(conn);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
|
||||
{
|
||||
int err;
|
||||
|
||||
BT_DBG("conn %p sec %u", conn, sec);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* nothing to do */
|
||||
if (conn->sec_level >= sec || conn->required_sec_level >= sec) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
conn->required_sec_level = sec;
|
||||
|
||||
err = start_security(conn);
|
||||
if (err) {
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
u8_t bt_conn_enc_key_size(struct bt_conn *conn)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_conn_cb_register(struct bt_conn_cb *cb)
|
||||
{
|
||||
cb->_next = callback_list;
|
||||
callback_list = cb;
|
||||
}
|
||||
|
||||
int bt_le_set_auto_conn(bt_addr_le_t *addr,
|
||||
const struct bt_le_conn_param *param)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_create_slave_le(const bt_addr_le_t *peer,
|
||||
const struct bt_le_adv_param *param)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb)
|
||||
{
|
||||
if (!cb) {
|
||||
nble.auth = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* cancel callback should always be provided */
|
||||
if (!cb->cancel) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (nble.auth) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
nble.auth = cb;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
|
||||
{
|
||||
return bt_smp_auth_passkey_entry(conn, passkey);
|
||||
}
|
||||
|
||||
int bt_conn_auth_cancel(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
return bt_smp_auth_cancel(conn);
|
||||
}
|
||||
|
||||
int bt_conn_auth_passkey_confirm(struct bt_conn *conn)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int bt_conn_auth_pairing_confirm(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
return bt_smp_auth_pairing_confirm(conn);
|
||||
}
|
||||
|
||||
/* Connection related events */
|
||||
|
||||
static void notify_connected(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_conn_cb *cb;
|
||||
|
||||
/* TODO: Add l2cap_connected callback if needed */
|
||||
|
||||
bt_smp_connected(conn);
|
||||
bt_gatt_connected(conn);
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->connected) {
|
||||
cb->connected(conn, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void notify_disconnected(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_conn_cb *cb;
|
||||
|
||||
bt_gatt_disconnected(conn);
|
||||
bt_smp_disconnected(conn);
|
||||
|
||||
/*
|
||||
* FIXME: When disconnected NBLE stops advertising, this should
|
||||
* be fixed in the NBLE firmware, use this hack for now
|
||||
*/
|
||||
if (atomic_test_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING)) {
|
||||
BT_WARN("Re-enable advertising on disconnect");
|
||||
nble_gap_start_adv_req();
|
||||
}
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->disconnected) {
|
||||
cb->disconnected(conn, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void le_conn_update(struct k_work *work)
|
||||
{
|
||||
struct bt_conn *conn = CONTAINER_OF(work, struct bt_conn, update_work);
|
||||
|
||||
bt_conn_le_param_update(conn, BT_LE_CONN_PARAM_DEFAULT);
|
||||
}
|
||||
|
||||
void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
BT_DBG("handle %u role %u", ev->conn_handle, ev->role_slave);
|
||||
|
||||
conn = conn_get(&ev->peer_bda);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to get bt_conn object");
|
||||
return;
|
||||
}
|
||||
|
||||
conn->handle = ev->conn_handle;
|
||||
conn->role = ev->role_slave ? BT_CONN_ROLE_SLAVE : BT_CONN_ROLE_MASTER;
|
||||
conn->interval = ev->conn_values.interval;
|
||||
conn->latency = ev->conn_values.latency;
|
||||
conn->timeout = ev->conn_values.supervision_to;
|
||||
bt_addr_le_copy(&conn->dst, &ev->peer_bda);
|
||||
k_delayed_work_init(&conn->update_work, le_conn_update);
|
||||
|
||||
conn->state = BT_CONN_CONNECTED;
|
||||
|
||||
notify_connected(conn);
|
||||
|
||||
/*
|
||||
* Core 4.2 Vol 3, Part C, 9.3.12.2
|
||||
* The Peripheral device should not perform a Connection Parameter
|
||||
* Update procedure within 5 s after establishing a connection.
|
||||
*/
|
||||
k_delayed_work_submit(&conn->update_work,
|
||||
conn->role == BT_HCI_ROLE_MASTER ? K_NO_WAIT :
|
||||
CONN_UPDATE_TIMEOUT);
|
||||
}
|
||||
|
||||
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
conn = bt_conn_lookup_handle(ev->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", ev->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p handle %u", conn, ev->conn_handle);
|
||||
|
||||
conn->state = BT_CONN_DISCONNECTED;
|
||||
|
||||
notify_disconnected(conn);
|
||||
|
||||
/* Cancel Connection Update if it is pending */
|
||||
k_delayed_work_cancel(&conn->update_work);
|
||||
|
||||
/* Drop the reference given by lookup_handle() */
|
||||
bt_conn_unref(conn);
|
||||
/* Drop the initial reference from conn_new() */
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
static void notify_le_param_updated(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_conn_cb *cb;
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->le_param_updated) {
|
||||
cb->le_param_updated(conn, conn->interval,
|
||||
conn->latency, conn->timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
conn = bt_conn_lookup_handle(ev->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", ev->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p handle %u interval %u latency %u to %u",
|
||||
conn, ev->conn_handle, ev->conn_values.interval,
|
||||
ev->conn_values.latency, ev->conn_values.supervision_to);
|
||||
|
||||
conn->interval = ev->conn_values.interval;
|
||||
conn->latency = ev->conn_values.latency;
|
||||
conn->timeout = ev->conn_values.supervision_to;
|
||||
|
||||
notify_le_param_updated(conn);
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
struct bt_conn *bt_conn_lookup_handle(u16_t handle);
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
struct bt_conn {
|
||||
u16_t handle;
|
||||
u8_t role;
|
||||
atomic_t ref;
|
||||
|
||||
bt_addr_le_t dst;
|
||||
|
||||
bt_security_t sec_level;
|
||||
bt_security_t required_sec_level;
|
||||
|
||||
u16_t interval;
|
||||
u16_t latency;
|
||||
u16_t timeout;
|
||||
|
||||
enum {
|
||||
BT_CONN_DISCONNECTED,
|
||||
BT_CONN_CONNECT,
|
||||
BT_CONN_CONNECTED,
|
||||
BT_CONN_DISCONNECT,
|
||||
} state;
|
||||
|
||||
/* Delayed work used to update connection parameters */
|
||||
struct k_delayed_work update_work;
|
||||
|
||||
void *gatt_private;
|
||||
struct k_sem gatt_notif_sem;
|
||||
};
|
|
@ -1,380 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <device.h>
|
||||
|
||||
#include <net/buf.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include <bluetooth/gatt.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_GAP)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "gap_internal.h"
|
||||
#include "conn_internal.h"
|
||||
#include "gatt_internal.h"
|
||||
#include "uart.h"
|
||||
#include "conn.h"
|
||||
#include "rpc.h"
|
||||
#include "smp.h"
|
||||
|
||||
#define NBLE_VERSION(a, b, c) \
|
||||
((((a) & 0xFF) << 16) | (((b) & 0xFF) << 8) | ((c) & 0xFF))
|
||||
|
||||
#define NBLE_VERSION_MAJOR(v) (((v) >> 16) & 0xFF)
|
||||
#define NBLE_VERSION_MINOR(v) (((v) >> 8) & 0xFF)
|
||||
#define NBLE_VERSION_PATCH(v) (((v) >> 0) & 0xFF)
|
||||
|
||||
/* Set the firmware compatible with Nordic BLE RPC */
|
||||
static const u32_t compatible_firmware = NBLE_VERSION(4, 0, 31);
|
||||
|
||||
static bt_ready_cb_t bt_ready_cb;
|
||||
static bt_le_scan_cb_t *scan_dev_found_cb;
|
||||
|
||||
struct nble nble;
|
||||
|
||||
static const struct bt_storage *storage;
|
||||
|
||||
static void clear_bonds(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct nble_sm_clear_bonds_req params = { { 0 }, };
|
||||
|
||||
bt_addr_le_copy(¶ms.addr, addr);
|
||||
|
||||
nble_sm_clear_bonds_req(¶ms);
|
||||
}
|
||||
|
||||
int bt_enable(bt_ready_cb_t cb)
|
||||
{
|
||||
int ret;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
if (!cb) {
|
||||
/* With nble the callback is mandatory */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_test_and_set_bit(&nble.flags, NBLE_FLAG_ENABLE)) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
ret = nble_open();
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bt_ready_cb = cb;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool valid_adv_param(const struct bt_le_adv_param *param)
|
||||
{
|
||||
if (!(param->options & BT_LE_ADV_OPT_CONNECTABLE)) {
|
||||
/*
|
||||
* BT Core 4.2 [Vol 2, Part E, 7.8.5]
|
||||
* The Advertising_Interval_Min and Advertising_Interval_Max
|
||||
* shall not be set to less than 0x00A0 (100 ms) if the
|
||||
* Advertising_Type is set to ADV_SCAN_IND or ADV_NONCONN_IND.
|
||||
*/
|
||||
|
||||
if (param->interval_min < 0x00a0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (param->interval_min > param->interval_max ||
|
||||
param->interval_min < 0x0020 || param->interval_max > 0x4000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int set_ad(struct nble_eir_data *eir, const struct bt_data *ad,
|
||||
size_t ad_len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ad_len; i++) {
|
||||
u8_t *p;
|
||||
|
||||
/* Check if ad fit in the remaining buffer */
|
||||
if (eir->len + ad[i].data_len + 2 > 31) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
p = &eir->data[eir->len];
|
||||
*p++ = ad[i].data_len + 1;
|
||||
*p++ = ad[i].type;
|
||||
memcpy(p, ad[i].data, ad[i].data_len);
|
||||
eir->len += ad[i].data_len + 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_adv_start(const struct bt_le_adv_param *param,
|
||||
const struct bt_data *ad, size_t ad_len,
|
||||
const struct bt_data *sd, size_t sd_len)
|
||||
{
|
||||
struct nble_gap_set_adv_params_req params = { 0 };
|
||||
struct nble_gap_set_adv_data_req data = { 0 };
|
||||
int err;
|
||||
|
||||
if (!valid_adv_param(param)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = set_ad(&data.ad, ad, ad_len);
|
||||
if (err) {
|
||||
BT_ERR("Error setting ad data %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = set_ad(&data.sd, sd, sd_len);
|
||||
if (err) {
|
||||
BT_ERR("Error setting scan response data %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Set advertising data */
|
||||
nble_gap_set_adv_data_req(&data);
|
||||
|
||||
/* TODO: Timeout is handled by application timer */
|
||||
params.timeout = 0;
|
||||
/* forced to none currently (no whitelist support) */
|
||||
params.filter_policy = 0;
|
||||
params.interval_max = param->interval_max;
|
||||
params.interval_min = param->interval_min;
|
||||
|
||||
if (param->options & BT_LE_ADV_OPT_CONNECTABLE) {
|
||||
params.type = BT_LE_ADV_IND;
|
||||
} else {
|
||||
if (sd) {
|
||||
params.type = BT_LE_ADV_SCAN_IND;
|
||||
} else {
|
||||
params.type = BT_LE_ADV_NONCONN_IND;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set advertising parameters */
|
||||
nble_gap_set_adv_params_req(¶ms);
|
||||
|
||||
/* Start advertising */
|
||||
nble_gap_start_adv_req();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_gap_start_adv_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Start advertise falied, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_set_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING);
|
||||
|
||||
BT_DBG("status %u", rsp->status);
|
||||
}
|
||||
|
||||
int bt_le_adv_stop(void)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
nble_gap_stop_adv_req(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_gap_stop_advertise_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Stop advertise failed, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_clear_bit(&nble.flags, NBLE_FLAG_KEEP_ADVERTISING);
|
||||
|
||||
BT_DBG("status %d", rsp->status);
|
||||
}
|
||||
|
||||
static bool valid_le_scan_param(const struct bt_le_scan_param *param)
|
||||
{
|
||||
if (param->type != BT_HCI_LE_SCAN_PASSIVE &&
|
||||
param->type != BT_HCI_LE_SCAN_ACTIVE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->filter_dup != BT_HCI_LE_SCAN_FILTER_DUP_DISABLE &&
|
||||
param->filter_dup != BT_HCI_LE_SCAN_FILTER_DUP_ENABLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->interval < 0x0004 || param->interval > 0x4000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->window < 0x0004 || param->window > 0x4000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param->window > param->interval) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)
|
||||
{
|
||||
struct nble_gap_start_scan_req nble_params;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
/* Check that the parameters have valid values */
|
||||
if (!valid_le_scan_param(param)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
nble_params.scan_params.interval = param->interval;
|
||||
nble_params.scan_params.window = param->window;
|
||||
nble_params.scan_params.scan_type = param->type;
|
||||
nble_params.scan_params.use_whitelist = 0;
|
||||
|
||||
/* Check is scan already enabled */
|
||||
|
||||
scan_dev_found_cb = cb;
|
||||
|
||||
nble_gap_start_scan_req(&nble_params);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt,
|
||||
const u8_t *buf, u8_t len)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
if (scan_dev_found_cb) {
|
||||
struct net_buf_simple *data = NET_BUF_SIMPLE(31);
|
||||
|
||||
net_buf_simple_init(data, 0);
|
||||
memcpy(net_buf_simple_add(data, len), buf, len);
|
||||
|
||||
scan_dev_found_cb(&evt->addr, evt->rssi, evt->adv_type, data);
|
||||
}
|
||||
}
|
||||
|
||||
int bt_le_scan_stop(void)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
scan_dev_found_cb = NULL;
|
||||
|
||||
nble_gap_stop_scan_req();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_gap_scan_start_stop_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Unable to stop scan, status %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("");
|
||||
}
|
||||
|
||||
void nble_log(const struct nble_log_s *param, char *format, u8_t len)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_DEBUG)
|
||||
/* Build meaningful output */
|
||||
printf("nble: ");
|
||||
printf(format, param->param0, param->param1, param->param2,
|
||||
param->param3);
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void on_nble_get_bda_rsp(const struct nble_get_bda_rsp *rsp)
|
||||
{
|
||||
bt_addr_le_copy(&nble.addr, &rsp->bda);
|
||||
|
||||
BT_DBG("Local bdaddr: %s", bt_addr_le_str(&nble.addr));
|
||||
|
||||
/* Make sure the nRF51 persistent memory is cleared */
|
||||
clear_bonds(BT_ADDR_LE_ANY);
|
||||
|
||||
if (bt_ready_cb) {
|
||||
bt_ready_cb(0);
|
||||
bt_ready_cb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void on_nble_common_rsp(const struct nble_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("Last request failed, error %d", rsp->status);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("status %d", rsp->status);
|
||||
}
|
||||
|
||||
void rpc_init_cb(u32_t version, bool compatible)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
if (!compatible) {
|
||||
BT_ERR("\n\n"
|
||||
"RPC reported incompatible firmware"
|
||||
"\n\n");
|
||||
}
|
||||
if (version != compatible_firmware) {
|
||||
BT_ERR("\n\n"
|
||||
"Incompatible firmware: %d.%d.%d, "
|
||||
"please use version %d.%d.%d"
|
||||
"\n\n",
|
||||
NBLE_VERSION_MAJOR(version),
|
||||
NBLE_VERSION_MINOR(version),
|
||||
NBLE_VERSION_PATCH(version),
|
||||
NBLE_VERSION_MAJOR(compatible_firmware),
|
||||
NBLE_VERSION_MINOR(compatible_firmware),
|
||||
NBLE_VERSION_PATCH(compatible_firmware));
|
||||
/* TODO: shall we allow to continue */
|
||||
}
|
||||
|
||||
bt_smp_init();
|
||||
bt_gatt_init();
|
||||
}
|
||||
|
||||
void bt_storage_register(const struct bt_storage *bt_storage)
|
||||
{
|
||||
storage = bt_storage;
|
||||
}
|
||||
|
||||
int bt_storage_clear(const bt_addr_le_t *addr)
|
||||
{
|
||||
clear_bonds(addr);
|
||||
/* FIXME: make the necessary storage callbacks too. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_oob_get_local(struct bt_le_oob *oob)
|
||||
{
|
||||
bt_addr_le_copy(&oob->addr, &nble.addr);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,614 +0,0 @@
|
|||
/** @file
|
||||
* @brief Internal API for Generic Access Profile.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Maximum security key len (LTK, CSRK) */
|
||||
#define BLE_GAP_SEC_MAX_KEY_LEN 16
|
||||
|
||||
#define BT_SMP_AUTH_NONE 0x00
|
||||
#define BT_SMP_AUTH_BONDING 0x01
|
||||
#define BT_SMP_AUTH_MITM 0x04
|
||||
#define BT_SMP_AUTH_SC 0x08
|
||||
|
||||
#define BT_SMP_ERR_PASSKEY_ENTRY_FAILED 0x01
|
||||
#define BT_SMP_ERR_OOB_NOT_AVAIL 0x02
|
||||
#define BT_SMP_ERR_AUTH_REQUIREMENTS 0x03
|
||||
#define BT_SMP_ERR_CONFIRM_FAILED 0x04
|
||||
#define BT_SMP_ERR_PAIRING_NOTSUPP 0x05
|
||||
#define BT_SMP_ERR_ENC_KEY_SIZE 0x06
|
||||
#define BT_SMP_ERR_CMD_NOTSUPP 0x07
|
||||
#define BT_SMP_ERR_UNSPECIFIED 0x08
|
||||
#define BT_SMP_ERR_REPEATED_ATTEMPTS 0x09
|
||||
#define BT_SMP_ERR_INVALID_PARAMS 0x0a
|
||||
#define BT_SMP_ERR_DHKEY_CHECK_FAILED 0x0b
|
||||
#define BT_SMP_ERR_NUMERIC_COMP_FAILED 0x0c
|
||||
#define BT_SMP_ERR_BREDR_PAIRING_IN_PROGRESS 0x0d
|
||||
#define BT_SMP_ERR_CROSS_TRANSP_NOT_ALLOWED 0x0e
|
||||
|
||||
enum NBLE_GAP_SM_PASSKEY_TYPE {
|
||||
NBLE_GAP_SM_REJECT = 0,
|
||||
NBLE_GAP_SM_PK_PASSKEY,
|
||||
NBLE_GAP_SM_PK_OOB,
|
||||
};
|
||||
|
||||
enum NBLE_GAP_SM_EVT {
|
||||
NBLE_GAP_SM_EVT_START_PAIRING,
|
||||
NBLE_GAP_SM_EVT_BONDING_COMPLETE,
|
||||
NBLE_GAP_SM_EVT_LINK_ENCRYPTED,
|
||||
NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE,
|
||||
};
|
||||
|
||||
struct nble_log_s {
|
||||
u8_t param0;
|
||||
u8_t param1;
|
||||
u8_t param2;
|
||||
u8_t param3;
|
||||
};
|
||||
|
||||
void nble_log(const struct nble_log_s *par, char *data, u8_t len);
|
||||
|
||||
struct nble_common_rsp {
|
||||
int status;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
struct bt_local_addr {
|
||||
bt_addr_le_t id_addr;
|
||||
#if defined(CONFIG_BLUETOOTH_PRIVACY)
|
||||
bt_addr_le_t rpa;
|
||||
#endif
|
||||
};
|
||||
|
||||
void on_nble_common_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
void nble_panic_req(void);
|
||||
|
||||
struct nble_version {
|
||||
u8_t version;
|
||||
u8_t major;
|
||||
u8_t minor;
|
||||
u8_t patch;
|
||||
char version_string[20];
|
||||
u8_t build_hash[4];
|
||||
u8_t hash[4];
|
||||
};
|
||||
|
||||
typedef void (*ble_get_version_cb_t)(const struct nble_version *ver);
|
||||
|
||||
void nble_get_version_req(ble_get_version_cb_t cb);
|
||||
|
||||
struct nble_get_version_rsp {
|
||||
ble_get_version_cb_t cb;
|
||||
struct nble_version ver;
|
||||
};
|
||||
|
||||
void on_nble_get_version_rsp(const struct nble_get_version_rsp *rsp);
|
||||
|
||||
enum NBLE_GAP_SVC_ATTR_TYPE {
|
||||
/* Device Name, UUID 0x2a00 */
|
||||
NBLE_GAP_SVC_ATTR_NAME = 0,
|
||||
/* Appearance, UUID 0x2a01 */
|
||||
NBLE_GAP_SVC_ATTR_APPEARANCE,
|
||||
/* Peripheral Preferred Connection Parameters (PPCP), UUID 0x2a04 */
|
||||
NBLE_GAP_SVC_ATTR_PPCP = 4,
|
||||
/* Central Address Resolution (CAR), UUID 0x2aa6, BT 4.2 */
|
||||
NBLE_GAP_SVC_ATTR_CAR = 0xa6,
|
||||
};
|
||||
|
||||
struct nble_gap_device_name {
|
||||
/* Security mode for writing device name, see BLE_GAP_SEC_MODES */
|
||||
u8_t sec_mode;
|
||||
/* 0: no authorization, 1: authorization required */
|
||||
u8_t authorization;
|
||||
/* Device name length (0-248) */
|
||||
u8_t len;
|
||||
u8_t name_array[20];
|
||||
};
|
||||
|
||||
struct nble_conn_param {
|
||||
/* minimal connection interval: range 0x0006 to 0x0c80 (unit 1.25ms) */
|
||||
u16_t interval_min;
|
||||
/* maximum connection interval: range 0x0006 to 0x0c80 must be bigger then min! */
|
||||
u16_t interval_max;
|
||||
/* maximum connection slave latency: 0x0000 to 0x01f3 */
|
||||
u16_t slave_latency;
|
||||
/* link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */
|
||||
u16_t link_sup_to;
|
||||
};
|
||||
|
||||
struct nble_gap_service_req {
|
||||
/* GAP Characteristics attribute type see NBLE_GAP_SVC_ATTR_TYPE */
|
||||
u16_t attr_type;
|
||||
union {
|
||||
struct nble_gap_device_name name;
|
||||
/* Appearance UUID */
|
||||
u16_t appearance;
|
||||
/* Preferred Peripheral Connection Parameters */
|
||||
struct nble_conn_param ppcp;
|
||||
/* Central Address Resolution support 0: no, 1: yes */
|
||||
u8_t car;
|
||||
};
|
||||
};
|
||||
|
||||
void nble_gap_service_req(const struct nble_gap_service_req *req);
|
||||
|
||||
struct nble_dbg_req {
|
||||
u32_t u0;
|
||||
u32_t u1;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
void nble_dbg_req(const struct nble_dbg_req *req);
|
||||
|
||||
struct nble_dbg_rsp {
|
||||
int status;
|
||||
u32_t u0;
|
||||
u32_t u1;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
void on_nble_dbg_rsp(const struct nble_dbg_rsp *rsp);
|
||||
|
||||
typedef void (*nble_set_bda_cb_t)(int status, void *user_data, const bt_addr_le_t *bda);
|
||||
|
||||
struct nble_set_bda_req {
|
||||
nble_set_bda_cb_t cb;
|
||||
void *user_data;
|
||||
bt_addr_le_t bda;
|
||||
};
|
||||
|
||||
void nble_set_bda_req(const struct nble_set_bda_req *req);
|
||||
|
||||
struct nble_set_bda_rsp {
|
||||
nble_set_bda_cb_t cb;
|
||||
void *user_data;
|
||||
int status;
|
||||
bt_addr_le_t bda;
|
||||
};
|
||||
|
||||
void on_nble_set_bda_rsp(const struct nble_set_bda_rsp *rsp);
|
||||
|
||||
typedef void (*nble_get_bda_cb_t)(const bt_addr_le_t *bda, void *user_data);
|
||||
|
||||
struct nble_get_bda_req {
|
||||
nble_get_bda_cb_t cb;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
void nble_get_bda_req(const struct nble_get_bda_req *req);
|
||||
|
||||
struct nble_get_bda_rsp {
|
||||
nble_get_bda_cb_t cb;
|
||||
void *user_data;
|
||||
bt_addr_le_t bda;
|
||||
};
|
||||
|
||||
void on_nble_get_bda_rsp(const struct nble_get_bda_rsp *rsp);
|
||||
|
||||
struct nble_eir_data {
|
||||
u8_t len;
|
||||
u8_t data[31];
|
||||
};
|
||||
|
||||
struct nble_gap_set_adv_data_req {
|
||||
/* Advertisement data, maybe 0 (length) */
|
||||
struct nble_eir_data ad;
|
||||
/* Scan response data, maybe 0 (length) */
|
||||
struct nble_eir_data sd;
|
||||
};
|
||||
|
||||
void nble_gap_set_adv_data_req(struct nble_gap_set_adv_data_req *req);
|
||||
|
||||
struct nble_gap_set_adv_params_req {
|
||||
u16_t timeout;
|
||||
/* min interval 0xffff: use default 0x0800 */
|
||||
u16_t interval_min;
|
||||
/* max interval 0xffff: use default 0x0800 */
|
||||
u16_t interval_max;
|
||||
/* advertisement types see GAP_ADV_TYPES */
|
||||
u8_t type;
|
||||
/* filter policy to apply with white list */
|
||||
u8_t filter_policy;
|
||||
/* bd address of peer device in case of directed advertisement */
|
||||
bt_addr_le_t peer_bda;
|
||||
};
|
||||
|
||||
void nble_gap_set_adv_params_req(struct nble_gap_set_adv_params_req *req);
|
||||
|
||||
void nble_gap_start_adv_req(void);
|
||||
|
||||
void on_nble_gap_start_adv_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
void nble_gap_stop_adv_req(void *user_data);
|
||||
|
||||
struct nble_gap_conn_update_req {
|
||||
u16_t conn_handle;
|
||||
struct nble_conn_param params;
|
||||
};
|
||||
|
||||
void nble_gap_conn_update_req(const struct nble_gap_conn_update_req *req);
|
||||
|
||||
void on_nble_gap_conn_update_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
struct nble_gap_disconnect_req {
|
||||
u16_t conn_handle;
|
||||
u8_t reason;
|
||||
};
|
||||
|
||||
void nble_gap_disconnect_req(const struct nble_gap_disconnect_req *req);
|
||||
|
||||
struct nble_sm_config_rsp {
|
||||
void *user_data;
|
||||
int status;
|
||||
bool sm_bond_dev_avail;
|
||||
};
|
||||
|
||||
void on_nble_sm_config_rsp(struct nble_sm_config_rsp *rsp);
|
||||
|
||||
struct nble_sm_pairing_param {
|
||||
/* authentication level see BLE_GAP_SM_OPTIONS */
|
||||
u8_t auth;
|
||||
u8_t io_capabilities;
|
||||
u8_t max_key_size;
|
||||
u8_t min_key_size;
|
||||
u8_t oob_flag;
|
||||
};
|
||||
|
||||
struct nble_sm_security_req {
|
||||
struct bt_conn *conn;
|
||||
u16_t conn_handle;
|
||||
/* Local authentication/bonding parameters */
|
||||
struct nble_sm_pairing_param params;
|
||||
};
|
||||
|
||||
void nble_sm_security_req(const struct nble_sm_security_req *req);
|
||||
|
||||
enum NBLE_SM_PASSKEY_TYPE {
|
||||
NBLE_SM_PK_PASSKEY,
|
||||
NBLE_SM_PK_OOB,
|
||||
};
|
||||
|
||||
struct nble_sm_passkey {
|
||||
u8_t type; /* see NBLE_SM_PASSKEY_TYPE */
|
||||
union {
|
||||
u32_t passkey;
|
||||
u8_t oob[16];
|
||||
u8_t reason;
|
||||
};
|
||||
};
|
||||
|
||||
struct nble_sm_passkey_reply_req {
|
||||
struct bt_conn *conn;
|
||||
u16_t conn_handle;
|
||||
struct nble_sm_passkey params;
|
||||
};
|
||||
|
||||
void nble_sm_passkey_reply_req(const struct nble_sm_passkey_reply_req *req);
|
||||
|
||||
struct nble_sm_clear_bonds_req {
|
||||
bt_addr_le_t addr;
|
||||
};
|
||||
|
||||
void nble_sm_clear_bonds_req(const struct nble_sm_clear_bonds_req *req);
|
||||
|
||||
struct nble_sm_common_rsp {
|
||||
int status;
|
||||
struct bt_conn *conn;
|
||||
};
|
||||
|
||||
void on_nble_sm_common_rsp(const struct nble_sm_common_rsp *rsp);
|
||||
|
||||
struct nble_sm_pairing_response_req {
|
||||
struct bt_conn *conn;
|
||||
u16_t conn_handle;
|
||||
struct nble_sm_pairing_param params;
|
||||
};
|
||||
|
||||
void nble_sm_pairing_response_req(const struct nble_sm_pairing_response_req *req);
|
||||
|
||||
struct nble_sm_error_req {
|
||||
struct bt_conn *conn;
|
||||
u16_t conn_handle;
|
||||
u8_t reason;
|
||||
};
|
||||
|
||||
void nble_sm_error_req(const struct nble_sm_error_req *req);
|
||||
|
||||
struct nble_gap_set_rssi_report_req {
|
||||
u16_t conn_handle;
|
||||
/* RSSI operation see NBLE_GAP_RSSI_OPS */
|
||||
u8_t op;
|
||||
/* Channel for RSSI enabling */
|
||||
u8_t channel;
|
||||
/* minimum RSSI dBm change to report a new RSSI value */
|
||||
u8_t delta_dBm;
|
||||
/* number of delta_dBm changes before sending a new RSSI report */
|
||||
u8_t min_count;
|
||||
};
|
||||
|
||||
void nble_gap_set_rssi_report_req(const struct nble_gap_set_rssi_report_req *req,
|
||||
void *user_data);
|
||||
|
||||
void on_nble_gap_set_rssi_report_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
struct nble_scan_param {
|
||||
u16_t interval;
|
||||
u16_t window;
|
||||
/* Unused for the connection request */
|
||||
u8_t scan_type;
|
||||
/* Unused for the connection request */
|
||||
u8_t use_whitelist;
|
||||
};
|
||||
|
||||
struct nble_gap_start_scan_req {
|
||||
struct nble_scan_param scan_params;
|
||||
};
|
||||
|
||||
void nble_gap_start_scan_req(const struct nble_gap_start_scan_req *req);
|
||||
|
||||
void nble_gap_stop_scan_req(void);
|
||||
|
||||
void on_nble_gap_scan_start_stop_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
struct nble_gap_connect_req {
|
||||
bt_addr_le_t bda;
|
||||
struct nble_conn_param conn_params;
|
||||
struct nble_scan_param scan_params;
|
||||
};
|
||||
|
||||
void nble_gap_connect_req(const struct nble_gap_connect_req *req,
|
||||
void *user_data);
|
||||
|
||||
void on_nble_gap_connect_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
void nble_gap_cancel_connect_req(void *user_data);
|
||||
|
||||
void on_nble_gap_cancel_connect_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
/* Temporary patch: RSSI processing for UAS */
|
||||
struct nble_uas_rssi_calibrate_req {
|
||||
float distance;
|
||||
};
|
||||
void nble_uas_rssi_calibrate_req(const struct nble_uas_rssi_calibrate_req *req);
|
||||
|
||||
/* Temporary patch: RSSI processing for UAS */
|
||||
struct nble_uas_bucket_change {
|
||||
u8_t distance;
|
||||
};
|
||||
|
||||
void on_nble_uas_bucket_change(const struct nble_uas_bucket_change *par);
|
||||
|
||||
void nble_gap_dtm_init_req(void *user_data);
|
||||
|
||||
void on_nble_gap_dtm_init_rsp(void *user_data);
|
||||
|
||||
struct nble_gap_set_tx_power_req {
|
||||
s8_t tx_power;
|
||||
};
|
||||
|
||||
void nble_gap_set_tx_power_req(const struct nble_gap_set_tx_power_req *req);
|
||||
|
||||
void on_nble_gap_set_tx_power_rsp(const struct nble_common_rsp *rsp);
|
||||
|
||||
struct nble_conn_values {
|
||||
/* Connection interval (unit 1.25 ms) */
|
||||
u16_t interval;
|
||||
/* Connection latency (unit interval) */
|
||||
u16_t latency;
|
||||
/* Connection supervision timeout (unit 10ms)*/
|
||||
u16_t supervision_to;
|
||||
};
|
||||
|
||||
struct nble_gap_connect_evt {
|
||||
u16_t conn_handle;
|
||||
struct nble_conn_values conn_values;
|
||||
/* 0 if connected as master, otherwise as slave */
|
||||
u8_t role_slave;
|
||||
/* Address of peer device */
|
||||
bt_addr_le_t peer_bda;
|
||||
};
|
||||
|
||||
void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *evt);
|
||||
|
||||
struct nble_gap_disconnect_evt {
|
||||
u16_t conn_handle;
|
||||
u8_t hci_reason;
|
||||
};
|
||||
|
||||
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *evt);
|
||||
|
||||
struct nble_gap_conn_update_evt {
|
||||
u16_t conn_handle;
|
||||
struct nble_conn_values conn_values;
|
||||
};
|
||||
|
||||
void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *evt);
|
||||
|
||||
struct nble_gap_adv_report_evt {
|
||||
bt_addr_le_t addr;
|
||||
s8_t rssi;
|
||||
u8_t adv_type;
|
||||
};
|
||||
|
||||
void on_nble_gap_adv_report_evt(const struct nble_gap_adv_report_evt *evt,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gap_dir_adv_timeout_evt {
|
||||
u16_t conn_handle;
|
||||
u16_t error;
|
||||
};
|
||||
|
||||
void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *evt);
|
||||
|
||||
#define BLE_GAP_RSSI_EVT_SIZE 32
|
||||
|
||||
struct nble_gap_rssi_evt {
|
||||
u16_t conn_handle;
|
||||
s8_t rssi_data[BLE_GAP_RSSI_EVT_SIZE];
|
||||
};
|
||||
|
||||
void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *evt);
|
||||
|
||||
struct nble_sm_passkey_req_evt {
|
||||
u16_t conn_handle;
|
||||
u8_t key_type;
|
||||
};
|
||||
|
||||
void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *evt);
|
||||
|
||||
struct nble_sm_passkey_disp_evt {
|
||||
u16_t conn_handle;
|
||||
u32_t passkey;
|
||||
};
|
||||
|
||||
void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *evt);
|
||||
|
||||
enum NBLE_SM_STATUS_EVT {
|
||||
NBLE_SM_STATUS_START_PAIRING,
|
||||
NBLE_SM_STATUS_BONDING_COMPLETE,
|
||||
NBLE_SM_STATUS_LINK_ENCRYPTED,
|
||||
NBLE_SM_STATUS_LINK_SECURITY_CHANGE,
|
||||
};
|
||||
|
||||
struct nble_link_sec {
|
||||
bt_security_t sec_level;
|
||||
u8_t enc_size;
|
||||
};
|
||||
|
||||
struct nble_sm_status_evt {
|
||||
u16_t conn_handle;
|
||||
u8_t evt_type; /* see NBLE_SM_STATUS_EVT */
|
||||
int status;
|
||||
union {
|
||||
struct nble_link_sec enc_link_sec;
|
||||
bt_addr_le_t addr;
|
||||
};
|
||||
};
|
||||
|
||||
void on_nble_sm_status_evt(const struct nble_sm_status_evt *evt);
|
||||
|
||||
struct nble_sec_param {
|
||||
u8_t auth;
|
||||
u8_t io_capabilities;
|
||||
u8_t min_key_size;
|
||||
u8_t max_key_size;
|
||||
};
|
||||
|
||||
struct nble_sm_pairing_request_evt {
|
||||
u16_t conn_handle;
|
||||
struct nble_sec_param sec_param;
|
||||
};
|
||||
|
||||
void on_nble_sm_pairing_request_evt(const struct nble_sm_pairing_request_evt *evt);
|
||||
|
||||
struct nble_sm_security_request_evt {
|
||||
u16_t conn_handle;
|
||||
struct nble_sec_param sec_param;
|
||||
};
|
||||
|
||||
void on_nble_sm_security_request_evt(const struct nble_sm_security_request_evt *evt);
|
||||
|
||||
struct nble_sm_bond_info;
|
||||
typedef void (*ble_bond_info_cb_t)(const struct nble_sm_bond_info *info,
|
||||
const bt_addr_le_t *addr, u16_t len,
|
||||
void *user_data);
|
||||
|
||||
struct nble_sm_bond_info_req {
|
||||
ble_bond_info_cb_t cb;
|
||||
void *user_data;
|
||||
bool include_bonded_addrs;
|
||||
};
|
||||
|
||||
void nble_sm_bond_info_req(const struct nble_sm_bond_info_req *req);
|
||||
|
||||
struct nble_sm_bond_info {
|
||||
int err;
|
||||
u8_t addr_count;
|
||||
u8_t irk_count;
|
||||
};
|
||||
|
||||
struct nble_sm_bond_info_rsp {
|
||||
ble_bond_info_cb_t cb;
|
||||
void *user_data;
|
||||
struct nble_sm_bond_info info;
|
||||
};
|
||||
|
||||
void on_nble_sm_bond_info_rsp(const struct nble_sm_bond_info_rsp *rsp,
|
||||
const bt_addr_le_t *peer_addr, u16_t len);
|
||||
|
||||
struct nble_uart_test_req {
|
||||
/* Test type: 1 = start peer test, 2 = loopback test */
|
||||
u16_t test_type;
|
||||
/* Test type 1: Number of test events packets sent from peer to host */
|
||||
u16_t nb_loops;
|
||||
/* Test type 1: The maximum delay between packets (in ms) */
|
||||
u16_t max_delay;
|
||||
/* Test type 1: The maximum length of packets (in bytes) */
|
||||
u16_t max_len;
|
||||
};
|
||||
|
||||
void nble_uart_test_req(const struct nble_uart_test_req *req,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_uart_test_evt {
|
||||
/* Number of loops executed */
|
||||
u16_t nb_loops;
|
||||
};
|
||||
|
||||
void on_nble_uart_test_evt(const struct nble_uart_test_evt *evt,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
/*
|
||||
* The following functions are NOT RPC functions
|
||||
*/
|
||||
|
||||
void ble_gap_get_bonding_info(ble_bond_info_cb_t func, void *user_data,
|
||||
bool include_bonded_addrs);
|
||||
|
||||
void ble_gap_get_version(ble_get_version_cb_t func);
|
||||
|
||||
void ble_gap_get_bda_info(struct bt_local_addr *addr);
|
||||
|
||||
enum NBLE_GAP_RSSI_OPS {
|
||||
NBLE_GAP_RSSI_DISABLE_REPORT = 0,
|
||||
NBLE_GAP_RSSI_ENABLE_REPORT
|
||||
};
|
||||
|
||||
typedef void (*rssi_report_t)(const s8_t *rssi_data);
|
||||
|
||||
typedef void (*rssi_report_resp_t)(int status);
|
||||
|
||||
struct ble_rssi_report_params {
|
||||
/* RSSI operation see NBLE_GAP_RSSI_OPS */
|
||||
u8_t op;
|
||||
/* Channel for RSSI enabling */
|
||||
u8_t channel;
|
||||
/* minimum RSSI dBm change to report a new RSSI value */
|
||||
u8_t delta_dBm;
|
||||
/* number of delta_dBm changes before sending a new RSSI report */
|
||||
u8_t min_count;
|
||||
};
|
||||
|
||||
void ble_gap_set_rssi_report(struct ble_rssi_report_params *par,
|
||||
struct bt_conn *conn,
|
||||
rssi_report_resp_t resp_cb, rssi_report_t evt_cb);
|
||||
|
||||
enum {
|
||||
NBLE_FLAG_ENABLE,
|
||||
NBLE_FLAG_KEEP_ADVERTISING,
|
||||
};
|
||||
|
||||
struct nble {
|
||||
/* Local Bluetooth LE Device Address */
|
||||
bt_addr_le_t addr;
|
||||
const struct bt_conn_auth_cb *auth;
|
||||
atomic_t flags;
|
||||
};
|
||||
|
||||
extern struct nble nble;
|
File diff suppressed because it is too large
Load diff
|
@ -1,286 +0,0 @@
|
|||
/** @file
|
||||
* @brief Internal API for Generic Attribute Profile handling.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Max number of service supported, if changed update BLE core needs to be
|
||||
* updated too!
|
||||
*/
|
||||
#define BLE_GATTS_MAX_SERVICES 10
|
||||
|
||||
void bt_gatt_init(void);
|
||||
|
||||
/*
|
||||
* GATT Attribute stream structure.
|
||||
*
|
||||
* This structure is a "compressed" copy of bt_gatt_attr.
|
||||
* UUID pointer and user_data pointer are used as offset into buffer itself.
|
||||
* The offset is from the beginning of the buffer. therefore a value of 0
|
||||
* means that UUID or user_data is not present.
|
||||
*/
|
||||
struct nble_gatts_attr {
|
||||
/* Attribute permissions */
|
||||
u16_t perm;
|
||||
/* Attribute variable data size */
|
||||
u16_t data_size;
|
||||
/* Attribute variable data: always starts with the UUID and data follows */
|
||||
u8_t data[];
|
||||
};
|
||||
|
||||
struct nble_gatts_register_req {
|
||||
/* Base address of the attribute table in the Quark mem space */
|
||||
struct bt_gatt_attr *attr_base;
|
||||
/* Number of of attributes in this service */
|
||||
u8_t attr_count;
|
||||
/* Size of struct bt_gatt_attr */
|
||||
u8_t attr_size;
|
||||
};
|
||||
|
||||
void nble_gatts_register_req(const struct nble_gatts_register_req *req,
|
||||
u8_t *data, u16_t len);
|
||||
|
||||
struct nble_gatts_register_rsp {
|
||||
int status;
|
||||
struct bt_gatt_attr *attr_base;
|
||||
/* Number of attributes successfully added */
|
||||
u8_t attr_count;
|
||||
};
|
||||
|
||||
struct nble_gatt_attr_handles {
|
||||
u16_t handle;
|
||||
};
|
||||
|
||||
void on_nble_gatts_register_rsp(const struct nble_gatts_register_rsp *rsp,
|
||||
const struct nble_gatt_attr_handles *attrs,
|
||||
u8_t len);
|
||||
|
||||
enum nble_gatt_wr_flag {
|
||||
NBLE_GATT_WR_FLAG_REPLY = 1,
|
||||
NBLE_GATT_WR_FLAG_PREP = 2,
|
||||
};
|
||||
|
||||
struct nble_gatts_write_evt {
|
||||
struct bt_gatt_attr *attr;
|
||||
u16_t conn_handle;
|
||||
u16_t offset;
|
||||
/* see nble_gatt_wr_flag */
|
||||
u8_t flag;
|
||||
};
|
||||
|
||||
void on_nble_gatts_write_evt(const struct nble_gatts_write_evt *evt,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gatts_write_reply_req {
|
||||
u16_t conn_handle;
|
||||
u16_t offset;
|
||||
s32_t status;
|
||||
};
|
||||
|
||||
void nble_gatts_write_reply_req(const struct nble_gatts_write_reply_req *req,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gatts_write_exec_evt {
|
||||
u16_t conn_handle;
|
||||
u8_t flag;
|
||||
};
|
||||
|
||||
void on_nble_gatts_write_exec_evt(const struct nble_gatts_write_exec_evt *evt);
|
||||
|
||||
struct nble_gatts_read_evt {
|
||||
struct bt_gatt_attr *attr;
|
||||
u16_t conn_handle;
|
||||
u16_t offset;
|
||||
};
|
||||
|
||||
void on_nble_gatts_read_evt(const struct nble_gatts_read_evt *evt);
|
||||
|
||||
struct nble_gatts_read_reply_req {
|
||||
u16_t conn_handle;
|
||||
u16_t offset;
|
||||
s32_t status;
|
||||
};
|
||||
|
||||
void nble_gatts_read_reply_req(const struct nble_gatts_read_reply_req *req,
|
||||
u8_t *data, u16_t len);
|
||||
|
||||
struct nble_gatts_value_change_param {
|
||||
const struct bt_gatt_attr *attr;
|
||||
u16_t conn_handle;
|
||||
u16_t offset;
|
||||
};
|
||||
|
||||
struct nble_gatts_notify_req {
|
||||
/* Function to be invoked when buffer is freed */
|
||||
bt_gatt_notify_func_t cback;
|
||||
struct nble_gatts_value_change_param params;
|
||||
};
|
||||
|
||||
void nble_gatts_notify_req(const struct nble_gatts_notify_req *req,
|
||||
const u8_t *data, u16_t len);
|
||||
|
||||
struct nble_gatts_notify_tx_evt {
|
||||
bt_gatt_notify_func_t cback;
|
||||
int status;
|
||||
u16_t conn_handle;
|
||||
struct bt_gatt_attr *attr;
|
||||
};
|
||||
|
||||
void on_nble_gatts_notify_tx_evt(const struct nble_gatts_notify_tx_evt *evt);
|
||||
|
||||
struct nble_gatts_indicate_req {
|
||||
/* Function to be invoked when buffer is freed */
|
||||
bt_gatt_indicate_func_t cback;
|
||||
struct nble_gatts_value_change_param params;
|
||||
};
|
||||
|
||||
void nble_gatts_indicate_req(const struct nble_gatts_indicate_req *req,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gatts_indicate_rsp {
|
||||
bt_gatt_indicate_func_t cback;
|
||||
struct bt_gatt_attr *attr;
|
||||
int status;
|
||||
u16_t conn_handle;
|
||||
};
|
||||
|
||||
void on_nble_gatts_indicate_rsp(const struct nble_gatts_indicate_rsp *rsp);
|
||||
|
||||
#define DISCOVER_FLAGS_UUID_PRESENT 1
|
||||
|
||||
struct nble_gatt_handle_range {
|
||||
u16_t start_handle;
|
||||
u16_t end_handle;
|
||||
};
|
||||
|
||||
struct nble_gattc_discover_req {
|
||||
void *user_data;
|
||||
struct bt_uuid_128 uuid;
|
||||
struct nble_gatt_handle_range handle_range;
|
||||
u16_t conn_handle;
|
||||
u8_t type;
|
||||
u8_t flags;
|
||||
};
|
||||
|
||||
void nble_gattc_discover_req(const struct nble_gattc_discover_req *req);
|
||||
|
||||
struct nble_gattc_primary {
|
||||
u16_t handle;
|
||||
struct nble_gatt_handle_range range;
|
||||
struct bt_uuid_128 uuid;
|
||||
};
|
||||
|
||||
struct nble_gattc_included {
|
||||
u16_t handle;
|
||||
struct nble_gatt_handle_range range;
|
||||
struct bt_uuid_128 uuid;
|
||||
};
|
||||
|
||||
struct nble_gattc_characteristic {
|
||||
u16_t handle;
|
||||
u8_t prop;
|
||||
u16_t value_handle;
|
||||
struct bt_uuid_128 uuid;
|
||||
};
|
||||
|
||||
struct nble_gattc_descriptor {
|
||||
u16_t handle;
|
||||
struct bt_uuid_128 uuid;
|
||||
};
|
||||
|
||||
struct nble_gattc_discover_rsp {
|
||||
s32_t status;
|
||||
void *user_data;
|
||||
u16_t conn_handle;
|
||||
u8_t type;
|
||||
};
|
||||
|
||||
void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp,
|
||||
const u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gattc_read_req {
|
||||
void *user_data;
|
||||
u16_t conn_handle;
|
||||
u16_t handle;
|
||||
u16_t offset;
|
||||
};
|
||||
|
||||
void nble_gattc_read_req(const struct nble_gattc_read_req *req);
|
||||
|
||||
struct nble_gattc_read_rsp {
|
||||
int status;
|
||||
void *user_data;
|
||||
u16_t conn_handle;
|
||||
u16_t handle;
|
||||
u16_t offset;
|
||||
};
|
||||
|
||||
void on_nble_gattc_read_rsp(const struct nble_gattc_read_rsp *rsp,
|
||||
u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gattc_read_multi_req {
|
||||
void *user_data;
|
||||
u16_t conn_handle;
|
||||
};
|
||||
|
||||
void nble_gattc_read_multi_req(const struct nble_gattc_read_multi_req *req,
|
||||
const u16_t *handles, u16_t len);
|
||||
|
||||
void on_nble_gattc_read_multi_rsp(const struct nble_gattc_read_rsp *rsp,
|
||||
u8_t *data, u8_t len);
|
||||
|
||||
struct nble_gattc_write_param;
|
||||
|
||||
typedef void (*nble_att_func_t)(struct bt_conn *conn, u8_t err,
|
||||
const struct nble_gattc_write_param *par);
|
||||
|
||||
struct nble_gattc_write_param {
|
||||
/* Function invoked upon write response */
|
||||
nble_att_func_t func;
|
||||
/* User specific data */
|
||||
void *user_data[2];
|
||||
};
|
||||
|
||||
struct nble_gattc_write_req {
|
||||
u16_t conn_handle;
|
||||
u16_t handle;
|
||||
u16_t offset;
|
||||
/* different than 0 if response required */
|
||||
u8_t with_resp;
|
||||
struct nble_gattc_write_param wr_params;
|
||||
};
|
||||
|
||||
void nble_gattc_write_req(const struct nble_gattc_write_req *req,
|
||||
const u8_t *data, u16_t len);
|
||||
|
||||
struct nble_gattc_write_rsp {
|
||||
int status;
|
||||
u16_t conn_handle;
|
||||
u16_t handle;
|
||||
struct nble_gattc_write_param wr_params;
|
||||
};
|
||||
|
||||
void on_nble_gattc_write_rsp(const struct nble_gattc_write_rsp *rsp);
|
||||
|
||||
void bt_gatt_connected(struct bt_conn *conn);
|
||||
void bt_gatt_disconnected(struct bt_conn *conn);
|
||||
|
||||
enum NBLE_GATTC_EVT {
|
||||
NBLE_GATTC_EVT_NOTIFICATION,
|
||||
NBLE_GATTC_EVT_INDICATION,
|
||||
};
|
||||
|
||||
struct nble_gattc_value_evt {
|
||||
int status;
|
||||
u16_t conn_handle;
|
||||
u16_t handle;
|
||||
/* see NBLE_GATTC_VALUE_EVT */
|
||||
u8_t type;
|
||||
};
|
||||
|
||||
void on_nble_gattc_value_evt(const struct nble_gattc_value_evt *evt,
|
||||
u8_t *data, u8_t len);
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <net/buf.h>
|
||||
|
||||
/** Identifiers of the signature supported by the RPC */
|
||||
enum {
|
||||
SIG_TYPE_NONE = 1,
|
||||
SIG_TYPE_S,
|
||||
SIG_TYPE_P,
|
||||
SIG_TYPE_S_B,
|
||||
SIG_TYPE_B_B_P,
|
||||
SIG_TYPE_S_P,
|
||||
SIG_TYPE_S_B_P,
|
||||
SIG_TYPE_S_B_B_P,
|
||||
SIG_TYPE_CONTROL = 0xFF
|
||||
};
|
||||
|
||||
/**
|
||||
* RPC memory allocation function, must be implemented by the user of the RPC.
|
||||
*
|
||||
* This function is called by the RPC mechanism to allocate a buffer for
|
||||
* transmission of a serialized function. The function should not fail.
|
||||
*
|
||||
* @param length Length of the buffer to allocate.
|
||||
*
|
||||
* @return Pointer to the allocated buffer, the allocation shall not fail,
|
||||
* error must be handled internally
|
||||
*/
|
||||
struct net_buf *rpc_alloc_cb(u16_t length);
|
||||
|
||||
/**
|
||||
* RPC transmission function, must be implemented by the user of the RPC.
|
||||
*
|
||||
* @param buf Pointer to the buffer allocated for transmission
|
||||
* by @ref rpc_alloc_cb
|
||||
*/
|
||||
void rpc_transmit_cb(struct net_buf *buf);
|
||||
|
||||
/**
|
||||
* RPC initialization function that notifies the peer with an initialization
|
||||
* packet containing the information to check the compatibility of the
|
||||
* frameworks.
|
||||
*
|
||||
* @param version Local version to send to the peer.
|
||||
*/
|
||||
void rpc_init(u32_t version);
|
||||
|
||||
/**
|
||||
* RPC initialization packet reception function, can optionally be implemented
|
||||
* by the user of the RPC. If this function is not implemented, it will default
|
||||
* to an empty function.
|
||||
*
|
||||
* This function is called by the RPC mechanism when an initialization packet is
|
||||
* received from the connected peer.
|
||||
*
|
||||
* @param version Peer advertised version.
|
||||
* @param compatible True if the peer runs a compatible RPC framework.
|
||||
*/
|
||||
void rpc_init_cb(u32_t version, bool compatible);
|
||||
|
||||
/** RPC serialize hash number generation.
|
||||
*
|
||||
* @return The unique identifier of the RPC deserialization.
|
||||
*/
|
||||
u32_t rpc_serialize_hash(void);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that does not require any
|
||||
* parameter.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
*/
|
||||
void rpc_serialize_none(u8_t fn_index);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* as parameter.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param struct_data Pointer to the structure to serialize
|
||||
* @param struct_length Length of the structure to serialize
|
||||
*/
|
||||
void rpc_serialize_s(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* and a pointer as parameters.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param struct_data Pointer to the structure to serialize
|
||||
* @param struct_length Length of the structure to serialize
|
||||
* @param p_priv Pointer to serialize
|
||||
*/
|
||||
void rpc_serialize_s_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, void *p_priv);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a pointer as
|
||||
* parameter.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param p_priv Pointer to serialize
|
||||
*/
|
||||
void rpc_serialize_p(u8_t fn_index, void *p_priv);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* and a buffer as parameters.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param struct_data Pointer to the structure to serialize
|
||||
* @param struct_length Length of the structure to serialize
|
||||
* @param vbuf Pointer to the buffer to serialize
|
||||
* @param vbuf_length Length of the buffer to serialize
|
||||
*/
|
||||
void rpc_serialize_s_b(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf,
|
||||
u16_t vbuf_length);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* and a buffer as parameters.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param vbuf1 Pointer to the buffer1 to serialize
|
||||
* @param vbuf1_length Length of the buffer1 to serialize
|
||||
* @param vbuf2 Pointer to the buffer2 to serialize
|
||||
* @param vbuf2_length Length of the buffer2 to serialize
|
||||
* @param p_priv Pointer to serialize
|
||||
*/
|
||||
void rpc_serialize_b_b_p(u8_t fn_index, const void *vbuf1,
|
||||
u16_t vbuf1_length, const void *vbuf2,
|
||||
u16_t vbuf2_length, void *p_priv);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* and a buffer as parameters.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param struct_data Pointer to the structure to serialize
|
||||
* @param struct_length Length of the structure to serialize
|
||||
* @param vbuf Pointer to the buffer to serialize
|
||||
* @param vbuf_length Length of the buffer to serialize
|
||||
* @param p_priv Pointer to serialize
|
||||
*/
|
||||
void rpc_serialize_s_b_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf,
|
||||
u16_t vbuf_length, void *p_priv);
|
||||
|
||||
/**
|
||||
* RPC serialization function to serialize a function that expects a structure
|
||||
* and a buffer as parameters.
|
||||
*
|
||||
* @param fn_index Index of the function
|
||||
* @param struct_data Pointer to the structure to serialize
|
||||
* @param struct_length Length of the structure to serialize
|
||||
* @param vbuf1 Pointer to the buffer1 to serialize
|
||||
* @param vbuf1_length Length of the buffer1 to serialize
|
||||
* @param vbuf2 Pointer to the buffer2 to serialize
|
||||
* @param vbuf2_length2 Length of the buffer2 to serialize
|
||||
* @param p_priv Pointer to serialize
|
||||
*/
|
||||
void rpc_serialize_s_b_b_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf1,
|
||||
u16_t vbuf1_length, const void *vbuf2,
|
||||
u16_t vbuf2_length, void *p_priv);
|
||||
|
||||
/**
|
||||
* RPC deserialization function, shall be invoked when a buffer is received
|
||||
* over the transport interface.
|
||||
*
|
||||
* @param buf Pointer to the received buffer
|
||||
*/
|
||||
void rpc_deserialize(struct net_buf *buf);
|
||||
|
||||
/** RPC deserialize hash number generation.
|
||||
*
|
||||
* @return The unique identifier of the RPC deserialization.
|
||||
*/
|
||||
u32_t rpc_deserialize_hash(void);
|
||||
|
|
@ -1,639 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
/* for bt_security_t */
|
||||
#include <bluetooth/conn.h>
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
#include <misc/printk.h>
|
||||
#define PRINTK(...) printk(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTK(...)
|
||||
#endif /* CONFIG_PRINTK */
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_NBLE_DEBUG_RPC)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "rpc.h"
|
||||
#include "gap_internal.h"
|
||||
#include "gatt_internal.h"
|
||||
|
||||
#include "rpc_functions_to_quark.h"
|
||||
|
||||
/* Build the list of prototypes and check that list are made only of matching
|
||||
* signatures
|
||||
*/
|
||||
#define FN_SIG_NONE(__fn) void __fn(void);
|
||||
LIST_FN_SIG_NONE
|
||||
#undef FN_SIG_NONE
|
||||
|
||||
#define FN_SIG_S(__fn, __s) void __fn(__s p_s);
|
||||
LIST_FN_SIG_S
|
||||
#undef FN_SIG_S
|
||||
|
||||
#define FN_SIG_P(__fn, __type) void __fn(__type priv);
|
||||
LIST_FN_SIG_P
|
||||
#undef FN_SIG_P
|
||||
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
void __fn(__s p_s, __type buf, __length length);
|
||||
LIST_FN_SIG_S_B
|
||||
#undef FN_SIG_S_B
|
||||
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) \
|
||||
void __fn(__type1 p_buf1, __length1 length1, __type2 p_buf2, \
|
||||
__length2 length2, __type3 priv);
|
||||
LIST_FN_SIG_B_B_P
|
||||
#undef FN_SIG_B_B_P
|
||||
|
||||
#define FN_SIG_S_P(__fn, __s, __type) void __fn(__s p_s, __type priv);
|
||||
LIST_FN_SIG_S_P
|
||||
#undef FN_SIG_S_P
|
||||
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
void __fn(__s p_s, __type buf, __length length, __type_ptr priv);
|
||||
LIST_FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_P
|
||||
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type_ptr) \
|
||||
void __fn(__s p_s, __type1 p_buf1, __length1 length1, \
|
||||
__type2 p_buf2, __length2 length2, __type_ptr priv);
|
||||
LIST_FN_SIG_S_B_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
/* 1 - define the size check arrays */
|
||||
#define FN_SIG_NONE(__fn)
|
||||
|
||||
#define FN_SIG_S(__fn, __s) sizeof(*((__s)0)),
|
||||
|
||||
#define FN_SIG_P(__fn, __type)
|
||||
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) sizeof(*((__s)0)),
|
||||
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) sizeof(*((__s)0)),
|
||||
|
||||
#define FN_SIG_S_P(__fn, __s, __type) sizeof(*((__s)0)),
|
||||
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
sizeof(*((__s)0)),
|
||||
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) sizeof(*((__s)0)),
|
||||
|
||||
static u8_t m_size_s[] = { LIST_FN_SIG_S };
|
||||
static u8_t m_size_s_b[] = { LIST_FN_SIG_S_B };
|
||||
static u8_t m_size_s_p[] = { LIST_FN_SIG_S_P };
|
||||
static u8_t m_size_s_b_p[] = { LIST_FN_SIG_S_B_P };
|
||||
static u8_t m_size_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P };
|
||||
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
/* 2- build the enumerations list */
|
||||
#define FN_SIG_NONE(__fn) fn_index_##__fn,
|
||||
#define FN_SIG_S(__fn, __s) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_P(__fn, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_P(__fn, __s, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) FN_SIG_NONE(__fn)
|
||||
|
||||
/* Build the list of function indexes in the deserialization array */
|
||||
enum { LIST_FN_SIG_NONE fn_none_index_max };
|
||||
enum { LIST_FN_SIG_S fn_s_index_max };
|
||||
enum { LIST_FN_SIG_P fn_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B fn_s_b_index_max };
|
||||
enum { LIST_FN_SIG_B_B_P fn_b_b_p_index_max };
|
||||
enum { LIST_FN_SIG_S_P fn_s_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B_P fn_s_b_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B_B_P fn_s_b_b_p_index_max };
|
||||
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
/* 3- build the array */
|
||||
#define FN_SIG_NONE(__fn) [fn_index_##__fn] = \
|
||||
(void *)__fn,
|
||||
#define FN_SIG_S(__fn, __s) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_P(__fn, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_P(__fn, __s, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) FN_SIG_NONE(__fn)
|
||||
|
||||
static void (*m_fct_none[])(void) = { LIST_FN_SIG_NONE };
|
||||
static void (*m_fct_s[])(void *structure) = { LIST_FN_SIG_S };
|
||||
static void (*m_fct_p[])(void *pointer) = { LIST_FN_SIG_P };
|
||||
static void (*m_fct_s_b[])(void *structure, void *buffer,
|
||||
u8_t length) = { LIST_FN_SIG_S_B };
|
||||
static void (*m_fct_b_b_p[])(void *buffer1, u8_t length1,
|
||||
void *buffer2, u8_t length2,
|
||||
void *pointer) = { LIST_FN_SIG_B_B_P };
|
||||
static void (*m_fct_s_p[])(void *structure,
|
||||
void *pointer) = { LIST_FN_SIG_S_P };
|
||||
static void (*m_fct_s_b_p[])(void *structure, void *buffer, u8_t length,
|
||||
void *pointer) = { LIST_FN_SIG_S_B_P };
|
||||
static void (*m_fct_s_b_b_p[])(void *structure, void *buffer1, u8_t length1,
|
||||
void *buffer2, u8_t length2,
|
||||
void *pointer) = { LIST_FN_SIG_S_B_B_P };
|
||||
|
||||
/* Build debug table to help development with this "robust" macro stuff */
|
||||
|
||||
#if defined(CONFIG_NBLE_DEBUG_RPC)
|
||||
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
#define FN_SIG_NONE(__fn) #__fn,
|
||||
#define FN_SIG_S(__fn, __s) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_P(__fn, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_P(__fn, __s, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) FN_SIG_NONE(__fn)
|
||||
|
||||
static char *debug_func_none[] = { LIST_FN_SIG_NONE };
|
||||
static char *debug_func_s[] = { LIST_FN_SIG_S };
|
||||
static char *debug_func_p[] = { LIST_FN_SIG_P };
|
||||
static char *debug_func_s_b[] = { LIST_FN_SIG_S_B };
|
||||
static char *debug_func_b_b_p[] = { LIST_FN_SIG_B_B_P };
|
||||
static char *debug_func_s_p[] = { LIST_FN_SIG_S_P };
|
||||
static char *debug_func_s_b_p[] = { LIST_FN_SIG_S_B_P };
|
||||
static char *debug_func_s_b_b_p[] = { LIST_FN_SIG_S_B_B_P};
|
||||
|
||||
#define DBG_FUNC(name) BT_DBG("%s", name)
|
||||
#else
|
||||
#define DBG_FUNC(name)
|
||||
#endif
|
||||
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
#define DJB2_HASH(__h, __v) ((((__h) << 5) + (__h)) + (__v))
|
||||
|
||||
#define FN_SIG_NONE(__fn) \
|
||||
hash = DJB2_HASH(hash, 1);
|
||||
|
||||
#define FN_SIG_S(__fn, __s) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 2); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_P(__fn, __type) \
|
||||
hash = DJB2_HASH(hash, 3);
|
||||
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 4); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 5); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_P(__fn, __s, __type) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 6); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 7); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 8); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
u32_t rpc_deserialize_hash(void)
|
||||
{
|
||||
u32_t hash = 5381;
|
||||
|
||||
LIST_FN_SIG_NONE;
|
||||
LIST_FN_SIG_S;
|
||||
LIST_FN_SIG_P;
|
||||
LIST_FN_SIG_S_B;
|
||||
LIST_FN_SIG_B_B_P;
|
||||
LIST_FN_SIG_S_P;
|
||||
LIST_FN_SIG_S_B_P;
|
||||
LIST_FN_SIG_S_B_B_P;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static void panic(int err)
|
||||
{
|
||||
PRINTK("panic: errcode %d", err);
|
||||
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_struct(struct net_buf *buf, const u8_t **struct_ptr,
|
||||
u8_t *struct_length)
|
||||
{
|
||||
*struct_length = net_buf_pull_u8(buf);
|
||||
*struct_ptr = buf->data;
|
||||
net_buf_pull(buf, *struct_length);
|
||||
}
|
||||
|
||||
static void deserialize_buf(struct net_buf *buf, const u8_t **buf_ptr,
|
||||
u16_t *buf_len)
|
||||
{
|
||||
u8_t b;
|
||||
|
||||
/* Get the current byte */
|
||||
b = net_buf_pull_u8(buf);
|
||||
*buf_len = b & 0x7F;
|
||||
if (b & 0x80) {
|
||||
/* Get the current byte */
|
||||
b = net_buf_pull_u8(buf);
|
||||
*buf_len += (u16_t)b << 7;
|
||||
}
|
||||
|
||||
/* Return the values */
|
||||
*buf_ptr = buf->data;
|
||||
|
||||
net_buf_pull(buf, *buf_len);
|
||||
}
|
||||
|
||||
static void deserialize_ptr(struct net_buf *buf, uintptr_t *priv)
|
||||
{
|
||||
memcpy(priv, buf->data, sizeof(*priv));
|
||||
net_buf_pull(buf, sizeof(*priv));
|
||||
}
|
||||
|
||||
static void deserialize_none(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
(void)buf;
|
||||
|
||||
if (buf->len != 0) {
|
||||
panic(-1);
|
||||
}
|
||||
|
||||
m_fct_none[fn_index]();
|
||||
}
|
||||
|
||||
static void deserialize_s(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *struct_ptr;
|
||||
u8_t struct_length;
|
||||
|
||||
deserialize_struct(buf, &struct_ptr, &struct_length);
|
||||
|
||||
if (struct_length != m_size_s[fn_index]) {
|
||||
panic(-1);
|
||||
} else {
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t struct_data[(struct_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
|
||||
memcpy(struct_data, struct_ptr, struct_length);
|
||||
|
||||
m_fct_s[fn_index](struct_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_p(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
uintptr_t priv;
|
||||
|
||||
if (buf->len != sizeof(priv)) {
|
||||
panic(-1);
|
||||
}
|
||||
|
||||
deserialize_ptr(buf, &priv);
|
||||
|
||||
m_fct_p[fn_index]((void *)priv);
|
||||
}
|
||||
|
||||
static void deserialize_s_b(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_struct_data;
|
||||
u8_t struct_length;
|
||||
const u8_t *p_vbuf;
|
||||
u16_t vbuf_length;
|
||||
|
||||
deserialize_struct(buf, &p_struct_data, &struct_length);
|
||||
deserialize_buf(buf, &p_vbuf, &vbuf_length);
|
||||
|
||||
if (struct_length != m_size_s_b[fn_index]) {
|
||||
panic(-1);
|
||||
} else {
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t struct_data[(struct_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
uintptr_t vbuf[(vbuf_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
void *buf = NULL;
|
||||
|
||||
memcpy(struct_data, p_struct_data, struct_length);
|
||||
|
||||
if (vbuf_length) {
|
||||
memcpy(vbuf, p_vbuf, vbuf_length);
|
||||
buf = vbuf;
|
||||
}
|
||||
|
||||
m_fct_s_b[fn_index](struct_data, buf, vbuf_length);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_b_b_p(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_vbuf1;
|
||||
u16_t vbuf1_length;
|
||||
const u8_t *p_vbuf2;
|
||||
u16_t vbuf2_length;
|
||||
uintptr_t priv;
|
||||
|
||||
deserialize_buf(buf, &p_vbuf1, &vbuf1_length);
|
||||
deserialize_buf(buf, &p_vbuf2, &vbuf2_length);
|
||||
deserialize_ptr(buf, &priv);
|
||||
|
||||
{
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t vbuf1[(vbuf1_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
uintptr_t vbuf2[(vbuf2_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
void *buf1 = NULL;
|
||||
void *buf2 = NULL;
|
||||
|
||||
if (vbuf1_length) {
|
||||
memcpy(vbuf1, p_vbuf1, vbuf1_length);
|
||||
buf1 = vbuf1;
|
||||
}
|
||||
|
||||
if (vbuf2_length) {
|
||||
memcpy(vbuf2, p_vbuf2, vbuf2_length);
|
||||
buf2 = vbuf2;
|
||||
}
|
||||
|
||||
m_fct_b_b_p[fn_index](buf1, vbuf1_length, buf2, vbuf2_length,
|
||||
(void *)priv);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_s_p(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_struct_data;
|
||||
u8_t struct_length;
|
||||
uintptr_t priv;
|
||||
|
||||
deserialize_struct(buf, &p_struct_data, &struct_length);
|
||||
deserialize_ptr(buf, &priv);
|
||||
|
||||
if (struct_length != m_size_s_p[fn_index]) {
|
||||
panic(-1);
|
||||
} else {
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t struct_data[(struct_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
|
||||
memcpy(struct_data, p_struct_data, struct_length);
|
||||
|
||||
m_fct_s_p[fn_index](struct_data, (void *)priv);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_s_b_p(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_struct_data;
|
||||
u8_t struct_length;
|
||||
const u8_t *p_vbuf;
|
||||
u16_t vbuf_length;
|
||||
uintptr_t priv;
|
||||
|
||||
deserialize_struct(buf, &p_struct_data, &struct_length);
|
||||
deserialize_buf(buf, &p_vbuf, &vbuf_length);
|
||||
deserialize_ptr(buf, &priv);
|
||||
|
||||
if (struct_length != m_size_s_b_p[fn_index]) {
|
||||
panic(-1);
|
||||
} else {
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t struct_data[(struct_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
uintptr_t vbuf[(vbuf_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
void *buf = NULL;
|
||||
|
||||
memcpy(struct_data, p_struct_data, struct_length);
|
||||
|
||||
if (vbuf_length) {
|
||||
memcpy(vbuf, p_vbuf, vbuf_length);
|
||||
buf = vbuf;
|
||||
}
|
||||
|
||||
m_fct_s_b_p[fn_index](struct_data, buf, vbuf_length,
|
||||
(void *)priv);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_s_b_b_p(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_struct_data;
|
||||
u8_t struct_length;
|
||||
const u8_t *p_vbuf1;
|
||||
u16_t vbuf1_length;
|
||||
const u8_t *p_vbuf2;
|
||||
u16_t vbuf2_length;
|
||||
uintptr_t priv;
|
||||
|
||||
deserialize_struct(buf, &p_struct_data, &struct_length);
|
||||
deserialize_buf(buf, &p_vbuf1, &vbuf1_length);
|
||||
deserialize_buf(buf, &p_vbuf2, &vbuf2_length);
|
||||
deserialize_ptr(buf, &priv);
|
||||
|
||||
if (struct_length != m_size_s_b_b_p[fn_index]) {
|
||||
panic(-1);
|
||||
} else {
|
||||
/* Always align structures on word boundary */
|
||||
uintptr_t struct_data[(struct_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
uintptr_t vbuf1[(vbuf1_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
uintptr_t vbuf2[(vbuf2_length +
|
||||
(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
|
||||
void *buf1 = NULL;
|
||||
void *buf2 = NULL;
|
||||
|
||||
memcpy(struct_data, p_struct_data, struct_length);
|
||||
|
||||
if (vbuf1_length) {
|
||||
memcpy(vbuf1, p_vbuf1, vbuf1_length);
|
||||
buf1 = vbuf1;
|
||||
}
|
||||
|
||||
if (vbuf2_length) {
|
||||
memcpy(vbuf2, p_vbuf2, vbuf2_length);
|
||||
buf2 = vbuf2;
|
||||
}
|
||||
|
||||
m_fct_s_b_b_p[fn_index](struct_data, buf1, vbuf1_length, buf2,
|
||||
vbuf2_length, (void *)priv);
|
||||
}
|
||||
}
|
||||
|
||||
static void deserialize_control(u8_t fn_index, struct net_buf *buf)
|
||||
{
|
||||
const u8_t *p_struct_data;
|
||||
u8_t struct_length;
|
||||
struct {
|
||||
u32_t version;
|
||||
u32_t ser_hash;
|
||||
u32_t des_hash;
|
||||
} struct_data;
|
||||
|
||||
switch (fn_index) {
|
||||
case 0:
|
||||
deserialize_struct(buf, &p_struct_data, &struct_length);
|
||||
|
||||
if (struct_length != sizeof(struct_data))
|
||||
panic(-1);
|
||||
memcpy(&struct_data, p_struct_data, struct_length);
|
||||
if (struct_data.ser_hash != rpc_deserialize_hash() ||
|
||||
struct_data.des_hash != rpc_serialize_hash()) {
|
||||
rpc_init_cb(struct_data.version, false);
|
||||
} else {
|
||||
rpc_init_cb(struct_data.version, true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
panic(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rpc_deserialize(struct net_buf *buf)
|
||||
{
|
||||
|
||||
u8_t fn_index;
|
||||
u8_t sig_type;
|
||||
|
||||
sig_type = buf->data[0];
|
||||
fn_index = buf->data[1];
|
||||
|
||||
net_buf_pull(buf, 2);
|
||||
|
||||
switch (sig_type) {
|
||||
case SIG_TYPE_NONE:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_none)) {
|
||||
DBG_FUNC(debug_func_none[fn_index]);
|
||||
deserialize_none(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_S:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_s)) {
|
||||
DBG_FUNC(debug_func_s[fn_index]);
|
||||
deserialize_s(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_P:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_p)) {
|
||||
DBG_FUNC(debug_func_p[fn_index]);
|
||||
deserialize_p(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_S_B:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_s_b)) {
|
||||
DBG_FUNC(debug_func_s_b[fn_index]);
|
||||
deserialize_s_b(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_B_B_P:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_b_b_p)) {
|
||||
DBG_FUNC(debug_func_b_b_p[fn_index]);
|
||||
deserialize_b_b_p(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_S_P:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_s_p)) {
|
||||
DBG_FUNC(debug_func_s_p[fn_index]);
|
||||
deserialize_s_p(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_S_B_P:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_s_b_p)) {
|
||||
DBG_FUNC(debug_func_s_b_p[fn_index]);
|
||||
deserialize_s_b_p(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_S_B_B_P:
|
||||
if (fn_index < ARRAY_SIZE(m_fct_s_b_b_p)) {
|
||||
DBG_FUNC(debug_func_s_b_b_p[fn_index]);
|
||||
deserialize_s_b_b_p(fn_index, buf);
|
||||
}
|
||||
break;
|
||||
case SIG_TYPE_CONTROL:
|
||||
deserialize_control(fn_index, buf);
|
||||
break;
|
||||
default:
|
||||
panic(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
__weak
|
||||
void rpc_init_cb(u32_t version, bool compatible)
|
||||
{
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* declare the list of functions sorted by signature */
|
||||
#define LIST_FN_SIG_NONE \
|
||||
FN_SIG_NONE(nble_gap_start_adv_req) \
|
||||
FN_SIG_NONE(nble_gap_stop_scan_req) \
|
||||
FN_SIG_NONE(nble_panic_req)
|
||||
|
||||
#define LIST_FN_SIG_S \
|
||||
FN_SIG_S(nble_gap_set_adv_data_req, \
|
||||
struct nble_gap_set_adv_data_req *) \
|
||||
FN_SIG_S(nble_gap_set_adv_params_req, \
|
||||
struct nble_gap_set_adv_params_req *) \
|
||||
FN_SIG_S(nble_gap_start_scan_req, \
|
||||
const struct nble_gap_start_scan_req *) \
|
||||
FN_SIG_S(nble_sm_passkey_reply_req, \
|
||||
const struct nble_sm_passkey_reply_req *) \
|
||||
FN_SIG_S(nble_sm_bond_info_req, \
|
||||
const struct nble_sm_bond_info_req *) \
|
||||
FN_SIG_S(nble_sm_security_req, \
|
||||
const struct nble_sm_security_req *) \
|
||||
FN_SIG_S(nble_sm_clear_bonds_req, \
|
||||
const struct nble_sm_clear_bonds_req *) \
|
||||
FN_SIG_S(nble_set_bda_req, const struct nble_set_bda_req *) \
|
||||
FN_SIG_S(nble_get_bda_req, const struct nble_get_bda_req *) \
|
||||
FN_SIG_S(nble_gap_conn_update_req, \
|
||||
const struct nble_gap_conn_update_req *) \
|
||||
FN_SIG_S(nble_gattc_discover_req, \
|
||||
const struct nble_gattc_discover_req *) \
|
||||
FN_SIG_S(nble_uas_rssi_calibrate_req, \
|
||||
const struct nble_uas_rssi_calibrate_req *) \
|
||||
FN_SIG_S(nble_gap_service_req, \
|
||||
const struct nble_gap_service_req *) \
|
||||
FN_SIG_S(nble_gap_disconnect_req, \
|
||||
const struct nble_gap_disconnect_req *) \
|
||||
FN_SIG_S(nble_gattc_read_req, \
|
||||
const struct nble_gattc_read_req *) \
|
||||
FN_SIG_S(nble_gap_set_tx_power_req, \
|
||||
const struct nble_gap_set_tx_power_req *) \
|
||||
FN_SIG_S(nble_dbg_req, const struct nble_dbg_req *) \
|
||||
FN_SIG_S(nble_sm_pairing_response_req, \
|
||||
const struct nble_sm_pairing_response_req *) \
|
||||
FN_SIG_S(nble_sm_error_req, \
|
||||
const struct nble_sm_error_req *)
|
||||
|
||||
|
||||
#define LIST_FN_SIG_P \
|
||||
FN_SIG_P(nble_gap_dtm_init_req, void *) \
|
||||
FN_SIG_P(nble_gap_stop_adv_req, void *) \
|
||||
FN_SIG_P(nble_get_version_req, ble_get_version_cb_t) \
|
||||
FN_SIG_P(nble_gap_cancel_connect_req, void *)
|
||||
|
||||
#define LIST_FN_SIG_S_B \
|
||||
FN_SIG_S_B(nble_gatts_register_req, \
|
||||
const struct nble_gatts_register_req *, \
|
||||
u8_t *, u16_t) \
|
||||
FN_SIG_S_B(nble_gatts_notify_req, \
|
||||
const struct nble_gatts_notify_req *, \
|
||||
const u8_t *, u16_t) \
|
||||
FN_SIG_S_B(nble_gatts_indicate_req, \
|
||||
const struct nble_gatts_indicate_req *, \
|
||||
const u8_t *, u8_t) \
|
||||
FN_SIG_S_B(nble_gatts_read_reply_req, \
|
||||
const struct nble_gatts_read_reply_req *, \
|
||||
u8_t *, u16_t) \
|
||||
FN_SIG_S_B(nble_gattc_write_req, \
|
||||
const struct nble_gattc_write_req *, \
|
||||
const u8_t *, u16_t) \
|
||||
FN_SIG_S_B(nble_gattc_read_multi_req, \
|
||||
const struct nble_gattc_read_multi_req *, \
|
||||
const u16_t *, u16_t) \
|
||||
FN_SIG_S_B(nble_uart_test_req, \
|
||||
const struct nble_uart_test_req *, \
|
||||
const u8_t *, u8_t) \
|
||||
FN_SIG_S_B(nble_gatts_write_reply_req, \
|
||||
const struct nble_gatts_write_reply_req *, \
|
||||
const u8_t *, u8_t)
|
||||
|
||||
#define LIST_FN_SIG_B_B_P
|
||||
|
||||
#define LIST_FN_SIG_S_P \
|
||||
FN_SIG_S_P(nble_gap_connect_req, \
|
||||
const struct nble_gap_connect_req *, void *) \
|
||||
FN_SIG_S_P(nble_gap_set_rssi_report_req, \
|
||||
const struct nble_gap_set_rssi_report_req *, void *)
|
||||
|
||||
#define LIST_FN_SIG_S_B_P
|
||||
|
||||
#define LIST_FN_SIG_S_B_B_P
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* declare the list of functions sorted by signature */
|
||||
#define LIST_FN_SIG_NONE
|
||||
|
||||
#define LIST_FN_SIG_S \
|
||||
FN_SIG_S(on_nble_get_version_rsp, \
|
||||
const struct nble_get_version_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_connect_evt, \
|
||||
const struct nble_gap_connect_evt *) \
|
||||
FN_SIG_S(on_nble_gap_disconnect_evt, \
|
||||
const struct nble_gap_disconnect_evt *) \
|
||||
FN_SIG_S(on_nble_gap_conn_update_evt, \
|
||||
const struct nble_gap_conn_update_evt *) \
|
||||
FN_SIG_S(on_nble_sm_status_evt, \
|
||||
const struct nble_sm_status_evt *) \
|
||||
FN_SIG_S(on_nble_sm_passkey_disp_evt, \
|
||||
const struct nble_sm_passkey_disp_evt *) \
|
||||
FN_SIG_S(on_nble_sm_passkey_req_evt, \
|
||||
const struct nble_sm_passkey_req_evt *) \
|
||||
FN_SIG_S(on_nble_gap_rssi_evt, \
|
||||
const struct nble_gap_rssi_evt *) \
|
||||
FN_SIG_S(on_nble_common_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_connect_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_cancel_connect_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_get_bda_rsp, \
|
||||
const struct nble_get_bda_rsp *) \
|
||||
FN_SIG_S(on_nble_sm_config_rsp, \
|
||||
struct nble_sm_config_rsp *) \
|
||||
FN_SIG_S(on_nble_sm_common_rsp, \
|
||||
const struct nble_sm_common_rsp *) \
|
||||
FN_SIG_S(on_nble_set_bda_rsp, \
|
||||
const struct nble_set_bda_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_set_rssi_report_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_dbg_rsp, \
|
||||
const struct nble_dbg_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_dir_adv_timeout_evt, \
|
||||
const struct nble_gap_dir_adv_timeout_evt *) \
|
||||
FN_SIG_S(on_nble_gatts_notify_tx_evt, \
|
||||
const struct nble_gatts_notify_tx_evt *) \
|
||||
FN_SIG_S(on_nble_gatts_indicate_rsp, \
|
||||
const struct nble_gatts_indicate_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_start_adv_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_scan_start_stop_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_gatts_read_evt, \
|
||||
const struct nble_gatts_read_evt *) \
|
||||
FN_SIG_S(on_nble_gatts_write_exec_evt, \
|
||||
const struct nble_gatts_write_exec_evt *) \
|
||||
FN_SIG_S(on_nble_uas_bucket_change, \
|
||||
const struct nble_uas_bucket_change *) \
|
||||
FN_SIG_S(on_nble_gattc_write_rsp, \
|
||||
const struct nble_gattc_write_rsp *) \
|
||||
FN_SIG_S(on_nble_gap_set_tx_power_rsp, \
|
||||
const struct nble_common_rsp *) \
|
||||
FN_SIG_S(on_nble_sm_pairing_request_evt, \
|
||||
const struct nble_sm_pairing_request_evt *) \
|
||||
FN_SIG_S(on_nble_sm_security_request_evt, \
|
||||
const struct nble_sm_security_request_evt *)
|
||||
|
||||
|
||||
#define LIST_FN_SIG_P \
|
||||
FN_SIG_P(on_nble_gap_dtm_init_rsp, void *)
|
||||
|
||||
#define LIST_FN_SIG_S_B \
|
||||
FN_SIG_S_B(nble_log, const struct nble_log_s *, char *, \
|
||||
u8_t) \
|
||||
FN_SIG_S_B(on_nble_gattc_value_evt, \
|
||||
const struct nble_gattc_value_evt *, \
|
||||
u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_gatts_write_evt, \
|
||||
const struct nble_gatts_write_evt *, \
|
||||
const u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_gatts_register_rsp, \
|
||||
const struct nble_gatts_register_rsp *, \
|
||||
const struct nble_gatt_attr_handles *, \
|
||||
u8_t) \
|
||||
FN_SIG_S_B(on_nble_gattc_discover_rsp, \
|
||||
const struct nble_gattc_discover_rsp *, \
|
||||
const u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_gap_adv_report_evt, \
|
||||
const struct nble_gap_adv_report_evt *, \
|
||||
const u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_sm_bond_info_rsp, \
|
||||
const struct nble_sm_bond_info_rsp *, \
|
||||
const bt_addr_le_t *, u16_t) \
|
||||
FN_SIG_S_B(on_nble_gattc_read_rsp, \
|
||||
const struct nble_gattc_read_rsp *, \
|
||||
u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_gattc_read_multi_rsp, \
|
||||
const struct nble_gattc_read_rsp *, \
|
||||
u8_t *, u8_t) \
|
||||
FN_SIG_S_B(on_nble_uart_test_evt, \
|
||||
const struct nble_uart_test_evt *, \
|
||||
const u8_t *, u8_t)
|
||||
|
||||
#define LIST_FN_SIG_B_B_P
|
||||
|
||||
#define LIST_FN_SIG_S_P
|
||||
|
||||
#define LIST_FN_SIG_S_B_P
|
||||
|
||||
#define LIST_FN_SIG_S_B_B_P
|
|
@ -1,417 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
#include <bluetooth/conn.h>
|
||||
|
||||
#include "rpc.h"
|
||||
#include "gap_internal.h"
|
||||
#include "gatt_internal.h"
|
||||
|
||||
#include "rpc_functions_to_ble_core.h"
|
||||
|
||||
/* Build the functions exposed */
|
||||
/* Define the functions identifiers per signature */
|
||||
#define FN_SIG_NONE(__fn) fn_index_##__fn,
|
||||
#define FN_SIG_S(__fn, __s) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_P(__fn, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, __type3) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_P(__fn, __s, __type) FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
FN_SIG_NONE(__fn)
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, __length2, \
|
||||
__type3) FN_SIG_NONE(__fn)
|
||||
|
||||
/* Build the list of function indexes -> this should match the array at
|
||||
* deserialization
|
||||
*/
|
||||
enum { LIST_FN_SIG_NONE fn_none_index_max };
|
||||
enum { LIST_FN_SIG_S fn_s_index_max };
|
||||
enum { LIST_FN_SIG_P fn_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B fn_s_b_index_max };
|
||||
enum { LIST_FN_SIG_B_B_P fn_b_b_p_index_max };
|
||||
enum { LIST_FN_SIG_S_P fn_s_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B_P fn_s_b_p_index_max };
|
||||
enum { LIST_FN_SIG_S_B_B_P fn_s_b_b_p_index_max };
|
||||
|
||||
/* Implement the functions using serialization API */
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
#define FN_SIG_NONE(__fn) \
|
||||
void __fn(void) \
|
||||
{ \
|
||||
rpc_serialize_none(fn_index_##__fn); \
|
||||
}
|
||||
|
||||
#define FN_SIG_S(__fn, __s) \
|
||||
void __fn(__s p_s) \
|
||||
{ \
|
||||
rpc_serialize_s(fn_index_##__fn, p_s, sizeof(*p_s)); \
|
||||
}
|
||||
|
||||
#define FN_SIG_P(__fn, __type) \
|
||||
void __fn(__type p_priv) \
|
||||
{ \
|
||||
rpc_serialize_p(fn_index_##__fn, p_priv); \
|
||||
}
|
||||
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
void __fn(__s p_s, __type p_buf, __length length) \
|
||||
{ \
|
||||
rpc_serialize_s_b(fn_index_##__fn, p_s, sizeof(*p_s), \
|
||||
p_buf, length); \
|
||||
}
|
||||
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) \
|
||||
void __fn(__type1 p_buf1, __length1 length1, __type2 p_buf2, \
|
||||
__length2 length2, __type3 p_priv) \
|
||||
{ \
|
||||
rpc_serialize_b_b_p(fn_index_##__fn, p_buf1, length1, \
|
||||
p_buf2, length2, p_priv); \
|
||||
}
|
||||
|
||||
#define FN_SIG_S_P(__fn, __s, __type) \
|
||||
void __fn(__s p_s, __type p_priv) \
|
||||
{ \
|
||||
rpc_serialize_s_p(fn_index_##__fn, p_s, sizeof(*p_s), \
|
||||
p_priv); \
|
||||
}
|
||||
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
void __fn(__s p_s, __type p_buf, __length length, \
|
||||
__type_ptr p_priv) \
|
||||
{ \
|
||||
rpc_serialize_s_b_p(fn_index_##__fn, p_s, sizeof(*p_s), \
|
||||
p_buf, length, p_priv); \
|
||||
}
|
||||
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) \
|
||||
void __fn(__s p_s, __type1 p_buf1, __length1 length1, \
|
||||
__type2 p_buf2, __length2 length2, __type3 p_priv) \
|
||||
{ \
|
||||
rpc_serialize_s_b_b_p(fn_index_##__fn, p_s, \
|
||||
sizeof(*p_s), p_buf1, length1, \
|
||||
p_buf2, length2, p_priv); \
|
||||
}
|
||||
|
||||
|
||||
/* Build the functions */
|
||||
LIST_FN_SIG_NONE
|
||||
LIST_FN_SIG_S
|
||||
LIST_FN_SIG_P
|
||||
LIST_FN_SIG_S_B
|
||||
LIST_FN_SIG_B_B_P
|
||||
LIST_FN_SIG_S_P
|
||||
LIST_FN_SIG_S_B_P
|
||||
LIST_FN_SIG_S_B_B_P
|
||||
|
||||
#undef FN_SIG_NONE
|
||||
#undef FN_SIG_S
|
||||
#undef FN_SIG_P
|
||||
#undef FN_SIG_S_B
|
||||
#undef FN_SIG_B_B_P
|
||||
#undef FN_SIG_S_P
|
||||
#undef FN_SIG_S_B_P
|
||||
#undef FN_SIG_S_B_B_P
|
||||
|
||||
#define DJB2_HASH(__h, __v) ((((__h) << 5) + (__h)) + (__v))
|
||||
|
||||
#define FN_SIG_NONE(__fn) \
|
||||
hash = DJB2_HASH(hash, 1);
|
||||
|
||||
#define FN_SIG_S(__fn, __s) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 2); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_P(__fn, __type) \
|
||||
hash = DJB2_HASH(hash, 3);
|
||||
|
||||
#define FN_SIG_S_B(__fn, __s, __type, __length) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 4); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_B_B_P(__fn, __type1, __length1, __type2, __length2, \
|
||||
__type3) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 5); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_P(__fn, __s, __type) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 6); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_B_P(__fn, __s, __type, __length, __type_ptr) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 7); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
#define FN_SIG_S_B_B_P(__fn, __s, __type1, __length1, __type2, \
|
||||
__length2, __type3) \
|
||||
do { \
|
||||
hash = DJB2_HASH(hash, 8); \
|
||||
hash = DJB2_HASH(hash, sizeof(*((__s)0))); \
|
||||
} while (0);
|
||||
|
||||
u32_t rpc_serialize_hash(void)
|
||||
{
|
||||
u32_t hash = 5381;
|
||||
|
||||
LIST_FN_SIG_NONE;
|
||||
LIST_FN_SIG_S;
|
||||
LIST_FN_SIG_P;
|
||||
LIST_FN_SIG_S_B;
|
||||
LIST_FN_SIG_B_B_P;
|
||||
LIST_FN_SIG_S_P;
|
||||
LIST_FN_SIG_S_B_P;
|
||||
LIST_FN_SIG_S_B_B_P;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
#define SIG_TYPE_SIZE 1
|
||||
#define FN_INDEX_SIZE 1
|
||||
#define POINTER_SIZE 4
|
||||
|
||||
static void _send(struct net_buf *buf)
|
||||
{
|
||||
rpc_transmit_cb(buf);
|
||||
}
|
||||
|
||||
static u16_t encoded_structlen(u8_t structlen)
|
||||
{
|
||||
return 1 + structlen;
|
||||
}
|
||||
|
||||
static void serialize_struct(struct net_buf *buf, const u8_t *struct_data,
|
||||
u8_t struct_length)
|
||||
{
|
||||
net_buf_add_u8(buf, struct_length);
|
||||
net_buf_add_mem(buf, struct_data, struct_length);
|
||||
}
|
||||
|
||||
static u16_t encoded_buflen(const u8_t *buf, u16_t buflen)
|
||||
{
|
||||
if (!buf) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (buflen < (1 << 7)) {
|
||||
return 1 + buflen;
|
||||
} else {
|
||||
return 2 + buflen;
|
||||
}
|
||||
}
|
||||
|
||||
static void serialize_buf(struct net_buf *buf, const u8_t *data,
|
||||
u16_t len)
|
||||
{
|
||||
u16_t varint;
|
||||
u8_t *p;
|
||||
|
||||
if (!data) {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
varint = len;
|
||||
|
||||
p = net_buf_add_u8(buf, (varint & 0x7f));
|
||||
if (varint >= (1 << 7)) {
|
||||
*p |= 0x80;
|
||||
net_buf_add_u8(buf, (varint >> 7));
|
||||
}
|
||||
|
||||
net_buf_add_mem(buf, data, len);
|
||||
}
|
||||
|
||||
static void serialize_p(struct net_buf *buf, void *ptr)
|
||||
{
|
||||
uintptr_t val = (uintptr_t)ptr;
|
||||
|
||||
net_buf_add_mem(buf, &val, sizeof(val));
|
||||
}
|
||||
|
||||
void rpc_serialize_none(u8_t fn_index)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_NONE);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_s(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(struct_length));
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_S);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_struct(buf, struct_data, struct_length);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_p(u8_t fn_index, void *priv)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE + POINTER_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_P);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
serialize_p(buf, priv);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_s_b(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf,
|
||||
u16_t vbuf_length)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(struct_length) +
|
||||
encoded_buflen(vbuf, vbuf_length));
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_S_B);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_struct(buf, struct_data, struct_length);
|
||||
serialize_buf(buf, vbuf, vbuf_length);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_b_b_p(u8_t fn_index, const void *vbuf1,
|
||||
u16_t vbuf1_length, const void *vbuf2,
|
||||
u16_t vbuf2_length, void *priv)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_buflen(vbuf1, vbuf1_length) +
|
||||
encoded_buflen(vbuf2, vbuf2_length) + POINTER_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_B_B_P);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_buf(buf, vbuf1, vbuf1_length);
|
||||
serialize_buf(buf, vbuf2, vbuf2_length);
|
||||
serialize_p(buf, priv);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_s_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, void *priv)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(struct_length) + POINTER_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_S_P);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_struct(buf, struct_data, struct_length);
|
||||
serialize_p(buf, priv);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_s_b_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf,
|
||||
u16_t vbuf_length, void *priv)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(struct_length) +
|
||||
encoded_buflen(vbuf, vbuf_length) + POINTER_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_S_B_P);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_struct(buf, struct_data, struct_length);
|
||||
serialize_buf(buf, vbuf, vbuf_length);
|
||||
serialize_p(buf, priv);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_serialize_s_b_b_p(u8_t fn_index, const void *struct_data,
|
||||
u8_t struct_length, const void *vbuf1,
|
||||
u16_t vbuf1_length, const void *vbuf2,
|
||||
u16_t vbuf2_length, void *priv)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(struct_length) +
|
||||
encoded_buflen(vbuf1, vbuf1_length) +
|
||||
encoded_buflen(vbuf2, vbuf2_length) + POINTER_SIZE);
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_S_B_B_P);
|
||||
net_buf_add_u8(buf, fn_index);
|
||||
|
||||
serialize_struct(buf, struct_data, struct_length);
|
||||
serialize_buf(buf, vbuf1, vbuf1_length);
|
||||
serialize_buf(buf, vbuf2, vbuf2_length);
|
||||
serialize_p(buf, priv);
|
||||
|
||||
_send(buf);
|
||||
}
|
||||
|
||||
void rpc_init(u32_t version)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
struct {
|
||||
u32_t version;
|
||||
u32_t ser_hash;
|
||||
u32_t des_hash;
|
||||
} struct_data;
|
||||
|
||||
struct_data.version = version;
|
||||
struct_data.ser_hash = rpc_serialize_hash();
|
||||
struct_data.des_hash = rpc_deserialize_hash();
|
||||
buf = rpc_alloc_cb(SIG_TYPE_SIZE + FN_INDEX_SIZE +
|
||||
encoded_structlen(sizeof(struct_data)));
|
||||
|
||||
net_buf_add_u8(buf, SIG_TYPE_CONTROL);
|
||||
net_buf_add_u8(buf, 0);
|
||||
serialize_struct(buf, (u8_t *)&struct_data, sizeof(struct_data));
|
||||
_send(buf);
|
||||
}
|
|
@ -1,590 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <atomic.h>
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <device.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/conn.h>
|
||||
|
||||
#include <misc/util.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(NBLE_DEBUG_GAP)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "gap_internal.h"
|
||||
#include "conn_internal.h"
|
||||
#include "conn.h"
|
||||
|
||||
#define BT_SMP_IO_DISPLAY_ONLY 0x00
|
||||
#define BT_SMP_IO_DISPLAY_YESNO 0x01
|
||||
#define BT_SMP_IO_KEYBOARD_ONLY 0x02
|
||||
#define BT_SMP_IO_NO_INPUT_OUTPUT 0x03
|
||||
#define BT_SMP_IO_KEYBOARD_DISPLAY 0x04
|
||||
|
||||
#define BT_SMP_OOB_NOT_PRESENT 0x00
|
||||
#define BT_SMP_OOB_PRESENT 0x01
|
||||
|
||||
#define BT_SMP_MIN_ENC_KEY_SIZE 7
|
||||
#define BT_SMP_MAX_ENC_KEY_SIZE 16
|
||||
|
||||
enum {
|
||||
SMP_FLAG_CFM_DELAYED, /* if confirm should be send when TK is valid */
|
||||
SMP_FLAG_ENC_PENDING, /* if waiting for an encryption change event */
|
||||
SMP_FLAG_KEYS_DISTR, /* if keys distribution phase is in progress */
|
||||
SMP_FLAG_PAIRING, /* if pairing is in progress */
|
||||
SMP_FLAG_TIMEOUT, /* if SMP timeout occurred */
|
||||
SMP_FLAG_SC, /* if LE Secure Connections is used */
|
||||
SMP_FLAG_PKEY_SEND, /* if should send Public Key when available */
|
||||
SMP_FLAG_DHKEY_PENDING, /* if waiting for local DHKey */
|
||||
SMP_FLAG_DHKEY_SEND, /* if should generate and send DHKey Check */
|
||||
SMP_FLAG_USER, /* if waiting for user input */
|
||||
SMP_FLAG_BOND, /* if bonding */
|
||||
SMP_FLAG_SC_DEBUG_KEY, /* if Secure Connection are using debug key */
|
||||
SMP_FLAG_SEC_REQ, /* if Security Request was sent/received */
|
||||
};
|
||||
|
||||
enum pairing_method {
|
||||
JUST_WORKS, /* JustWorks pairing */
|
||||
PASSKEY_INPUT, /* Passkey Entry input */
|
||||
PASSKEY_DISPLAY, /* Passkey Entry display */
|
||||
PASSKEY_CONFIRM, /* Passkey confirm */
|
||||
PASSKEY_ROLE, /* Passkey Entry depends on role */
|
||||
};
|
||||
|
||||
struct bt_smp {
|
||||
/* The channel this context is associated with (nble conn object)*/
|
||||
struct bt_conn *conn;
|
||||
|
||||
/* Flags for SMP state machine */
|
||||
atomic_t flags;
|
||||
|
||||
/* Type of method used for pairing */
|
||||
u8_t method;
|
||||
};
|
||||
|
||||
static struct bt_smp bt_smp_pool[CONFIG_BLUETOOTH_MAX_CONN];
|
||||
|
||||
static struct bt_smp *smp_chan_get(struct bt_conn *conn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_smp_pool); i++) {
|
||||
struct bt_smp *smp = &bt_smp_pool[i];
|
||||
|
||||
if (smp->conn == conn) {
|
||||
return smp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void smp_reset(struct bt_smp *smp)
|
||||
{
|
||||
smp->flags = 0;
|
||||
smp->method = 0;
|
||||
smp->conn = NULL;
|
||||
}
|
||||
|
||||
void bt_smp_connected(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_smp *smp = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_smp_pool); i++) {
|
||||
smp = &bt_smp_pool[i];
|
||||
|
||||
if (!smp->conn) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset flags and states */
|
||||
smp_reset(smp);
|
||||
|
||||
smp->conn = conn;
|
||||
}
|
||||
|
||||
void bt_smp_disconnected(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_smp *smp = smp_chan_get(conn);
|
||||
|
||||
if (smp) {
|
||||
smp_reset(smp);
|
||||
}
|
||||
}
|
||||
|
||||
/* based on table 2.8 Core Spec 2.3.5.1 Vol. 3 Part H */
|
||||
static const u8_t gen_method_legacy[5 /* remote */][5 /* local */] = {
|
||||
{ JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT },
|
||||
{ JUST_WORKS, JUST_WORKS, PASSKEY_INPUT, JUST_WORKS, PASSKEY_INPUT },
|
||||
{ PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS,
|
||||
PASSKEY_DISPLAY },
|
||||
{ JUST_WORKS, JUST_WORKS, JUST_WORKS, JUST_WORKS, JUST_WORKS },
|
||||
{ PASSKEY_DISPLAY, PASSKEY_DISPLAY, PASSKEY_INPUT, JUST_WORKS,
|
||||
PASSKEY_ROLE },
|
||||
};
|
||||
|
||||
static u8_t get_io_capa(void)
|
||||
{
|
||||
if (!nble.auth) {
|
||||
return BT_SMP_IO_NO_INPUT_OUTPUT;
|
||||
}
|
||||
|
||||
/* Passkey Confirmation is valid only for LE SC */
|
||||
if (nble.auth->passkey_display && nble.auth->passkey_entry &&
|
||||
nble.auth->passkey_confirm) {
|
||||
return BT_SMP_IO_KEYBOARD_DISPLAY;
|
||||
}
|
||||
|
||||
/* DisplayYesNo is useful only for LE SC */
|
||||
if (nble.auth->passkey_display &&
|
||||
nble.auth->passkey_confirm) {
|
||||
return BT_SMP_IO_DISPLAY_YESNO;
|
||||
}
|
||||
|
||||
if (nble.auth->passkey_entry) {
|
||||
return BT_SMP_IO_KEYBOARD_ONLY;
|
||||
}
|
||||
|
||||
if (nble.auth->passkey_display) {
|
||||
return BT_SMP_IO_DISPLAY_ONLY;
|
||||
}
|
||||
|
||||
return BT_SMP_IO_NO_INPUT_OUTPUT;
|
||||
}
|
||||
|
||||
static u8_t legacy_get_pair_method(struct bt_smp *smp, u8_t remote_io)
|
||||
{
|
||||
u8_t local_io = get_io_capa();
|
||||
u8_t method;
|
||||
|
||||
if (remote_io > BT_SMP_IO_KEYBOARD_DISPLAY)
|
||||
return JUST_WORKS;
|
||||
|
||||
method = gen_method_legacy[remote_io][local_io];
|
||||
|
||||
/* if both sides have KeyboardDisplay capabilities, initiator displays
|
||||
* and responder inputs
|
||||
*/
|
||||
if (method == PASSKEY_ROLE) {
|
||||
if (smp->conn->role == BT_HCI_ROLE_MASTER) {
|
||||
method = PASSKEY_DISPLAY;
|
||||
} else {
|
||||
method = PASSKEY_INPUT;
|
||||
}
|
||||
}
|
||||
|
||||
BT_DBG("local_io %u remote_io %u method %u", local_io, remote_io,
|
||||
method);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
static u8_t get_auth(u8_t auth)
|
||||
{
|
||||
if (get_io_capa() == BT_SMP_IO_NO_INPUT_OUTPUT) {
|
||||
auth &= ~(BT_SMP_AUTH_MITM);
|
||||
} else {
|
||||
auth |= BT_SMP_AUTH_MITM;
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
static u8_t legacy_pairing_req(struct bt_smp *smp,
|
||||
const struct nble_sec_param *par)
|
||||
{
|
||||
struct nble_sm_pairing_response_req req;
|
||||
|
||||
smp->method = legacy_get_pair_method(smp, par->io_capabilities);
|
||||
|
||||
BT_DBG("method %u io_caps %u", smp->method, par->io_capabilities);
|
||||
|
||||
/* ask for consent if pairing is not due to sending SecReq*/
|
||||
if (smp->method == JUST_WORKS &&
|
||||
!atomic_test_bit(&smp->flags, SMP_FLAG_SEC_REQ) &&
|
||||
nble.auth && nble.auth->pairing_confirm) {
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_USER);
|
||||
nble.auth->pairing_confirm(smp->conn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
req.conn = smp->conn;
|
||||
req.conn_handle = smp->conn->handle;
|
||||
req.params.auth = get_auth(par->auth);
|
||||
req.params.io_capabilities = get_io_capa();
|
||||
req.params.max_key_size = par->max_key_size;
|
||||
req.params.min_key_size = par->min_key_size;
|
||||
req.params.oob_flag = BT_SMP_OOB_NOT_PRESENT;
|
||||
|
||||
nble_sm_pairing_response_req(&req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_sm_pairing_request_evt(const struct nble_sm_pairing_request_evt *evt)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
struct bt_smp *smp;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
conn = bt_conn_lookup_handle(evt->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", evt->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
BT_ERR("No smp");
|
||||
bt_conn_unref(conn);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_PAIRING);
|
||||
|
||||
legacy_pairing_req(smp, &evt->sec_param);
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
static void nble_start_security(struct bt_conn *conn)
|
||||
{
|
||||
struct nble_sm_security_req req = { 0 };
|
||||
|
||||
req.conn = conn,
|
||||
req.conn_handle = conn->handle,
|
||||
req.params.auth = get_auth(BT_SMP_AUTH_BONDING | BT_SMP_AUTH_MITM);
|
||||
req.params.io_capabilities = get_io_capa();
|
||||
req.params.max_key_size = BT_SMP_MAX_ENC_KEY_SIZE;
|
||||
req.params.min_key_size = BT_SMP_MIN_ENC_KEY_SIZE;
|
||||
req.params.oob_flag = BT_SMP_OOB_NOT_PRESENT;
|
||||
|
||||
/**
|
||||
* nble stack generates either a smp security or pairing request
|
||||
* depending on role.
|
||||
*/
|
||||
nble_sm_security_req(&req);
|
||||
}
|
||||
|
||||
int bt_smp_send_pairing_req(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_smp *smp;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* pairing is in progress */
|
||||
if (atomic_test_bit(&smp->flags, SMP_FLAG_PAIRING)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* TODO: Verify sec level reachable */
|
||||
|
||||
nble_start_security(conn);
|
||||
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_PAIRING);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int bt_smp_send_security_req(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_smp *smp;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* pairing is in progress */
|
||||
if (atomic_test_bit(&smp->flags, SMP_FLAG_PAIRING)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* TODO: Verify sec level reachable */
|
||||
|
||||
nble_start_security(conn);
|
||||
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_SEC_REQ);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void on_nble_sm_security_request_evt(const struct nble_sm_security_request_evt *evt)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
struct bt_smp *smp;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
conn = bt_conn_lookup_handle(evt->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", evt->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
BT_ERR("No smp");
|
||||
bt_conn_unref(conn);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p remote_io %u auth %u", conn,
|
||||
evt->sec_param.io_capabilities, evt->sec_param.auth);
|
||||
|
||||
smp->method = legacy_get_pair_method(smp,
|
||||
evt->sec_param.io_capabilities);
|
||||
|
||||
if (smp->method == JUST_WORKS &&
|
||||
nble.auth && nble.auth->pairing_confirm) {
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_USER);
|
||||
nble.auth->pairing_confirm(smp->conn);
|
||||
goto done;
|
||||
}
|
||||
|
||||
bt_smp_send_pairing_req(conn);
|
||||
|
||||
done:
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_SEC_REQ);
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
void on_nble_sm_common_rsp(const struct nble_sm_common_rsp *rsp)
|
||||
{
|
||||
if (rsp->status) {
|
||||
BT_ERR("GAP SM request failed: conn %p err %d", rsp->conn,
|
||||
rsp->status);
|
||||
|
||||
/* TODO: Handle error */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void on_nble_sm_status_evt(const struct nble_sm_status_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
struct bt_smp *smp;
|
||||
|
||||
conn = bt_conn_lookup_handle(ev->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", ev->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
BT_ERR("No smp for conn %p", conn);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p status %d evt_type %d sec_level %d enc_size %u",
|
||||
conn, ev->status, ev->evt_type, ev->enc_link_sec.sec_level,
|
||||
ev->enc_link_sec.enc_size);
|
||||
|
||||
switch (ev->evt_type) {
|
||||
case NBLE_GAP_SM_EVT_BONDING_COMPLETE:
|
||||
BT_DBG("Bonding complete");
|
||||
if (ev->status) {
|
||||
if (nble.auth && nble.auth->cancel) {
|
||||
nble.auth->cancel(conn);
|
||||
}
|
||||
}
|
||||
smp_reset(smp);
|
||||
break;
|
||||
case NBLE_GAP_SM_EVT_LINK_ENCRYPTED:
|
||||
BT_DBG("Link encrypted");
|
||||
break;
|
||||
case NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE:
|
||||
BT_DBG("Security change");
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown event %d", ev->evt_type);
|
||||
break;
|
||||
}
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
void on_nble_sm_passkey_disp_evt(const struct nble_sm_passkey_disp_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
conn = bt_conn_lookup_handle(ev->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", ev->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p passkey %u", conn, ev->passkey);
|
||||
|
||||
/* TODO: Check shall we store io_caps globally */
|
||||
if (get_io_capa() == BT_SMP_IO_DISPLAY_YESNO) {
|
||||
if (nble.auth && nble.auth->passkey_confirm) {
|
||||
nble.auth->passkey_confirm(conn, ev->passkey);
|
||||
}
|
||||
} else {
|
||||
if (nble.auth && nble.auth->passkey_display) {
|
||||
nble.auth->passkey_display(conn, ev->passkey);
|
||||
}
|
||||
}
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
void on_nble_sm_passkey_req_evt(const struct nble_sm_passkey_req_evt *ev)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
struct bt_smp *smp;
|
||||
|
||||
conn = bt_conn_lookup_handle(ev->conn_handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to find conn for handle %u", ev->conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
bt_conn_unref(conn);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("conn %p key_type %u", conn, ev->key_type);
|
||||
|
||||
/* Set user input expected flag */
|
||||
atomic_set_bit(&smp->flags, SMP_FLAG_USER);
|
||||
|
||||
if (ev->key_type == NBLE_GAP_SM_PK_PASSKEY) {
|
||||
if (nble.auth && nble.auth->passkey_entry) {
|
||||
nble.auth->passkey_entry(conn);
|
||||
}
|
||||
}
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
static void nble_security_reply(struct bt_conn *conn,
|
||||
struct nble_sm_passkey *par)
|
||||
{
|
||||
struct nble_sm_passkey_reply_req rsp = {
|
||||
.conn = conn,
|
||||
.conn_handle = conn->handle,
|
||||
};
|
||||
|
||||
memcpy(&rsp.params, par, sizeof(*par));
|
||||
|
||||
nble_sm_passkey_reply_req(&rsp);
|
||||
}
|
||||
|
||||
static int sm_error(struct bt_conn *conn, u8_t reason)
|
||||
{
|
||||
struct nble_sm_passkey params;
|
||||
|
||||
params.type = NBLE_GAP_SM_REJECT;
|
||||
params.reason = reason;
|
||||
|
||||
nble_security_reply(conn, ¶ms);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void legacy_passkey_entry(struct bt_smp *smp, unsigned int passkey)
|
||||
{
|
||||
struct nble_sm_passkey pkey = {
|
||||
.type = NBLE_SM_PK_PASSKEY,
|
||||
.passkey = passkey,
|
||||
};
|
||||
|
||||
BT_DBG("passkey %u", passkey);
|
||||
|
||||
nble_security_reply(smp->conn, &pkey);
|
||||
}
|
||||
|
||||
int bt_smp_auth_cancel(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
return sm_error(conn, BT_SMP_ERR_PASSKEY_ENTRY_FAILED);
|
||||
}
|
||||
|
||||
int bt_smp_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
|
||||
{
|
||||
struct bt_smp *smp;
|
||||
|
||||
BT_DBG("passkey %u", passkey);
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!atomic_test_and_clear_bit(&smp->flags, SMP_FLAG_USER)) {
|
||||
BT_ERR("Not expected user input");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!atomic_test_bit(&smp->flags, SMP_FLAG_SC)) {
|
||||
legacy_passkey_entry(smp, passkey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_smp_auth_pairing_confirm(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_smp *smp;
|
||||
struct nble_sm_pairing_response_req req;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
smp = smp_chan_get(conn);
|
||||
if (!smp) {
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
if (!atomic_test_and_clear_bit(&smp->flags, SMP_FLAG_USER)) {
|
||||
BT_ERR("Not expected user input");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (conn->role == BT_CONN_ROLE_MASTER) {
|
||||
bt_smp_send_pairing_req(conn);
|
||||
} else {
|
||||
req.conn = conn;
|
||||
req.conn_handle = conn->handle;
|
||||
req.params.auth = get_auth(BT_SMP_AUTH_BONDING);
|
||||
req.params.io_capabilities = get_io_capa();
|
||||
req.params.max_key_size = BT_SMP_MAX_ENC_KEY_SIZE;
|
||||
req.params.min_key_size = BT_SMP_MIN_ENC_KEY_SIZE;
|
||||
req.params.oob_flag = BT_SMP_OOB_NOT_PRESENT;
|
||||
|
||||
nble_sm_pairing_response_req(&req);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_smp_init(void)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
nble_get_bda_req(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
void bt_smp_connected(struct bt_conn *conn);
|
||||
void bt_smp_disconnected(struct bt_conn *conn);
|
||||
int bt_smp_init(void);
|
||||
|
||||
int bt_smp_auth_cancel(struct bt_conn *conn);
|
||||
int bt_smp_auth_pairing_confirm(struct bt_conn *conn);
|
||||
int bt_smp_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
|
||||
|
||||
int bt_smp_send_security_req(struct bt_conn *conn);
|
||||
int bt_smp_send_pairing_req(struct bt_conn *conn);
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <atomic.h>
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include "common/log.h"
|
||||
|
||||
#include "gap_internal.h"
|
||||
#include "gatt_internal.h"
|
||||
|
||||
#include "rpc_functions_to_quark.h"
|
||||
|
||||
#ifndef __weak
|
||||
#define __weak __attribute__((weak))
|
||||
#endif
|
||||
|
||||
#define FN_SIG_NONE(n) \
|
||||
__weak void n(void) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_NONE
|
||||
|
||||
#define FN_SIG_S(n, s) \
|
||||
__weak void n(s _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_S
|
||||
|
||||
#define FN_SIG_P(n, p) \
|
||||
__weak void n(p _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_P
|
||||
|
||||
#define FN_SIG_S_B(n, s, b, l) \
|
||||
__weak void n(s _p, b _b, l _l) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_S_B
|
||||
|
||||
#define FN_SIG_B_B_P(n, b1, l1, b2, l2, p) \
|
||||
__weak void n(b1 _b1, l1 _l1, b2 _b2, l2 _l2, p _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_B_B_P
|
||||
|
||||
#define FN_SIG_S_P(n, s, p) \
|
||||
__weak void n(s _s, p _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_S_P
|
||||
|
||||
#define FN_SIG_S_B_P(n, s, b, l, p) \
|
||||
__weak void n(s _s, b _b, l _l, p _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_S_B_P
|
||||
|
||||
#define FN_SIG_S_B_B_P(n, s, b1, l1, b2, l2, p) \
|
||||
__weak void n(s _s, b1 _b1, l1 _l1, b2 _b2, l2 _l2, p _p) \
|
||||
{ \
|
||||
BT_WARN("Not implemented"); \
|
||||
}
|
||||
LIST_FN_SIG_S_B_B_P
|
|
@ -1,244 +0,0 @@
|
|||
/* uart.c - Nordic BLE UART based Bluetooth driver */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <sections.h>
|
||||
|
||||
#include <board.h>
|
||||
#include <init.h>
|
||||
#include <uart.h>
|
||||
#include <string.h>
|
||||
#include <gpio.h>
|
||||
|
||||
#include <net/buf.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "../util.h"
|
||||
#include "rpc.h"
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
|
||||
#include "../nrf51_pm.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @note this structure must be self-aligned and self-packed
|
||||
*/
|
||||
struct ipc_uart_header {
|
||||
u16_t len; /**< Length of IPC message. */
|
||||
u8_t channel; /**< Channel number of IPC message. */
|
||||
u8_t src_cpu_id; /**< CPU id of IPC sender. */
|
||||
} __packed;
|
||||
|
||||
/* TODO: check size */
|
||||
#define NBLE_TX_BUF_COUNT 2
|
||||
#define NBLE_RX_BUF_COUNT 10
|
||||
#define NBLE_BUF_SIZE 384
|
||||
|
||||
NET_BUF_POOL_DEFINE(rx_pool, NBLE_RX_BUF_COUNT, NBLE_BUF_SIZE, 0, NULL);
|
||||
NET_BUF_POOL_DEFINE(tx_pool, NBLE_TX_BUF_COUNT, NBLE_BUF_SIZE, 0, NULL);
|
||||
|
||||
static BT_STACK_NOINIT(rx_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
|
||||
static struct k_thread rx_thread_data;
|
||||
|
||||
static struct device *nble_dev;
|
||||
|
||||
static K_FIFO_DEFINE(rx_queue);
|
||||
|
||||
static void rx_thread(void)
|
||||
{
|
||||
BT_DBG("Started");
|
||||
|
||||
while (true) {
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
BT_DBG("Got buf %p", buf);
|
||||
|
||||
rpc_deserialize(buf);
|
||||
|
||||
net_buf_unref(buf);
|
||||
|
||||
/* Make sure we don't hog the CPU if the rx_queue never
|
||||
* gets empty.
|
||||
*/
|
||||
k_yield();
|
||||
}
|
||||
}
|
||||
|
||||
struct net_buf *rpc_alloc_cb(u16_t length)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("length %u", length);
|
||||
|
||||
buf = net_buf_alloc(&tx_pool, K_FOREVER);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to get tx buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
net_buf_reserve(buf, sizeof(struct ipc_uart_header));
|
||||
|
||||
if (length > net_buf_tailroom(buf)) {
|
||||
BT_ERR("Too big tx buffer requested");
|
||||
net_buf_unref(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void rpc_transmit_cb(struct net_buf *buf)
|
||||
{
|
||||
struct ipc_uart_header *hdr;
|
||||
|
||||
BT_DBG("buf %p length %u", buf, buf->len);
|
||||
|
||||
hdr = net_buf_push(buf, sizeof(*hdr));
|
||||
hdr->len = buf->len - sizeof(*hdr);
|
||||
hdr->channel = 0;
|
||||
hdr->src_cpu_id = 0;
|
||||
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
|
||||
/* Wake-up nble */
|
||||
nrf51_wakeup();
|
||||
#endif
|
||||
while (buf->len) {
|
||||
uart_poll_out(nble_dev, net_buf_pull_u8(buf));
|
||||
}
|
||||
|
||||
net_buf_unref(buf);
|
||||
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
|
||||
/* TODO check if FIFO is empty */
|
||||
/* Allow nble to go to deep sleep */
|
||||
nrf51_allow_sleep();
|
||||
#endif
|
||||
}
|
||||
|
||||
static size_t nble_discard(struct device *uart, size_t len)
|
||||
{
|
||||
/* FIXME: correct size for nble */
|
||||
u8_t buf[33];
|
||||
|
||||
return uart_fifo_read(uart, buf, min(len, sizeof(buf)));
|
||||
}
|
||||
|
||||
static void bt_uart_isr(struct device *unused)
|
||||
{
|
||||
static struct net_buf *buf;
|
||||
|
||||
ARG_UNUSED(unused);
|
||||
|
||||
while (uart_irq_update(nble_dev) && uart_irq_is_pending(nble_dev)) {
|
||||
static struct ipc_uart_header hdr;
|
||||
static u8_t hdr_bytes;
|
||||
int read;
|
||||
|
||||
if (!uart_irq_rx_ready(nble_dev)) {
|
||||
if (uart_irq_tx_ready(nble_dev)) {
|
||||
BT_DBG("transmit ready");
|
||||
/*
|
||||
* Implementing ISR based transmit requires
|
||||
* extra API for uart such as
|
||||
* uart_line_status(), etc. The support was
|
||||
* removed from the recent code, using polling
|
||||
* for transmit for now.
|
||||
*/
|
||||
} else {
|
||||
BT_DBG("spurious interrupt");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hdr_bytes < sizeof(hdr)) {
|
||||
/* Get packet type */
|
||||
hdr_bytes += uart_fifo_read(nble_dev,
|
||||
(u8_t *)&hdr + hdr_bytes,
|
||||
sizeof(hdr) - hdr_bytes);
|
||||
if (hdr_bytes < sizeof(hdr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hdr.len > NBLE_BUF_SIZE) {
|
||||
BT_ERR("Too much data to fit buffer");
|
||||
buf = NULL;
|
||||
} else {
|
||||
buf = net_buf_alloc(&rx_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("No available IPC buffers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!buf) {
|
||||
hdr.len -= nble_discard(nble_dev, hdr.len);
|
||||
if (!hdr.len) {
|
||||
hdr_bytes = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
read = uart_fifo_read(nble_dev, net_buf_tail(buf), hdr.len);
|
||||
|
||||
buf->len += read;
|
||||
hdr.len -= read;
|
||||
|
||||
if (!hdr.len) {
|
||||
BT_DBG("full packet received");
|
||||
hdr_bytes = 0;
|
||||
/* Pass buffer to the stack */
|
||||
net_buf_put(&rx_queue, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nble_open(void)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
/* Initialize receive queue and start rx_thread */
|
||||
k_thread_create(&rx_thread_data, rx_thread_stack,
|
||||
sizeof(rx_thread_stack), (k_thread_entry_t)rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
uart_irq_rx_disable(nble_dev);
|
||||
uart_irq_tx_disable(nble_dev);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
|
||||
if (nrf51_init(nble_dev) < 0) {
|
||||
return -EIO;
|
||||
}
|
||||
#else
|
||||
bt_uart_drain(nble_dev);
|
||||
#endif
|
||||
|
||||
uart_irq_callback_set(nble_dev, bt_uart_isr);
|
||||
|
||||
uart_irq_rx_enable(nble_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _bt_nble_init(struct device *unused)
|
||||
{
|
||||
ARG_UNUSED(unused);
|
||||
|
||||
nble_dev = device_get_binding(CONFIG_NBLE_UART_ON_DEV_NAME);
|
||||
if (!nble_dev) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEVICE_INIT(bt_nble, "", _bt_nble_init, NULL, NULL, POST_KERNEL,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
|
@ -1,131 +0,0 @@
|
|||
/* uart.h - Nordic BLE UART based Bluetooth driver */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* IPC Uart power management driver.
|
||||
*/
|
||||
extern struct driver ipc_uart_ns16550_driver;
|
||||
|
||||
int nble_open(void);
|
||||
|
||||
/**
|
||||
* This function triggers the sending of PDU buffer over UART.
|
||||
*
|
||||
* This constructs an IPC message header and triggers the sending of it and
|
||||
* message buffer. If a transmission is already ongoing, it will fail.
|
||||
* In this case upper layer needs to queue the message buffer.
|
||||
*
|
||||
* @param dev structure of the opened device
|
||||
* @param handle structure of opened IPC uart channel
|
||||
* @param len length of message to send
|
||||
* @param p_data message buffer to send
|
||||
*
|
||||
* @return IPC_UART_ERROR_OK TX has been initiated, IPC_UART_TX_BUSY a
|
||||
* transmission is already going, message needs to be queued
|
||||
*
|
||||
* @note This function needs to be executed with (UART) irq off to avoid
|
||||
* preemption from uart_ipc_isr causing state variable corruption.
|
||||
* It also called from uart_ipc_isr() to send the next IPC message.
|
||||
*/
|
||||
int ipc_uart_ns16550_send_pdu(struct device *dev, void *handle, int len,
|
||||
void *p_data);
|
||||
|
||||
/**
|
||||
* This function registers a callback function being called on TX start/end.
|
||||
*
|
||||
* This constructs an IPC message header and triggers the sending of it and
|
||||
* message buffer. If a transmission is already ongoing, it will fail. In
|
||||
* this case upper layer needs to queue the message buffer.
|
||||
*
|
||||
* @param dev structure of the opened device
|
||||
* @param cb callback function for OOB sleep mode handling called at tx start
|
||||
* and end
|
||||
* @param param parameter passed to cb when being called
|
||||
*/
|
||||
void ipc_uart_ns16550_set_tx_cb(struct device *dev, void (*cb)(bool, void*),
|
||||
void *param);
|
||||
|
||||
/**
|
||||
* Opens a UART channel for QRK/BLE Core IPC, and defines the callback function
|
||||
* for receiving IPC messages.
|
||||
*
|
||||
* @param channel IPC channel ID to use
|
||||
* @param cb Callback to handle messages
|
||||
*
|
||||
* @return
|
||||
* - Pointer to channel structure if success,
|
||||
* - NULL if opening fails.
|
||||
*/
|
||||
void *ipc_uart_channel_open(int channel, int (*cb)(int chan, int request,
|
||||
int len, void *data));
|
||||
|
||||
/**
|
||||
* The frame is a message.
|
||||
*/
|
||||
#define IPC_MSG_TYPE_MESSAGE 0x1
|
||||
|
||||
/**
|
||||
* Requests to free a message.
|
||||
*/
|
||||
#define IPC_MSG_TYPE_FREE 0x2
|
||||
|
||||
/**
|
||||
* Sets the MessageBox as synchronized.
|
||||
*/
|
||||
#define IPC_MSG_TYPE_SYNC 0x3
|
||||
|
||||
/**
|
||||
* Allocates a port.
|
||||
*
|
||||
* This request is always flowing from a slave to the master.
|
||||
*/
|
||||
#define IPC_REQUEST_ALLOC_PORT 0x10
|
||||
|
||||
/**
|
||||
* Registers a service.
|
||||
*
|
||||
* This request is always flowing from a slave to the master.
|
||||
*/
|
||||
#define IPC_REQUEST_REGISTER_SERVICE 0x11
|
||||
|
||||
/**
|
||||
* Unregisters a service.
|
||||
*/
|
||||
#define IPC_REQUEST_DEREGISTER_SERVICE 0x12
|
||||
|
||||
/**
|
||||
* The message is for test commands engine.
|
||||
*/
|
||||
#define IPC_REQUEST_REG_TCMD_ENGINE 0x13
|
||||
|
||||
/**
|
||||
* Registers a Service Manager Proxy to the Service Manager.
|
||||
*
|
||||
* This request always flow from a slave to the master.
|
||||
*/
|
||||
#define IPC_REQUEST_REGISTER_PROXY 0x14
|
||||
|
||||
/**
|
||||
* Notifies a panic (for log dump).
|
||||
*/
|
||||
#define IPC_PANIC_NOTIFICATION 0x15
|
||||
|
||||
/**
|
||||
* The message is for power management.
|
||||
*/
|
||||
#define IPC_REQUEST_POWER_MANAGEMENT 0x16
|
||||
|
||||
/**
|
||||
* Sends the log of a slave to the master (for log aggregation).
|
||||
*/
|
||||
#define IPC_REQUEST_LOGGER 0x17
|
||||
|
||||
/**
|
||||
* The message is for power management (deep sleep).
|
||||
*/
|
||||
#define IPC_REQUEST_INFRA_PM 0x18
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="Test beacon"
|
|
@ -2,10 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Eddystone"
|
|
@ -358,7 +358,6 @@ static ssize_t read_unlock(struct bt_conn *conn,
|
|||
return BT_GATT_ERR(BT_ATT_ERR_READ_NOT_PERMITTED);
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_NBLE)
|
||||
/* returns a 128-bit challenge token. This token is for one-time use
|
||||
* and cannot be replayed.
|
||||
*/
|
||||
|
@ -368,9 +367,6 @@ static ssize_t read_unlock(struct bt_conn *conn,
|
|||
|
||||
return bt_gatt_attr_read(conn, attr, buf, len, offset, slot->challenge,
|
||||
sizeof(slot->challenge));
|
||||
#else
|
||||
return BT_GATT_ERR(BT_ATT_ERR_NOT_SUPPORTED);
|
||||
#endif /* CONFIG_NBLE */
|
||||
}
|
||||
|
||||
static ssize_t write_unlock(struct bt_conn *conn,
|
||||
|
|
|
@ -2,10 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=2
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="Test peripheral"
|
|
@ -2,11 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
filter = CONFIG_SOC_QUARK_SE_C1000
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
CONFIG_RANDOM_GENERATOR=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_STDOUT=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="CSC peripheral"
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="ESP peripheral"
|
|
@ -2,11 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
filter = CONFIG_SOC_QUARK_SE_C1000
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="Test HoG mouse"
|
|
@ -2,10 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="Zephyr Heartrate Sensor"
|
|
@ -2,11 +2,3 @@
|
|||
tags = bluetooth
|
||||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86 frdm_k64f hexiwear_k64
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
arch_whitelist = x86
|
||||
filter = CONFIG_SOC_QUARK_SE_C1000
|
||||
platform_whitelist = arduino_101
|
||||
|
|
|
@ -171,7 +171,6 @@ tests/legacy/kernel/test_stack/nanokernel/test,x86,qemu_x86_iamcu,True,,,True,1.
|
|||
tests/crypto/test_mbedtls/test,x86,quark_se_c1000_devboard,True,,,False,,23360,79568
|
||||
tests/ztest/test/base/test_verbose_1,x86,quark_d2000_crb,True,,CONF_FILE=prj_verbose_1.conf,False,,2540,8461
|
||||
tests/legacy/kernel/test_mem_safe/test,x86,qemu_x86,True,,,True,0.2202446460723877,18887,15079
|
||||
samples/bluetooth/peripheral/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,13872,36645
|
||||
tests/drivers/build_all/test_build_ethernet,arm,nrf51_blenano,True,,CONF_FILE=ethernet.conf,False,,9896,50904
|
||||
samples/legacy/synchronization/microkernel/test,arm,nucleo_f401re,True,,,False,,6212,12474
|
||||
tests/legacy/kernel/test_stackprot/nanokernel/test,arm,nrf52_pca10040,True,,,False,,9628,55724
|
||||
|
@ -250,7 +249,6 @@ tests/legacy/benchmark/footprint/microkernel/footprint-min,arc,arduino_101_sss,T
|
|||
tests/legacy/kernel/test_map_priv/test,arm,arduino_101_ble,True,,,False,,14424,45558
|
||||
samples/bluetooth/eddystone/test,x86,qemu_x86,True,,,True,,60323,50403
|
||||
tests/legacy/kernel/test_context/test,arm,qemu_cortex_m3,True,,,True,6.080919981002808,7464,13334
|
||||
tests/bluetooth/shell/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,16420,50000
|
||||
tests/legacy/kernel/test_sema_priv/test,x86,arduino_101,True,,,False,,14948,15475
|
||||
tests/legacy/benchmark/footprint/nanokernel/footprint-reg,nios2,qemu_nios2,True,,TEST=reg,True,,4972,16916
|
||||
tests/legacy/kernel/test_mutex/test,x86,quark_d2000_crb,True,,,False,,6028,11062
|
||||
|
@ -372,7 +370,6 @@ tests/crypto/test_ctr_prng/test,arc,em_starterkit,True,,,False,,26768,20804
|
|||
tests/legacy/benchmark/footprint/nanokernel/footprint-reg,arm,v2m_beetle,True,,TEST=reg,False,,2352,9726
|
||||
tests/ztest/test/base/test_verbose_0,x86,arduino_101,True,,CONF_FILE=prj_verbose_0.conf,False,,4876,10597
|
||||
samples/net/echo_server/test_bt,x86,minnowboard,True,,"CONF_FILE=""prj_bt.conf""",False,,140574,119582
|
||||
samples/bluetooth/peripheral_hids/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,13072,34885
|
||||
samples/legacy/synchronization/nanokernel/test,arm,cc3200_launchxl,True,,,False,,18852,13172
|
||||
samples/legacy/philosophers/microkernel/test,arm,nucleo_f103rb,True,,,False,,11604,12138
|
||||
tests/kernel/test_build/test_newlib,x86,galileo,True,,CONF_FILE=newlib.conf,False,,43851,35155
|
||||
|
@ -381,7 +378,6 @@ tests/legacy/kernel/test_task_priv/test,arm,96b_carbon,True,,,False,,8308,15232
|
|||
samples/hello_world/test,arm,quark_se_c1000_ble,True,,,False,,8120,44590
|
||||
samples/drivers/gpio/test,arc,arduino_101_sss,True,,,False,,4988,13024
|
||||
tests/legacy/kernel/test_sema_priv/test,arm,stm32_mini_a15,True,,,False,,15044,16134
|
||||
samples/bluetooth/peripheral_hr/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,12948,35027
|
||||
tests/legacy/kernel/test_fifo_priv/test,arm,hexiwear_k64,True,,,False,,8216,16250
|
||||
tests/legacy/benchmark/latency_measure/test,arm,v2m_beetle,True,,,False,,10460,19822
|
||||
tests/kernel/test_common/test,arm,cc3200_launchxl,True,,,False,,28954,22202
|
||||
|
@ -913,7 +909,6 @@ tests/net/zoap/test,arm,nrf52_pca10040,True,,,False,,10856,54910
|
|||
tests/legacy/kernel/test_pipe/test,arc,quark_se_c1000_ss_devboard,True,,,False,,13600,21916
|
||||
tests/legacy/kernel/test_errno/test,x86,galileo,True,,,False,,37666,30474
|
||||
tests/kernel/test_build/test_newlib,x86,quark_se_c1000_devboard,True,,CONF_FILE=newlib.conf,False,,5944,12075
|
||||
samples/bluetooth/beacon/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,11824,27833
|
||||
tests/legacy/kernel/test_task_priv/test,arm,nucleo_f401re,True,,,False,,8288,15196
|
||||
tests/bluetooth/init/test_17,arm,qemu_cortex_m3,True,,CONF_FILE=prj_17.conf,True,,18580,110066
|
||||
tests/legacy/kernel/test_task/test,arm,nucleo_f401re,True,,,False,,8288,15196
|
||||
|
@ -1082,7 +1077,6 @@ tests/kernel/test_multilib/test,arm,frdm_k64f,True,,,False,,3936,13742
|
|||
tests/legacy/kernel/test_early_sleep/test,arm,arduino_due,True,,,False,,6488,10898
|
||||
tests/kernel/test_sprintf/test,x86,minnowboard,True,,,False,,26251,22571
|
||||
tests/legacy/kernel/test_nano_work/test,arm,nrf51_pca10028,True,,,False,,10508,49432
|
||||
samples/environmental_sensing/x86/test-nble,x86,quark_se_c1000_devboard,True,,"CONF_FILE=""prj_nble.conf""",False,,12384,29742
|
||||
tests/kernel/test_build/test_newlib,arc,arduino_101_sss,True,,CONF_FILE=newlib.conf,False,,6968,13512
|
||||
samples/legacy/philosophers/microkernel/test,arc,arduino_101_sss,True,,,False,,12464,11940
|
||||
tests/bluetooth/init/test_19,arm,qemu_cortex_m3,True,,CONF_FILE=prj_19.conf,True,,14436,57250
|
||||
|
@ -1226,7 +1220,6 @@ samples/logger-hook/test,x86,arduino_101,True,,,False,,6072,14740
|
|||
tests/legacy/kernel/test_stack/nanokernel/test,arm,stm32_mini_a15,True,,,False,,10272,15336
|
||||
tests/legacy/kernel/test_tickless/microkernel/test,arm,frdm_k64f,True,,,False,,8128,12878
|
||||
tests/crypto/test_mbedtls/test,arm,96b_nitrogen,True,,,False,,28104,104506
|
||||
samples/bluetooth/peripheral_esp/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,13392,36305
|
||||
tests/legacy/kernel/test_libs/test,arm,nrf51_pca10028,True,,,False,,12400,48798
|
||||
tests/legacy/kernel/test_map/test,arc,em_starterkit,True,,,False,,26096,15204
|
||||
tests/kernel/test_build/test_runtime_nmi,arm,frdm_k64f,True,,CONF_FILE=runtime_nmi.conf,False,,6060,12386
|
||||
|
@ -1273,7 +1266,6 @@ tests/legacy/kernel/test_timer/nanokernel/test,arm,96b_carbon,True,,,False,,8324
|
|||
tests/legacy/kernel/test_pool/test,x86,minnowboard,True,,,False,,33378,17122
|
||||
tests/legacy/kernel/test_irq_offload/test,nios2,altera_max10,True,,,False,,4436,13516
|
||||
samples/synchronization/test,arm,frdm_k64f,True,,,False,,6060,12182
|
||||
samples/bluetooth/eddystone/test_nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,13144,31197
|
||||
tests/kernel/test_common/test,arm,v2m_beetle,True,,,False,,7044,19586
|
||||
samples/legacy/synchronization/nanokernel/test,arm,nrf51_pca10028,True,,,False,,10168,46944
|
||||
samples/legacy/task_profiler/nanokernel/test,x86,qemu_x86,True,,,True,,28932,20252
|
||||
|
@ -1404,7 +1396,6 @@ tests/drivers/build_all/test_build_sensor_triggers,arm,stm32_mini_a15,True,,CONF
|
|||
samples/basic/button/test,arm,nucleo_f103rb,True,,,False,,3992,10690
|
||||
tests/legacy/kernel/test_events/test,x86,arduino_101,True,,,False,,10240,13957
|
||||
samples/bluetooth/peripheral_sc_only/test,arm,qemu_cortex_m3,True,,,True,,12204,45206
|
||||
tests/bluetooth/shell/test_nble,x86,quark_se_c1000_devboard,True,,"CONF_FILE=""prj_nble.conf""",False,,16420,49891
|
||||
tests/drivers/build_all/test_build_ethernet,arm,nrf52_pca10040,True,,CONF_FILE=ethernet.conf,False,,10348,48906
|
||||
tests/legacy/kernel/test_sema/microkernel/test,arm,nrf51_pca10028,True,,,False,,12872,51110
|
||||
tests/crypto/test_ctr_prng/test,arc,arduino_101_sss,True,,,False,,6380,19840
|
||||
|
@ -1848,7 +1839,6 @@ tests/legacy/benchmark/footprint/nanokernel/footprint-min,arm,nrf51_blenano,True
|
|||
tests/legacy/benchmark/footprint/nanokernel/footprint-max,arc,quark_se_c1000_ss_devboard,True,,TEST=max,False,,5908,13852
|
||||
tests/legacy/kernel/test_critical/test,x86,qemu_x86_iamcu,True,,,True,15.53974986076355,18415,11667
|
||||
tests/legacy/kernel/test_mutex/test,arm,96b_carbon,True,,,False,,8616,15012
|
||||
tests/bluetooth/tester/test_nble,x86,arduino_101,True,,"CONF_FILE=""nble.conf""",False,,22244,40821
|
||||
samples/logger-hook/test,arm,96b_carbon,True,,,False,,6260,15560
|
||||
tests/legacy/kernel/test_arm_irq_vector_table/test,arm,hexiwear_k64,True,,,False,,3980,11422
|
||||
tests/kernel/test_bitfield/test,nios2,qemu_nios2,True,,,True,0.0020706653594970703,4404,15792
|
||||
|
@ -2372,7 +2362,6 @@ tests/drivers/build_all/test_build_sensors_a_m,x86,qemu_x86_iamcu,True,,CONF_FIL
|
|||
tests/kernel/test_multilib/test,arm,arduino_101_ble,True,,,False,,8120,44626
|
||||
tests/legacy/kernel/test_critical/test,arm,stm32_mini_a15,True,,,False,,7156,12846
|
||||
tests/crypto/test_aes/test,arm,quark_se_c1000_ble,True,,,False,,12216,56118
|
||||
samples/environmental_sensing/x86/test-nble,x86,arduino_101,True,,"CONF_FILE=""prj_nble.conf""",False,,12384,29851
|
||||
tests/legacy/kernel/test_mail_priv/test,arm,nucleo_f103rb,True,,,False,,11684,21386
|
||||
tests/kernel/test_build/test_newlib,arm,96b_carbon,True,,CONF_FILE=newlib.conf,False,,6196,15140
|
||||
tests/legacy/kernel/test_obj_tracing/microkernel/test,x86,minnowboard,True,,,False,,24252,12344
|
||||
|
|
|
|
@ -1,9 +0,0 @@
|
|||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_CONSOLE_HANDLER=y
|
||||
CONFIG_CONSOLE_SHELL=y
|
||||
CONFIG_BLUETOOTH_DEBUG_LOG=y
|
||||
CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=2
|
||||
CONFIG_BLUETOOTH_DEVICE_NAME="test shell"
|
|
@ -3,12 +3,6 @@ tags = bluetooth
|
|||
build_only = true
|
||||
platform_whitelist = qemu_cortex_m3 qemu_x86 arduino_101
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_nble.conf"
|
||||
filter = CONFIG_SOC_QUARK_SE_C1000
|
||||
|
||||
[test_br]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
CONFIG_UART_PIPE=y
|
||||
CONFIG_CONSOLE_HANDLER=y
|
||||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_CUSTOM=y
|
||||
CONFIG_NBLE=y
|
||||
CONFIG_UART_CONSOLE=n
|
||||
CONFIG_BLUETOOTH_ATT_PREPARE_COUNT=4
|
|
@ -3,11 +3,3 @@ tags = bluetooth
|
|||
build_only = true
|
||||
# FIXME: minnowboard using IRQ3 for both UART console and h4
|
||||
platform_whitelist = minnowboard
|
||||
|
||||
[test_nble]
|
||||
tags = bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="nble.conf"
|
||||
arch_whitelist = x86
|
||||
filter = CONFIG_SOC_QUARK_SE_C1000
|
||||
platform_whitelist = arduino_101
|
||||
|
|
Loading…
Reference in a new issue