# EEMIP: Energy-Efficient Communication Using Timing Channels and Prioritization in ZigBee
## 3 The Proposed EEMIP Method
### Priority and Time Interval Selection  
Before the data transmission, the end device needs to decide which priority is used for specific data. This process is explained using an example of the prototype. The prototype of the proposed method supports two priorities, low and high. An end device can assign more important data with the high priority. Based on the selected priority, the time interval is set for the data flow. The time interval is a period in which the device starts the communication (e.g., a time interval of 5 s means that each five seconds the device sends its data). The coordinator can communicate with end devices only during free time slots and cannot communicate with multiple devices at the same time (i.e., each device has a dedicated time slot). Based on this fact, the end device uses time slots to compute its time interval for transmission. Time intervals are computed based on a timestamp from communication with the coordinator. To clarify the difference between a time interval and a time slot, we provide an illustration of time slots in Figure 4.  
Figure 3: Exchange of control messages. Figure 2: Bitwise distribution of message types. The time interval selection algorithm of the end device is provided in Algorithm 1. The algorithm for a time interval assignment by the coordinator to an end device is provided in Algorithm 2. ```
Data: ZigBee communication-initiation phase is over. Time intervals \(T\!I\) for priorities are configured. Input: Received Offer message at the time \(T\). Output: Selected time interval \(T\!I\!(P)\). 1 application selects a suitable priority \(P\) from the Offer message ifSelection not sent then
2 send Selection with priority \(P\) Sleep time = (\(T\!I\! (P)\) - time required for data processing) sleep while time < (\(T\) + Sleep time) repeat
3 process data send data wait for Acknowledgement sleep for (Sleep time - time actually waited for Acknowledgement) until another Offer message received
```  
**Algorithm 1**Time interval selection and operation algorithm for an end device. ```
Data: Time intervals \(T\!I\) for priorities are configured. Input: Received message from the device \(D\). Output: Assigned time interval \(T\!I\! (P)\) for the device \(D\). 1 ZigBee communication initiation of device \(D\) if\(D\) not assigned with time interval then
2 send Offer message with available priorities to \(D\) at the time \(T\) wait for Selection message from \(D\) with priority \(P\) assign \(D\) with time interval \(T\!I\! (P)\) based on the time \(T\) repeat
3 wait for data from \(D\) in time interval \(T\!I\! (P)\) send Acknowledgement to \(D\) until\(D\) communicates out of time interval \(T\!I\! (P)\)
```  
**Algorithm 2**Time interval assignment and operation algorithm for the coordinator. The example of time interval selection is as follows. _Premises_:  
* Two types of priorities--high and low
* The high priority time interval is 1 s
* The low priority time interval is 5 s
* Each end device has one sensor with one data type  
Figure 4: Time slots and time intervals example. Steps included in time-interval selection:_  
1. The coordinator sends the Offer message to an end device. 2. The end device receives the Offer message at the system time of 08:05:13. It recognizes that it is a free time slot; thus, it can start sending data based on this timestamp. 3. The end device selects high priority (1) for its data, replies with the Selection message, and starts transmission of its data in the time interval of 1s starting in 08:05:14 (+1 s because of delay). 4. Meanwhile, the coordinator receives the Selection message containing the selected priority from the end device. The coordinator stores the information, so it is aware of the new device. 5. The coordinator receives data from the end device and sends the Acknowledgement message back to the end device. Since the coordinator is coordinated with all the end devices in the network, it can recompute and identify free time slots when a new device arrives.