From fd975d27fbd0c63697f2ffa02cc8cb788bba5d14 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 11 Jan 2016 14:27:50 +0200 Subject: [PATCH] drivers/nble: Introduce basic skeleton Introduce the basic skeleton for NBLE, which is the Bluetooth LE API implementation targeting a custom firmware running on Nordic Semiconductor nRF51 chips. Change-Id: I1ce69d6ee0205e71f6bd8d256d9233c93d2cde41 Signed-off-by: Johan Hedberg --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/nble/Kconfig | 50 ++++++++++++++ drivers/nble/Makefile | 1 + drivers/nble/conn.c | 69 +++++++++++++++++++ drivers/nble/gap.c | 68 +++++++++++++++++++ drivers/nble/gatt.c | 149 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 340 insertions(+) create mode 100644 drivers/nble/Kconfig create mode 100644 drivers/nble/Makefile create mode 100644 drivers/nble/conn.c create mode 100644 drivers/nble/gap.c create mode 100644 drivers/nble/gatt.c diff --git a/drivers/Kconfig b/drivers/Kconfig index d051a9378ff..dc663bb005e 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -63,4 +63,6 @@ source "drivers/aio/Kconfig" source "drivers/qmsi/Kconfig" +source "drivers/nble/Kconfig" + endmenu diff --git a/drivers/Makefile b/drivers/Makefile index 57d05ed0f63..bac51bcaa04 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -19,4 +19,5 @@ obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_RTC) += rtc/ obj-$(CONFIG_CLOCK_CONTROL) += clock_control/ obj-$(CONFIG_IPM) += ipm/ +obj-$(CONFIG_NBLE) += nble/ obj-y += aio/ diff --git a/drivers/nble/Kconfig b/drivers/nble/Kconfig new file mode 100644 index 00000000000..8fcbcec275e --- /dev/null +++ b/drivers/nble/Kconfig @@ -0,0 +1,50 @@ +# Kconfig - NBLE configuration options + +# +# Copyright (c) 2016 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# These BLUETOOTH_* dependencies are redefined here since we can't use +# net/bluetooth/KConfig (which depend on CONFIG_BLUETOOTH) +# +config BLUETOOTH_PERIPHERAL + bool + default n + +config BLUETOOTH_CENTRAL + bool + default n + +config BLUETOOTH_GATT_CLIENT + bool + default n + +config BLUETOOTH_SMP + bool + default n + +config NBLE + bool "Support for custom Nordic Semiconductor BLE protocol" + default n + depends on !BLUETOOTH + select BLUETOOTH_PERIPHERAL + select BLUETOOTH_CENTRAL + select BLUETOOTH_GATT_CLIENT + select BLUETOOTH_SMP + help + Enables support for using Nordic Semicondutor nRF51 Bluetooth + LE chips with a custom firmware. The API for this is a subset of + the normal Bluetooth API (include/bluetooth/*.h). This driver can + only be enabled if CONFIG_BLUETOOTH has not been enabled. diff --git a/drivers/nble/Makefile b/drivers/nble/Makefile new file mode 100644 index 00000000000..b1aa0e35a3a --- /dev/null +++ b/drivers/nble/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_NBLE) += gap.o conn.o gatt.o diff --git a/drivers/nble/conn.c b/drivers/nble/conn.c new file mode 100644 index 00000000000..2ffe6c6e0c1 --- /dev/null +++ b/drivers/nble/conn.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +struct bt_conn *bt_conn_ref(struct bt_conn *conn) +{ + return NULL; +} + +void bt_conn_unref(struct bt_conn *conn) +{ +} + +struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer) +{ + return NULL; +} + +const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn) +{ + return NULL; +} + +int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info) +{ + return -ENOSYS; +} + +int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason) +{ + return -ENOSYS; +} + +struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer, + const struct bt_le_conn_param *param) +{ + return NULL; +} + +int bt_conn_security(struct bt_conn *conn, bt_security_t sec) +{ + return -ENOSYS; +} + +uint8_t bt_conn_enc_key_size(struct bt_conn *conn) +{ + return 0; +} + +void bt_conn_cb_register(struct bt_conn_cb *cb) +{ +} diff --git a/drivers/nble/gap.c b/drivers/nble/gap.c new file mode 100644 index 00000000000..356ab8c359a --- /dev/null +++ b/drivers/nble/gap.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +int bt_enable(bt_ready_cb_t cb) +{ + return -ENOSYS; +} + +int bt_le_adv_start(const struct bt_le_adv_param *param, + const struct bt_eir *ad, const struct bt_eir *sd) +{ + return -ENOSYS; +} + +int bt_le_adv_stop(void) +{ + return -ENOSYS; +} + +int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb) +{ + return -ENOSYS; +} + +int bt_le_scan_stop(void) +{ + return -ENOSYS; +} + +int bt_le_set_auto_conn(bt_addr_le_t *addr, + const struct bt_le_conn_param *param) +{ + return -ENOSYS; +} + +int bt_auth_cb_register(const struct bt_auth_cb *cb) +{ + return -ENOSYS; +} + +void bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) +{ +} + +void bt_auth_cancel(struct bt_conn *conn) +{ +} + +void bt_auth_passkey_confirm(struct bt_conn *conn, bool match) +{ +} diff --git a/drivers/nble/gatt.c b/drivers/nble/gatt.c new file mode 100644 index 00000000000..d6830404b0c --- /dev/null +++ b/drivers/nble/gatt.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count) +{ + return -ENOSYS; +} + +void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle, + bt_gatt_attr_func_t func, void *user_data) +{ +} + +int bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_service(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_included(struct bt_conn *conn, + const struct bt_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_chrc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_write_ccc(struct bt_conn *conn, + const struct bt_gatt_attr *attr, const void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_cep(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_cud(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_attr_read_cpf(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + uint16_t len, uint16_t offset) +{ + return -ENOSYS; +} + +int bt_gatt_notify(struct bt_conn *conn, uint16_t handle, const void *data, + uint16_t len) +{ + return -ENOSYS; +} + +int bt_gatt_exchange_mtu(struct bt_conn *conn, bt_gatt_rsp_func_t func) +{ + return -ENOSYS; +} + +int bt_gatt_discover(struct bt_conn *conn, + struct bt_gatt_discover_params *params) +{ + return -ENOSYS; +} + +int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params) +{ + return -ENOSYS; +} + +int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset, + const void *data, uint16_t length, bt_gatt_rsp_func_t func) +{ + return -ENOSYS; +} + +int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle, + const void *data, uint16_t length, + bool sign) +{ + return -ENOSYS; +} + +int bt_gatt_subscribe(struct bt_conn *conn, + struct bt_gatt_subscribe_params *params) +{ + return -ENOSYS; +} + +int bt_gatt_unsubscribe(struct bt_conn *conn, + struct bt_gatt_subscribe_params *params) +{ + return -ENOSYS; +} + +void bt_gatt_cancel(struct bt_conn *conn) +{ +} + +int bt_gatt_read_multiple(struct bt_conn *conn, const uint16_t *handles, + size_t count, bt_gatt_read_func_t func) +{ + return -ENOSYS; +}