![]() |
nRF51 IoT SDK
|
The IoT SDK implements only the Host role of an IPv6 node. Therefore, each node must connect to a router to be accessible to other notes.
Current versions of the Linux kernel ( > 3.17.0-rc1 ) support 6LoWPAN over L2CAP connection oriented channels, so they can be used as a router. Instead of running the router on a standard computer, you can also use our implementation of the Linux kernel for Raspberry PI. See Setting up Raspberry Pi as router for detailed instructions.
Tested Linux kernel version: 3.17.0-rc2
This section lists the most essential Linux commands needed to set up a Linux computer as BLE enabled router. Several of the commands require administrator credentials, so you should log in as a root user by issuing the sudo su
command.
By default debugfs file system is not mounted to specific location. To be aligned with most of the Linux distribution, it is recommended to use /sys/kernel/debug location. To make this mount persist it can also be mounted permanently by editing the /etc/fstab file. The following proceedure can be used to mount the debugfs.
Current versions of the Linux kernel provide support for 6LoWPAN in Bluetooth low energy in a stand-alone module. After initializing it, you get access to essential debugfs files.
The Protocol Service Multiplexer number (PSM) can be set in the module. This must be set to the PSM of the Internet Protocol Support Profile (IPSP), which is 0x23 in hex or 35 decimal.
To load the 6LoWPAN module:
To set the correct PSM number:
To verify that the module is indeed loaded:
To use 6LoWPAN communication, both a GAP connection and an L2CAP connection oriented channel must be established. Both can be controled by the debugfs command 6lowpan_control
. Use this command to connect a device to or disconnect it from the Linux router.
The parameters of this command are:
To establish a 6LoWPAN connection:
To disconnect a device from the router:
HCI commands are used to configure Bluetooth devices. The device name hciX is assigned to the device installed in the system.
To display basic status information about for example interface type, BD address, MTU, and flags (up, running, ...):
To check that the Bluetooth device installed in the system has low energy support:
To reset the HCI device hciX (to ensure that it is cleared before starting):
To discover all advertising devices:
Figure 1 displays an example of the output of the hcitool
command.
The ifconfig
command can be used to display and configure Linux network interfaces that are currently active. After successfully establishing a 6LoWPAN connection, you should see a newly added btX interface in the list.
To display all active network interfaces:
Specifiy an interface name (for example, bt0)to display information about that interface:
Communication between Linux and the device through IPv6 can use different types of protocols. One of these protocols is ICMPv6, which has diagnostic capabilities by sending and receiving echo request and echo response messages.
Use the IPv6 link-local address (see Creating IPv6 addresses) to ping a specific device:
Send an echo request to an IPv6 multicast all nodes address to discover all devices that are currently attached to router:
In this case, not only the device will respond, but also the btX interface itself.
The device will only send an echo response message if the application supports it (for example, when using Nordic's stack).
The entire procedure how to establish a connection between an nRF51 device and the Linux router is presented below. Some of the commands, like loading the 6LoWPAN module or setting the PSM value, can be called only once per Linux session.