wireless/bluetooth and net/bluetooth: Clean up some garbage left in Kconfig file that broke 'make menuconfig'. Clean up some craziness with Bluetooth frame length definitions.
This commit is contained in:
parent
7e05d5e9c7
commit
aae0d92598
|
@ -46,13 +46,31 @@
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* REVISIT: Is there any header on the Bluetooth data as received by the
|
||||
* network stack?
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* BLUETOOTH_MAX_FRAMELEN
|
||||
* Maximum amount of data that can fit in a buffer.
|
||||
*
|
||||
* The biggest foreseeable buffer size requirement right now comes from
|
||||
* the Bluetooth 4.2 SMP MTU which is 65. This then become 65 + 4 (L2CAP
|
||||
* header) + 4 (ACL header) + 1 (H4 header) = 74. This also covers the
|
||||
* biggest HCI commands and events which are a bit under the 70 byte
|
||||
* mark.
|
||||
*/
|
||||
|
||||
#warning REVISIT
|
||||
#define BLUETOOTH_SMP_MTU 65
|
||||
|
||||
#define BLUETOOTH_L2CAP_HDRLEN 4 /* Size of L2CAP header */
|
||||
#define BLUETOOTH_ACL_HDRLEN 4 /* Size of ACL header */
|
||||
#define BLUETOOTH_H4_HDRLEN 1 /* Size of H4 header */
|
||||
|
||||
#define BLUETOOTH_FRAME_HDRLEN \
|
||||
(BLUETOOTH_L2CAP_HDRLEN + BLUETOOTH_ACL_HDRLEN + BLUETOOTH_H4_HDRLEN)
|
||||
|
||||
#define BLUETOOTH_MAX_FRAMELEN (BLUETOOTH_SMP_MTU + BLUETOOTH_FRAME_HDRLEN)
|
||||
|
||||
#define BLUETOOTH_HDRLEN 8 /* Size of L2CAP header */
|
||||
#define BLUETOOTH_ADDRSIZE 6
|
||||
#define BLUETOOTH_ADDRCOPY(d,s) memcpy((d),(s),BLUETOOTH_ADDRSIZE)
|
||||
#define BLUETOOTH_ADDRCMP(a,b) (memcmp((a),(b),BLUETOOTH_ADDRSIZE) == 0)
|
||||
|
|
|
@ -49,22 +49,6 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* BT_BUF_MAX_DATA
|
||||
* Maximum amount of data that can fit in a buffer.
|
||||
*
|
||||
* The biggest foreseeable buffer size requirement right now comes from
|
||||
* the Bluetooth 4.2 SMP MTU which is 65. This then become 65 + 4 (L2CAP
|
||||
* header) + 4 (ACL header) + 1 (H4 header) = 74. This also covers the
|
||||
* biggest HCI commands and events which are a bit under the 70 byte
|
||||
* mark.
|
||||
*/
|
||||
|
||||
#define BT_BUF_MAX_DATA 74
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
|
|
@ -22,17 +22,6 @@ config NET_BLUETOOTH
|
|||
|
||||
if NET_BLUETOOTH
|
||||
|
||||
config NET_BLUETOOTH_FRAMELEN
|
||||
int "Bluetooth Frame Length"
|
||||
default 127
|
||||
range 1 999999
|
||||
---help---
|
||||
For standard Bluetooth radios, this should always be 127 bytes.
|
||||
However, some Bluetooth radios may non-standard frame lengths.
|
||||
|
||||
This setting is currently used only for detection data transfers
|
||||
that would exceed the radio frame length.
|
||||
|
||||
config NET_BLUETOOTH_NCONNS
|
||||
int "Max Bluetooth sockets"
|
||||
default 4
|
||||
|
|
|
@ -65,28 +65,6 @@
|
|||
#define BLUETOOTH_POOL_PREALLOCATED 0
|
||||
#define BLUETOOTH_POOL_DYNAMIC 1
|
||||
|
||||
/* Frame size */
|
||||
|
||||
/* This maximum size of an Bluetooth frame. Certain, non-standard
|
||||
* devices may exceed this value, however.
|
||||
*/
|
||||
|
||||
#define BLUETOOTH_MAC_STDFRAME 127
|
||||
|
||||
/* Space for a two byte FCS must be reserved at the end of the frame */
|
||||
|
||||
#define BLUETOOTH_MAC_FCSSIZE 2
|
||||
|
||||
/* This, then, is the usable size of the frame... */
|
||||
|
||||
#if defined(CONFIG_NET_BLUETOOTH_FRAMELEN)
|
||||
# define BLUETOOTH_MAX_FRAMELEN CONFIG_NET_BLUETOOTH_FRAMELEN
|
||||
#else
|
||||
# define BLUETOOTH_MAX_FRAMELEN BLUETOOTH_MAC_STDFRAME
|
||||
#endif
|
||||
|
||||
#define BLUETOOTH_FRAMELEN (BLUETOOTH_MAX_FRAMELEN - BLUETOOTH_MAC_FCSSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -146,8 +146,8 @@ static uint16_t bluetooth_sendto_eventhandler(FAR struct net_driver_s *dev,
|
|||
* MAC header.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(CONFIG_NET_BLUETOOTH_FRAMELEN <= CONFIG_IOB_BUFSIZE);
|
||||
if (pstate->is_buflen + hdrlen > BLUETOOTH_FRAMELEN)
|
||||
DEBUGASSERT(BLUETOOTH_MAX_FRAMELEN <= CONFIG_IOB_BUFSIZE);
|
||||
if (pstate->is_buflen + hdrlen > BLUETOOTH_MAX_FRAMELEN)
|
||||
{
|
||||
nerr("ERROR: User buffer will not fit into the frame: %u > %u\n",
|
||||
(unsigned int)(pstate->is_buflen + hdrlen),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/****************************************************************************
|
||||
* net/netdev/netdev_register.c
|
||||
*
|
||||
* Copyright (C) 2007-2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2012, 2014-2015, 2017-2018 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -220,13 +221,13 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
|
|||
|
||||
#ifdef CONFIG_NET_BLUETOOTH
|
||||
case NET_LL_BLUETOOTH: /* Bluetooth */
|
||||
dev->d_llhdrlen = BLUETOOTH_HDRLEN;
|
||||
dev->d_llhdrlen = BLUETOOTH_FRAME_HDRLEN;
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
# warning Missing logic
|
||||
dev->d_mtu = ???;
|
||||
dev->d_mtu = CONFIG_NET_6LOWPAN_MTU;
|
||||
#ifdef CONFIG_NET_TCP
|
||||
# warning Missing logic
|
||||
dev->d_recvwndo = ???;
|
||||
dev->d_recvwndo = CONFIG_NET_6LOWPAN_TCP_RECVWNDO;
|
||||
#endif
|
||||
#endif
|
||||
devfmt = NETDEV_BNEP_FORMAT;
|
||||
|
|
|
@ -96,18 +96,6 @@ config BLUETOOTH_MAXSCANRESULT
|
|||
This contributes to a static memory allocation that will be greater
|
||||
than CONFIG_BLUETOOTH_MAXSCANDATA * CONFIG_BLUETOOTH_MAXSCANRESULT
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH_BUFFER_PREALLOC) || \
|
||||
CONFIG_BLUETOOTH_BUFFER_PREALLOC < 0
|
||||
# undef CONFIG_BLUETOOTH_BUFFER_PREALLOC
|
||||
# define CONFIG_BLUETOOTH_BUFFER_PREALLOC 20
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_) || \
|
||||
CONFIG_BLUETOOTH_BUFFER_IRQRESERVE < 0
|
||||
# undef CONFIG_BLUETOOTH_BUFFER_IRQRESERVE
|
||||
# define CONFIG_BLUETOOTH_BUFFER_IRQRESERVE 0
|
||||
#endif
|
||||
|
||||
config BLUETOOTH_BUFFER_PREALLOC
|
||||
int "Number of pre-allocated buffer structures"
|
||||
default 20
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/bluetooth.h>
|
||||
#include <nuttx/wireless/bt_hci.h>
|
||||
#include <nuttx/wireless/bt_core.h>
|
||||
#include <nuttx/wireless/bt_uuid.h>
|
||||
|
@ -559,9 +560,9 @@ static uint8_t att_mtu_rsp(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
|
|||
* L2CAP, ACL and driver headers.
|
||||
*/
|
||||
|
||||
maxmtu = BT_BUF_MAX_DATA - (sizeof(struct bt_l2cap_hdr_s) +
|
||||
sizeof(struct bt_hci_acl_hdr_s) +
|
||||
g_btdev.dev->head_reserve);
|
||||
maxmtu = BLUETOOTH_MAX_FRAMELEN - (sizeof(struct bt_l2cap_hdr_s) +
|
||||
sizeof(struct bt_hci_acl_hdr_s) +
|
||||
g_btdev.dev->head_reserve);
|
||||
if (mtu > maxmtu)
|
||||
{
|
||||
mtu = maxmtu;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/bluetooth.h>
|
||||
#include <nuttx/wireless/bt_hci.h>
|
||||
#include <nuttx/wireless/bt_core.h>
|
||||
#include <nuttx/wireless/bt_buf.h>
|
||||
|
@ -641,5 +642,5 @@ size_t bt_buf_headroom(FAR struct bt_buf_s *buf)
|
|||
|
||||
size_t bt_buf_tailroom(FAR struct bt_buf_s * buf)
|
||||
{
|
||||
return BT_BUF_MAX_DATA - bt_buf_headroom(buf) - buf->len;
|
||||
return BLUETOOTH_MAX_FRAMELEN - bt_buf_headroom(buf) - buf->len;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/net/bluetooth.h>
|
||||
#include <nuttx/wireless/bt_core.h>
|
||||
#include <nuttx/wireless/bt_hci.h>
|
||||
|
||||
|
@ -1102,7 +1103,7 @@ static int hci_init(void)
|
|||
|
||||
hbs = bt_buf_extend(buf, sizeof(*hbs));
|
||||
memset(hbs, 0, sizeof(*hbs));
|
||||
hbs->acl_mtu = BT_HOST2LE16(BT_BUF_MAX_DATA -
|
||||
hbs->acl_mtu = BT_HOST2LE16(BLUETOOTH_MAX_FRAMELEN -
|
||||
sizeof(struct bt_hci_acl_hdr_s) -
|
||||
g_btdev.dev->head_reserve);
|
||||
hbs->acl_pkts = BT_HOST2LE16(CONFIG_BLUETOOTH_RXTHREAD_NMSGS);
|
||||
|
|
|
@ -85,10 +85,8 @@
|
|||
|
||||
/* Frame size */
|
||||
|
||||
#if defined(CONFIG_NET_BLUETOOTH_FRAMELEN)
|
||||
# define MACNET_FRAMELEN CONFIG_NET_BLUETOOTH_FRAMELEN
|
||||
#else
|
||||
# define MACNET_FRAMELEN BLUETOOTH_MAX_PHY_PACKET_SIZE
|
||||
#if BLUETOOTH_MAX_FRAMELEN > CONFIG_IOB_BUFSIZE
|
||||
# error CONFIG_IOB_BUFSIZE to small for max Bluetooth frame
|
||||
#endif
|
||||
|
||||
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
|
||||
|
@ -861,7 +859,7 @@ static int btnet_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
|||
static int btnet_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta)
|
||||
{
|
||||
return sizeof(struct bt_l2cap_hdr_s);
|
||||
return BLUETOOTH_FRAME_HDRLEN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -919,7 +917,7 @@ static int btnet_req_data(FAR struct radio_driver_s *netdev,
|
|||
|
||||
/* Allocate a buffer to contain the IOB */
|
||||
|
||||
buf = bt_buf_alloc(BT_ACL_OUT, iob, sizeof(struct bt_l2cap_hdr_s));
|
||||
buf = bt_buf_alloc(BT_ACL_OUT, iob, BLUETOOTH_FRAME_HDRLEN);
|
||||
if (buf == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to allocate buffer container\n");
|
||||
|
@ -962,25 +960,10 @@ static int btnet_properties(FAR struct radio_driver_s *netdev,
|
|||
|
||||
/* General */
|
||||
|
||||
properties->sp_addrlen = BLUETOOTH_ADDRSIZE; /* Length of an address */
|
||||
properties->sp_framelen = MACNET_FRAMELEN; /* Fixed frame length */
|
||||
properties->sp_addrlen = BLUETOOTH_ADDRSIZE; /* Length of an address */
|
||||
properties->sp_framelen = BLUETOOTH_MAX_FRAMELEN; /* Fixed frame length */
|
||||
|
||||
/* Multicast address -- not supported */
|
||||
|
||||
properties->sp_mcast.nv_addrlen = BLUETOOTH_ADDRSIZE;
|
||||
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
|
||||
|
||||
/* Broadcast address -- not supported */
|
||||
|
||||
properties->sp_bcast.nv_addrlen = BLUETOOTH_ADDRSIZE;
|
||||
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
/* Star hub node address -- not supported. */
|
||||
|
||||
properties->sp_hubnode.nv_addrlen = BLUETOOTH_ADDRSIZE;
|
||||
memset(properties->sp_hubnode.nv_addr, RADIO_MAX_ADDRLEN);
|
||||
#endif
|
||||
/* Multicast, multicast, and star hub node addresses not supported */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue