net/bluetooth: Add support for connection to any address and any channel.

This commit is contained in:
Gregory Nutt 2018-04-01 17:53:07 -06:00
parent 3ba6cc7921
commit 5dd11f465b
2 changed files with 16 additions and 7 deletions

View File

@ -51,8 +51,12 @@
/* Well known addresses: */ /* Well known addresses: */
#define BDADDR_ANY {0, 0, 0, 0, 0, 0} #define BT_ADDR_ANY {0, 0, 0, 0, 0, 0}
#define BDADDR_LOCAL {0, 0, 0, 0xff, 0xff, 0xff} #define BT_ADDR_LOCAL {0, 0, 0, 0xff, 0xff, 0xff}
/* Any channel */
#define BT_CHANNEL_ANY 0
/* Socket protocols. /* Socket protocols.
* *

View File

@ -43,6 +43,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <netpacket/bluetooth.h>
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/mm/iob.h> #include <nuttx/mm/iob.h>
@ -75,6 +76,11 @@ static dq_queue_t g_free_bluetooth_connections;
static dq_queue_t g_active_bluetooth_connections; static dq_queue_t g_active_bluetooth_connections;
static const bt_addr_t g_any_addr =
{
BT_ADDR_ANY
};
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -218,12 +224,11 @@ FAR struct bluetooth_conn_s *
conn = (FAR struct bluetooth_conn_s *)conn->bc_node.flink) conn = (FAR struct bluetooth_conn_s *)conn->bc_node.flink)
{ {
/* Does the destination address match the bound address of the socket. */ /* Does the destination address match the bound address of the socket. */
/* REVISIT: Currently and explicit address must be assigned. Should we
* support some moral equivalent to INADDR_ANY?
*/
if (!BLUETOOTH_ADDRCMP(&meta->bm_raddr, &conn->bc_laddr) || if ((BLUETOOTH_ADDRCMP(&conn->bc_raddr, &meta->bm_raddr) ||
meta->bm_channel != conn->bc_channel) BLUETOOTH_ADDRCMP(&conn->bc_raddr, &g_any_addr)) &&
(meta->bm_channel == conn->bc_channel ||
BT_CHANNEL_ANY == conn->bc_channel))
{ {
continue; continue;
} }