# An Automatic Embedded Device Registration Procedure Based on the OGC SensorThings API
## 3 Methodology
### Communication Protocol for the Gateway Layer and the Device Layer
#### 3.2.1 ZigBee Configuration  
To wirelessly connect to the Internet, Wi-Fi was designed for wireless Ethernet connectivity. However, Wi-Fi modules have high power consumption for embedded devices to support. Therefore, wireless network techniques with low power consumption are more preferable for embedded devices, such as Bluetooth, ZigBee, LoRa, SigFox, NB-IoT, etc. Therefore, in the SW-IoT architecture, a gateway should communicate with devices via these low-power-consumption wireless communication protocols and connect with services via Wi-Fi or Ethernet. In this research, we choose ZigBee as the wireless communication network to prove the concept. ZigBee [27] is based on the IEEE 802.15.4 standard [28]. The IEEE 802.15.4 standard focuses on low energy consumption, low-rate transmission, and low-cost wireless network to provide low-speed interconnection between different devices. As the transmission distance of ZigBee is about 10-100 m, ZigBee is suitable for many small-scale SW-IoT use cases, such as smart home, e-health, industrial 4.0. According to the IEEE 802.15.4 standard, a ZigBee network has full-function devices (FFDs) and reduced-function devices (RFDs). An FFD can communicate with both FFDs and RFDs. An FFD can only communicate with FFDs. An FFD associated with an RFD is called the coordinator of that RFD. There is an only FFD, called PAN (Personal Area Network) coordinator, in one ZigBee network, which is the main controller of that network. The PAN coordinator is responsible for managing other FFDs (i.e., routers) and RFDs (i.e., end devices) in the network. The PAN coordinator needs to select a PAN ID (16-bit and 64-bit) and a channel to establish the network. All devices in one ZigBee network share the same PAN ID and channel with the PAN coordinator. While the 16-bit PAN ID is randomly selected when a PAN coordinator starts a new network, the ZigBee Alliance defines the 64-bit PAN ID (i.e., Extended PAN ID) which can be preconfigured on a PAN coordinator. Other devices that are configured with the same 64-bit PAN ID can join the same network. Each ZigBee device possesses 16-bit and 64-bit addresses. The 16-bit address, also called a network address, is randomly generated by the coordinator that allows the device to join the network. However, the 16-bit address is not static, which is sometimes not reliable for data transmission. On the other hand, the 64-bit address, also called extended address or IEEE address, is a universally unique identifier for a ZigBee device, which is a better choice to identify destination devices. Table 1 shows our design for the IoT-PNP default ZigBee network configuration. First of all, to allow devices to connect to gateways automatically, the wireless communication modules of both devices and gateways should share the same PAN ID. Gateways and devices which want to support the IoT-PNP should follow the defined extended PAN ID (i.e., 14,647). Second of all, based on the ZigBee standard, to configure ZigBee network that (1) the PAN coordinator forwards messages to all devices (i.e., broadcast mode) and (2) messages from devices are transmitted/forwarded to the PAN coordinator, where we define that the PAN coordinator uses \"0 xFF\" as the extended address of destination to broadcast messages to the entire network, and routers and end devices use \"0\" as the extended address of destination to forward messages to the PAN coordinator. Please note that the role of this configuration is intended to be a global or national setting to establish a public gateway infrastructure, and the current ZigBee configuration is defined to prove the concept. However, this public configuration would result in security concerns such as intercepting \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Configuration** \\ \hline extended PAN ID (64-bit) & 14,647 \\ destination extended address (64-bit) & Coordinator: 0 xFF \\  & Router/End device: 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: IoT-Plug and Play (PNP) ZigBee network configurations.