nRF51 IoT SDK
|
The Domain Name System (DNS) is the protocol of the IP stack that enables translating the domain name, for example example.com, to a corresponding set of parameters, such as the IPv6 address.
To demonstrate DNS protocol support on nRF51, Nordic's IPv6 stack is used. Currently lwIP does not support AAAA (IPv6) records in the DNS module.
This application implements a simple state machine which queries the DNS Server in order to retrieve the IPv6 address of the given hostname. Right after the response is received, the module starts to send ICMP Echo Requests periodically until the host is reachable. If the maximum retransmission number of ICMP Echo Requests without response is exceeded, the DNS Query is sent again.
The demo setup and flow diagram are presented in Figure 1.
This example demonstrates how Nordic's IPv6 stack can be used for sending a DNS Query and receiving the response packets of the DNS Server.
The state machine of the application is triggered by the BUTTON_1 on the kit and can be stopped by pushing BUTTON_2. The LED configuration indicates the actual state of the process.
The MSC below provides an overview of the data exchange in the application between the node (nRF51) and the router/cloud in two cases:
This section summarizes the usage of nRF51 resources and common modules in the examples apart from the IoT 6lowpan and IPv6 stack library.
Module | Inclusion/Usage | Description |
---|---|---|
Timer | 3 | Three timers - IoT timer, button module and for timing ICMP Ping requests. |
Buttons | 2 | Buttons are used for switching application states. |
LEDs | 4 | LEDs are used to indicate the application states. See LED assignments. |
Adv Data Encoder | Yes | The device name used is 'IPv6DNS', IPSP Service UUID is included in the UUID list. |
Scheduler | No | Scheduler is used for processing stack events. |
UART Trace | Included not enabled | Tracing is included but not enabled by default. |
The name of this example is iot_ipv6_dns. The source code and project file of the example can be found at: <InstallFolder>/Nordic/nrf51/examples/iot/dns
See the short state diagram below that describes the application states.
Application State | LED 1 State | LED 2 State | LED 3 State | LED 4 State |
---|---|---|---|---|
Idle | OFF | OFF | OFF | OFF |
Advertising | BLINKING | OFF | OFF | OFF |
IPv6 Interface Up | OFF | ON | OFF | OFF |
IPv6 Interface Down | ON | OFF | OFF | OFF |
DNS response has been received | OFF | ON | ON | OFF |
Echo Reply has been received | OFF | ON | ON | INVERT |
ASSERT | ON | ON | ON | ON |
See Connecting devices to the router for a list of relevant Linux commands.