Creating a basic 6LoWPAN HTTP server with Nordic IoT SDK

This tutorial shows how to create a basic HTTP server that will run via the 6LoWPAN (IPv6 over Bluetooth LE) protocol on the Nordic nRF52 device.

Before you begin, follow our basic Nordic IoT tutorial to connect your nRF52 device to your network and configure the necessary routing.

  1. Start Visual Studio and open the VisualGDB Embedded Project Wizard:01-httpprj
  2. Proceed with the default settings on the first page:02-msbuild
  3. Select the IoT version of your Nordic device so that VisualGDB can use the Nordic IoT SDK:03-iot
  4. On the next page select the IoT TCP Server sample:04-tcp
  5. On the last page select the debug method. We recommend debugging nRF52 devices with Segger J-Link:05-debug
  6. Press “Finish” to generate the project and ensure it builds successfully by pressing Ctrl-Shift-B:06-build
  7. The TCP server example will expect special binary packets to be sent to port 9000, so we will modify it to support very basic HTTP requests. First of all, locate the tcp_recv_data_handler() function and replace its contents with the following code:

    It will read the entire HTTP request and respond with a very basic fixed response:07-recv-handler
  8. Now modify the tcp_write_complete() function to simply close the connection:

  9. Press F5 to build and start debugging your program. Then go to your Raspberry Pi and reconnect to the nRF52 via Bluetooth (see the basic Nordic IoT tutorial for the explanation on the rolte of Raspberry Pi):09-restart
  10. Ensure that the board responds to pings:ping
  11. Now you can check the connection to the board by opening http://[IPv6 address in square brackets]:9000/ in your browser (e.g. http://[fd00:a::2f5:3fff:fe54:96b]:9000/):10-hello