# Secure Utilization of Beacons and UAVs in Emergency Response Systems for Building Fire Hazard
## 3 UAV-Assisted Emergency Monitoring and Response System
### System Protocols  
In our UAV-EMOR system, a smart sensor indicates one of four states: (1) \"Active\": indicates that the sensor is functioning correctly; (2) \"Unsafe\": indicates when the local temperature is beyond an established threshold; (3) \"Fire\": indicates when a fire has been detected; (4) \"Inactive\": indicates that the sensor is no longer functioning. A smart sensor automatically indicates these states, according to the settings chosen by the system administrator, as shown in Figure 5.  
* Active: When a smart sensor is functioning correctly or if it detects that a fire has ended, it indicates this by sending an \"Active\" message to the server.
* Unsafe: If a smart sensor detects an abnormal temperature or the smoke detection system detects smoke, it is indicated with the message \"Unsafe\". The manager receives the abnormal temperature data or the smoke data and confirms whether there is an abnormality or not.
* Fire: If a manager confirms that there is a fire, the smart sensor enters the \"Fire\" state. When the control server receives the \"Fire\" message, it guides UAVs to observe the location of the smart sensor where the fire has been detected and the sprinkler is activated Furthermore, the control server sends an emergency message to everyone who is connected to the system. Via beacons, the smart sensors collect user positions and send them to the control server and manager.
* Inactive: This status indicates that a smart sensor is no longer functioning correctly due to error, loss of power, etc. In such a situation, the smart sensor notifies the control server of its \"Inactive\" state.  
Figure 5: State diagram of a smart sensor.  
```
**Algorithm 1**Management Algorithm of Control Server
```  State : \(Active,InActive,Unsafe,Fire\)  Tt : Temperature value in time T  Tm : Normal threshold of temperature  IPhoto : Photo taken by an indoor drone  OPhoto : Photo taken by an outdoor drone  CCTVimage : image taken by CCTV  Monitoring Group : Indoor Drone, Outdoor Drone, CCTV, Smart Sensor
1 Connect to Smart Sensor
2 ifSmart Sensor == InActivethen
3 Transmit \"InActive\" message to Security Manager
4 end if
5 whileSmart Sensor == Activedo
6 Receive Tt from Smart Sensor
7 ifThe temperature change == Truethen
8 Save Tt to DB
9 Transmit Warning Message to Security Manager
10 if\(Tt<Tm\)then
11 Receive \"Safe\" message from Security Manager
12 Run Normal Operation of Day-to-Day Monitoring
13 end if
14 if\(Tt>=Tm\)then
15 State = UnSafe
16 Broadcast \"Unsafe\" message to Security Manager and Monitoring Group
17 whileState == Unsafe of Firedo
18 Run \"Abnormal Response\" operation
19 Run the fire detection system (or smoke detection system)
20 Update IPhoto in DB
21 Update CCTVimage in DB
22 Receive Tt from Smart sensors
23 Receive State and location from Security Manager
24 ifState == Firethen
25 Broadcast \"Fire\" message to Users and Monitoring Group
26 Run \"Emergency Response\" operation
27 Run the sprinkler system
28 end if
29 end if
30
31 end while
32
33 end while ```  
**Algorithm 1**Management Algorithm of Control Server