nRF5 SDK v14.2.0
Block transfer server
This information applies to the following SoftDevice: S132

The CoAP block transfer server example illustrates Nordic's implementation of the CoAP block transfer. The CoAP block transfer allows large payloads to be broken into separate packages that can then be handled by the CoAP protocol.

The two CoAP server examples in this SDK have the same behavior, but use different IPv6 protocol stacks as a UDP transport protocol.

Both examples implement an endpoint that hosts the following resources:

    host
    |-- .well-known
    |   `-- core
    `-- block

CoAP server resources required for this example can be accessed by any CoAP client provided the client knows the server's IPv6 address. To use this example, the CoAP client needs to support sending block1 options in order to transfer larger data blocks. This example makes use of CoAP Block transfer library functions in order to ease the encoding and decoding of the block1 options from the CoAP requests.

Figure 1 illustrates how a CoAP client on a PC accesses available resources from a CoAP server. The figure also shows the PC (UART terminal) attached to the kit (CoAP server) and displaying the logs from UART.


CoAP_server_block.svg
Figure 1: Setup of the CoAP server application block transfer capability.


Configuration parameters for all used modules are defined and described in the sdk_config.h file. This file is located in the config subfolder of the main application folder.

Note
This application is not power optimized!
This application will start advertising again after disconnection.

Common module dependency and usage

This section summarizes the usage of nRF5 resources and common modules in the examples with the exceptions of the IoT 6LoWPAN and the IPv6 stack library.

Module Inclusion/Usage Description
Timer 1 One timer is used for servicing the IoT timer.
Buttons 0 No buttons are used in this example.
LEDs 2 LEDs are used to indicate the application states. See LED assignments.
Adv Data Encoder Yes The device name used is 'COAP_Server'. IPSP Service UUID is included in the UUID list.
Scheduler Yes Scheduler is used for processing stack events.

Setup

LED assignments

LED 1 LED 2
Blinking Off Device advertising as BLE peripheral.
On Blinking BLE link established, IPv6 interface down.
Off On BLE link established, IPv6 interface up.
On On Assertion failure in the application.

Testing

See Connecting devices to the router for a list of relevant Linux commands.

  1. Compile and program the application. Observe that the device is advertising.
  2. Prepare the Linux router device by initializing the 6LoWPAN module.
  3. Discover the advertising device by using the hcitool lescan command.
  4. Connect to the discovered device from the Linux console by using the Bluetooth 6LoWPAN connect command.
  5. Check if the connected state is reflected by the LEDs.
  6. Run the Wireshark or hcidump program to monitor the btX interface.
  7. An ICMPv6 ping can be used on the link-local and on the global IPv6 address assigned to the device to check if the device is reachable.
    Note
    To find the global address, use the prefix assigned to the interface in Router Advertisement.
  8. Use any CoAP client with block transfer requests to interact with the application. A freely available CoAP client implementation is the Mozilla Firefox browser with the Copper (Cu) CoAP user-agent add-on (Figure 3).
    Note
    A global address is necessary to test the example with Copper (Cu). Link-local addresses (FE80::) cannot be resolved in the browser as they are not bound to a specific interface.
    This example is designed to complement the Nordic CoAP client example, and they will work together provided that the Nordic CoAP client application is modified with the server address.
  9. Write some large text bulk in the "Outgoing" payload tab.
  10. Select payload "Text" from the top menu of the plugin.
  11. Choose the desired block size you want to test out, for example, a 64-byte block. This can be changed through the "Behavior" menu from the plugin main menu. Note that the text to transfer needs to be larger than the block size chosen in order to make the block transfer succeed. An example of setting the block size is shown in Figure 2.
    coap_block_copper_64_bytes_block_size.png
    Figure 2: Block size settings in the Copper (Cu) CoAP user-agent add-on.
  12. Select content type "text/plain" as Content-Format in order to make the server accept the content format. An example of settings is shown in Figure 3.
    coap_block_copper_content_type.png
    Figure 3: Content-Format settings in the Copper (Cu) CoAP user-agent add-on.
  13. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  14. Select Put in the plugin main menu in order to start the block transfer.
  15. Verify that the blocks are printed out on the UART serial terminal. An example output is shown in Figure 4.
    coap_block_uart_log.png
    Figure 4: PC UART serial log from the connected development kit.
  16. Disconnect from the device using Bluetooth 6LoWPAN disconnect command.
  17. Observe that the device is advertising.

Troubleshooting

  1. It is possible that the global address is not immediately available on the connection as the Neighbor Discovery, Router Advertisement, and Duplicate Address Detection procedures take a few seconds to complete.
  2. If you observe that the CoAP server responses are received at the btX interface but the CoAP client device never receives them, it is possible that the forwarding between networks is not enabled. This can be done on Linux using the command sysctl -w net.ipv6.conf.all.forwarding=1.

Documentation feedback | Developer Zone | Subscribe | Updated