## 4 System Implementation of IoT AP
### UPnP Device Management Module  
To allow remote users to discover the ZigBee devices, the _UPnP Device Management Module_ applies the UPnP protocol to broadcast the information of ZigBee devices on to the network. Therefore, the remote users are able to discover the ZigBee devices and subsequently perform the control accesses of the ZigBee devices.  
UPnP is a service discovery protocol proposed by the UPnP Forum. The main purpose of this protocol is to allow various devices connected with each other in a home network. To achieve this goal, the UPnP forum developed an UPnP device control protocol based on the Internet communication network protocol standard. UPnP protocol consists of three basic components, including the device, the service, and the control point (CP). Figure 5 depicts that a user controls UPnP devices through a smartphone. Initially, the UPnP software application is installed in the smartphone, namely the UPnP CP. It is responsible for searching and controlling the UPnP devices. In this situation, the UPnP device plays the role of a media server that provides streaming to execute the command for processing the CP. After a smartphone has discovered a multimedia server, it requests a media streaming. The realization of UPnP streaming is divided into five main steps, including _Discovery_, _Description_, _Control_, _Event Notification_, and _Presentation_. In the _Discovery_ step, the smartphone allows the control point to broadcast its service through SSDP protocol. After the control point has joined the network, the cellphone can search for the UPnP devices in the network. In the _Description_ step, UPnP device uses XML method to provide information (nickname, serial number, manufacturer name, brand, _etc._), service list, control, event and other relevant information for the manufacturer. In the _Control_ step, a CP sends a control message to UPnP device and subsequently the device can be controlled according to the control message. In the _Event Notification_ step, control point can subscribe a service. When the device status changes, the service sends the message to control point in XML format. In the _Presentation_ step, UPnP device can allow the control point to obtain the device status or control through a webpage. Based on the protocols mentioned above, the UPnP Forum standardizes various devices such as printers, multimedia servers, _etc._, with a variety of functions. However, the standardized devices are unable to cover all the ZigBee devices. Therefore, in this paper, the IoT AP uses UPnP protocol to broadcast the ZigBee devices. The following describes how IoT AP uses UPnP protocol to obtain the ZigBee devices status.  
Figure 4: Management Information of ZigBee Device. The pink mark is the command input mark in the CLI (command line interface) mode of Linux.  
To discover the UPnP devices, this paper implemented _UPnP Device Management Module_ by using open-source portable UPnP library [38]. This module operates by obtaining information of the ZigBee device from the ZigBee Device Management Module. Afterward, it puts the information of ZigBee device into UPnP device description file, and subsequently the ZigBee device broadcasts the information of local devices. Therefore, the remote user enable to discover this UPnP device by description file. As shown in Figure 6, this file contains IEEE address, network address, device ID, ZigBee device information and GoAhead web server port and URL. Therefore, when the ZigBee device is removed, this module also removes the corresponding UPnP device. By using the method described above, this module has the ability to manage UPnP devices and allow remote users to search the ZigBee devices through UPnP protocol.