diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c index a2233a5fd8..98274a15ef 100644 --- a/configs/sim/src/sim_bringup.c +++ b/configs/sim/src/sim_bringup.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -256,6 +257,16 @@ int sim_bringup(void) } #endif +#ifdef CONFIG_BLUETOOTH_NULL + /* Register the NULL Bluetooth network device */ + + ret = btnull_register(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btnull_register() failed: %d\n", ret); + } +#endif + UNUSED(ret); return OK; } diff --git a/drivers/audio/Kconfig b/drivers/audio/Kconfig index a8d9fa82c1..b46df815d3 100644 --- a/drivers/audio/Kconfig +++ b/drivers/audio/Kconfig @@ -249,7 +249,7 @@ config AUDIO_NULL default n depends on AUDIO ---help--- - A do-nothinig audio device driver to simplify testing of audio + A do-nothing audio device driver to simplify testing of audio decoders. if AUDIO_NULL diff --git a/drivers/wireless/bluetooth/Kconfig b/drivers/wireless/bluetooth/Kconfig index 27fe4cda5c..04794b1b47 100644 --- a/drivers/wireless/bluetooth/Kconfig +++ b/drivers/wireless/bluetooth/Kconfig @@ -47,4 +47,13 @@ config BLUETOOTH_UART ---help--- Enable Bluetooth UART driver. +config BLUETOOTH_NULL + bool "NULL Bluetooth device" + default n + ---help--- + A do-nothing Bluetooth device driver to permit some basic testing of + the Bluetooth stack on the simulator. This driver just "closes the + loop" and nothing more: It is a just a bit-bucket for outgoing + packets; it generates no incoming packets. + endif # DRIVERS_BLUETOOTH diff --git a/drivers/wireless/bluetooth/Make.defs b/drivers/wireless/bluetooth/Make.defs index 128122ba88..7328518e11 100644 --- a/drivers/wireless/bluetooth/Make.defs +++ b/drivers/wireless/bluetooth/Make.defs @@ -43,6 +43,10 @@ ifeq ($(CONFIG_BLUETOOTH_UART),y) CSRCS += bt_uart.c endif +ifeq ($(CONFIG_BLUETOOTH_NULL),y) +CSRCS += bt_null.c +endif + # Include common Bluetooth drvier build support DEPPATH += --dep-path wireless$(DELIM)bluetooth diff --git a/drivers/wireless/bluetooth/bt_null.c b/drivers/wireless/bluetooth/bt_null.c new file mode 100644 index 0000000000..4368f664a4 --- /dev/null +++ b/drivers/wireless/bluetooth/bt_null.c @@ -0,0 +1,100 @@ +/**************************************************************************** + * drivers/wireless/bluetooth/bt_null.c + * UART based Bluetooth driver + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int btnull_open(FAR const struct bt_driver_s *dev); +static int btnull_send(FAR const struct bt_driver_s *dev, + FAR struct bt_buf_s *buf); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct bt_driver_s g_bt_null = +{ + 0, /* head_reserve */ + btnull_open, /* open */ + btnull_send /* send */ +} + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int btnull_send(FAR const struct bt_driver_s *dev, + FAR struct bt_buf_s *buf) +{ + return OK; +} + +static int btnull_open(FAR const struct bt_driver_s *dev) +{ + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: btnull_register + * + * Description: + * Register the NULL Bluetooth stack with the Bluetooth stack + * + * Input Parameters: + * None + * + * Returned Value: + * Zero is returned on success; a negated errno value is returned on any + * failure. + * + ****************************************************************************/ + +int btnull_register(void) +{ + /* Register the driver with the Bluetooth stack */ + + return bt_driver_register(&g_bt_null); +} diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c index 40e3b6cd7f..a53a4e6f4b 100644 --- a/drivers/wireless/bluetooth/bt_uart.c +++ b/drivers/wireless/bluetooth/bt_uart.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/wireless/bluetooth/btuart.c + * drivers/wireless/bluetooth/bt_uart.c * UART based Bluetooth driver * * Copyright (C) 2018 Gregory Nutt. All rights reserved. diff --git a/include/nuttx/wireless/bt_null.h b/include/nuttx/wireless/bt_null.h new file mode 100644 index 0000000000..46820aa082 --- /dev/null +++ b/include/nuttx/wireless/bt_null.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * drivers/wireless/bluetooth/bt_null.h + * NULL based Bluetooth driver + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_WIRELESS_BT_NULL_H +#define __INCLUDE_NUTTX_WIRELESS_BT_NULL_H 1 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: btnull_register + * + * Description: + * Register the NULL Bluetooth stack with the Bluetooth stack + * + * Input Parameters: + * None + * + * Returned Value: + * Zero is returned on success; a negated errno value is returned on any + * failure. + * + ****************************************************************************/ + +int btnull_register(void); + +#endif /* __INCLUDE_NUTTX_WIRELESS_BT_NULL_H */