Skip to content
GitLab
Explore
Sign in
f4grx
NuttX RTOS
Compare revisions
89be27cafa0ab166f6d8514826f1196770370bd6 to 80ec46a69edec4a46a00ff323800f81b736454a5
Hide whitespace changes
Inline
Side-by-side
net/ieee802154/ieee802154_conn.c
View file @
80ec46a6
...
@@ -83,7 +83,7 @@ static dq_queue_t g_active_ieee802154_connections;
...
@@ -83,7 +83,7 @@ static dq_queue_t g_active_ieee802154_connections;
* Name: ieee802154_conn_initialize
* Name: ieee802154_conn_initialize
*
*
* Description:
* Description:
* Initialize the IEEE 802.15.
5
connection structure allocator. Called
* Initialize the IEEE 802.15.
4
connection structure allocator. Called
* once and only from ieee802154_initialize().
* once and only from ieee802154_initialize().
*
*
* Assumptions:
* Assumptions:
...
@@ -218,7 +218,7 @@ FAR struct ieee802154_conn_s *
...
@@ -218,7 +218,7 @@ FAR struct ieee802154_conn_s *
conn
=
(
FAR
struct
ieee802154_conn_s
*
)
conn
->
node
.
flink
)
conn
=
(
FAR
struct
ieee802154_conn_s
*
)
conn
->
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 explict address must be assigned. Should we
/* REVISIT: Currently and explic
i
t address must be assigned. Should we
* support some moral equivalent to INADDR_ANY?
* support some moral equivalent to INADDR_ANY?
*/
*/
...
...
net/ieee802154/ieee802154_container.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
*
wireless/pktradio
/ieee802154_container.c
*
net/ieee802154
/ieee802154_container.c
*
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
...
...
net/ieee802154/ieee802154_finddev.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/ieee802154/ieee802154_finddev.c
* net/ieee802154/ieee802154_finddev.c
*
*
* Copyright (C) 201
5
Gregory Nutt. All rights reserved.
* Copyright (C) 201
7
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -56,8 +56,8 @@
...
@@ -56,8 +56,8 @@
struct
ieee802154_finddev_s
struct
ieee802154_finddev_s
{
{
FAR
const
struct
ieee802154_saddr_s
*
addr
;
FAR
const
struct
ieee802154_saddr_s
*
addr
;
FAR
struct
radio_driver_s
*
radio
;
FAR
struct
radio_driver_s
*
radio
;
};
};
/****************************************************************************
/****************************************************************************
...
@@ -65,7 +65,7 @@ struct ieee802154_finddev_s
...
@@ -65,7 +65,7 @@ struct ieee802154_finddev_s
****************************************************************************/
****************************************************************************/
/****************************************************************************
/****************************************************************************
* Name: ieee802154
5
_dev_callback
* Name: ieee802154_dev_callback
*
*
* Description:
* Description:
* Check if this device matches the connections local address.
* Check if this device matches the connections local address.
...
@@ -79,7 +79,7 @@ struct ieee802154_finddev_s
...
@@ -79,7 +79,7 @@ struct ieee802154_finddev_s
*
*
****************************************************************************/
****************************************************************************/
static
int
ieee802154
5
_dev_callback
(
FAR
struct
net_driver_s
*
dev
,
FAR
void
*
arg
)
static
int
ieee802154_dev_callback
(
FAR
struct
net_driver_s
*
dev
,
FAR
void
*
arg
)
{
{
FAR
struct
ieee802154_finddev_s
*
match
=
FAR
struct
ieee802154_finddev_s
*
match
=
(
FAR
struct
ieee802154_finddev_s
*
)
arg
;
(
FAR
struct
ieee802154_finddev_s
*
)
arg
;
...
@@ -174,10 +174,10 @@ FAR struct radio_driver_s *
...
@@ -174,10 +174,10 @@ FAR struct radio_driver_s *
addr
->
s_mode
==
IEEE802154_ADDRMODE_EXTENDED
);
addr
->
s_mode
==
IEEE802154_ADDRMODE_EXTENDED
);
/* Other, search for the IEEE 802.15.4 network device whose MAC is equal to
/* Other, search for the IEEE 802.15.4 network device whose MAC is equal to
* the sockets boun
t
local address.
* the sockets boun
d
local address.
*/
*/
ret
=
netdev_foreach
(
ieee802154
5
_dev_callback
,
(
FAR
void
*
)
&
match
);
ret
=
netdev_foreach
(
ieee802154_dev_callback
,
(
FAR
void
*
)
&
match
);
if
(
ret
==
1
)
if
(
ret
==
1
)
{
{
DEBUGASSERT
(
match
.
radio
!=
NULL
);
DEBUGASSERT
(
match
.
radio
!=
NULL
);
...
...
net/ieee802154/ieee802154_input.c
View file @
80ec46a6
...
@@ -94,7 +94,7 @@ static int ieee802154_count_frames(FAR struct ieee802154_conn_s *conn)
...
@@ -94,7 +94,7 @@ static int ieee802154_count_frames(FAR struct ieee802154_conn_s *conn)
* Input Parameters:
* Input Parameters:
* conn - The socket connection structure.
* conn - The socket connection structure.
* framel - A single frame to add to the RX queue.
* framel - A single frame to add to the RX queue.
* meta - Meta data characterizing the received fra
n
e.
* meta - Meta data characterizing the received fra
m
e.
*
*
* Returned Value:
* Returned Value:
* Zero (OK) is returned on success; A negated errno value is returned on
* Zero (OK) is returned on success; A negated errno value is returned on
...
@@ -222,9 +222,9 @@ static int ieee802154_queue_frame(FAR struct ieee802154_conn_s *conn,
...
@@ -222,9 +222,9 @@ static int ieee802154_queue_frame(FAR struct ieee802154_conn_s *conn,
* framelist - The head of an incoming list of frames. Normally this
* framelist - The head of an incoming list of frames. Normally this
* would be a single frame. A list may be provided if
* would be a single frame. A list may be provided if
* appropriate, however.
* appropriate, however.
* meta - Meta data characterizing the received fra
n
e.
* meta - Meta data characterizing the received fra
m
e.
*
*
* If there are multi
l
ple frames in the list, this metadata
* If there are multiple frames in the list, this metadata
* must apply to all of the frames in the list.
* must apply to all of the frames in the list.
*
*
* Returned Value:
* Returned Value:
...
...
net/ieee802154/ieee802154_sendto.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/ieee802154/ieee802154_sendto.c
* net/ieee802154/ieee802154_sendto.c
*
*
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -57,7 +56,6 @@
...
@@ -57,7 +56,6 @@
#include
<nuttx/mm/iob.h>
#include
<nuttx/mm/iob.h>
#include
<nuttx/net/radiodev.h>
#include
<nuttx/net/radiodev.h>
#include
<nuttx/net/net.h>
#include
<nuttx/net/net.h>
#include
<nuttx/net/ip.h>
#include
"netdev/netdev.h"
#include
"netdev/netdev.h"
#include
"devif/devif.h"
#include
"devif/devif.h"
...
@@ -78,7 +76,7 @@ struct ieee802154_sendto_s
...
@@ -78,7 +76,7 @@ struct ieee802154_sendto_s
{
{
FAR
struct
socket
*
is_sock
;
/* Points to the parent socket structure */
FAR
struct
socket
*
is_sock
;
/* Points to the parent socket structure */
FAR
struct
devif_callback_s
*
is_cb
;
/* Reference to callback instance */
FAR
struct
devif_callback_s
*
is_cb
;
/* Reference to callback instance */
struct
ieee802154_saddr_s
is_destaddr
;
/* Frame destinatin address */
struct
ieee802154_saddr_s
is_destaddr
;
/* Frame destinati
o
n address */
sem_t
is_sem
;
/* Used to wake up the waiting thread */
sem_t
is_sem
;
/* Used to wake up the waiting thread */
FAR
const
uint8_t
*
is_buffer
;
/* User buffer of data to send */
FAR
const
uint8_t
*
is_buffer
;
/* User buffer of data to send */
size_t
is_buflen
;
/* Number of bytes in the is_buffer */
size_t
is_buflen
;
/* Number of bytes in the is_buffer */
...
@@ -163,7 +161,7 @@ static inline bool ieee802154_eaddrnull(FAR const uint8_t *eaddr)
...
@@ -163,7 +161,7 @@ static inline bool ieee802154_eaddrnull(FAR const uint8_t *eaddr)
*
*
* Description:
* Description:
* Based on the collected attributes and addresses, construct the MAC meta
* Based on the collected attributes and addresses, construct the MAC meta
* data structure that we need to interface with the IEEE802.15.4 MAC.
* data structure that we need to interface with the IEEE
802.15.4 MAC.
*
*
* Input Parameters:
* Input Parameters:
* radio - Radio network driver state instance.
* radio - Radio network driver state instance.
...
@@ -179,9 +177,9 @@ static inline bool ieee802154_eaddrnull(FAR const uint8_t *eaddr)
...
@@ -179,9 +177,9 @@ static inline bool ieee802154_eaddrnull(FAR const uint8_t *eaddr)
*
*
****************************************************************************/
****************************************************************************/
void
ieee802154_meta_data
(
FAR
struct
radio_driver_s
*
radio
,
static
void
ieee802154_meta_data
(
FAR
struct
radio_driver_s
*
radio
,
FAR
struct
ieee802154_sendto_s
*
pstate
,
FAR
struct
ieee802154_sendto_s
*
pstate
,
FAR
struct
ieee802154_frame_meta_s
*
meta
)
FAR
struct
ieee802154_frame_meta_s
*
meta
)
{
{
FAR
struct
ieee802154_saddr_s
*
destaddr
;
FAR
struct
ieee802154_saddr_s
*
destaddr
;
FAR
struct
ieee802154_saddr_s
*
srcaddr
;
FAR
struct
ieee802154_saddr_s
*
srcaddr
;
...
@@ -538,7 +536,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
...
@@ -538,7 +536,7 @@ ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
psock
->
s_flags
=
_SS_SETSTATE
(
psock
->
s_flags
,
_SF_IDLE
);
psock
->
s_flags
=
_SS_SETSTATE
(
psock
->
s_flags
,
_SF_IDLE
);
/* Check for a errors, Errors are signal
l
ed by negative errno values
/* Check for a errors, Errors are signaled by negative errno values
* for the send length
* for the send length
*/
*/
...
...
net/ieee802154/ieee802154_sockif.c
View file @
80ec46a6
...
@@ -47,10 +47,11 @@
...
@@ -47,10 +47,11 @@
#include
<errno.h>
#include
<errno.h>
#include
<debug.h>
#include
<debug.h>
#include
<socket/socket.h>
#include
<netpacket/ieee802154.h>
#include
<nuttx/net/net.h>
#include
<nuttx/net/net.h>
#include
<nuttx/net/radiodev.h>
#include
<nuttx/net/radiodev.h>
#include
<netpacket/packet.h>
#include
<socket/socket.h>
#include
"ieee802154/ieee802154.h"
#include
"ieee802154/ieee802154.h"
...
@@ -270,9 +271,42 @@ static void ieee802154_addref(FAR struct socket *psock)
...
@@ -270,9 +271,42 @@ static void ieee802154_addref(FAR struct socket *psock)
****************************************************************************/
****************************************************************************/
static
int
ieee802154_connect
(
FAR
struct
socket
*
psock
,
static
int
ieee802154_connect
(
FAR
struct
socket
*
psock
,
FAR
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
FAR
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
{
return
-
EAFNOSUPPORT
;
FAR
struct
ieee802154_conn_s
*
conn
;
FAR
struct
sockaddr_ieee802154_s
*
ieeeaddr
;
int
ret
;
DEBUGASSERT
(
psock
!=
NULL
||
addr
!=
NULL
);
conn
=
(
FAR
struct
ieee802154_conn_s
*
)
psock
->
s_conn
;
DEBUGASSERT
(
conn
!=
NULL
);
/* Verify the address family */
if
(
addr
->
sa_family
==
AF_IEEE802154
)
{
/* Save the "connection" address */
ieeeaddr
=
(
FAR
struct
sockaddr_ieee802154_s
*
)
addr
;
memcpy
(
&
conn
->
raddr
,
&
ieeeaddr
->
sa_addr
,
sizeof
(
struct
ieee802154_saddr_s
));
/* Mark the socket as connected. */
psock
->
s_flags
|=
_SF_CONNECTED
;
ret
=
OK
;
}
else
{
/* The specified address is not a valid address for the address family
* of the specified socket.
*/
ret
=
-
EAFNOSUPPORT
;
}
return
ret
;
}
}
/****************************************************************************
/****************************************************************************
...
@@ -362,7 +396,7 @@ static int ieee802154_bind(FAR struct socket *psock,
...
@@ -362,7 +396,7 @@ static int ieee802154_bind(FAR struct socket *psock,
addrlen
<
sizeof
(
struct
sockaddr_ieee802154_s
))
addrlen
<
sizeof
(
struct
sockaddr_ieee802154_s
))
{
{
nerr
(
"ERROR: Invalid family: %u or address length: %d < %d
\n
"
,
nerr
(
"ERROR: Invalid family: %u or address length: %d < %d
\n
"
,
addr
->
sa_family
,
addrlen
,
sizeof
(
struct
sockaddr_
ll
));
addr
->
sa_family
,
addrlen
,
sizeof
(
struct
sockaddr_
ieee802154_s
));
return
-
EBADF
;
return
-
EBADF
;
}
}
...
@@ -459,7 +493,7 @@ static int ieee802154_getsockname(FAR struct socket *psock,
...
@@ -459,7 +493,7 @@ static int ieee802154_getsockname(FAR struct socket *psock,
/* Create a copy of the full address on the stack */
/* Create a copy of the full address on the stack */
tmp
.
sa_family
=
P
F_IEEE802154
;
tmp
.
sa_family
=
A
F_IEEE802154
;
memcpy
(
&
tmp
.
sa_addr
,
&
conn
->
laddr
,
sizeof
(
struct
ieee802154_saddr_s
));
memcpy
(
&
tmp
.
sa_addr
,
&
conn
->
laddr
,
sizeof
(
struct
ieee802154_saddr_s
));
/* Copy to the user buffer, truncating if necessary */
/* Copy to the user buffer, truncating if necessary */
...
@@ -573,7 +607,7 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
...
@@ -573,7 +607,7 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
if
(
psock
->
s_type
==
SOCK_DGRAM
)
if
(
psock
->
s_type
==
SOCK_DGRAM
)
{
{
/* send() may be used only if the socket
is
has been connected. */
/* send() may be used only if the socket has been connected. */
if
(
!
_SS_ISCONNECTED
(
psock
->
s_flags
)
||
if
(
!
_SS_ISCONNECTED
(
psock
->
s_flags
)
||
conn
->
raddr
.
s_mode
==
IEEE802154_ADDRMODE_NONE
)
conn
->
raddr
.
s_mode
==
IEEE802154_ADDRMODE_NONE
)
...
@@ -582,7 +616,7 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
...
@@ -582,7 +616,7 @@ static ssize_t ieee802154_send(FAR struct socket *psock, FAR const void *buf,
}
}
else
else
{
{
to
.
sa_family
=
P
F_IEEE802154
;
to
.
sa_family
=
A
F_IEEE802154
;
memcpy
(
&
to
.
sa_addr
,
&
conn
->
raddr
,
memcpy
(
&
to
.
sa_addr
,
&
conn
->
raddr
,
sizeof
(
struct
ieee802154_saddr_s
));
sizeof
(
struct
ieee802154_saddr_s
));
...
...
net/net_initialize.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/net_initialize.c
* net/net_initialize.c
*
*
* Copyright (C) 2007-2009, 2011-2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2015, 2017-2018 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -56,6 +57,7 @@
...
@@ -56,6 +57,7 @@
#include
"tcp/tcp.h"
#include
"tcp/tcp.h"
#include
"udp/udp.h"
#include
"udp/udp.h"
#include
"pkt/pkt.h"
#include
"pkt/pkt.h"
#include
"bluetooth/bluetooth.h"
#include
"ieee802154/ieee802154.h"
#include
"ieee802154/ieee802154.h"
#include
"local/local.h"
#include
"local/local.h"
#include
"igmp/igmp.h"
#include
"igmp/igmp.h"
...
@@ -140,6 +142,12 @@ void net_setup(void)
...
@@ -140,6 +142,12 @@ void net_setup(void)
icmpv6_sock_initialize
();
icmpv6_sock_initialize
();
#endif
#endif
#ifdef CONFIG_NET_BLUETOOTH
/* Initialize Bluetooth socket support */
bluetooth_initialize
();
#endif
#ifdef CONFIG_NET_IEEE802154
#ifdef CONFIG_NET_IEEE802154
/* Initialize IEEE 802.15.4 socket support */
/* Initialize IEEE 802.15.4 socket support */
...
...
net/netdev/netdev_ioctl.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/netdev/netdev_ioctl.c
* net/netdev/netdev_ioctl.c
*
*
* Copyright (C) 2007-2012, 2015-201
7
Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2012, 2015-201
8
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -73,6 +73,10 @@
...
@@ -73,6 +73,10 @@
#endif
#endif
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN)
# ifdef CONFIG_WIRELESS_BLUETOOTH
# include <nuttx/wireless/bt_ioctl.h>
# endif
# ifdef CONFIG_WIRELESS_IEEE802154
# ifdef CONFIG_WIRELESS_IEEE802154
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
# include <nuttx/wireless/ieee802154/ieee802154_mac.h>
# endif
# endif
...
@@ -356,7 +360,7 @@ static void ioctl_set_ipv4addr(FAR in_addr_t *outaddr,
...
@@ -356,7 +360,7 @@ static void ioctl_set_ipv4addr(FAR in_addr_t *outaddr,
*
*
* Input Parameters:
* Input Parameters:
* outaddr - Pointer to the source IP address in the device structure.
* outaddr - Pointer to the source IP address in the device structure.
* inaddr - Pointer to the user-provided memory to containing the new IP
* inaddr
- Pointer to the user-provided memory to containing the new IP
* address.
* address.
*
*
****************************************************************************/
****************************************************************************/
...
@@ -370,6 +374,68 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
...
@@ -370,6 +374,68 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
}
}
#endif
#endif
/****************************************************************************
* Name: netdev_iee802154_ioctl
*
* Description:
* Perform Bluetooth network device specific operations.
*
* Input Parameters:
* psock - Socket structure
* dev - Ethernet driver device structure
* cmd - The ioctl command
* req - The argument of the ioctl cmd
*
* Returned Value:
* >=0 on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_6LOWPAN) && \
defined(CONFIG_WIRELESS_BLUETOOTH)
static
int
netdev_iee802154_ioctl
(
FAR
struct
socket
*
psock
,
int
cmd
,
unsigned
long
arg
)
{
FAR
struct
net_driver_s
*
dev
;
FAR
char
*
ifname
;
int
ret
=
-
ENOTTY
;
if
(
arg
!=
0ul
)
{
if
(
WL_IBLUETOOTHCMD
(
cmd
))
{
/* Get the name of the Bluetooth device to receive the IOCTL
* command
*/
FAR
struct
bluetooth_ifreq_s
*
cmddata
=
(
FAR
struct
bluetooth_ifreq_s
*
)((
uintptr_t
)
arg
);
ifname
=
cmddata
->
ifr_name
;
}
else
{
/* Not a Bluetooth IOCTL command */
return
-
ENOTTY
;
}
/* Find the device with this name */
dev
=
netdev_findbyname
(
ifname
);
if
(
dev
!=
NULL
&&
dev
->
d_lltype
==
NET_LL_BLUETOOTH
)
{
/* Perform the device IOCTL */
ret
=
dev
->
d_ioctl
(
dev
,
cmd
,
arg
);
}
}
return
ret
;
}
#endif
/****************************************************************************
/****************************************************************************
* Name: netdev_iee802154_ioctl
* Name: netdev_iee802154_ioctl
*
*
...
@@ -377,10 +443,10 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
...
@@ -377,10 +443,10 @@ static void ioctl_set_ipv6addr(FAR net_ipv6addr_t outaddr,
* Perform IEEE802.15.4 network device specific operations.
* Perform IEEE802.15.4 network device specific operations.
*
*
* Input Parameters:
* Input Parameters:
* psock
Socket structure
* psock
-
Socket structure
* dev
Ethernet driver device structure
* dev
-
Ethernet driver device structure
* cmd
The ioctl command
* cmd
-
The ioctl command
* req
The argument of the ioctl cmd
* req
-
The argument of the ioctl cmd
*
*
* Returned Value:
* Returned Value:
* >=0 on success (positive non-zero values are cmd-specific)
* >=0 on success (positive non-zero values are cmd-specific)
...
@@ -439,10 +505,10 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
...
@@ -439,10 +505,10 @@ static int netdev_iee802154_ioctl(FAR struct socket *psock, int cmd,
* Perform non-IEEE802.15.4 packet radio network device specific operations.
* Perform non-IEEE802.15.4 packet radio network device specific operations.
*
*
* Input Parameters:
* Input Parameters:
* psock
Socket structure
* psock
-
Socket structure
* dev
Ethernet driver device structure
* dev
-
Ethernet driver device structure
* cmd
The ioctl command
* cmd
-
The ioctl command
* req
The argument of the ioctl cmd
* req
-
The argument of the ioctl cmd
*
*
* Returned Value:
* Returned Value:
* >=0 on success (positive non-zero values are cmd-specific)
* >=0 on success (positive non-zero values are cmd-specific)
...
...
net/netdev/netdev_lladdrsize.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/netdev/netdev_lladdrsize.c
* net/netdev/netdev_lladdrsize.c
*
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2017
-2018
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#include
<nuttx/net/net.h>
#include
<nuttx/net/net.h>
#include
<nuttx/net/netdev.h>
#include
<nuttx/net/netdev.h>
#include
<nuttx/net/radiodev.h>
#include
<nuttx/net/radiodev.h>
#include
<nuttx/net/bluetooth.h>
#include
<nuttx/net/sixlowpan.h>
#include
<nuttx/net/sixlowpan.h>
#include
"netdev/netdev.h"
#include
"netdev/netdev.h"
...
@@ -62,7 +63,7 @@
...
@@ -62,7 +63,7 @@
* Description:
* Description:
* Returns the size of the node address associated with a packet radio.
* Returns the size of the node address associated with a packet radio.
* This is probably CONFIG_PKTRADIO_ADDRLEN but we cannot be sure in the
* This is probably CONFIG_PKTRADIO_ADDRLEN but we cannot be sure in the
* case that there ar mutiple packet radios. In that case, we have to
* case that there ar
e
mu
l
tiple packet radios. In that case, we have to
* query the radio for its address length.
* query the radio for its address length.
*
*
* Input Parameters:
* Input Parameters:
...
@@ -127,6 +128,17 @@ int netdev_dev_lladdrsize(FAR struct net_driver_s *dev)
...
@@ -127,6 +128,17 @@ int netdev_dev_lladdrsize(FAR struct net_driver_s *dev)
#endif
#endif
#ifdef CONFIG_NET_6LOWPAN
#ifdef CONFIG_NET_6LOWPAN
#ifdef CONFIG_WIRELESS_BLUETOOTH
case
NET_LL_BLUETOOTH
:
{
/* 6LoWPAN can be configured to use either extended or short
* addressing.
*/
return
BLUETOOTH_HDRLEN
;
}
#endif
/* CONFIG_WIRELESS_BLUETOOTH */
#ifdef CONFIG_WIRELESS_IEEE802154
#ifdef CONFIG_WIRELESS_IEEE802154
case
NET_LL_IEEE802154
:
case
NET_LL_IEEE802154
:
{
{
...
@@ -140,7 +152,6 @@ int netdev_dev_lladdrsize(FAR struct net_driver_s *dev)
...
@@ -140,7 +152,6 @@ int netdev_dev_lladdrsize(FAR struct net_driver_s *dev)
return
NET_6LOWPAN_SADDRSIZE
;
return
NET_6LOWPAN_SADDRSIZE
;
#endif
#endif
}
}
#endif
/* CONFIG_WIRELESS_IEEE802154 */
#endif
/* CONFIG_WIRELESS_IEEE802154 */
#ifdef CONFIG_WIRELESS_PKTRADIO
#ifdef CONFIG_WIRELESS_PKTRADIO
...
...
net/netdev/netdev_register.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/netdev/netdev_register.c
* 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>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -53,6 +54,7 @@
...
@@ -53,6 +54,7 @@
#include
<nuttx/net/netconfig.h>
#include
<nuttx/net/netconfig.h>
#include
<nuttx/net/netdev.h>
#include
<nuttx/net/netdev.h>
#include
<nuttx/net/arp.h>
#include
<nuttx/net/arp.h>
#include
<nuttx/net/bluetooth.h>
#include
"utils/utils.h"
#include
"utils/utils.h"
#include
"igmp/igmp.h"
#include
"igmp/igmp.h"
...
@@ -66,6 +68,8 @@
...
@@ -66,6 +68,8 @@
#define NETDEV_LO_FORMAT "lo"
#define NETDEV_LO_FORMAT "lo"
#define NETDEV_SLIP_FORMAT "sl%d"
#define NETDEV_SLIP_FORMAT "sl%d"
#define NETDEV_TUN_FORMAT "tun%d"
#define NETDEV_TUN_FORMAT "tun%d"
#define NETDEV_BNEP_FORMAT "bnep%d"
#define NETDEV_PAN_FORMAT "pan%d"
#define NETDEV_WLAN_FORMAT "wlan%d"
#define NETDEV_WLAN_FORMAT "wlan%d"
#define NETDEV_WPAN_FORMAT "wpan%d"
#define NETDEV_WPAN_FORMAT "wpan%d"
...
@@ -215,6 +219,21 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
...
@@ -215,6 +219,21 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
break
;
break
;
#endif
#endif
#ifdef CONFIG_NET_BLUETOOTH
case
NET_LL_BLUETOOTH
:
/* Bluetooth */
dev
->
d_llhdrlen
=
BLUETOOTH_FRAME_HDRLEN
;
#ifdef CONFIG_NET_6LOWPAN
# warning Missing logic
dev
->
d_mtu
=
CONFIG_NET_6LOWPAN_MTU
;
#ifdef CONFIG_NET_TCP
# warning Missing logic
dev
->
d_recvwndo
=
CONFIG_NET_6LOWPAN_TCP_RECVWNDO
;
#endif
#endif
devfmt
=
NETDEV_BNEP_FORMAT
;
break
;
#endif
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
case
NET_LL_IEEE802154
:
/* IEEE 802.15.4 MAC */
case
NET_LL_IEEE802154
:
/* IEEE 802.15.4 MAC */
case
NET_LL_PKTRADIO
:
/* Non-IEEE 802.15.4 packet radio */
case
NET_LL_PKTRADIO
:
/* Non-IEEE 802.15.4 packet radio */
...
...
net/socket/net_sockif.c
View file @
80ec46a6
/****************************************************************************
/****************************************************************************
* net/socket/net_sockif.c
* net/socket/net_sockif.c
*
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2017
-2018
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#include
"inet/inet.h"
#include
"inet/inet.h"
#include
"local/local.h"
#include
"local/local.h"
#include
"pkt/pkt.h"
#include
"pkt/pkt.h"
#include
"bluetooth/bluetooth.h"
#include
"ieee802154/ieee802154.h"
#include
"ieee802154/ieee802154.h"
#include
"socket/socket.h"
#include
"socket/socket.h"
...
@@ -104,6 +105,12 @@ FAR const struct sock_intf_s *
...
@@ -104,6 +105,12 @@ FAR const struct sock_intf_s *
break
;
break
;
#endif
#endif
#ifdef CONFIG_NET_BLUETOOTH
case
PF_BLUETOOTH
:
sockif
=
&
g_bluetooth_sockif
;
break
;
#endif
#ifdef CONFIG_NET_IEEE802154
#ifdef CONFIG_NET_IEEE802154
case
PF_IEEE802154
:
case
PF_IEEE802154
:
sockif
=
&
g_ieee802154_sockif
;
sockif
=
&
g_ieee802154_sockif
;
...
...
net/udp/udp.h
View file @
80ec46a6
...
@@ -115,7 +115,7 @@ struct udp_conn_s
...
@@ -115,7 +115,7 @@ struct udp_conn_s
struct
iob_queue_s
readahead
;
/* Read-ahead buffering */
struct
iob_queue_s
readahead
;
/* Read-ahead buffering */
#endif
#endif
#ifdef CONFIG_NET_
TC
P_WRITE_BUFFERS
#ifdef CONFIG_NET_
UD
P_WRITE_BUFFERS
/* Write buffering
/* Write buffering
*
*
* write_q - The queue of unsent I/O buffers. The head of this
* write_q - The queue of unsent I/O buffers. The head of this
...
...
net/udp/udp_conn.c
View file @
80ec46a6
...
@@ -486,7 +486,7 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain)
...
@@ -486,7 +486,7 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain)
conn
->
lport
=
0
;
conn
->
lport
=
0
;
conn
->
ttl
=
IP_TTL
;
conn
->
ttl
=
IP_TTL
;
#ifdef CONFIG_NET_
TC
P_WRITE_BUFFERS
#ifdef CONFIG_NET_
UD
P_WRITE_BUFFERS
/* Initialize the write buffer lists */
/* Initialize the write buffer lists */
sq_init
(
&
conn
->
write_q
);
sq_init
(
&
conn
->
write_q
);
...
...
net/udp/udp_psock_sendto_buffered.c
View file @
80ec46a6
...
@@ -684,7 +684,9 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
...
@@ -684,7 +684,9 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
/* Initialize the write buffer */
/* Initialize the write buffer */
memcpy
(
&
wrb
->
wb_dest
,
to
,
tolen
);
memcpy
(
&
wrb
->
wb_dest
,
to
,
tolen
);
#ifdef CONFIG_NET_SOCKOPTS
wrb
->
wb_start
=
clock_systimer
();
wrb
->
wb_start
=
clock_systimer
();
#endif
/* Copy the user data into the write buffer. We cannot wait for
/* Copy the user data into the write buffer. We cannot wait for
* buffer space if the socket was opened non-blocking.
* buffer space if the socket was opened non-blocking.
...
...
net/udp/udp_send.c
View file @
80ec46a6
...
@@ -114,7 +114,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
...
@@ -114,7 +114,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
ip6_is_ipv4addr
((
FAR
struct
in6_addr
*
)
conn
->
u
.
ipv6
.
raddr
)))
ip6_is_ipv4addr
((
FAR
struct
in6_addr
*
)
conn
->
u
.
ipv6
.
raddr
)))
#endif
#endif
{
{
/* Get pointers to the IPv4 header and the offset
TC
P header */
/* Get pointers to the IPv4 header and the offset
UD
P header */
FAR
struct
ipv4_hdr_s
*
ipv4
=
IPv4BUF
;
FAR
struct
ipv4_hdr_s
*
ipv4
=
IPv4BUF
;
...
@@ -176,7 +176,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
...
@@ -176,7 +176,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
else
else
#endif
#endif
{
{
/* Get pointers to the IPv6 header and the offset
TC
P header */
/* Get pointers to the IPv6 header and the offset
UD
P header */
FAR
struct
ipv6_hdr_s
*
ipv6
=
IPv6BUF
;
FAR
struct
ipv6_hdr_s
*
ipv6
=
IPv6BUF
;
...
...
wireless/bluetooth/Kconfig
View file @
80ec46a6
...
@@ -72,6 +72,64 @@ config BLUETOOTH_MAX_PAIRED
...
@@ -72,6 +72,64 @@ config BLUETOOTH_MAX_PAIRED
Maximum number of paired Bluetooth devices. The minimum (and
Maximum number of paired Bluetooth devices. The minimum (and
default) number is 1.
default) number is 1.
config BLUETOOTH_MAXSCANDATA
int "Max scan data size"
default 64
range 1 255
---help---
Scan results will be buffered in memory until the user requests the
scan results. This parameter specifies the maximum size of the
advertiser data that accompanies the scan result.
This contributes to a static memory allocation that will be greater
than CONFIG_BLUETOOTH_MAXSCANDATA * CONFIG_BLUETOOTH_MAXSCANRESULT
config BLUETOOTH_MAXSCANRESULT
int "Max scan results"
default 8
range 1 255
---help---
Scan results will be buffered in memory until the user requests the
scan results. This parameter specifies the maximum number of
results that can be buffered before scan results are lost.
This contributes to a static memory allocation that will be greater
than CONFIG_BLUETOOTH_MAXSCANDATA * CONFIG_BLUETOOTH_MAXSCANRESULT
config BLUETOOTH_BUFFER_PREALLOC
int "Number of pre-allocated buffer structures"
default 20
---help---
This specifies the total number of preallocated buffer structures.
This is for performance optimization. If additional buffer structures
are needed, they will be allocated dynamically at some loss of
performance.
config BLUETOOTH_BUFFER_IRQRESERVE
int "Reserved pre-allocated primitive structures"
default 0
---help---
If buffer structures can be allocated from interrupt handlers, then
this specifies the number of pre-allocated structures that are
reserved for for use only by interrupt handlers. This may be set
zero to reserve no buffers for interrupt handlers. In that case,
the allocation will fail if tasking logic has allocated them all.
Interrupt logic will first attempt to allocate from the general,
pre-allocated buffer pool that will contain up to (size
CONFIG_BLUETOOTH_BUFFER_PREALLOC - BLUETOOTH_BUFFER_IRQRESERVE)
entries. If that fails, then it will try to take a buffer from
the reserve (size CONFIG_BLUETOOTH_BUFFER_IRQRESERVE).
Non-interrupt logic will also first attempt to allocate from the
general, pre-allocated buffer pool. If that fails, it will
dynamically allocate the buffer with an additional cost in
performance.
NOTE: The Bluetooth stack never allocates buffers from the
interrupt level. This setting only needs to be non-zero if your
low-level Bluetooth driver needs to do such allocations.
menu "Kernel Thread Configuration"
menu "Kernel Thread Configuration"
config BLUETOOTH_RXTHREAD_STACKSIZE
config BLUETOOTH_RXTHREAD_STACKSIZE
...
...
wireless/bluetooth/Make.defs
View file @
80ec46a6
...
@@ -38,7 +38,8 @@ ifeq ($(CONFIG_WIRELESS_BLUETOOTH),y)
...
@@ -38,7 +38,8 @@ ifeq ($(CONFIG_WIRELESS_BLUETOOTH),y)
# Include Bluetooth support
# Include Bluetooth support
CSRCS += bt_atomic.c bt_att.c bt_buf.c bt_conn.c bt_gatt.c bt_hcicore.c
CSRCS += bt_atomic.c bt_att.c bt_buf.c bt_conn.c bt_gatt.c bt_hcicore.c
CSRCS += bt_keys.c bt_l2cap.c bt_queue.c bt_smp.c bt_uuid.c
CSRCS += bt_ioctl.c bt_keys.c bt_l2cap.c bt_netdev.c bt_queue.c bt_smp.c
CSRCS += bt_uuid.c
DEPPATH += --dep-path bluetooth
DEPPATH += --dep-path bluetooth
VPATH += :bluetooth
VPATH += :bluetooth
...
...
wireless/bluetooth/bt_atomic.c
View file @
80ec46a6
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
#include
"bt_atomic.h"
#include
"bt_atomic.h"
/****************************************************************************
/****************************************************************************
* Public Function
* Public Function
s
****************************************************************************/
****************************************************************************/
#ifndef CONFIG_HAVE_INLINE
#ifndef CONFIG_HAVE_INLINE
...
...
wireless/bluetooth/bt_atomic.h
View file @
80ec46a6
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
typedef
uint8_t
bt_atomic_t
;
typedef
uint8_t
bt_atomic_t
;
/****************************************************************************
/****************************************************************************
* Inline
Prototype
s
* Inline
Function
s
****************************************************************************/
****************************************************************************/
#ifdef CONFIG_HAVE_INLINE
#ifdef CONFIG_HAVE_INLINE
...
...
wireless/bluetooth/bt_att.c
View file @
80ec46a6
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
#include
<errno.h>
#include
<errno.h>
#include
<debug.h>
#include
<debug.h>
#include
<nuttx/net/bluetooth.h>
#include
<nuttx/wireless/bt_hci.h>
#include
<nuttx/wireless/bt_hci.h>
#include
<nuttx/wireless/bt_core.h>
#include
<nuttx/wireless/bt_core.h>
#include
<nuttx/wireless/bt_uuid.h>
#include
<nuttx/wireless/bt_uuid.h>
...
@@ -276,10 +277,12 @@ static uint8_t att_handle_read_mult_rsp(FAR struct bt_conn_s *conn,
...
@@ -276,10 +277,12 @@ static uint8_t att_handle_read_mult_rsp(FAR struct bt_conn_s *conn,
FAR
struct
bt_buf_s
*
buf
);
FAR
struct
bt_buf_s
*
buf
);
static
uint8_t
att_handle_write_rsp
(
FAR
struct
bt_conn_s
*
conn
,
static
uint8_t
att_handle_write_rsp
(
FAR
struct
bt_conn_s
*
conn
,
FAR
struct
bt_buf_s
*
buf
);
FAR
struct
bt_buf_s
*
buf
);
static
void
bt_att_recv
(
FAR
struct
bt_conn_s
*
conn
,
static
void
bt_att_receive
(
FAR
struct
bt_conn_s
*
conn
,
FAR
struct
bt_buf_s
*
buf
);
FAR
struct
bt_buf_s
*
buf
,
FAR
void
*
context
,
uint16_t
cid
);
static
void
bt_att_connected
(
FAR
struct
bt_conn_s
*
conn
);
static
void
bt_att_connected
(
FAR
struct
bt_conn_s
*
conn
,
FAR
void
*
context
,
static
void
bt_att_disconnected
(
FAR
struct
bt_conn_s
*
conn
);
uint16_t
cid
);
static
void
bt_att_disconnected
(
FAR
struct
bt_conn_s
*
conn
,
FAR
void
*
context
,
uint16_t
cid
);
/****************************************************************************
/****************************************************************************
* Private Data
* Private Data
...
@@ -451,7 +454,7 @@ static void send_err_rsp(struct bt_conn_s *conn, uint8_t req, uint16_t handle,
...
@@ -451,7 +454,7 @@ static void send_err_rsp(struct bt_conn_s *conn, uint8_t req, uint16_t handle,
return
;
return
;
}
}
rsp
=
bt_buf_
ad
d
(
buf
,
sizeof
(
*
rsp
));
rsp
=
bt_buf_
exten
d
(
buf
,
sizeof
(
*
rsp
));
rsp
->
request
=
req
;
rsp
->
request
=
req
;
rsp
->
handle
=
BT_HOST2LE16
(
handle
);
rsp
->
handle
=
BT_HOST2LE16
(
handle
);
rsp
->
error
=
err
;
rsp
->
error
=
err
;
...
@@ -499,7 +502,7 @@ static uint8_t att_mtu_req(struct bt_conn_s *conn, struct bt_buf_s *data)
...
@@ -499,7 +502,7 @@ static uint8_t att_mtu_req(struct bt_conn_s *conn, struct bt_buf_s *data)
att
->
mtu
=
mtu
;
att
->
mtu
=
mtu
;
rsp
=
bt_buf_
ad
d
(
buf
,
sizeof
(
*
rsp
));
rsp
=
bt_buf_
exten
d
(
buf
,
sizeof
(
*
rsp
));
rsp
->
mtu
=
BT_HOST2LE16
(
mtu
);
rsp
->
mtu
=
BT_HOST2LE16
(
mtu
);
bt_l2cap_send
(
conn
,
BT_L2CAP_CID_ATT
,
buf
);
bt_l2cap_send
(
conn
,
BT_L2CAP_CID_ATT
,
buf
);
...
@@ -557,9 +560,9 @@ static uint8_t att_mtu_rsp(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
...
@@ -557,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.
* L2CAP, ACL and driver headers.
*/
*/
maxmtu
=
B
T_BUF_MAX_DATA
-
(
sizeof
(
struct
bt_l2cap_hdr_s
)
+
maxmtu
=
B
LUETOOTH_MAX_FRAMELEN
-
(
sizeof
(
struct
bt_l2cap_hdr_s
)
+
sizeof
(
struct
bt_hci_acl_hdr_s
)
+
sizeof
(
struct
bt_hci_acl_hdr_s
)
+
g_btdev
.
dev
->
head_reserve
);
g_btdev
.
dev
->
head_reserve
);
if
(
mtu
>
maxmtu
)
if
(
mtu
>
maxmtu
)
{
{
mtu
=
maxmtu
;
mtu
=
maxmtu
;
...
@@ -610,7 +613,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -610,7 +613,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
if
(
!
data
->
rsp
)
if
(
!
data
->
rsp
)
{
{
data
->
rsp
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
rsp
));
data
->
rsp
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
rsp
));
data
->
rsp
->
format
=
(
attr
->
uuid
->
type
==
BT_UUID_16
)
?
data
->
rsp
->
format
=
(
attr
->
uuid
->
type
==
BT_UUID_16
)
?
BT_ATT_INFO_16
:
BT_ATT_INFO_128
;
BT_ATT_INFO_16
:
BT_ATT_INFO_128
;
}
}
...
@@ -625,7 +628,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -625,7 +628,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
/* Fast foward to next item position */
/* Fast foward to next item position */
data
->
u
.
info16
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
u
.
info16
));
data
->
u
.
info16
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
u
.
info16
));
data
->
u
.
info16
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
u
.
info16
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
u
.
info16
->
uuid
=
BT_HOST2LE16
(
attr
->
uuid
->
u
.
u16
);
data
->
u
.
info16
->
uuid
=
BT_HOST2LE16
(
attr
->
uuid
->
u
.
u16
);
...
@@ -640,7 +643,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -640,7 +643,7 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
/* Fast foward to next item position */
/* Fast foward to next item position */
data
->
u
.
info128
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
u
.
info128
));
data
->
u
.
info128
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
u
.
info128
));
data
->
u
.
info128
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
u
.
info128
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
memcpy
(
data
->
u
.
info128
->
uuid
,
attr
->
uuid
->
u
.
u128
,
memcpy
(
data
->
u
.
info128
->
uuid
,
attr
->
uuid
->
u
.
u128
,
sizeof
(
data
->
u
.
info128
->
uuid
));
sizeof
(
data
->
u
.
info128
->
uuid
));
...
@@ -670,7 +673,7 @@ static uint8_t att_find_info_rsp(FAR struct bt_conn_s *conn,
...
@@ -670,7 +673,7 @@ static uint8_t att_find_info_rsp(FAR struct bt_conn_s *conn,
if
(
!
data
.
rsp
)
if
(
!
data
.
rsp
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond since handle is set */
/* Respond since handle is set */
...
@@ -759,7 +762,7 @@ static uint8_t find_type_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -759,7 +762,7 @@ static uint8_t find_type_cb(FAR const struct bt_gatt_attr_s *attr,
/* Fast foward to next item position */
/* Fast foward to next item position */
data
->
group
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
group
));
data
->
group
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
group
));
data
->
group
->
start_handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
group
->
start_handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
group
->
end_handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
group
->
end_handle
=
BT_HOST2LE16
(
attr
->
handle
);
...
@@ -791,7 +794,7 @@ static uint8_t att_find_type_rsp(FAR struct bt_conn_s *conn,
...
@@ -791,7 +794,7 @@ static uint8_t att_find_type_rsp(FAR struct bt_conn_s *conn,
if
(
!
data
.
group
)
if
(
!
data
.
group
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond since handle is set */
/* Respond since handle is set */
...
@@ -819,7 +822,7 @@ static uint8_t att_find_type_req(FAR struct bt_conn_s *conn,
...
@@ -819,7 +822,7 @@ static uint8_t att_find_type_req(FAR struct bt_conn_s *conn,
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
type
=
BT_LE162HOST
(
req
->
type
);
type
=
BT_LE162HOST
(
req
->
type
);
value
=
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
value
=
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
wlinfo
(
"start_handle 0x%04x end_handle 0x%04x type %u
\n
"
,
start_handle
,
wlinfo
(
"start_handle 0x%04x end_handle 0x%04x type %u
\n
"
,
start_handle
,
end_handle
,
type
);
end_handle
,
type
);
...
@@ -858,7 +861,7 @@ static bool uuid_create(FAR struct bt_uuid_s *uuid, FAR struct bt_buf_s *data)
...
@@ -858,7 +861,7 @@ static bool uuid_create(FAR struct bt_uuid_s *uuid, FAR struct bt_buf_s *data)
{
{
case
2
:
case
2
:
uuid
->
type
=
BT_UUID_16
;
uuid
->
type
=
BT_UUID_16
;
uuid
->
u
.
u16
=
bt_buf_
pull
_le16
(
data
);
uuid
->
u
.
u16
=
bt_buf_
get
_le16
(
data
);
return
true
;
return
true
;
case
16
:
case
16
:
...
@@ -888,7 +891,7 @@ static uint8_t read_type_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -888,7 +891,7 @@ static uint8_t read_type_cb(FAR const struct bt_gatt_attr_s *attr,
/* Fast foward to next item position */
/* Fast foward to next item position */
data
->
item
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
item
));
data
->
item
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
item
));
data
->
item
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
data
->
item
->
handle
=
BT_HOST2LE16
(
attr
->
handle
);
/* Read attribute value and store in the buffer */
/* Read attribute value and store in the buffer */
...
@@ -916,7 +919,7 @@ static uint8_t read_type_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -916,7 +919,7 @@ static uint8_t read_type_cb(FAR const struct bt_gatt_attr_s *attr,
return
BT_GATT_ITER_STOP
;
return
BT_GATT_ITER_STOP
;
}
}
bt_buf_
ad
d
(
data
->
buf
,
read
);
bt_buf_
exten
d
(
data
->
buf
,
read
);
/* Return true only if there are still space for more items */
/* Return true only if there are still space for more items */
...
@@ -941,14 +944,14 @@ static uint8_t att_read_type_rsp(FAR struct bt_conn_s *conn,
...
@@ -941,14 +944,14 @@ static uint8_t att_read_type_rsp(FAR struct bt_conn_s *conn,
}
}
data
.
uuid
=
uuid
;
data
.
uuid
=
uuid
;
data
.
rsp
=
bt_buf_
ad
d
(
data
.
buf
,
sizeof
(
*
data
.
rsp
));
data
.
rsp
=
bt_buf_
exten
d
(
data
.
buf
,
sizeof
(
*
data
.
rsp
));
data
.
rsp
->
len
=
0
;
data
.
rsp
->
len
=
0
;
bt_gatt_foreach_attr
(
start_handle
,
end_handle
,
read_type_cb
,
&
data
);
bt_gatt_foreach_attr
(
start_handle
,
end_handle
,
read_type_cb
,
&
data
);
if
(
!
data
.
rsp
->
len
)
if
(
!
data
.
rsp
->
len
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Response here since handle is set */
/* Response here since handle is set */
...
@@ -981,7 +984,7 @@ static uint8_t att_read_type_req(FAR struct bt_conn_s *conn,
...
@@ -981,7 +984,7 @@ static uint8_t att_read_type_req(FAR struct bt_conn_s *conn,
req
=
(
FAR
void
*
)
data
->
data
;
req
=
(
FAR
void
*
)
data
->
data
;
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
if
(
!
uuid_create
(
&
uuid
,
data
))
if
(
!
uuid_create
(
&
uuid
,
data
))
{
{
...
@@ -1062,7 +1065,7 @@ static uint8_t read_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -1062,7 +1065,7 @@ static uint8_t read_cb(FAR const struct bt_gatt_attr_s *attr,
wlinfo
(
"handle 0x%04x
\n
"
,
attr
->
handle
);
wlinfo
(
"handle 0x%04x
\n
"
,
attr
->
handle
);
data
->
rsp
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
rsp
));
data
->
rsp
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
rsp
));
if
(
!
attr
->
read
)
if
(
!
attr
->
read
)
{
{
...
@@ -1088,7 +1091,7 @@ static uint8_t read_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -1088,7 +1091,7 @@ static uint8_t read_cb(FAR const struct bt_gatt_attr_s *attr,
return
BT_GATT_ITER_STOP
;
return
BT_GATT_ITER_STOP
;
}
}
bt_buf_
ad
d
(
data
->
buf
,
read
);
bt_buf_
exten
d
(
data
->
buf
,
read
);
return
BT_GATT_ITER_CONTINUE
;
return
BT_GATT_ITER_CONTINUE
;
}
}
...
@@ -1119,7 +1122,7 @@ static uint8_t att_read_rsp(FAR struct bt_conn_s *conn, uint8_t op,
...
@@ -1119,7 +1122,7 @@ static uint8_t att_read_rsp(FAR struct bt_conn_s *conn, uint8_t op,
if
(
data
.
err
)
if
(
data
.
err
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond here since handle is set */
/* Respond here since handle is set */
...
@@ -1181,7 +1184,7 @@ static uint8_t att_read_mult_req(FAR struct bt_conn_s *conn,
...
@@ -1181,7 +1184,7 @@ static uint8_t att_read_mult_req(FAR struct bt_conn_s *conn,
while
(
buf
->
len
>=
sizeof
(
uint16_t
))
while
(
buf
->
len
>=
sizeof
(
uint16_t
))
{
{
handle
=
bt_buf_
pull
_le16
(
buf
);
handle
=
bt_buf_
get
_le16
(
buf
);
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
...
@@ -1191,7 +1194,7 @@ static uint8_t att_read_mult_req(FAR struct bt_conn_s *conn,
...
@@ -1191,7 +1194,7 @@ static uint8_t att_read_mult_req(FAR struct bt_conn_s *conn,
if
(
data
.
err
)
if
(
data
.
err
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond here since handle is set */
/* Respond here since handle is set */
...
@@ -1235,7 +1238,7 @@ static uint8_t read_group_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -1235,7 +1238,7 @@ static uint8_t read_group_cb(FAR const struct bt_gatt_attr_s *attr,
/* Fast forward to next group position */
/* Fast forward to next group position */
data
->
group
=
bt_buf_
ad
d
(
data
->
buf
,
sizeof
(
*
data
->
group
));
data
->
group
=
bt_buf_
exten
d
(
data
->
buf
,
sizeof
(
*
data
->
group
));
/* Initialize group handle range */
/* Initialize group handle range */
...
@@ -1267,7 +1270,7 @@ static uint8_t read_group_cb(FAR const struct bt_gatt_attr_s *attr,
...
@@ -1267,7 +1270,7 @@ static uint8_t read_group_cb(FAR const struct bt_gatt_attr_s *attr,
return
false
;
return
false
;
}
}
bt_buf_
ad
d
(
data
->
buf
,
read
);
bt_buf_
exten
d
(
data
->
buf
,
read
);
/* Continue to find the end handle */
/* Continue to find the end handle */
...
@@ -1292,14 +1295,14 @@ static uint8_t att_read_group_rsp(FAR struct bt_conn_s *conn,
...
@@ -1292,14 +1295,14 @@ static uint8_t att_read_group_rsp(FAR struct bt_conn_s *conn,
data
.
conn
=
conn
;
data
.
conn
=
conn
;
data
.
uuid
=
uuid
;
data
.
uuid
=
uuid
;
data
.
rsp
=
bt_buf_
ad
d
(
data
.
buf
,
sizeof
(
*
data
.
rsp
));
data
.
rsp
=
bt_buf_
exten
d
(
data
.
buf
,
sizeof
(
*
data
.
rsp
));
data
.
rsp
->
len
=
0
;
data
.
rsp
->
len
=
0
;
bt_gatt_foreach_attr
(
start_handle
,
end_handle
,
read_group_cb
,
&
data
);
bt_gatt_foreach_attr
(
start_handle
,
end_handle
,
read_group_cb
,
&
data
);
if
(
!
data
.
rsp
->
len
)
if
(
!
data
.
rsp
->
len
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond here since handle is set */
/* Respond here since handle is set */
...
@@ -1332,7 +1335,7 @@ static uint8_t att_read_group_req(FAR struct bt_conn_s *conn,
...
@@ -1332,7 +1335,7 @@ static uint8_t att_read_group_req(FAR struct bt_conn_s *conn,
req
=
(
FAR
void
*
)
data
->
data
;
req
=
(
FAR
void
*
)
data
->
data
;
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
start_handle
=
BT_LE162HOST
(
req
->
start_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
end_handle
=
BT_LE162HOST
(
req
->
end_handle
);
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
if
(
!
uuid_create
(
&
uuid
,
data
))
if
(
!
uuid_create
(
&
uuid
,
data
))
{
{
...
@@ -1456,7 +1459,7 @@ static uint8_t att_write_rsp(FAR struct bt_conn_s *conn, uint8_t op,
...
@@ -1456,7 +1459,7 @@ static uint8_t att_write_rsp(FAR struct bt_conn_s *conn, uint8_t op,
{
{
if
(
rsp
)
if
(
rsp
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
/* Respond here since handle is set */
/* Respond here since handle is set */
...
@@ -1474,10 +1477,10 @@ static uint8_t att_write_rsp(FAR struct bt_conn_s *conn, uint8_t op,
...
@@ -1474,10 +1477,10 @@ static uint8_t att_write_rsp(FAR struct bt_conn_s *conn, uint8_t op,
{
{
FAR
struct
bt_att_prepare_write_rsp_s
*
wrrsp
;
FAR
struct
bt_att_prepare_write_rsp_s
*
wrrsp
;
wrrsp
=
bt_buf_
ad
d
(
data
.
buf
,
sizeof
(
*
wrrsp
));
wrrsp
=
bt_buf_
exten
d
(
data
.
buf
,
sizeof
(
*
wrrsp
));
wrrsp
->
handle
=
BT_HOST2LE16
(
handle
);
wrrsp
->
handle
=
BT_HOST2LE16
(
handle
);
wrrsp
->
offset
=
BT_HOST2LE16
(
offset
);
wrrsp
->
offset
=
BT_HOST2LE16
(
offset
);
bt_buf_
ad
d
(
data
.
buf
,
len
);
bt_buf_
exten
d
(
data
.
buf
,
len
);
memcpy
(
wrrsp
->
value
,
value
,
len
);
memcpy
(
wrrsp
->
value
,
value
,
len
);
}
}
...
@@ -1496,7 +1499,7 @@ static uint8_t att_write_req(FAR struct bt_conn_s *conn,
...
@@ -1496,7 +1499,7 @@ static uint8_t att_write_req(FAR struct bt_conn_s *conn,
req
=
(
FAR
void
*
)
data
->
data
;
req
=
(
FAR
void
*
)
data
->
data
;
handle
=
BT_LE162HOST
(
req
->
handle
);
handle
=
BT_LE162HOST
(
req
->
handle
);
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
...
@@ -1514,7 +1517,7 @@ static uint8_t att_prepare_write_req(FAR struct bt_conn_s *conn,
...
@@ -1514,7 +1517,7 @@ static uint8_t att_prepare_write_req(FAR struct bt_conn_s *conn,
req
=
(
FAR
void
*
)
data
->
data
;
req
=
(
FAR
void
*
)
data
->
data
;
handle
=
BT_LE162HOST
(
req
->
handle
);
handle
=
BT_LE162HOST
(
req
->
handle
);
offset
=
BT_LE162HOST
(
req
->
offset
);
offset
=
BT_LE162HOST
(
req
->
offset
);
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
wlinfo
(
"handle 0x%04x offset %u
\n
"
,
handle
,
offset
);
wlinfo
(
"handle 0x%04x offset %u
\n
"
,
handle
,
offset
);
...
@@ -1577,7 +1580,7 @@ static uint8_t att_exec_write_rsp(FAR struct bt_conn_s *conn, uint8_t flags)
...
@@ -1577,7 +1580,7 @@ static uint8_t att_exec_write_rsp(FAR struct bt_conn_s *conn, uint8_t flags)
if
(
data
.
err
)
if
(
data
.
err
)
{
{
bt_buf_
put
(
data
.
buf
);
bt_buf_
release
(
data
.
buf
);
return
data
.
err
;
return
data
.
err
;
}
}
...
@@ -1628,7 +1631,7 @@ static uint8_t att_signed_write_cmd(FAR struct bt_conn_s *conn,
...
@@ -1628,7 +1631,7 @@ static uint8_t att_signed_write_cmd(FAR struct bt_conn_s *conn,
req
=
(
FAR
void
*
)
data
->
data
;
req
=
(
FAR
void
*
)
data
->
data
;
handle
=
BT_LE162HOST
(
req
->
handle
);
handle
=
BT_LE162HOST
(
req
->
handle
);
bt_buf_
pull
(
data
,
sizeof
(
*
req
));
bt_buf_
consume
(
data
,
sizeof
(
*
req
));
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
wlinfo
(
"handle 0x%04x
\n
"
,
handle
);
...
@@ -1712,7 +1715,9 @@ static uint8_t att_handle_write_rsp(FAR struct bt_conn_s *conn,
...
@@ -1712,7 +1715,9 @@ static uint8_t att_handle_write_rsp(FAR struct bt_conn_s *conn,
return
att_handle_rsp
(
conn
,
buf
->
data
,
buf
->
len
,
0
);
return
att_handle_rsp
(
conn
,
buf
->
data
,
buf
->
len
,
0
);
}
}
static
void
bt_att_recv
(
FAR
struct
bt_conn_s
*
conn
,
FAR
struct
bt_buf_s
*
buf
)
static
void
bt_att_receive
(
FAR
struct
bt_conn_s
*
conn
,
FAR
struct
bt_buf_s
*
buf
,
FAR
void
*
context
,
uint16_t
cid
)
{
{
FAR
struct
bt_att_hdr_s
*
hdr
=
(
FAR
void
*
)
buf
->
data
;
FAR
struct
bt_att_hdr_s
*
hdr
=
(
FAR
void
*
)
buf
->
data
;
uint8_t
err
=
BT_ATT_ERR_NOT_SUPPORTED
;
uint8_t
err
=
BT_ATT_ERR_NOT_SUPPORTED
;
...
@@ -1728,7 +1733,7 @@ static void bt_att_recv(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
...
@@ -1728,7 +1733,7 @@ static void bt_att_recv(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
wlinfo
(
"Received ATT code 0x%02x len %u
\n
"
,
hdr
->
code
,
buf
->
len
);
wlinfo
(
"Received ATT code 0x%02x len %u
\n
"
,
hdr
->
code
,
buf
->
len
);
bt_buf_
pull
(
buf
,
sizeof
(
*
hdr
));
bt_buf_
consume
(
buf
,
sizeof
(
*
hdr
));
for
(
i
=
0
;
i
<
NHANDLERS
;
i
++
)
for
(
i
=
0
;
i
<
NHANDLERS
;
i
++
)
{
{
...
@@ -1763,10 +1768,11 @@ static void bt_att_recv(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
...
@@ -1763,10 +1768,11 @@ static void bt_att_recv(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
}
}
done:
done:
bt_buf_
put
(
buf
);
bt_buf_
release
(
buf
);
}
}
static
void
bt_att_connected
(
FAR
struct
bt_conn_s
*
conn
)
static
void
bt_att_connected
(
FAR
struct
bt_conn_s
*
conn
,
FAR
void
*
context
,
uint16_t
cid
)
{
{
int
i
;
int
i
;
...
@@ -1789,7 +1795,8 @@ static void bt_att_connected(FAR struct bt_conn_s *conn)
...
@@ -1789,7 +1795,8 @@ static void bt_att_connected(FAR struct bt_conn_s *conn)
wlerr
(
"ERROR: No available ATT context for conn %p
\n
"
,
conn
);
wlerr
(
"ERROR: No available ATT context for conn %p
\n
"
,
conn
);
}
}
static
void
bt_att_disconnected
(
FAR
struct
bt_conn_s
*
conn
)
static
void
bt_att_disconnected
(
FAR
struct
bt_conn_s
*
conn
,
FAR
void
*
context
,
uint16_t
cid
)
{
{
FAR
struct
bt_att_s
*
att
=
conn
->
att
;
FAR
struct
bt_att_s
*
att
=
conn
->
att
;
...
@@ -1809,12 +1816,12 @@ static void bt_att_disconnected(FAR struct bt_conn_s *conn)
...
@@ -1809,12 +1816,12 @@ static void bt_att_disconnected(FAR struct bt_conn_s *conn)
* Public Functions
* Public Functions
****************************************************************************/
****************************************************************************/
void
bt_att_init
(
void
)
void
bt_att_init
ialize
(
void
)
{
{
static
struct
bt_l2cap_chan_s
chan
=
static
struct
bt_l2cap_chan_s
chan
=
{
{
.
cid
=
BT_L2CAP_CID_ATT
,
.
cid
=
BT_L2CAP_CID_ATT
,
.
rec
v
=
bt_att_rec
v
,
.
rec
eive
=
bt_att_rec
eive
,
.
connected
=
bt_att_connected
,
.
connected
=
bt_att_connected
,
.
disconnected
=
bt_att_disconnected
,
.
disconnected
=
bt_att_disconnected
,
};
};
...
@@ -1841,7 +1848,7 @@ FAR struct bt_buf_s *bt_att_create_pdu(FAR struct bt_conn_s *conn, uint8_t op,
...
@@ -1841,7 +1848,7 @@ FAR struct bt_buf_s *bt_att_create_pdu(FAR struct bt_conn_s *conn, uint8_t op,
return
NULL
;
return
NULL
;
}
}
hdr
=
bt_buf_
ad
d
(
buf
,
sizeof
(
*
hdr
));
hdr
=
bt_buf_
exten
d
(
buf
,
sizeof
(
*
hdr
));
hdr
->
code
=
op
;
hdr
->
code
=
op
;
return
buf
;
return
buf
;
...
...
Prev
1
2
3
4
5
Next