drivers/wireless/bluetooth: Add a NULL device to support some very low level testing on the Simulator.
This commit is contained in:
parent
a91edf7f3c
commit
15d033e32b
@ -52,6 +52,7 @@
|
|||||||
#include <nuttx/video/fb.h>
|
#include <nuttx/video/fb.h>
|
||||||
#include <nuttx/timers/oneshot.h>
|
#include <nuttx/timers/oneshot.h>
|
||||||
#include <nuttx/wireless/pktradio.h>
|
#include <nuttx/wireless/pktradio.h>
|
||||||
|
#include <nuttx/wireless/bt_null.h>
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
@ -256,6 +257,16 @@ int sim_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#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);
|
UNUSED(ret);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ config AUDIO_NULL
|
|||||||
default n
|
default n
|
||||||
depends on AUDIO
|
depends on AUDIO
|
||||||
---help---
|
---help---
|
||||||
A do-nothinig audio device driver to simplify testing of audio
|
A do-nothing audio device driver to simplify testing of audio
|
||||||
decoders.
|
decoders.
|
||||||
|
|
||||||
if AUDIO_NULL
|
if AUDIO_NULL
|
||||||
|
@ -47,4 +47,13 @@ config BLUETOOTH_UART
|
|||||||
---help---
|
---help---
|
||||||
Enable Bluetooth UART driver.
|
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
|
endif # DRIVERS_BLUETOOTH
|
||||||
|
@ -43,6 +43,10 @@ ifeq ($(CONFIG_BLUETOOTH_UART),y)
|
|||||||
CSRCS += bt_uart.c
|
CSRCS += bt_uart.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_BLUETOOTH_NULL),y)
|
||||||
|
CSRCS += bt_null.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Include common Bluetooth drvier build support
|
# Include common Bluetooth drvier build support
|
||||||
|
|
||||||
DEPPATH += --dep-path wireless$(DELIM)bluetooth
|
DEPPATH += --dep-path wireless$(DELIM)bluetooth
|
||||||
|
100
drivers/wireless/bluetooth/bt_null.c
Normal file
100
drivers/wireless/bluetooth/bt_null.c
Normal file
@ -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 <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* 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 <nuttx/wireless/bt_driver.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/wireless/bluetooth/btuart.c
|
* drivers/wireless/bluetooth/bt_uart.c
|
||||||
* UART based Bluetooth driver
|
* UART based Bluetooth driver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
|
60
include/nuttx/wireless/bt_null.h
Normal file
60
include/nuttx/wireless/bt_null.h
Normal file
@ -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 <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* 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 */
|
Loading…
Reference in New Issue
Block a user