====== WPAN IoT Use Case: IEEE 802.15.4, CoAP and Azure ====== Netualizer can also be used to set up a real life //WPAN// IoT topology. For example: {{:wiki:ieee802154.png?700|}} In this case, an embedded device (a raspberry pi) running a Netualizer agent is connected through an //I2C// interface to an 12-bit Analog-to-Digital (//ADC//) converter //[[https://www.ti.com/product/ADS1015/|ADS1015]]//. The readouts generated by the //ADC// are encapsulated by //CoAP// and transmitted over //IEEE 802.15.4//. The frames eventually arrive at a laptop that also runs a Netualizer agent. The readouts are decapsulated and transmitted over MQTT to a Microsoft Azure IoT Hub. As in other examples, once the controller programs and deploys the agents, it is not needed anymore. The real scenario looks like: {{:1.jpg?800|}} First, let's create a new project by clicking on //File ⇒ New ⇒ Project//. Name it //802154Azure//. Make sure that the local built-in agent does not get attached (uncheck box): {{:2.png?1000|}} Then attach the agent running on the device sensor by clicking on //Agents ⇒ Add Agent// and entering the management IP address of the raspberry pi that runs the Netualizer agent: {{:3.png?1000|}} Double click on the agent entry and name it //sensor//: {{:4.png?1000|}} Attach the agent to the project: {{:5.png?1000|}} Create a physical link layer and select the IEEE 802.15.4 radio: {{:6.png?1000|}} And place it on the configuration: {{:7.png?1000|}} Then let's create an IEEE 802.15.4 layer and call it //ieee802154//: {{:8.png?1000|}} Place it on top of the physical layer: {{:9.png?1000|}} Similarly, create an 6LoWPAN layer, call it //sixlow//, place it on top of the //ieee802154// layer. Then create an IP layer and name it //ip//: {{:11.png?1000|}} Put the //ip// layer on top of the //sixlow// layer and create a new UDP layer and name it //udp//: {{:12.png?1000|}} Place the UDP layer on top of the IP layer and create a new CoAP layer. Call it //coap//: {{:13.png?1000|}} Put the //coap// layer on top of the //udp// layer. The stack should look like: {{:14.png?1000|}} Then create an I2C interface and call it //i2c//: {{:15.png?1000|}} Place it on top of the //coap// layer: {{:16.png?1000|}} Next, let's create an AD1015 helper layer and name it //ads1015//: {{:17.png?1000|}} This finalizes the full stack: {{:18.png?1000|}} Now, let's add the other Netualizer agent running on the laptop by clicking on //Agents ⇒ Add Agent// and entering the management IP address: {{:19.png?1000|}} Double click on the agent entry and name it //gateway//: {{:20.png?1000|}} Add the agent to the project: {{:21.png?1000|}} Create a physical layer and select the IEEE 802.15.4 radio: {{:22.png?1000|}} Then continue to build the whole stack up to the CoAP layer: {{:23.png?1000|}} Now, let's build the ethernet based stack. Click on the physical layer and select the ethernet interface: {{:24.png?1000|}} Place it on the configuration; {{:25.png?1000|}} Click on the ethernet layer and name it //eth//: {{:26.png?1000|}} Put it on top of the physical layer: {{:27.png?1000|}} Then let's create an IP layer and call it //ip2// (since the //ip// layer was created on the IEEE 802.15.4 stack): {{:28.png?1000|}} Set the //ip2// layer on top of the //eth// layer: {{:29.png?1000|}} Create a TCP layer and name it //tcp//: {{:30.png?1000|}} Place it on top of the //ip2// layer: {{:31.png?1000|}} Similarly, create a TLS layer and call it //tls//: {{:32.png?1000|}} Put it on top of the //tcp// layer: {{:33.png?1000|}} Then create an MQTT layer and name it //mqtt//: {{:34.png?1000|}} Place the //mqtt// layer on top of the //tls// layer: {{:35.png?1000|}} Then create an Azure helper layer and name it //azure//: {{:36.png?1000|}} Put it on top of the //mqtt// layer: {{:37.png?1000|}} Now, let's configure the //azure// layer. First let's right click on it and select action: {{:38.png?1000|}} Then select //Publish//: {{:39.png?1000|}} Next select the //Hub Name//: {{:40.png?1000|}} And enter it in accordance with the Azure configuration: {{:41.png?1000|}} Select then the //Device Id//: {{:42.png?1000|}} And, again, enter it in accordance with the Azure configuration: {{:43.png?1000|}} Select the CA certificate: {{:44.png?1000|}} And fill it in: {{:45.png?1000|}} Select the client certificate: {{:46.png?1000|}} And fill it in: {{:47.png?1000|}} And again, select the client private key: {{:48.png?1000|}} And fill it in: {{:49.png?1000|}} Right click on the IP layer to figure out what the IPv6 address of the IEEE 802.15.4 based stack is: {{:50.png?1000|}} Back in the sensor IEEE 802.15.4 stack, select //Url//: {{:51.png?1000|}} And enter the URL that results from the IPv6 address //[2001::41:11]/SensorData//: {{:52.png?1000|}} Also let's make sure to enable //Post Readouts// in the CoAP layer: {{:53.png?1000|}} Change the transmission period on the //ads1015// layer by selecting //Period//: {{:60.png?1000|}} And enter //5000//: {{:61.png?1000|}} In the CoAP layer of the gateway select the //Forward List// field: {{:54.png?1000|}} And enter //SensorData//: {{:55.png?1000|}} Make sure to forward traffic arriving at the CoAP layer to the Azure layer by clicking on //Destination Peer// and selecting //azure//: {{:56.png?1000|}} The gateway configuration then looks like: {{:57.png?1000|}} Then start the suite by clicking on //Scripts ⇒ Run Suite//: {{:58.png?1000|}} Azure's Device Explorer shows the 12-bit readouts: {{:59.png?1000|}}