{"id":2402,"date":"2016-11-29T22:46:58","date_gmt":"2016-11-30T06:46:58","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=2402"},"modified":"2016-11-29T22:46:58","modified_gmt":"2016-11-30T06:46:58","slug":"connecting-the-nordic-nrf52-chip-to-ipv6-networks-via-6lowpan","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/nrf51\/6lowpan\/","title":{"rendered":"Connecting the Nordic nRF52 chip to IPv6 networks via 6LoWPAN"},"content":{"rendered":"<p>This tutorial shows how to create a basic 6LoWPAN (IPv6 over Bluetooth) device using the Nordic nRF5x IoT SDK, connect it to an IPv6 network using Raspberry Pi 3 as a Bluetooth-to-Ethernet router and access the device from a PC connected to Ethernet or WiFi.<\/p>\n<p>The Bluetooth LE-powered NRF52 device cannot directly connect to a WiFi network, so it requires a device like Raspberry Pi 3 that will communicate to it via Bluetooth LE and forward the traffic from it to other Ethernet devices:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/overview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2403\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/overview.png\" alt=\"overview\" width=\"1010\" height=\"325\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/overview.png 1010w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/overview-300x97.png 300w\" sizes=\"(max-width: 1010px) 100vw, 1010px\" \/><\/a>We will show how to create a basic firmware that responds to the &#8216;ping&#8217; packets and how to configure Raspberry Pi to do the necessary routing. Instead of Raspberry Pi 3 you can use any other Linux board that supports Bluetooth LE (or use a USB-to-Bluetooth LE dongle).<\/p>\n<p>Before you begin, install Visual Studio and VisualGDB.<\/p>\n<ol>\n<li>Open Visual Studio and launch the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/01-newprj1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2404\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/01-newprj1.png\" alt=\"01-newprj\" width=\"786\" height=\"452\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/01-newprj1.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/01-newprj1-300x173.png 300w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/li>\n<li>Proceed with the default MSBuild subsystem:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/02-msbuild2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2405\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/02-msbuild2.png\" alt=\"02-msbuild\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/02-msbuild2.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/02-msbuild2-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>Select your ARM toolchain and the <strong>nRF52832_XXAA (IoT)<\/strong> device. Note that the regular <strong>nRF52832_XXAA<\/strong> device will create a project based on the regular nRF5x SDK that does not support IPv6-over-Bluetooth functionality:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/03-device2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2406\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/03-device2.png\" alt=\"03-device\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/03-device2.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/03-device2-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>If you don&#8217;t see the IoT device in the device list, click &#8220;Download more devices&#8221; and install the Nordic nRF52 IoT BSP:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/04-getiot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2407\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/04-getiot.png\" alt=\"04-getiot\" width=\"720\" height=\"421\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/04-getiot.png 720w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/04-getiot-300x175.png 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/a><\/li>\n<li>On the Sample Selection page proceed with the default IoT ICMP sample:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/05-icmp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2408\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/05-icmp.png\" alt=\"05-icmp\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/05-icmp.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/05-icmp-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Select your debug interface on the last page. The nRF52-DK board comes with an on-board Segger J-Link, so we will use it in this tutorial:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/06-segger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2409\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/06-segger.png\" alt=\"06-segger\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/06-segger.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/06-segger-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project and build it via Build-&gt;Build Solution:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/07-build2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2410\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/07-build2.png\" alt=\"07-build\" width=\"977\" height=\"646\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/07-build2.png 977w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/07-build2-300x198.png 300w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/li>\n<li>Now we will modify the sample project to blink the LEDs each time it receives an ICMP echo (ping) packet. First of all, reduce the <strong>LED_BLINK_INTERVAL_MS<\/strong> to 100 and add a new member called <strong>LEDS_BLINK_ONCE_MODE<\/strong> to <strong>display_state_t<\/strong>:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/08-blinkonce.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2411\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/08-blinkonce.png\" alt=\"08-blinkonce\" width=\"977\" height=\"646\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/08-blinkonce.png 977w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/08-blinkonce-300x198.png 300w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/li>\n<li>Then add a global <strong>g_PingCount<\/strong> variable and insert the following code to the <strong>ICMP_TYPE_ECHO_REQUEST<\/strong> handler to initiate the LED blinking:\n<pre class=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 m_disp_state\u00a0 = LEDS_BLINK_ONCE_MODE;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 g_PingCount++;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 m_led_feedback_enabled = false;<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/09-startblink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2412\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/09-startblink.png\" alt=\"09-startblink\" width=\"977\" height=\"646\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/09-startblink.png 977w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/09-startblink-300x198.png 300w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/li>\n<li>Finally locate the <strong>LEDS_BLINK_MODE<\/strong> case inside <strong>blink_timeout_handler()<\/strong> and add a similar handler for <strong>LEDS_BLINK_ONCE_MODE<\/strong>:\n<pre class=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case LEDS_BLINK_ONCE_MODE:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (previous_display_state != LEDS_BLINK_ONCE_MODE)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LEDS_OFF(RESPONSE_LED_1 | RESPONSE_LED_2);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 m_blink_count = 0;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (++m_blink_count &lt; 2)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LEDS_INVERT(RESPONSE_LED_1 | RESPONSE_LED_2);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LEDS_OFF(RESPONSE_LED_1 | RESPONSE_LED_2);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 m_disp_state = LEDS_IPV6_IF_UP;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 };\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/10-blinklogic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2413\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/10-blinklogic.png\" alt=\"10-blinklogic\" width=\"977\" height=\"646\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/10-blinklogic.png 977w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/10-blinklogic-300x198.png 300w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/li>\n<li>Press F5 to start debugging your program. If you have not tried your Raspberry Pi yet, follow <a href=\"http:\/\/visualgdb.com\/tutorials\/raspberry\/\">this tutorial<\/a> to prepare the SD card and ensure that the board is accessible via network. Otherwise connect to your Raspberry Pi using <a href=\"http:\/\/smartty.sysprogs.com\/\">SmarTTY<\/a> and run the following commands:\n<pre class=\"\">sudo su\r\nmodprobe bluetooth_6lowpan\r\necho 1 &gt; \/sys\/kernel\/debug\/bluetooth\/6lowpan_enable\r\nhcitool lescan<\/pre>\n<p>The first 2 commands load and enable the IPv6-over-Bluetooth support on Raspberry Pi. The last command scans for the nearby Bluetooth LE devices. It should show your nRF52 board with the\u00a0 IPv6ICMP name:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/11-scan.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2414\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/11-scan.png\" alt=\"11-scan\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/11-scan.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/11-scan-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a>If the board does not appear in the hcitool output, try resetting it while hcitool is running.<\/li>\n<li>Now you should be able to connect to your nRF52 firmware. Run the following command in the &#8216;sudo&#8217; prompt:\n<pre class=\"\">echo \"connect &lt;mac address from hcitool output&gt; 1\" &gt; \/sys\/kernel\/debug\/bluetooth\/6lowpan_control<\/pre>\n<p>Once the connection is complete, a new network interface called &#8216;bt0&#8217; should appear on your Raspberry Pi. You can check this by typing &#8220;ifconfig bt0&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/12-connect.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2415\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/12-connect.png\" alt=\"12-connect\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/12-connect.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/12-connect-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a><\/li>\n<li>Now we will try to ping the Bluetooth LE device from Raspberry Pi. As we have not configured any routing yet, this needs to be done using the link-local IPv6 address of the nRF52 device derived from its MAC address. For a MAC address of <strong>&lt;XX&gt;:&lt;#1&gt;:&lt;#2&gt;:&lt;#3&gt;:&lt;#4&gt;:&lt;#5&gt;<\/strong> the link-local IPv6 address will be <strong>fe80::02&lt;#1&gt;:&lt;#2&gt;ff:fe&lt;#3&gt;:&lt;#4&gt;&lt;#5&gt;<\/strong>. E.g. for the MAC address of <strong>00:F5:3F:54:09:6B<\/strong> the ping command will be the following:\n<pre class=\"\">ping6 fe80::2f5:3fff:fe54:096b -I bt0<\/pre>\n<p>Note that IPv6 addresses starting with <strong>fe80<\/strong> are special link-local addresses that are not globally unique are not routed between network interfaces. In order to ping a device based on its link-local address, you need to specify the <strong>bt0<\/strong> interface in the &#8216;ping6&#8217; command explicitly (-I bt0).<\/li>\n<li>The pings should now succeed and the LEDs on the board should blink each time a packet is received by the board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/13-ping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2416\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/13-ping.png\" alt=\"13-ping\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/13-ping.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/13-ping-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a><\/li>\n<li>You can observe how the device receives the ping packets via the Live Variables window in VisualGDB. Simply add <strong>g_PingCount<\/strong> to Live Variables and try pinging the board again. Note that most likely stopping the debugger to add a variable will cause an internal overflow in the nRF52 softdevice and the connection will be dropped:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/14-noiface.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2417\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/14-noiface.png\" alt=\"14-noiface\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/14-noiface.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/14-noiface-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a><\/li>\n<li>To fix that, reset the firmware via the &#8216;reset device&#8217; button in the GDB Session window and reconnect to your device from Raspberry Pi:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/15-ping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2418\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/15-ping.png\" alt=\"15-ping\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/15-ping.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/15-ping-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a><\/li>\n<li>Observe how the <strong>g_Pings<\/strong> value is increasing each time a ping packet reaches the device:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/16-live.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2419\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/16-live.png\" alt=\"16-live\" width=\"977\" height=\"646\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/16-live.png 977w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/16-live-300x198.png 300w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/li>\n<li>Now we will show how to configure your Raspberry Pi to route packets between the nRF52 board and normal network devices like your PC. This consists of 3 steps:\n<ol style=\"list-style-type: upper-alpha;\">\n<li>Configuring an IPv6 network connecting your Raspberry Pi and the nRF52 device (<strong>fd00:a::&#8230;<\/strong> addresses)<\/li>\n<li>Configuring an IPv6 network connecting your PC and Raspberry Pi (<strong>fd00:b::&#8230;<\/strong> addresses)<\/li>\n<li>Configuring routing between networks A and B<\/li>\n<\/ol>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/routing2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2427\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/routing2.png\" alt=\"routing\" width=\"1360\" height=\"408\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/routing2.png 1360w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/routing2-300x90.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/routing2-1024x307.png 1024w\" sizes=\"(max-width: 1360px) 100vw, 1360px\" \/><\/a><\/li>\n<li>First of all we will setup a network between Raspberry Pi and the nRF52 board (Network A). We will configure Raspberry Pi to give global (not link-local) IPv6 addresses to the connected Bluetooth devices. Install the radvd package (<strong>sudo apt-get install radvd<\/strong>) and put the following contents to the <strong>\/etc\/radvd.conf<\/strong> file:\n<pre class=\"\">interface bt0\r\n{\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0AdvSendAdvert on;\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0prefix fd00:a::\/64\r\n\u00a0\u00a0 \u00a0{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0AdvOnLink off;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0AdvAutonomous on;\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0AdvRouterAddr on;\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0};\r\n};<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/21-radvdconf.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2428\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/21-radvdconf.png\" alt=\"21-radvdconf\" width=\"936\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/21-radvdconf.png 936w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/21-radvdconf-300x154.png 300w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a>To get a global address for your nRF52 board, replace the &#8220;fe80&#8221; prefix in the local-link address with the prefix of your network A. E.g. a node that has a link-local address of <strong>fe80::2f5:3fff:fe54:096b<\/strong>, will have a global address of <strong>fd00:a::2f5:3fff:fe54:096b<\/strong> in the<strong> fd00:a::&#8230;<\/strong> network.<\/li>\n<li>Before we can access the nRF52 board using the new address, we need to do several extra configuration steps. First we need to enable IPv6 forwarding:\n<pre class=\"\">echo 1 &gt; \/proc\/sys\/net\/ipv6\/conf\/all\/forwarding\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Then we need to assign a static address from the network A (e.g.<strong> fd00:a::1<\/strong>) to the <strong>bt0<\/strong> interface so that Raspberry Pi can be on the same network with the Bluetooth devices and communicate to them:<\/p>\n<pre class=\"\">ifconfig bt0 add fd00:a::1\/64<\/pre>\n<p>Finally we need to restart the <strong>radvd<\/strong> service so that Raspberry Pi can assign an IP address to the nRF52 board:<\/p>\n<pre class=\"\">service radvd restart<\/pre>\n<p>Now try pinging your nRF52 device using the global address:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/23-ping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2429\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/23-ping.png\" alt=\"23-ping\" width=\"936\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/23-ping.png 936w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/23-ping-300x154.png 300w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a>Note that the &#8220;-I&#8221; parameter is no longer required as we are no longer using the link-local addresses.<\/li>\n<li>Now we will setup the network between Raspberry Pi and your PC (network B). Enable IPv6 for your network interface on Windows and run the &#8220;ipconfig&#8221; command to find out the IP address:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/17-ipconfig.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2423\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/17-ipconfig.png\" alt=\"17-ipconfig\" width=\"825\" height=\"469\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/17-ipconfig.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/17-ipconfig-300x171.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>If the only IP address you see starts with <strong>fe80<\/strong>, it the link-local IPv6 address that cannot be routed to the Bluetooth device on the network B. You can fix this by adding a static address using the following command:\n<pre class=\"\">netsh interface ipv6 add address &lt;connection name&gt; &lt;address&gt;\/&lt;mask&gt;<\/pre>\n<p>You can use any addresses starting with <strong>fd00<\/strong> for your private networks (<strong>fd00<\/strong> addresses are roughly equivalent to <strong>192.168.x.y<\/strong> in IPv4) . In this tutorial we will use<strong> fd00:b::1<\/strong> for the Ethernet interface of Raspberry Pi and<strong> fd00:b::2<\/strong> for the Windows PC:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/18-addlocal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2424\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/18-addlocal.png\" alt=\"18-addlocal\" width=\"825\" height=\"526\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/18-addlocal.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/18-addlocal-300x191.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a>The <strong>fd00:b::2\/64<\/strong> expression corresponds to a network containing <strong>fd00:000b:0000:0000:xxxx:xxxx:xxxx:xxxx<\/strong> addresses. Both <strong>fd00:b::1<\/strong> and <strong>fd00:b::2<\/strong> belong to it, but <strong>fd00:a::1<\/strong> and the nRF52 addresses starting with <strong>fd00:a<\/strong> do not.<\/li>\n<li>Now assign a static IPv6 address from the same network to your Raspberry Pi:\n<pre class=\"\">ifconfig eth0 add &lt;address&gt;\/&lt;mask&gt;<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/19-ifconfig.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2425\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/19-ifconfig.png\" alt=\"19-ifconfig\" width=\"830\" height=\"480\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/19-ifconfig.png 830w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/19-ifconfig-300x173.png 300w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/a><\/li>\n<li>Finally test the IPv6 connection between Raspberry Pi and your PC by pinging Raspberry Pi from Windows:\n<pre class=\"\">ping &lt;IPv6 address of Raspberry Pi&gt;<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/20-ping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2426\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/20-ping.png\" alt=\"20-ping\" width=\"825\" height=\"301\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/20-ping.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/20-ping-300x109.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>Now that have configured both Network A and Network B, we can setup routing between them. Try pinging the Network A address of Raspberry Pi from your PC:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/24-nowinping.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2430\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/24-nowinping.png\" alt=\"24-nowinping\" width=\"825\" height=\"322\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/24-nowinping.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/24-nowinping-300x117.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>The pings will not go through because Windows does not know how to send packets to network A. You can fix that by adding a static route:\n<pre class=\"\">netsh interface ipv6 add route &lt;Network A address&gt;\/&lt;Network A mask&gt; &lt;connection name&gt; &lt;Network B address of Raspberry Pi&gt;<\/pre>\n<p>In our example the command will look like this:<\/p>\n<pre class=\"\">netsh interface ipv6 add route fd00:a::\/64 &lt;connection name&gt; fd00:b::1<\/pre>\n<\/li>\n<li>This instructs Windows to send packets addressed to <strong>fd00:a:&#8230;<\/strong> directly to <strong>fd00:b::1<\/strong> (that is on the same network as the PC) expecting that it will forward them properly. Try pinging the Raspberry Pi address from Network A again:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/25-ping2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2432\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/25-ping2.png\" alt=\"25-ping2\" width=\"825\" height=\"369\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/25-ping2.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/25-ping2-300x134.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>Now you can try pinging the global IPv6 address of the nRF52 board from Windows:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/26-pingdev.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2431\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/26-pingdev.png\" alt=\"26-pingdev\" width=\"825\" height=\"369\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/26-pingdev.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/26-pingdev-300x134.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>If the ping packets don&#8217;t reach the board, try enabling forwarding on Raspberry Pi explicitly:\n<pre class=\"\">ip6tables -A FORWARD -i eth0 -o bt0 -j ACCEPT -d fd0:a::\/64\r\nip6tables -A FORWARD -i bt0 -o eth0 -j ACCEPT<\/pre>\n<p>This will explicitly forward all packets addressed to Network A from <strong>eth0<\/strong> to <strong>bt0<\/strong> and all packets from <strong>bt0<\/strong> to <strong>eth0<\/strong>.<\/li>\n<li>You can check how the packets are routed by running the &#8216;tracert&#8217; command on Windows. It will show that the packets to the nRF52 board are sent through your Raspberry Pi:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/27-tracert.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2433\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/27-tracert.png\" alt=\"27-tracert\" width=\"825\" height=\"232\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/27-tracert.png 825w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/27-tracert-300x84.png 300w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/a><\/li>\n<li>If you restart your nRF52 firmware, the Bluetooth connection will be lost and the <strong>bt0<\/strong> interface will disappear. To reconnect it and setup routing again, run the following commands:\n<pre class=\"\">echo \"connect &lt;MAC address&gt; 1\" &gt; \/sys\/kernel\/debug\/bluetooth\/6lowpan_control\r\nifconfig bt0 add fd00:a::1\/64\r\nservice radvd restart<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/28-reconn.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2434\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/28-reconn.png\" alt=\"28-reconn\" width=\"936\" height=\"293\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/28-reconn.png 936w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/11\/28-reconn-300x94.png 300w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create a basic 6LoWPAN (IPv6 over Bluetooth) device using the Nordic nRF5x IoT SDK, connect<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[96,56,95],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2402"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=2402"}],"version-history":[{"count":4,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2402\/revisions"}],"predecessor-version":[{"id":2451,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2402\/revisions\/2451"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=2402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=2402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=2402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}