Network: L2: remove IPSP
Remove IPSP support from the tree. It has no maintainers, and is regularly broken. The fact that it's nontrivial to set-up in linux makes it hard to fix reported issues. Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This commit is contained in:
parent
5997815352
commit
e3ff993000
|
@ -20,37 +20,6 @@ endchoice
|
|||
|
||||
endif # BT
|
||||
|
||||
if NETWORKING
|
||||
|
||||
# Re-create the NET_L2_BT dependencies here
|
||||
config BT
|
||||
default y
|
||||
|
||||
config BT_PERIPHERAL
|
||||
default BT
|
||||
|
||||
config BT_CENTRAL
|
||||
default BT
|
||||
|
||||
config BT_SMP
|
||||
default BT
|
||||
|
||||
config BT_L2CAP_DYNAMIC_CHANNEL
|
||||
default BT
|
||||
|
||||
# BT is the only onboard network iface, so use it for IP networking
|
||||
# if it's enabled
|
||||
|
||||
config NET_L2_BT
|
||||
depends on NET_IPV6
|
||||
default BT
|
||||
|
||||
config NET_L2_BT_ZEP1656
|
||||
depends on NET_IPV6
|
||||
default BT
|
||||
|
||||
endif # NETWORKING
|
||||
|
||||
endif # BOARD_96B_CARBON_STM32F401XE
|
||||
|
||||
if BOARD_96B_CARBON_NRF51822
|
||||
|
|
|
@ -338,16 +338,16 @@ in general, see :ref:`build_an_application`.
|
|||
|
||||
#. Install the dfu-util flashing app, as described above.
|
||||
|
||||
#. Build and flash the ``samples/bluetooth/ipsp`` application for
|
||||
#. Build and flash the ``samples/bluetooth/peripheral_hr`` application for
|
||||
96b_carbon. See the instructions above for how to put your board
|
||||
into DFU mode if you haven't done this before:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/bluetooth/ipsp
|
||||
:zephyr-app: samples/bluetooth/peripheral_hr
|
||||
:board: 96b_carbon/stm32f401xe
|
||||
:goals: build flash
|
||||
|
||||
#. Refer to the instructions in :ref:`bluetooth-ipsp-sample` for how
|
||||
#. Refer to the instructions in :ref:`peripheral_hr` for how
|
||||
to verify functionality.
|
||||
|
||||
Congratulations! Your 96Boards Carbon now has Bluetooth
|
||||
|
|
|
@ -78,10 +78,6 @@ grown to be mature and feature-rich, as can be seen in the section below.
|
|||
* Foundation Models included
|
||||
* Highly configurable, fits as small as 16k RAM devices
|
||||
|
||||
* IPSP/6LoWPAN for IPv6 connectivity over Bluetooth LE
|
||||
|
||||
* IPSP node sample application
|
||||
|
||||
* Basic Bluetooth BR/EDR (Classic) support
|
||||
|
||||
* Generic Access Profile (GAP)
|
||||
|
|
|
@ -34,8 +34,8 @@ specified.
|
|||
|
||||
Zephyr supports both, native IEEE 802.15.4 and Thread, with 6LoWPAN. Zephyr's
|
||||
:ref:`thread_protocol_interface` implementation is based on `OpenThread
|
||||
<https://openthread.io/>`_. The IPv6 header compression in 6LoWPAN is shared
|
||||
among native IEEE 802.15.4 and the Bluetooth IPSP (IP support profile).
|
||||
<https://openthread.io/>`_. The IPv6 header compression in 6LoWPAN is used for
|
||||
native IEEE 802.15.4.
|
||||
|
||||
API Reference
|
||||
*************
|
||||
|
|
|
@ -50,9 +50,6 @@ setup the system:
|
|||
this option tells that the network application needs IPv6 router to exists
|
||||
before continuing. This means in practice that the application wants to wait
|
||||
until it receives IPv6 router advertisement message before continuing."
|
||||
":kconfig:option:`CONFIG_NET_CONFIG_BT_NODE`", "Enables application to operate in
|
||||
Bluetooth node mode which requires GATT service to be registered and start
|
||||
advertising as peripheral."
|
||||
|
||||
Sample usage
|
||||
************
|
||||
|
|
|
@ -24,10 +24,9 @@ object. The L2 layer dictates the API provided by the device driver,
|
|||
specific for that device, and optimized for working together.
|
||||
|
||||
Currently, there are L2 layers for :ref:`Ethernet <ethernet_interface>`,
|
||||
:ref:`IEEE 802.15.4 Soft-MAC <ieee802154_interface>`,
|
||||
:ref:`Bluetooth IPSP <bluetooth-ipsp-sample>`, :ref:`CANBUS <can_api>`,
|
||||
:ref:`OpenThread <thread_protocol_interface>`, Wi-Fi, and a dummy layer
|
||||
example that can be used as a template for writing a new one.
|
||||
:ref:`IEEE 802.15.4 Soft-MAC <ieee802154_interface>`, :ref:`CANBUS <can_api>`,
|
||||
:ref:`OpenThread <thread_protocol_interface>`, Wi-Fi, and a dummy layer example
|
||||
that can be used as a template for writing a new one.
|
||||
|
||||
L2 layer API
|
||||
************
|
||||
|
|
|
@ -32,13 +32,12 @@ can be disabled if not needed.
|
|||
* Multicast Listener Discovery v2 support
|
||||
(`RFC 3810 <https://tools.ietf.org/html/rfc3810>`_) is enabled by default.
|
||||
* IPv6 header compression (6lo) is available for IPv6 connectivity for
|
||||
Bluetooth IPSP (`RFC 7668 <https://tools.ietf.org/html/rfc7668>`_) and
|
||||
IEEE 802.15.4 networks (`RFC 4944 <https://tools.ietf.org/html/rfc4944>`_).
|
||||
|
||||
* **IPv4** The legacy IPv4 is supported by the networking stack. It cannot be
|
||||
used by IEEE 802.15.4 or Bluetooth IPSP as those network technologies support
|
||||
only IPv6. IPv4 can be used in Ethernet based networks. By default IPv4
|
||||
support is disabled.
|
||||
* **IPv4** The legacy IPv4 is supported by the networking stack. It
|
||||
cannot be used by IEEE 802.15.4 as this network technology supports
|
||||
only IPv6. IPv4 can be used in Ethernet based networks. By default
|
||||
IPv4 support is disabled.
|
||||
|
||||
* DHCP (Dynamic Host Configuration Protocol) client is supported
|
||||
(`RFC 2131 <https://tools.ietf.org/html/rfc2131>`_).
|
||||
|
@ -154,7 +153,7 @@ The networking stack source code tree is organized as follows:
|
|||
|
||||
``subsys/net/l2/``
|
||||
This is where the IP stack layer 2 code is located. This includes generic
|
||||
support for Bluetooth IPSP adaptation, Ethernet, IEEE 802.15.4 and Wi-Fi.
|
||||
support for Ethernet, IEEE 802.15.4 and Wi-Fi.
|
||||
|
||||
``subsys/net/lib/``
|
||||
Application-level protocols (DNS, MQTT, etc.) and additional stack
|
||||
|
|
|
@ -201,6 +201,10 @@ Networking
|
|||
|
||||
* :c:func:`lwm2m_set_bulk`
|
||||
|
||||
* IPSP:
|
||||
|
||||
* Removed IPSP support. ``CONFIG_NET_L2_BT`` does not exist anymore.
|
||||
|
||||
USB
|
||||
***
|
||||
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Bluetooth L2 stack public header
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_NET_BT_H_
|
||||
#define ZEPHYR_INCLUDE_NET_BT_H_
|
||||
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Management part definitions */
|
||||
|
||||
#define _NET_BT_LAYER NET_MGMT_LAYER_L2
|
||||
#define _NET_BT_CODE 0x155
|
||||
#define _NET_BT_BASE (NET_MGMT_IFACE_BIT | \
|
||||
NET_MGMT_LAYER(_NET_BT_LAYER) | \
|
||||
NET_MGMT_LAYER_CODE(_NET_BT_CODE))
|
||||
#define _NET_BT_EVENT (_NET_BT_BASE | NET_MGMT_EVENT_BIT)
|
||||
|
||||
enum net_request_bt_cmd {
|
||||
NET_REQUEST_BT_CMD_ADVERTISE = 1,
|
||||
NET_REQUEST_BT_CMD_CONNECT,
|
||||
NET_REQUEST_BT_CMD_SCAN,
|
||||
NET_REQUEST_BT_CMD_DISCONNECT,
|
||||
};
|
||||
|
||||
#define NET_REQUEST_BT_ADVERTISE \
|
||||
(_NET_BT_BASE | NET_REQUEST_BT_CMD_ADVERTISE)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_BT_ADVERTISE);
|
||||
|
||||
#define NET_REQUEST_BT_CONNECT \
|
||||
(_NET_BT_BASE | NET_REQUEST_BT_CMD_CONNECT)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_BT_CONNECT);
|
||||
|
||||
#define NET_REQUEST_BT_SCAN \
|
||||
(_NET_BT_BASE | NET_REQUEST_BT_CMD_SCAN)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_BT_SCAN);
|
||||
|
||||
enum net_event_bt_cmd {
|
||||
NET_EVENT_BT_CMD_SCAN_RESULT = 1,
|
||||
};
|
||||
|
||||
#define NET_EVENT_BT_SCAN_RESULT \
|
||||
(_NET_BT_EVENT | NET_EVENT_BT_CMD_SCAN_RESULT)
|
||||
|
||||
#define NET_REQUEST_BT_DISCONNECT \
|
||||
(_NET_BT_BASE | NET_REQUEST_BT_CMD_DISCONNECT)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_BT_DISCONNECT);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_NET_BT_H_ */
|
|
@ -1385,15 +1385,6 @@ static inline void net_ipv6_addr_create_iid(struct in6_addr *addr,
|
|||
addr->s6_addr[12] = 0xfe;
|
||||
memcpy(&addr->s6_addr[13], lladdr->addr + 3, 3);
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_ZEP1656)
|
||||
/* Workaround against older Linux kernel BT IPSP code.
|
||||
* This will be removed eventually.
|
||||
*/
|
||||
if (lladdr->type == NET_LINK_BLUETOOTH) {
|
||||
addr->s6_addr[8] ^= 0x02;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lladdr->type == NET_LINK_ETHERNET) {
|
||||
addr->s6_addr[8] ^= 0x02;
|
||||
}
|
||||
|
@ -1439,20 +1430,6 @@ static inline bool net_ipv6_addr_based_on_ll(const struct in6_addr *addr,
|
|||
(addr->s6_addr[8] ^ 0x02) == lladdr->addr[0]) {
|
||||
return true;
|
||||
}
|
||||
} else if (lladdr->type == NET_LINK_BLUETOOTH) {
|
||||
if (!memcmp(&addr->s6_addr[9], &lladdr->addr[1], 2) &&
|
||||
!memcmp(&addr->s6_addr[13], &lladdr->addr[3], 3) &&
|
||||
addr->s6_addr[11] == 0xff &&
|
||||
addr->s6_addr[12] == 0xfe
|
||||
#if defined(CONFIG_NET_L2_BT_ZEP1656)
|
||||
/* Workaround against older Linux kernel BT IPSP
|
||||
* code. This will be removed eventually.
|
||||
*/
|
||||
&& (addr->s6_addr[8] ^ 0x02) == lladdr->addr[0]
|
||||
#endif
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -116,12 +116,6 @@ NET_L2_DECLARE_PUBLIC(PPP_L2);
|
|||
NET_L2_DECLARE_PUBLIC(IEEE802154_L2);
|
||||
#endif /* CONFIG_NET_L2_IEEE802154 */
|
||||
|
||||
#ifdef CONFIG_NET_L2_BT
|
||||
#define BLUETOOTH_L2 BLUETOOTH
|
||||
#define BLUETOOTH_L2_CTX_TYPE void*
|
||||
NET_L2_DECLARE_PUBLIC(BLUETOOTH_L2);
|
||||
#endif /* CONFIG_NET_L2_BT */
|
||||
|
||||
#ifdef CONFIG_NET_L2_OPENTHREAD
|
||||
#define OPENTHREAD_L2 OPENTHREAD
|
||||
NET_L2_DECLARE_PUBLIC(OPENTHREAD_L2);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(ipsp)
|
||||
|
||||
target_sources(app PRIVATE
|
||||
src/main.c
|
||||
)
|
|
@ -1,216 +0,0 @@
|
|||
.. _bluetooth-ipsp-sample:
|
||||
|
||||
Bluetooth: IPSP Sample
|
||||
######################
|
||||
|
||||
Overview
|
||||
********
|
||||
Application demonstrating the IPSP (Internet Protocol Support Profile) Node
|
||||
role. IPSP is the Bluetooth profile that underneath utilizes 6LoWPAN, i.e. gives
|
||||
you IPv6 connectivity over BLE.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
This sample can be found under :zephyr_file:`samples/bluetooth/ipsp` in the
|
||||
Zephyr tree.
|
||||
Sample can be built and executed for the nRF52840 DK NRF52840 as follows:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/bluetooth/ipsp
|
||||
:board: nrf52840dk/nrf52840
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
To build a debug version, with logging and shell support, use the config file
|
||||
:file:`prj_dbg.conf`:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/bluetooth/ipsp
|
||||
:board: nrf52840dk/nrf52840
|
||||
:conf: prj_dbg.conf
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
Building and Running for Linux kernels released before 4.12
|
||||
===========================================================
|
||||
.. note::
|
||||
|
||||
For hosts using kernels released before 4.12,
|
||||
option :kconfig:option:`CONFIG_NET_L2_BT_ZEP1656`
|
||||
must be selected. For more information, see :github:`Zephyr issue #3111
|
||||
<3111>`.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/bluetooth/ipsp
|
||||
:board: nrf52840dk/nrf52840
|
||||
:conf: "prj_zep1656.conf"
|
||||
:goals: build flash
|
||||
:compact:
|
||||
|
||||
Testing with a Linux host
|
||||
=========================
|
||||
|
||||
Make sure the Linux kernel has been built with Bluetooth 6LoWPAN module
|
||||
(CONFIG_BT_6LOWPAN=y) then proceed to enable it with with the following commands
|
||||
(as root):
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# modprobe bluetooth_6lowpan
|
||||
# echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable
|
||||
|
||||
If you connected your board to a UART console, you will see an output similar to
|
||||
(may vary slightly by application and Zephyr versions):
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
[bt] [WRN] set_static_addr: Using temporary static random address
|
||||
[bt] [INF] show_dev_info: Identity: cb:af:14:57:d8:6e (random)
|
||||
[bt] [INF] show_dev_info: HCI: version 5.0 (0x09) revision 0x0000, manufacturer 0xffff
|
||||
[bt] [INF] show_dev_info: LMP: version 5.0 (0x09) subver 0xffff
|
||||
[bt] [WRN] bt_pub_key_gen: ECC HCI commands not available
|
||||
[ipsp] [INF] init_app: Run IPSP sample
|
||||
[ipsp] [INF] listen: Starting to wait
|
||||
|
||||
The output above shows the BLE address assigned to your board for the
|
||||
current session; the address will be different on subsequent sessions.
|
||||
|
||||
Alternatively, you may scan for your board on the host. The modern way to do
|
||||
that is using ``bluetoothctl`` utility (included in the recent versions of
|
||||
BlueZ package) and its ``scan on`` command:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ bluetoothctl
|
||||
[NEW] Controller A3:24:97:EB:D6:23 ubuntu-0 [default]
|
||||
[NEW] Device D7:5C:D6:18:14:87 Zephyr
|
||||
[NEW] Device E1:E7:F9:56:EC:06 Zephyr
|
||||
[NEW] Device C8:12:C5:08:86:E1 Zephyr
|
||||
[bluetooth]# scan on
|
||||
Discovery started
|
||||
[NEW] Device DC:98:FB:22:CA:3A Zephyr
|
||||
|
||||
When started, ``bluetoothctl`` shows all BLE (and likely, BT/EDR) devices it
|
||||
knows about. As discussed above, the IPSP uses static random addresses, so
|
||||
entries for previously connected devices, as shown above, can accumulate and
|
||||
become stale. You need to be extra careful to find an entry for the active
|
||||
address. The best approach may be to reset your board after issuing
|
||||
``scan on`` command. This way it will reinitialize with the BLE address
|
||||
which will be discovered after the command.
|
||||
|
||||
As an alternative to ``bluetoothctl``, you can use the legacy ``hcitool``
|
||||
utility which talks directly to hardware and always shows fresh scan results:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ sudo hcitool lescan
|
||||
LE Scan ...
|
||||
CB:AF:14:57:D8:6E (unknown)
|
||||
CB:AF:14:57:D8:6E Test IPSP node
|
||||
|
||||
After you have found the board's BLE address, connect to the board (as root):
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# echo "connect <bdaddr> <type>" > /sys/kernel/debug/bluetooth/6lowpan_control
|
||||
|
||||
Where ``<bdaddr>`` is the BLE address and ``<type>`` is BLE address type:
|
||||
1 for public address and 2 for random address. As you can see from
|
||||
the IPSP sample output above, it uses a static random address. So, with the
|
||||
sample output above, the command will be:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# echo "connect CB:AF:14:57:D8:6E 2" > /sys/kernel/debug/bluetooth/6lowpan_control
|
||||
|
||||
Once connected a dedicated interface will be created, usually bt0. You can verify this
|
||||
with the following command:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# ifconfig
|
||||
bt0 Link encap:UNSPEC HWaddr F8-2F-A8-FF-FE-EB-6D-8C-00-00-00-00-00-00-00-00
|
||||
inet6 addr: fe80::fa2f:a8ff:feeb:6d8c/64 Scope:Link
|
||||
UP POINTOPOINT RUNNING MULTICAST MTU:1280 Metric:1
|
||||
RX packets:2 errors:0 dropped:3 overruns:0 frame:0
|
||||
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
|
||||
collisions:0 txqueuelen:1000
|
||||
RX bytes:92 (92.0 B) TX bytes:233 (233.0 B)
|
||||
|
||||
As can be seen from the output, only a link-local IPv6 address was assigned
|
||||
to the interface.
|
||||
|
||||
At this point, you can test IPv6 connectivity (and discover your board's IPv6
|
||||
address) by pinging "All local-link nodes" IPv6 address:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# ping6 -I bt0 ff02::1
|
||||
PING ff02::1(ff02::1) from fe80::fa54:a8ff:feeb:218f bt0: 56 data bytes
|
||||
64 bytes from fe80::fa54:a8ff:feeb:218f: icmp_seq=1 ttl=64 time=0.088 ms
|
||||
64 bytes from fe80::c9af:14ff:fe57:d86e: icmp_seq=1 ttl=64 time=285 ms (DUP!)
|
||||
|
||||
For each ping packet, both your host and the BLE board send a reply. You
|
||||
can see the board's reply marked as ``(DUP!)``. You can ping the board
|
||||
directly with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# ping6 fe80::c9af:14ff:fe57:d86e%bt0
|
||||
PING fe80::c9af:14ff:fe57:d86e%bt0(fe80::c9af:14ff:fe57:d86e) 56 data bytes
|
||||
64 bytes from fe80::c9af:14ff:fe57:d86e: icmp_seq=1 ttl=64 time=177 ms
|
||||
64 bytes from fe80::c9af:14ff:fe57:d86e: icmp_seq=2 ttl=64 time=53.0 ms
|
||||
|
||||
Note that the command uses a "scoped IPv6 address", where the scope is
|
||||
defined by the networking interface, with ``%bt0`` appended in this case.
|
||||
A specification like that is an alternative to passing ``-I bt0`` to
|
||||
``ping6`` (and works with other networking tools like ``telnet``, ``nc``,
|
||||
``curl``, etc.)
|
||||
|
||||
While we can use a link-local address, it's not very convenient, as it must be
|
||||
scoped and will change on each run. Instead, the IPSP sample is configured with
|
||||
``2001:db8::1`` static address and we'll configure the host's interface to
|
||||
access that address by configuring ``bt0`` with the complementary address
|
||||
``2001:db8::2``:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# ip address add 2001:db8::2/64 dev bt0
|
||||
|
||||
Now we can ping the board's static address with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# ping6 2001:db8::1
|
||||
PING 2001:db8::1(2001:db8::1) 56 data bytes
|
||||
64 bytes from 2001:db8::1: icmp_seq=1 ttl=64 time=282 ms
|
||||
|
||||
The IPSP sample includes builtin echo server for UDP and TCP on a port 4242,
|
||||
which we can test with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ telnet 2001:db8::1 4242
|
||||
Trying 2001:db8::1...
|
||||
Connected to 2001:db8::1.
|
||||
Escape character is '^]'.
|
||||
test
|
||||
test
|
||||
test2
|
||||
test2
|
||||
^]
|
||||
telnet> quit
|
||||
Connection closed.
|
||||
|
||||
In the output above, first ``test`` line was typed, next was echoed back by
|
||||
the board. Likewise for ``test2``. To quit telnet tool, type Ctrl+], then
|
||||
"quit" at the prompt.
|
||||
|
||||
As an alternative to using well-known networking tools above, and also to
|
||||
test both TCP and UDP echo, you can use Zephyr's helper tool in the GitHub
|
||||
``zephyrproject-rtos/net-tools`` repository:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ echo-client -i bt0 <ip>
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
&lptmr1 {
|
||||
interrupt-parent = <&intmux0_ch2>;
|
||||
};
|
||||
|
||||
&intmux0_ch2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&intmux0_ch3 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&generic_fsk {
|
||||
interrupt-parent = <&intmux0_ch3>;
|
||||
status = "okay";
|
||||
};
|
|
@ -1,28 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Test IPSP node"
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
|
||||
CONFIG_NET_MAX_CONTEXTS=6
|
||||
|
||||
CONFIG_NET_CONFIG_AUTO_INIT=y
|
||||
CONFIG_NET_CONFIG_SETTINGS=y
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
|
||||
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
|
@ -1,33 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Test IPSP node"
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
|
||||
CONFIG_NET_MAX_CONTEXTS=6
|
||||
|
||||
CONFIG_NET_SHELL=y
|
||||
CONFIG_BT_SHELL=y
|
||||
|
||||
CONFIG_NET_CONFIG_AUTO_INIT=y
|
||||
CONFIG_NET_CONFIG_SETTINGS=y
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
|
||||
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
|
@ -1,29 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Test IPSP node"
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_L2_BT_ZEP1656=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
|
||||
CONFIG_NET_MAX_CONTEXTS=6
|
||||
|
||||
CONFIG_NET_CONFIG_AUTO_INIT=y
|
||||
CONFIG_NET_CONFIG_SETTINGS=y
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
|
||||
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
|
@ -1,25 +0,0 @@
|
|||
sample:
|
||||
name: Bluetooth IPSP Sample
|
||||
description: IPSP (Internet Protocol Support Profile) Node role sample
|
||||
tests:
|
||||
sample.bluetooth.ipsp:
|
||||
harness: bluetooth
|
||||
platform_allow:
|
||||
- qemu_x86
|
||||
- qemu_cortex_m3
|
||||
tags:
|
||||
- bluetooth
|
||||
- net
|
||||
integration_platforms:
|
||||
- qemu_x86
|
||||
sample.bluetooth.ipsp.zep1656:
|
||||
harness: bluetooth
|
||||
extra_args: CONF_FILE="prj_zep1656.conf"
|
||||
platform_allow:
|
||||
- qemu_x86
|
||||
- qemu_cortex_m3
|
||||
tags:
|
||||
- bluetooth
|
||||
- net
|
||||
integration_platforms:
|
||||
- qemu_x86
|
|
@ -1,323 +0,0 @@
|
|||
/* main.c - Application main entry point */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
||||
LOG_MODULE_REGISTER(ipsp);
|
||||
|
||||
/* Preventing log module registration in net_core.h */
|
||||
#define NET_LOG_ENABLED 0
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <zephyr/net/net_pkt.h>
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/net_core.h>
|
||||
#include <zephyr/net/net_context.h>
|
||||
#include <zephyr/net/udp.h>
|
||||
|
||||
/* Define my IP address where to expect messages */
|
||||
#define MY_IP6ADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
||||
#define MY_PREFIX_LEN 64
|
||||
|
||||
static struct in6_addr in6addr_my = MY_IP6ADDR;
|
||||
|
||||
#define MY_PORT 4242
|
||||
|
||||
#define STACKSIZE 2000
|
||||
K_THREAD_STACK_DEFINE(thread_stack, STACKSIZE);
|
||||
static struct k_thread thread_data;
|
||||
|
||||
static uint8_t buf_tx[NET_IPV6_MTU];
|
||||
|
||||
#define MAX_DBG_PRINT 64
|
||||
|
||||
NET_PKT_TX_SLAB_DEFINE(echo_tx_tcp, 15);
|
||||
NET_PKT_DATA_POOL_DEFINE(echo_data_tcp, 30);
|
||||
|
||||
static struct k_mem_slab *tx_tcp_pool(void)
|
||||
{
|
||||
return &echo_tx_tcp;
|
||||
}
|
||||
|
||||
static struct net_buf_pool *data_tcp_pool(void)
|
||||
{
|
||||
return &echo_data_tcp;
|
||||
}
|
||||
|
||||
static struct k_sem quit_lock;
|
||||
|
||||
static inline void quit(void)
|
||||
{
|
||||
k_sem_give(&quit_lock);
|
||||
}
|
||||
|
||||
static inline void init_app(void)
|
||||
{
|
||||
LOG_INF("Run IPSP sample");
|
||||
|
||||
k_sem_init(&quit_lock, 0, K_SEM_MAX_LIMIT);
|
||||
|
||||
if (net_addr_pton(AF_INET6,
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR,
|
||||
&in6addr_my) < 0) {
|
||||
LOG_ERR("Invalid IPv6 address %s",
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR);
|
||||
}
|
||||
|
||||
do {
|
||||
struct net_if_addr *ifaddr;
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(net_if_get_default(),
|
||||
&in6addr_my, NET_ADDR_MANUAL, 0);
|
||||
} while (0);
|
||||
}
|
||||
|
||||
static inline bool get_context(struct net_context **udp_recv6,
|
||||
struct net_context **tcp_recv6)
|
||||
{
|
||||
int ret;
|
||||
struct sockaddr_in6 my_addr6 = { 0 };
|
||||
|
||||
my_addr6.sin6_family = AF_INET6;
|
||||
my_addr6.sin6_port = htons(MY_PORT);
|
||||
|
||||
ret = net_context_get(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, udp_recv6);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot get network context for IPv6 UDP (%d)", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = net_context_bind(*udp_recv6, (struct sockaddr *)&my_addr6,
|
||||
sizeof(struct sockaddr_in6));
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot bind IPv6 UDP port %d (%d)",
|
||||
ntohs(my_addr6.sin6_port), ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = net_context_get(AF_INET6, SOCK_STREAM, IPPROTO_TCP, tcp_recv6);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot get network context for IPv6 TCP (%d)", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
net_context_setup_pools(*tcp_recv6, tx_tcp_pool, data_tcp_pool);
|
||||
|
||||
ret = net_context_bind(*tcp_recv6, (struct sockaddr *)&my_addr6,
|
||||
sizeof(struct sockaddr_in6));
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot bind IPv6 TCP port %d (%d)",
|
||||
ntohs(my_addr6.sin6_port), ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = net_context_listen(*tcp_recv6, 0);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot listen IPv6 TCP (%d)", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int build_reply(const char *name,
|
||||
struct net_pkt *pkt,
|
||||
uint8_t *buf)
|
||||
{
|
||||
int reply_len = net_pkt_remaining_data(pkt);
|
||||
int ret;
|
||||
|
||||
LOG_DBG("%s received %d bytes", name, reply_len);
|
||||
|
||||
ret = net_pkt_read(pkt, buf, reply_len);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("cannot read packet: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LOG_DBG("sending %d bytes", reply_len);
|
||||
|
||||
return reply_len;
|
||||
}
|
||||
|
||||
static inline void pkt_sent(struct net_context *context,
|
||||
int status,
|
||||
void *user_data)
|
||||
{
|
||||
if (status >= 0) {
|
||||
LOG_DBG("Sent %d bytes", status);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void set_dst_addr(sa_family_t family,
|
||||
struct net_pkt *pkt,
|
||||
struct net_ipv6_hdr *ipv6_hdr,
|
||||
struct net_udp_hdr *udp_hdr,
|
||||
struct sockaddr *dst_addr)
|
||||
{
|
||||
net_ipv6_addr_copy_raw((uint8_t *)&net_sin6(dst_addr)->sin6_addr,
|
||||
ipv6_hdr->src);
|
||||
net_sin6(dst_addr)->sin6_family = AF_INET6;
|
||||
net_sin6(dst_addr)->sin6_port = udp_hdr->src_port;
|
||||
}
|
||||
|
||||
static void udp_received(struct net_context *context,
|
||||
struct net_pkt *pkt,
|
||||
union net_ip_header *ip_hdr,
|
||||
union net_proto_header *proto_hdr,
|
||||
int status,
|
||||
void *user_data)
|
||||
{
|
||||
struct sockaddr dst_addr;
|
||||
sa_family_t family = net_pkt_family(pkt);
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
int ret;
|
||||
|
||||
snprintf(dbg, MAX_DBG_PRINT, "UDP IPv%c",
|
||||
family == AF_INET6 ? '6' : '4');
|
||||
|
||||
set_dst_addr(family, pkt, ip_hdr->ipv6, proto_hdr->udp, &dst_addr);
|
||||
|
||||
ret = build_reply(dbg, pkt, buf_tx);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
ret = net_context_sendto(context, buf_tx, ret, &dst_addr,
|
||||
family == AF_INET6 ?
|
||||
sizeof(struct sockaddr_in6) :
|
||||
sizeof(struct sockaddr_in),
|
||||
pkt_sent, K_NO_WAIT, user_data);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void setup_udp_recv(struct net_context *udp_recv6)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = net_context_recv(udp_recv6, udp_received, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot receive IPv6 UDP packets");
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_received(struct net_context *context,
|
||||
struct net_pkt *pkt,
|
||||
union net_ip_header *ip_hdr,
|
||||
union net_proto_header *proto_hdr,
|
||||
int status,
|
||||
void *user_data)
|
||||
{
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
sa_family_t family;
|
||||
int ret, len;
|
||||
|
||||
if (!pkt) {
|
||||
/* EOF condition */
|
||||
return;
|
||||
}
|
||||
|
||||
family = net_pkt_family(pkt);
|
||||
len = net_pkt_remaining_data(pkt);
|
||||
|
||||
snprintf(dbg, MAX_DBG_PRINT, "TCP IPv%c",
|
||||
family == AF_INET6 ? '6' : '4');
|
||||
|
||||
ret = build_reply(dbg, pkt, buf_tx);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
(void)net_context_update_recv_wnd(context, len);
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
ret = net_context_send(context, buf_tx, ret, pkt_sent,
|
||||
K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
quit();
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_accepted(struct net_context *context,
|
||||
struct sockaddr *addr,
|
||||
socklen_t addrlen,
|
||||
int error,
|
||||
void *user_data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
NET_DBG("Accept called, context %p error %d", context, error);
|
||||
|
||||
net_context_set_accepting(context, false);
|
||||
|
||||
ret = net_context_recv(context, tcp_received, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot receive TCP packet (family %d)",
|
||||
net_context_get_family(context));
|
||||
}
|
||||
}
|
||||
|
||||
static void setup_tcp_accept(struct net_context *tcp_recv6)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = net_context_accept(tcp_recv6, tcp_accepted, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot receive IPv6 TCP packets (%d)", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void listen(void *p1, void *p2, void *p3)
|
||||
{
|
||||
ARG_UNUSED(p1);
|
||||
ARG_UNUSED(p2);
|
||||
ARG_UNUSED(p3);
|
||||
|
||||
struct net_context *udp_recv6 = { 0 };
|
||||
struct net_context *tcp_recv6 = { 0 };
|
||||
|
||||
if (!get_context(&udp_recv6, &tcp_recv6)) {
|
||||
LOG_ERR("Cannot get network contexts");
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INF("Starting to wait");
|
||||
|
||||
setup_tcp_accept(tcp_recv6);
|
||||
setup_udp_recv(udp_recv6);
|
||||
|
||||
k_sem_take(&quit_lock, K_FOREVER);
|
||||
|
||||
LOG_INF("Stopping...");
|
||||
|
||||
net_context_put(udp_recv6);
|
||||
net_context_put(tcp_recv6);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
init_app();
|
||||
|
||||
k_thread_create(&thread_data, thread_stack, STACKSIZE,
|
||||
listen,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
return 0;
|
||||
}
|
|
@ -49,9 +49,6 @@ samples/net/lwm2m_client directory:
|
|||
* - :file:`overlay-dtls.conf`
|
||||
- This overlay config can be added for DTLS support via MBEDTLS.
|
||||
|
||||
* - :file:`overlay-bt.conf`
|
||||
- This overlay config can be added to enable Bluetooth networking support.
|
||||
|
||||
* - :file:`overlay-queue.conf`
|
||||
- This overlay config can be added to enable LWM2M Queue Mode support.
|
||||
|
||||
|
@ -179,32 +176,6 @@ the overlay file for Bootstrap over DTLS (5784 in case of Leshan Demo Bootstrap
|
|||
Server) and to configure correct security mode in the ``LWM2M Bootstrap Server``
|
||||
tab in the web UI (Pre-shared Key).
|
||||
|
||||
Bluetooth Support
|
||||
=================
|
||||
|
||||
To build the lwm2m-client sample for hardware requiring Bluetooth for
|
||||
networking (IPSP node connected via 6lowpan) do the following:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/lwm2m_client
|
||||
:host-os: unix
|
||||
:board: <board to use>
|
||||
:conf: "prj.conf overlay-bt.conf"
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
The overlay-\*.conf files can also be combined. For example, you could build a
|
||||
DTLS-enabled LwM2M client sample for BLENano2 hardware by using the following
|
||||
commands (requires Bluetooth for networking):
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/lwm2m_client
|
||||
:host-os: unix
|
||||
:board: nrf52_blenano2
|
||||
:conf: "prj.conf overlay-bt.conf overlay-dtls.conf"
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
OpenThread Support
|
||||
==================
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="LwM2M IPSP node"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
|
||||
# raise bluetooth RX buffer settings for 6lowpan traffic
|
||||
CONFIG_BT_BUF_ACL_RX_COUNT=20
|
||||
CONFIG_BT_BUF_ACL_RX_SIZE=124
|
|
@ -52,17 +52,6 @@ tests:
|
|||
tags:
|
||||
- net
|
||||
- lwm2m
|
||||
sample.net.lwm2m_client.bt:
|
||||
harness: net
|
||||
extra_args: OVERLAY_CONFIG=overlay-bt.conf
|
||||
platform_allow:
|
||||
- nrf52840dk/nrf52840
|
||||
- disco_l475_iot1
|
||||
tags:
|
||||
- net
|
||||
- lwm2m
|
||||
integration_platforms:
|
||||
- disco_l475_iot1
|
||||
sample.net.lwm2m_client.queue_mode:
|
||||
harness: net
|
||||
depends_on: netif
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Zephyr Echo Server"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_MY_IPV4_GW=""
|
|
@ -1,15 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Zephyr MQTT"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
|
|
@ -23,4 +23,3 @@ CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
|
|||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
|
||||
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
|
||||
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
|
|
|
@ -41,9 +41,6 @@ echo-client directory:
|
|||
improve connection reliability, acknowledgments can be enabled with shell
|
||||
command: ``ieee802154 ack set``.
|
||||
|
||||
- :file:`overlay-bt.conf`
|
||||
This overlay config enables support for Bluetooth IPSP connectivity.
|
||||
|
||||
- :file:`overlay-qemu_802154.conf`
|
||||
This overlay config enables support for two QEMU's when simulating
|
||||
IEEE 802.15.4 network that are connected together.
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Zephyr Echo Client"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
|
||||
CONFIG_NET_BUF_RX_COUNT=64
|
|
@ -62,10 +62,6 @@ tests:
|
|||
- SHIELD=atmel_rf2xx_mikrobus
|
||||
- OVERLAY_CONFIG="overlay-802154.conf"
|
||||
platform_allow: lpcxpresso55s69/lpc55s69/cpu0/ns
|
||||
sample.net.sockets.echo_client.bt:
|
||||
extra_args: OVERLAY_CONFIG="overlay-bt.conf"
|
||||
platform_allow: qemu_x86
|
||||
tags: bluetooth
|
||||
sample.net.sockets.echo_client.mcr20a:
|
||||
extra_args:
|
||||
- SHIELD=frdm_cr20a
|
||||
|
|
|
@ -42,9 +42,6 @@ echo-server directory:
|
|||
improve connection reliability, acknowledgments can be enabled with shell
|
||||
command: ``ieee802154 ack set``.
|
||||
|
||||
- :file:`overlay-bt.conf`
|
||||
This overlay config enables support for Bluetooth IPSP connectivity.
|
||||
|
||||
- :file:`overlay-qemu_802154.conf`
|
||||
This overlay config enables support for two QEMU's when simulating
|
||||
IEEE 802.15.4 network that are connected together.
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Zephyr Echo Server"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
|
|
@ -64,10 +64,6 @@ tests:
|
|||
- SHIELD=atmel_rf2xx_mikrobus
|
||||
- OVERLAY_CONFIG="overlay-802154.conf"
|
||||
platform_allow: lpcxpresso55s69/lpc55s69/cpu0/ns
|
||||
sample.net.sockets.echo_server.bt:
|
||||
extra_args: OVERLAY_CONFIG="overlay-bt.conf"
|
||||
platform_allow: qemu_x86
|
||||
tags: bluetooth
|
||||
sample.net.sockets.echo_server.mcr20a:
|
||||
extra_args:
|
||||
- SHIELD=frdm_cr20a
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="Zephyr Telnet Shell"
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
|
||||
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
|
||||
CONFIG_NET_BUF_RX_COUNT=64
|
|
@ -1,9 +0,0 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_L2_BT_SHELL=y
|
||||
CONFIG_SHELL_CMDS_RESIZE=n
|
|
@ -34,7 +34,7 @@ Caveats
|
|||
application should build and run for other platforms with same connectivity.
|
||||
|
||||
* The sample provides overlay files to enable other technologies like WIFI,
|
||||
modem, BLE IPSP, 802.15.4 or OpenThread. These technologies depends on
|
||||
modem, 802.15.4 or OpenThread. These technologies depends on
|
||||
hardware resources and the correspondent overlay was designed to be generic
|
||||
instead full optimized.
|
||||
|
||||
|
@ -242,25 +242,6 @@ tested with both native linux driver and ``atusb`` and with ``wpanusb`` sample.
|
|||
:goals: build
|
||||
:compact:
|
||||
|
||||
Step 4.5: Build for BLE IPSP [experimental]
|
||||
-------------------------------------------
|
||||
|
||||
The BLE IPSP needs ``overlay-ipsp.conf``. This may requires two nodes:
|
||||
one will be the host and the second one will be the device under test. The
|
||||
validation needs a Linux kernel >= 4.9 with all 6loWPAN support. In this
|
||||
particular case the Bluetooth 6LoWPAN module is needed. The start point is try
|
||||
reproduce the Zephyr :ref:`bluetooth-ipsp-sample`. It is out of scope
|
||||
at this moment provide support since it is experimental. The gateway was
|
||||
tested with native linux driver and an USB dongle.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: zephyr/samples/subsys/mgmt/updatehub
|
||||
:board: nrf52840dk/nrf52840
|
||||
:build-dir: app
|
||||
:gen-args: -DEXTRA_CONF_FILE="overlay-ipsp.conf;overlay-prj.conf"
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
Step 4.6: Build for OpenThread Network [experimental]
|
||||
-----------------------------------------------------
|
||||
|
||||
|
@ -482,7 +463,6 @@ The below list of hardware have been used by UpdateHub team.
|
|||
3, "MODEM (PPP)", "SIMCOM 808"
|
||||
4, "IEEE 802.15.4 (6loWPAN)", "Native,
|
||||
:ref:`RF2XX <atmel_at86rf2xx_transceivers>`"
|
||||
5, "BLE IPSP (6loWPAN)", Native
|
||||
6, "OpenThread Network", Native
|
||||
|
||||
.. csv-table::
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
# Copyright (c) 2020 O.S.Systems
|
||||
# SPDX -License-Identifier: Apache-2.0
|
||||
|
||||
# Disable default configs
|
||||
CONFIG_NET_L2_IEEE802154=n
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_DHCPV4=n
|
||||
CONFIG_NET_TCP=n
|
||||
|
||||
# Enable Bluetooth LE IPSP
|
||||
CONFIG_BT=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="UpdateHub - IPSP"
|
||||
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_AUTO_INIT=y
|
||||
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_L2_BT_SHELL=y
|
||||
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_IPV6_FRAGMENT=y
|
||||
CONFIG_NET_6LO_CONTEXT=y
|
||||
CONFIG_NET_MAX_6LO_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_UDP=y
|
||||
|
||||
# Add DNS Server
|
||||
CONFIG_DNS_SERVER_IP_ADDRESSES=y
|
||||
CONFIG_DNS_SERVER1="2001:de8::1"
|
||||
|
||||
# UpdateHub
|
||||
CONFIG_UPDATEHUB_SERVER="2001:de8::1"
|
||||
CONFIG_UPDATEHUB_COAP_BLOCK_SIZE_EXP=2
|
|
@ -79,7 +79,6 @@ config BT_BUF_ACL_RX_SIZE
|
|||
|
||||
config BT_BUF_ACL_RX_COUNT
|
||||
int "Number of incoming ACL data buffers"
|
||||
default NET_BUF_RX_COUNT if NET_L2_BT
|
||||
default 6
|
||||
range 1 64
|
||||
help
|
||||
|
|
|
@ -8,7 +8,6 @@ menu "L2CAP Options"
|
|||
|
||||
config BT_L2CAP_TX_BUF_COUNT
|
||||
int "Number of L2CAP TX buffers"
|
||||
default NET_BUF_TX_COUNT if NET_L2_BT
|
||||
default BT_BUF_ACL_TX_COUNT
|
||||
range 2 255
|
||||
help
|
||||
|
@ -16,7 +15,6 @@ config BT_L2CAP_TX_BUF_COUNT
|
|||
|
||||
config BT_L2CAP_TX_FRAG_COUNT
|
||||
int "Number of L2CAP TX fragment buffers"
|
||||
default NET_BUF_TX_COUNT if NET_L2_BT
|
||||
default 2
|
||||
range 0 255
|
||||
help
|
||||
|
|
|
@ -695,9 +695,7 @@ config NET_PKT_BUF_TX_DATA_POOL_SIZE
|
|||
|
||||
config NET_PKT_BUF_USER_DATA_SIZE
|
||||
int "Size of user_data available in rx and tx network buffers"
|
||||
default BT_CONN_TX_USER_DATA_SIZE if NET_L2_BT
|
||||
default 4
|
||||
range BT_CONN_TX_USER_DATA_SIZE 16 if NET_L2_BT
|
||||
range 4 16
|
||||
help
|
||||
User data size used in rx and tx network buffers.
|
||||
|
@ -736,10 +734,6 @@ config NET_DEFAULT_IF_ETHERNET
|
|||
bool "Ethernet"
|
||||
depends on NET_L2_ETHERNET
|
||||
|
||||
config NET_DEFAULT_IF_BLUETOOTH
|
||||
bool "Bluetooth"
|
||||
depends on NET_L2_BT
|
||||
|
||||
config NET_DEFAULT_IF_IEEE802154
|
||||
bool "IEEE 802.15.4"
|
||||
depends on NET_L2_IEEE802154
|
||||
|
|
|
@ -14,7 +14,6 @@ if NET_IPV6
|
|||
|
||||
config NET_IF_MAX_IPV6_COUNT
|
||||
int "Max number of IPv6 network interfaces in the system"
|
||||
default BT_MAX_CONN if NET_L2_BT
|
||||
default NET_VLAN_COUNT if NET_VLAN
|
||||
default 2 if NET_LOOPBACK
|
||||
default 1
|
||||
|
|
|
@ -589,9 +589,6 @@ struct net_if *net_if_get_default(void)
|
|||
#if defined(CONFIG_NET_DEFAULT_IF_IEEE802154)
|
||||
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(IEEE802154));
|
||||
#endif
|
||||
#if defined(CONFIG_NET_DEFAULT_IF_BLUETOOTH)
|
||||
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(BLUETOOTH));
|
||||
#endif
|
||||
#if defined(CONFIG_NET_DEFAULT_IF_DUMMY)
|
||||
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
|
||||
#endif
|
||||
|
|
|
@ -317,10 +317,8 @@ end:
|
|||
|
||||
#define is_6lo_technology(pkt) \
|
||||
(IS_ENABLED(CONFIG_NET_IPV6) && net_pkt_family(pkt) == AF_INET6 && \
|
||||
((IS_ENABLED(CONFIG_NET_L2_BT) && \
|
||||
net_pkt_lladdr_dst(pkt)->type == NET_LINK_BLUETOOTH) || \
|
||||
(IS_ENABLED(CONFIG_NET_L2_IEEE802154) && \
|
||||
net_pkt_lladdr_dst(pkt)->type == NET_LINK_IEEE802154)))
|
||||
(IS_ENABLED(CONFIG_NET_L2_IEEE802154) && \
|
||||
net_pkt_lladdr_dst(pkt)->type == NET_LINK_IEEE802154))
|
||||
|
||||
static void tcp_send(struct net_pkt *pkt)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_NET_L2_BT OR CONFIG_NET_L2_BT_SHELL)
|
||||
add_subdirectory(bluetooth)
|
||||
endif()
|
||||
|
||||
if(CONFIG_NET_L2_VIRTUAL)
|
||||
add_subdirectory(virtual)
|
||||
endif()
|
||||
|
|
|
@ -14,62 +14,6 @@ if NET_L2_DUMMY
|
|||
source "subsys/net/l2/dummy/Kconfig"
|
||||
endif
|
||||
|
||||
config NET_L2_BT
|
||||
bool "Bluetooth support"
|
||||
depends on NET_IPV6
|
||||
depends on BT
|
||||
depends on BT_PERIPHERAL
|
||||
depends on BT_CENTRAL
|
||||
depends on BT_SMP
|
||||
depends on BT_L2CAP_DYNAMIC_CHANNEL
|
||||
select NET_6LO
|
||||
help
|
||||
Enable Bluetooth driver that send and receives IPv6 packets,
|
||||
does header compression on it and writes it to the
|
||||
Bluetooth stack via L2CAP channel.
|
||||
|
||||
if NET_L2_BT
|
||||
config NET_L2_BT_ZEP1656
|
||||
bool "***Workaround to work with Linux.***"
|
||||
help
|
||||
This workaround is necessary to interoperate with Linux up to 4.10 but
|
||||
it might not be compliant with RFC 7668 as it cause the stack to skip
|
||||
Neighbor Discovery cache causing the destination link address to be
|
||||
omitted. For more details why this is needed see:
|
||||
https://github.com/zephyrproject-rtos/zephyr/issues/3111
|
||||
|
||||
config NET_L2_BT_SEC_LEVEL
|
||||
int "Security level of Bluetooth Link"
|
||||
default 1
|
||||
range 1 4
|
||||
help
|
||||
Security level of Bluetooth Link:
|
||||
Level 1 (BT_SECURITY_L1) = No encryption or authentication required
|
||||
Level 2 (BT_SECURITY_L2) = Only encryption required
|
||||
Level 3 (BT_SECURITY_L3) = Encryption and authentication required
|
||||
Level 4 (BT_SECURITY_L4) = LE Secure Connection required
|
||||
|
||||
module = NET_L2_BT
|
||||
module-dep = NET_LOG
|
||||
module-str = Log level for Bluetooth L2 layer
|
||||
module-help = Enables Bluetooth L2 to output debug messages.
|
||||
source "subsys/net/Kconfig.template.log_config.net"
|
||||
endif
|
||||
|
||||
config NET_L2_BT_MGMT
|
||||
bool "Bluetooth Network Management support"
|
||||
depends on NET_L2_BT
|
||||
select NET_MGMT
|
||||
select NET_MGMT_EVENT
|
||||
|
||||
config NET_L2_BT_SHELL
|
||||
bool "Bluetooth shell module"
|
||||
select SHELL
|
||||
select NET_L2_BT_MGMT
|
||||
help
|
||||
This can be used for testing Bluetooth management commands through the
|
||||
console via a shell module named "net_bt".
|
||||
|
||||
source "subsys/net/l2/virtual/Kconfig"
|
||||
|
||||
source "subsys/net/l2/ethernet/Kconfig"
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library()
|
||||
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
|
||||
zephyr_library_compile_definitions_ifdef(
|
||||
CONFIG_NEWLIB_LIBC __LINUX_ERRNO_EXTENSIONS__
|
||||
)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_NET_L2_BT bluetooth.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NET_L2_BT_SHELL bluetooth_shell.c)
|
|
@ -1,639 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(net_bt, CONFIG_NET_L2_BT_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/init.h>
|
||||
|
||||
#include <zephyr/net/net_pkt.h>
|
||||
#include <zephyr/net/net_core.h>
|
||||
#include <zephyr/net/net_l2.h>
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/capture.h>
|
||||
#include <zephyr/net/bt.h>
|
||||
#include <6lo.h>
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/hci.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/uuid.h>
|
||||
#include <zephyr/bluetooth/l2cap.h>
|
||||
|
||||
#include "net_private.h"
|
||||
#include "ipv6.h"
|
||||
|
||||
#define BUF_TIMEOUT K_MSEC(50)
|
||||
|
||||
#define L2CAP_IPSP_PSM 0x0023
|
||||
#define L2CAP_IPSP_MTU 1280
|
||||
|
||||
#define CHAN_CONN(_conn) CONTAINER_OF(_conn, struct bt_if_conn, ipsp_chan.chan)
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_MGMT)
|
||||
static struct bt_conn *default_conn;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_SHELL)
|
||||
extern int net_bt_shell_init(void);
|
||||
#else
|
||||
#define net_bt_shell_init(...)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_BUF_FIXED_DATA_SIZE)
|
||||
#define IPSP_FRAG_LEN CONFIG_NET_BUF_DATA_SIZE
|
||||
#else
|
||||
#define IPSP_FRAG_LEN L2CAP_IPSP_MTU
|
||||
#endif /* CONFIG_NET_BUF_FIXED_DATA_SIZE */
|
||||
|
||||
struct bt_if_conn {
|
||||
struct net_if *iface;
|
||||
struct bt_l2cap_le_chan ipsp_chan;
|
||||
bt_addr_t src;
|
||||
bt_addr_t dst;
|
||||
};
|
||||
|
||||
struct bt_context {
|
||||
struct bt_if_conn conns[CONFIG_BT_MAX_CONN];
|
||||
};
|
||||
|
||||
static enum net_verdict net_bt_recv(struct net_if *iface, struct net_pkt *pkt)
|
||||
{
|
||||
NET_DBG("iface %p pkt %p len %zu", iface, pkt, net_pkt_get_len(pkt));
|
||||
|
||||
if (!net_6lo_uncompress(pkt)) {
|
||||
NET_DBG("Packet decompression failed");
|
||||
return NET_DROP;
|
||||
}
|
||||
|
||||
return NET_CONTINUE;
|
||||
}
|
||||
|
||||
static struct bt_if_conn *net_bt_get_conn(struct net_if *iface)
|
||||
{
|
||||
struct bt_context *ctxt = net_if_get_device(iface)->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_BT_MAX_CONN; i++) {
|
||||
if (ctxt->conns[i].iface == iface) {
|
||||
return &ctxt->conns[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int net_bt_send(struct net_if *iface, struct net_pkt *pkt)
|
||||
{
|
||||
struct bt_if_conn *conn = net_bt_get_conn(iface);
|
||||
struct net_buf *buffer;
|
||||
int length;
|
||||
int ret;
|
||||
|
||||
NET_DBG("iface %p pkt %p len %zu", iface, pkt, net_pkt_get_len(pkt));
|
||||
|
||||
/* Only accept IPv6 packets */
|
||||
if (net_pkt_family(pkt) != AF_INET6) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = net_6lo_compress(pkt, true);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Packet compression failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
length = net_pkt_get_len(pkt);
|
||||
|
||||
net_capture_pkt(iface, pkt);
|
||||
|
||||
/* Detach data fragments for packet */
|
||||
buffer = pkt->buffer;
|
||||
pkt->buffer = NULL;
|
||||
|
||||
ret = bt_l2cap_chan_send(&conn->ipsp_chan.chan, buffer);
|
||||
if (ret < 0) {
|
||||
NET_ERR("Unable to send packet: %d", ret);
|
||||
bt_l2cap_chan_disconnect(&conn->ipsp_chan.chan);
|
||||
net_buf_unref(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
static int net_bt_enable(struct net_if *iface, bool state)
|
||||
{
|
||||
NET_DBG("iface %p %s", iface, state ? "up" : "down");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum net_l2_flags net_bt_flags(struct net_if *iface)
|
||||
{
|
||||
/* TODO: add NET_L2_MULTICAST_SKIP_JOIN_SOLICIT_NODE once the stack
|
||||
* supports Address Registration Option for neighbor discovery.
|
||||
*/
|
||||
return NET_L2_MULTICAST;
|
||||
}
|
||||
|
||||
NET_L2_INIT(BLUETOOTH_L2, net_bt_recv, net_bt_send,
|
||||
net_bt_enable, net_bt_flags);
|
||||
|
||||
static void ipsp_connected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_if_conn *conn = CHAN_CONN(chan);
|
||||
struct bt_conn_info info;
|
||||
struct net_linkaddr ll;
|
||||
struct in6_addr in6;
|
||||
|
||||
if (bt_conn_get_info(chan->conn, &info) < 0) {
|
||||
NET_ERR("Unable to get connection info");
|
||||
bt_l2cap_chan_disconnect(chan);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CONFIG_NET_L2_BT_LOG_LEVEL >= LOG_LEVEL_DBG) {
|
||||
char src[BT_ADDR_LE_STR_LEN];
|
||||
char dst[BT_ADDR_LE_STR_LEN];
|
||||
|
||||
bt_addr_le_to_str(info.le.src, src, sizeof(src));
|
||||
bt_addr_le_to_str(info.le.dst, dst, sizeof(dst));
|
||||
|
||||
NET_DBG("Channel %p Source %s connected to Destination %s",
|
||||
chan, src, dst);
|
||||
}
|
||||
|
||||
/* Swap bytes since net APIs expect big endian address */
|
||||
sys_memcpy_swap(conn->src.val, info.le.src->a.val, sizeof(conn->src));
|
||||
sys_memcpy_swap(conn->dst.val, info.le.dst->a.val, sizeof(conn->dst));
|
||||
|
||||
net_if_set_link_addr(conn->iface, conn->src.val, sizeof(conn->src.val),
|
||||
NET_LINK_BLUETOOTH);
|
||||
|
||||
ll.addr = conn->dst.val;
|
||||
ll.len = sizeof(conn->dst.val);
|
||||
ll.type = NET_LINK_BLUETOOTH;
|
||||
|
||||
/* Add remote link-local address to the nbr cache to avoid sending ns:
|
||||
* https://tools.ietf.org/html/rfc7668#section-3.2.3
|
||||
* A Bluetooth LE 6LN MUST NOT register its link-local address.
|
||||
*/
|
||||
net_ipv6_addr_create_iid(&in6, &ll);
|
||||
net_ipv6_nbr_add(conn->iface, &in6, &ll, false,
|
||||
NET_IPV6_NBR_STATE_STATIC);
|
||||
|
||||
/* Leave dormant state (iface goes up if set to admin up) */
|
||||
net_if_dormant_off(conn->iface);
|
||||
}
|
||||
|
||||
static void ipsp_disconnected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_if_conn *conn = CHAN_CONN(chan);
|
||||
|
||||
NET_DBG("Channel %p disconnected", chan);
|
||||
|
||||
/* Enter dormant state (iface goes down) */
|
||||
net_if_dormant_on(conn->iface);
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_MGMT)
|
||||
if (chan->conn != default_conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
bt_conn_unref(default_conn);
|
||||
default_conn = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ipsp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
||||
{
|
||||
struct bt_if_conn *conn = CHAN_CONN(chan);
|
||||
struct net_pkt *pkt;
|
||||
|
||||
NET_DBG("Incoming data channel %p len %zu", chan,
|
||||
net_buf_frags_len(buf));
|
||||
|
||||
/* Get packet for bearer / protocol related data */
|
||||
pkt = net_pkt_rx_alloc_on_iface(conn->iface, BUF_TIMEOUT);
|
||||
if (!pkt) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Set destination address */
|
||||
net_pkt_lladdr_dst(pkt)->addr = conn->src.val;
|
||||
net_pkt_lladdr_dst(pkt)->len = sizeof(conn->src);
|
||||
net_pkt_lladdr_dst(pkt)->type = NET_LINK_BLUETOOTH;
|
||||
|
||||
/* Set source address */
|
||||
net_pkt_lladdr_src(pkt)->addr = conn->dst.val;
|
||||
net_pkt_lladdr_src(pkt)->len = sizeof(conn->dst);
|
||||
net_pkt_lladdr_src(pkt)->type = NET_LINK_BLUETOOTH;
|
||||
|
||||
/* Add data buffer as fragment of RX buffer, take a reference while
|
||||
* doing so since L2CAP will unref the buffer after return.
|
||||
*/
|
||||
net_pkt_append_buffer(pkt, net_buf_ref(buf));
|
||||
|
||||
if (net_recv_data(conn->iface, pkt) < 0) {
|
||||
NET_DBG("Packet dropped by NET stack");
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct net_buf *ipsp_alloc_buf(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
NET_DBG("Channel %p requires buffer", chan);
|
||||
|
||||
return net_pkt_get_reserve_rx_data(IPSP_FRAG_LEN, BUF_TIMEOUT);
|
||||
}
|
||||
|
||||
static const struct bt_l2cap_chan_ops ipsp_ops = {
|
||||
.alloc_buf = ipsp_alloc_buf,
|
||||
.recv = ipsp_recv,
|
||||
.connected = ipsp_connected,
|
||||
.disconnected = ipsp_disconnected,
|
||||
};
|
||||
|
||||
static struct bt_context bt_context_data = {
|
||||
.conns[0 ... (CONFIG_BT_MAX_CONN - 1)] = {
|
||||
.iface = NULL,
|
||||
.ipsp_chan.chan.ops = &ipsp_ops,
|
||||
.ipsp_chan.rx.mtu = L2CAP_IPSP_MTU,
|
||||
}
|
||||
};
|
||||
|
||||
static void bt_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct bt_context *ctxt = net_if_get_device(iface)->data;
|
||||
struct bt_if_conn *conn = NULL;
|
||||
int i;
|
||||
|
||||
NET_DBG("iface %p", iface);
|
||||
|
||||
/* Find unused slot to store the iface */
|
||||
for (i = 0; i < CONFIG_BT_MAX_CONN; i++) {
|
||||
if (!ctxt->conns[i].iface) {
|
||||
conn = &ctxt->conns[i];
|
||||
NET_DBG("[%d] alloc ctxt %p iface %p", i, ctxt, iface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conn) {
|
||||
NET_ERR("Unable to allocate iface");
|
||||
return;
|
||||
}
|
||||
|
||||
conn->iface = iface;
|
||||
|
||||
net_if_dormant_on(iface);
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_ZEP1656)
|
||||
/* Workaround Linux bug, see:
|
||||
* https://github.com/zephyrproject-rtos/zephyr/issues/3111
|
||||
*/
|
||||
net_if_flag_set(iface, NET_IF_POINTOPOINT);
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct net_if_api bt_if_api = {
|
||||
.init = bt_iface_init,
|
||||
};
|
||||
|
||||
static int ipsp_accept(struct bt_conn *conn, struct bt_l2cap_server *server,
|
||||
struct bt_l2cap_chan **chan)
|
||||
{
|
||||
struct bt_if_conn *if_conn = NULL;
|
||||
int i;
|
||||
|
||||
NET_DBG("Incoming conn %p", (void *)conn);
|
||||
|
||||
/* Find unused slot to store the iface */
|
||||
for (i = 0; i < CONFIG_BT_MAX_CONN; i++) {
|
||||
if (bt_context_data.conns[i].iface &&
|
||||
!bt_context_data.conns[i].ipsp_chan.chan.conn) {
|
||||
if_conn = &bt_context_data.conns[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!if_conn) {
|
||||
NET_ERR("No channels available");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*chan = &if_conn->ipsp_chan.chan;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bt_l2cap_server server = {
|
||||
.psm = L2CAP_IPSP_PSM,
|
||||
.sec_level = CONFIG_NET_L2_BT_SEC_LEVEL,
|
||||
.accept = ipsp_accept,
|
||||
};
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_MGMT)
|
||||
|
||||
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
|
||||
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
|
||||
#define UNKNOWN_APPEARANCE 0x0000
|
||||
|
||||
static const struct bt_data ad[] = {
|
||||
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
|
||||
BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_IPSS_VAL)),
|
||||
};
|
||||
|
||||
static const struct bt_data sd[] = {
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
|
||||
};
|
||||
|
||||
static int bt_advertise(uint32_t mgmt_request, struct net_if *iface, void *data,
|
||||
size_t len)
|
||||
{
|
||||
if (!strcmp(data, "on")) {
|
||||
return bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
|
||||
sd, ARRAY_SIZE(sd));
|
||||
} else if (!strcmp(data, "off")) {
|
||||
return bt_le_adv_stop();
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_connect(uint32_t mgmt_request, struct net_if *iface, void *data,
|
||||
size_t len)
|
||||
{
|
||||
struct bt_if_conn *conn = net_bt_get_conn(iface);
|
||||
bt_addr_le_t *addr = data;
|
||||
|
||||
if (len != sizeof(*addr)) {
|
||||
NET_ERR("Invalid address");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (conn->ipsp_chan.chan.conn) {
|
||||
NET_ERR("No channels available");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (default_conn) {
|
||||
return bt_l2cap_chan_connect(default_conn,
|
||||
&conn->ipsp_chan.chan,
|
||||
L2CAP_IPSP_PSM);
|
||||
}
|
||||
|
||||
return bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
|
||||
BT_LE_CONN_PARAM_DEFAULT, &default_conn);
|
||||
}
|
||||
|
||||
static bool eir_found(uint8_t type, const uint8_t *data, uint8_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (type != BT_DATA_UUID16_SOME && type != BT_DATA_UUID16_ALL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data_len % sizeof(uint16_t) != 0U) {
|
||||
NET_ERR("AD malformed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < data_len; i += sizeof(uint16_t)) {
|
||||
const struct bt_uuid *uuid;
|
||||
uint16_t u16;
|
||||
|
||||
memcpy(&u16, &data[i], sizeof(u16));
|
||||
uuid = BT_UUID_DECLARE_16(sys_le16_to_cpu(u16));
|
||||
if (bt_uuid_cmp(uuid, BT_UUID_IPSS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CONFIG_NET_L2_BT_LOG_LEVEL >= LOG_LEVEL_DBG) {
|
||||
bt_addr_le_t *addr = user_data;
|
||||
char dev[BT_ADDR_LE_STR_LEN];
|
||||
|
||||
bt_addr_le_to_str(addr, dev, sizeof(dev));
|
||||
NET_DBG("[DEVICE]: %s", dev);
|
||||
}
|
||||
|
||||
/* TODO: Notify device address found */
|
||||
net_mgmt_event_notify(NET_EVENT_BT_SCAN_RESULT,
|
||||
bt_context_data.conns[0].iface);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ad_parse(struct net_buf_simple *ad_buf,
|
||||
bool (*func)(uint8_t type, const uint8_t *data,
|
||||
uint8_t data_len, void *user_data),
|
||||
void *user_data)
|
||||
{
|
||||
while (ad_buf->len > 1) {
|
||||
uint8_t len = net_buf_simple_pull_u8(ad_buf);
|
||||
uint8_t type;
|
||||
|
||||
/* Check for early termination */
|
||||
if (len == 0U) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (len > ad_buf->len) {
|
||||
NET_ERR("AD malformed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
type = net_buf_simple_pull_u8(ad_buf);
|
||||
|
||||
if (func(type, ad_buf->data, len - 1, user_data)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
net_buf_simple_pull(ad_buf, len - 1);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
|
||||
struct net_buf_simple *ad_buf)
|
||||
{
|
||||
/* We're only interested in connectable events */
|
||||
if (type == BT_GAP_ADV_TYPE_ADV_IND ||
|
||||
type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) {
|
||||
ad_parse(ad_buf, eir_found, (void *)addr);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_active_scan(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_le_scan_start(BT_LE_SCAN_ACTIVE, device_found);
|
||||
if (err) {
|
||||
NET_ERR("Bluetooth set active scan failed (err %d)\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_passive_scan(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, device_found);
|
||||
if (err) {
|
||||
NET_ERR("Bluetooth set passive scan failed (err %d)\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_scan_off(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_le_scan_stop();
|
||||
if (err) {
|
||||
NET_ERR("Stopping scanning failed (err %d)\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
static int bt_scan(uint32_t mgmt_request, struct net_if *iface, void *data,
|
||||
size_t len)
|
||||
{
|
||||
if (!strcmp(data, "on") || !strcmp(data, "active")) {
|
||||
bt_active_scan();
|
||||
} else if (!strcmp(data, "passive")) {
|
||||
bt_passive_scan();
|
||||
} else if (!strcmp("off", data)) {
|
||||
bt_scan_off();
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_disconnect(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
struct bt_if_conn *conn = net_bt_get_conn(iface);
|
||||
|
||||
if (!conn->ipsp_chan.chan.conn) {
|
||||
NET_ERR("Not connected");
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* Release connect reference in case of central/router role */
|
||||
if (default_conn) {
|
||||
bt_conn_unref(default_conn);
|
||||
default_conn = NULL;
|
||||
}
|
||||
|
||||
return bt_l2cap_chan_disconnect(&conn->ipsp_chan.chan);
|
||||
}
|
||||
|
||||
static void connected(struct bt_conn *conn, uint8_t err)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (err) {
|
||||
if (CONFIG_NET_L2_BT_LOG_LEVEL >= LOG_LEVEL_DBG) {
|
||||
char addr[BT_ADDR_LE_STR_LEN];
|
||||
|
||||
bt_addr_le_to_str(bt_conn_get_dst(conn), addr,
|
||||
sizeof(addr));
|
||||
|
||||
NET_ERR("Failed to connect to %s (%u)\n",
|
||||
addr, err);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (conn != default_conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < CONFIG_BT_MAX_CONN; i++) {
|
||||
struct bt_if_conn *if_conn = &bt_context_data.conns[i];
|
||||
|
||||
if (if_conn->ipsp_chan.chan.conn == conn) {
|
||||
bt_l2cap_chan_connect(conn, &if_conn->ipsp_chan.chan,
|
||||
L2CAP_IPSP_PSM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void disconnected(struct bt_conn *conn, uint8_t reason)
|
||||
{
|
||||
if (conn != default_conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CONFIG_NET_L2_BT_LOG_LEVEL >= LOG_LEVEL_DBG) {
|
||||
char addr[BT_ADDR_LE_STR_LEN];
|
||||
|
||||
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
|
||||
|
||||
NET_DBG("Disconnected: %s (reason 0x%02x)\n",
|
||||
addr, reason);
|
||||
}
|
||||
|
||||
bt_conn_unref(default_conn);
|
||||
default_conn = NULL;
|
||||
}
|
||||
|
||||
BT_CONN_CB_DEFINE(conn_callbacks) = {
|
||||
.connected = connected,
|
||||
.disconnected = disconnected,
|
||||
};
|
||||
#endif /* CONFIG_NET_L2_BT_MGMT */
|
||||
|
||||
static int net_bt_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
|
||||
NET_DBG("dev %p driver_data %p", dev, dev->data);
|
||||
|
||||
err = bt_l2cap_server_register(&server);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
net_bt_shell_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT_MGMT)
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_BT_ADVERTISE, bt_advertise);
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_BT_CONNECT, bt_connect);
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_BT_SCAN, bt_scan);
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_BT_DISCONNECT, bt_disconnect);
|
||||
#endif
|
||||
|
||||
DEVICE_DEFINE(net_bt, "net_bt", net_bt_init, NULL, &bt_context_data, NULL,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &bt_if_api);
|
||||
NET_L2_DATA_INIT(net_bt, 0, NET_L2_GET_CTX_TYPE(BLUETOOTH_L2));
|
||||
NET_IF_INIT(net_bt, 0, BLUETOOTH_L2, L2CAP_IPSP_MTU, CONFIG_BT_MAX_CONN);
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(net_bt_shell, CONFIG_NET_L2_BT_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <zephyr/linker/sections.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <zephyr/shell/shell.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include <zephyr/net/net_core.h>
|
||||
#include <zephyr/net/net_l2.h>
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/bt.h>
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/hci.h>
|
||||
|
||||
static int shell_cmd_connect(const struct shell *sh,
|
||||
size_t argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
bt_addr_le_t addr;
|
||||
struct net_if *iface = net_if_get_default();
|
||||
|
||||
if (argc < 3) {
|
||||
shell_help(sh);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
err = bt_addr_le_from_str(argv[1], argv[2], &addr);
|
||||
if (err) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Invalid peer address (err %d)\n", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (net_mgmt(NET_REQUEST_BT_CONNECT, iface, &addr, sizeof(addr))) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Connection failed\n");
|
||||
} else {
|
||||
shell_fprintf(sh, SHELL_NORMAL,
|
||||
"Connection pending\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shell_cmd_scan(const struct shell *sh,
|
||||
size_t argc, char *argv[])
|
||||
{
|
||||
struct net_if *iface = net_if_get_default();
|
||||
|
||||
if (argc < 2) {
|
||||
shell_help(sh);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
if (net_mgmt(NET_REQUEST_BT_SCAN, iface, argv[1], strlen(argv[1]))) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Scan failed\n");
|
||||
} else {
|
||||
shell_fprintf(sh, SHELL_NORMAL,
|
||||
"Scan in progress\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shell_cmd_disconnect(const struct shell *sh,
|
||||
size_t argc, char *argv[])
|
||||
{
|
||||
struct net_if *iface = net_if_get_default();
|
||||
|
||||
if (net_mgmt(NET_REQUEST_BT_DISCONNECT, iface, NULL, 0)) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Disconnect failed\n");
|
||||
} else {
|
||||
shell_fprintf(sh, SHELL_NORMAL,
|
||||
"Disconnected\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shell_cmd_advertise(const struct shell *sh,
|
||||
size_t argc, char *argv[])
|
||||
{
|
||||
struct net_if *iface = net_if_get_default();
|
||||
|
||||
if (argc < 2) {
|
||||
shell_help(sh);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
if (net_mgmt(NET_REQUEST_BT_ADVERTISE, iface, argv[1],
|
||||
strlen(argv[1]))) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Advertise failed\n");
|
||||
} else {
|
||||
shell_fprintf(sh, SHELL_NORMAL,
|
||||
"Advertise in progress\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(bt_commands,
|
||||
SHELL_CMD(advertise, NULL,
|
||||
"on/off",
|
||||
shell_cmd_advertise),
|
||||
SHELL_CMD(connect, NULL,
|
||||
"<address: XX:XX:XX:XX:XX:XX> <type: (public|random)>",
|
||||
shell_cmd_connect),
|
||||
SHELL_CMD(scan, NULL,
|
||||
"<on/off/active/passive>",
|
||||
shell_cmd_scan),
|
||||
SHELL_CMD(disconnect, NULL,
|
||||
"",
|
||||
shell_cmd_disconnect),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
SHELL_CMD_REGISTER(net_bt, &bt_commands, "Net Bluetooth commands", NULL);
|
||||
|
||||
void net_bt_shell_init(void)
|
||||
{
|
||||
}
|
|
@ -12,11 +12,6 @@ if(CONFIG_NET_CONFIG_SETTINGS)
|
|||
CONFIG_NET_L2_IEEE802154
|
||||
ieee802154_settings.c
|
||||
)
|
||||
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_NET_L2_BT
|
||||
bt_settings.c
|
||||
)
|
||||
endif()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_NET_CONFIG_CLOCK_SNTP_INIT init_clock_sntp.c)
|
||||
|
|
|
@ -185,14 +185,6 @@ config NET_CONFIG_IEEE802154_ACK_REQUIRED
|
|||
|
||||
endif # NET_L2_IEEE802154 || IEEE802154_RAW_MODE
|
||||
|
||||
config NET_CONFIG_BT_NODE
|
||||
bool "Bluetooth node support"
|
||||
depends on NET_L2_BT
|
||||
select NET_L2_BT_MGMT
|
||||
help
|
||||
Enables application to operate in node mode which requires GATT
|
||||
service to be registered and start advertising as peripheral.
|
||||
|
||||
endif # NET_CONFIG_SETTINGS
|
||||
|
||||
if NET_DHCPV6
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* IEEE 802.15.4 settings code */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <zephyr/net/net_if.h>
|
||||
#include <zephyr/net/net_core.h>
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
#include <zephyr/net/bt.h>
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/uuid.h>
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
|
||||
#if defined(CONFIG_NET_CONFIG_BT_NODE)
|
||||
#define ADV_STR "on"
|
||||
|
||||
BT_GATT_SERVICE_DEFINE(ipss_svc,
|
||||
/* IP Support Service Declaration */
|
||||
BT_GATT_PRIMARY_SERVICE(BT_UUID_IPSS),
|
||||
);
|
||||
#endif
|
||||
|
||||
int z_net_config_bt_setup(void)
|
||||
{
|
||||
struct net_if *iface;
|
||||
const struct device *dev;
|
||||
int err;
|
||||
|
||||
err = bt_enable(NULL);
|
||||
if (err < 0 && err != -EALREADY) {
|
||||
return err;
|
||||
}
|
||||
|
||||
dev = device_get_binding("net_bt");
|
||||
if (!dev) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
iface = net_if_lookup_by_dev(dev);
|
||||
if (!iface) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_CONFIG_BT_NODE)
|
||||
if (net_mgmt(NET_REQUEST_BT_ADVERTISE, iface, ADV_STR,
|
||||
sizeof(ADV_STR))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
/* IEEE 802.15.4 settings header */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NET_L2_BT) && defined(CONFIG_NET_CONFIG_SETTINGS)
|
||||
int z_net_config_bt_setup(void);
|
||||
#else
|
||||
#define z_net_config_bt_setup(...) 0
|
||||
#endif
|
|
@ -29,7 +29,6 @@ LOG_MODULE_REGISTER(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
|
|||
#include <zephyr/net/net_config.h>
|
||||
|
||||
#include "ieee802154_settings.h"
|
||||
#include "bt_settings.h"
|
||||
|
||||
extern int net_init_clock_via_sntp(void);
|
||||
|
||||
|
@ -501,14 +500,6 @@ int net_config_init_app(const struct device *dev, const char *app_info)
|
|||
NET_ERR("Cannot setup IEEE 802.15.4 interface (%d)", ret);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
/* Bluetooth is only usable if IPv6 is enabled */
|
||||
ret = z_net_config_bt_setup();
|
||||
if (ret < 0) {
|
||||
NET_ERR("Cannot setup Bluetooth interface (%d)", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Only try to use a network interface that is auto started */
|
||||
if (iface == NULL) {
|
||||
net_if_foreach(iface_find_cb, &iface);
|
||||
|
|
|
@ -404,9 +404,6 @@ skip_ipv6:
|
|||
if (
|
||||
#if defined(CONFIG_NET_L2_IEEE802154)
|
||||
(net_if_l2(iface) == &NET_L2_GET_NAME(IEEE802154)) ||
|
||||
#endif
|
||||
#if defined(CONFIG_NET_L2_BT)
|
||||
(net_if_l2(iface) == &NET_L2_GET_NAME(BLUETOOTH)) ||
|
||||
#endif
|
||||
0) {
|
||||
PR_WARNING("%s not %s for this interface.\n", "IPv4",
|
||||
|
|
|
@ -202,16 +202,6 @@ const char *iface2str(struct net_if *iface, const char **extra)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_L2_BT
|
||||
if (net_if_l2(iface) == &NET_L2_GET_NAME(BLUETOOTH)) {
|
||||
if (extra) {
|
||||
*extra = "=========";
|
||||
}
|
||||
|
||||
return "Bluetooth";
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_OFFLOAD
|
||||
if (net_if_is_ip_offloaded(iface)) {
|
||||
if (extra) {
|
||||
|
|
|
@ -93,26 +93,13 @@ CONFIG_NET_L2_ETHERNET=y
|
|||
CONFIG_NET_L2_CANBUS_RAW=y
|
||||
CONFIG_NET_L2_ETHERNET_MGMT=y
|
||||
CONFIG_NET_L2_IEEE802154_RADIO_DFLT_TX_POWER=2
|
||||
CONFIG_NET_L2_BT=y
|
||||
CONFIG_NET_L2_BT_ZEP1656=y
|
||||
CONFIG_NET_L2_BT_SEC_LEVEL=4
|
||||
CONFIG_NET_L2_BT_MGMT=y
|
||||
CONFIG_NET_L2_BT_SHELL=y
|
||||
CONFIG_NET_L2_IEEE802154_LOG_LEVEL_DBG=y
|
||||
CONFIG_NET_L2_ETHERNET_LOG_LEVEL_DBG=y
|
||||
CONFIG_NET_L2_BT_LOG_LEVEL_DBG=y
|
||||
CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL_DBG=y
|
||||
CONFIG_NET_L2_WIFI_MGMT=y
|
||||
CONFIG_NET_L2_WIFI_SHELL=y
|
||||
CONFIG_NET_L2_PTP=y
|
||||
|
||||
# Bluetooth IPSP
|
||||
CONFIG_BT=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
|
||||
# IP offload support
|
||||
CONFIG_NET_OFFLOAD=y
|
||||
CONFIG_NET_OFFLOAD_LOG_LEVEL_DBG=y
|
||||
|
@ -188,7 +175,6 @@ CONFIG_NET_CONFIG_IEEE802154_CHANNEL=15
|
|||
CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY="key"
|
||||
CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY_MODE=0
|
||||
CONFIG_NET_CONFIG_IEEE802154_SECURITY_LEVEL=0
|
||||
CONFIG_NET_CONFIG_BT_NODE=y
|
||||
CONFIG_NET_CONFIG_AUTO_INIT=y
|
||||
CONFIG_NET_CONFIG_IEEE802154_RADIO_TX_POWER=10
|
||||
CONFIG_NET_CONFIG_INIT_PRIO=90
|
||||
|
@ -368,7 +354,6 @@ CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=10
|
|||
CONFIG_NET_SOCKETS_TLS_MAX_CREDENTIALS=10
|
||||
|
||||
# Network interface defaults
|
||||
CONFIG_NET_DEFAULT_IF_BLUETOOTH=y
|
||||
CONFIG_NET_DEFAULT_IF_CANBUS_RAW=y
|
||||
CONFIG_NET_DEFAULT_IF_DUMMY=y
|
||||
CONFIG_NET_DEFAULT_IF_ETHERNET=y
|
||||
|
@ -572,11 +557,6 @@ CONFIG_SHELL_MQTT_INIT_LOG_LEVEL_ERR=y
|
|||
#CONFIG_NET_IPV6_NBR_CACHE_LOG_LEVEL_INF
|
||||
#CONFIG_NET_IPV6_NBR_CACHE_LOG_LEVEL_OFF
|
||||
#CONFIG_NET_IPV6_NBR_CACHE_LOG_LEVEL_WRN
|
||||
#CONFIG_NET_L2_BT_LOG_LEVEL_DEFAULT
|
||||
#CONFIG_NET_L2_BT_LOG_LEVEL_ERR
|
||||
#CONFIG_NET_L2_BT_LOG_LEVEL_INF
|
||||
#CONFIG_NET_L2_BT_LOG_LEVEL_OFF
|
||||
#CONFIG_NET_L2_BT_LOG_LEVEL_WRN
|
||||
#CONFIG_NET_L2_ETHERNET_LOG_LEVEL_DEFAULT
|
||||
#CONFIG_NET_L2_ETHERNET_LOG_LEVEL_ERR
|
||||
#CONFIG_NET_L2_ETHERNET_LOG_LEVEL_INF
|
||||
|
|
Loading…
Reference in a new issue