# Streetlight Control System Based on Wireless Communication over DALI Protocol
## 3 System Architecture
### Network Topology  
The 802.15.4 standard is framed within the area of the wireless personal area networks (WPANs), with low consumption and cost. As a result, it is increasingly gaining relevance in the industrial  
Figure 1: Architecture of the system.  
domain. Standard 802.15.4 only defines the physical and media access control layers. A network and application layer has been developed on this standard, as shown by Figure 2.  
Standard 802.15.4 defines two types of topologies: star and peer-to-peer networks. The peer-to-peer topology allows each node of the network to communicate with any other node, provided that the node is within its range. The star topology allows the establishment of communication among the devices and of a sole central node that acts as the network coordinator. The network coordinator is responsible for starting and finishing the connections, and any communication between two nodes must compulsorily pass through the network coordinator.  
The network layer must take the topology of the lighting network into account. On the one hand, each luminaire is controlled by a node with 802.15.4 communication capacities. On the other hand, the luminaires are often deployed along long streets, which results in a linear structure with slight branches. Taking this topology formed by the luminaires into account, a tree topology created from the peer-to-peer connection possibilities of standard 802.15.4 has been chosen.  
In the tree topology, the coordinator is located on the first level of the network, with several end devices and a router. The router forms a new network level consisting of several end devices and a new router, and so on until the desired number of levels required in each case is achieved. The number of leaps allowed by the network layer must be high. This type of structure does not adapt well to any usual topology in wireless networks or to any standard. For example, Zigbee Pro has a limited tree-type number of network layers, with a maximum depth of 15. The number of network hops allowable within ZigBee PRO is increased to 30 from the 10 allowed under ZigBee.  
A tree topology with a high depth entails a serious routing problem, as almost all nodes need to have this ability. In [22], a novel routing algorithm is proposed for streetlight systems. Additionally, there are few alternatives in the event of an intermediate node failure. The allocation of addresses turns into a complex problem as well. In [23; 24; 25], a new address-allocation method that improves ZigBee tree addressing is proposed, which offers some results in simulations. For these reasons, we decided to create our own network layer that could adapt to a tree topology with a high number of levels: the computer that serves as the origin or destination of all exchanged information on the network. That is, we have implemented the communication by using IEEE 802.15.4 Std. and by creating our own (ad-hoc) Network layer (NWK).  
Each node has two unique identifiers--the radio module's MAC address and a node identifier (nodeID)--that allow it to be located by the application, similar to a lamp address. In this way, when a radio module is replaced, only the same nodeID needs to be selected in the node. This nodeID is easily set with a microswitch. The nodeID has a length of 16 bits and can select up to 65,536 ballasts, which  
Figure 2: Layers model.  
increases the number of ballasts that can be routed by a DALI controller. The user application only needs to know the nodeID. The network layer maintains some tables with the MAC addresses where the frames need to be sent to get to their destination. These tables are dynamically created when the network is initialised, when a node is connected, _etc._