## 3 Beacon-Based Hazard Alarm System Design
### Detailed Design of the Components  
#### 3.3.1 Beacon-Based Distance Monitoring  
A set of parameters is integrated into a BLE package. The Received Signal Strength Indicator (_RSSI_) value, measured power value, type, and name are the four types of data used in the alarm system. An _RSSI_ value is a value to represent the distance from one Bluetooth point to another Bluetooth point based on the Bluetooth propagation energy loss model [54]. It is generally expressed as \[RSSI=-10 nlg\bigg{(}\frac{d}{d_{0}}\bigg{)}+A+X_{\sigma}\, \tag{1}\]  
where \(X_{\sigma}\) is a Gaussian distribution random variable, usually taken as zero in calculations, and \(n\) is the space obstacle attenuation factor. Generally, the more factors that hinder Bluetooth transmission in the environment, the larger its value. \(A\) is defined as the average measured power value, meaning the \(RSSI\) value obtained at a distance \(d_{0}\) (generally taken as 1 m). Subsequently, the distance estimation model is written as  
\[RSSI=-2 nlg(d)+A. \tag{2}\]  
The type and name information in the Bluetooth data package are used to identify the beacon signal source. A construction site is a complicated environment with multiple hazards located in the same workspace, and therefore, it is likely that more than one BLE sensor is deployed at the same time. For that reason, the package type and name information are essential for the beacon signal receiver to identify the sources of particular beacon signals. Similarly, a unique package name is the identifier of a specific hazard, for which separate safety measures may be required for effective risk mitigation. Algorithm 1[55] shows the computational process through which a distance between the beacon sensors is calculated based on the RSSI value. In this system, the receiver application first checks the received package type and the identifier to choose the proper BLE package. The threshold for triggering the alarm system is set to be 3 m, and the receiver's responding range is set to be 5 m. This means the receiver sensor starts to send data to the cloud when the estimated distance is equal to or less than 5 m and sends an alarm trigger when the estimated distance is equal to or less than 3 m. Parameters n and A are related to the environment as mentioned, obtained, and calibrated from the experimental measurements. To minimize the fluctuation of the distance estimation results caused by surrounding obstacles and interference electromagnetic waves, this algorithm utilizes 1 average value based on every 10 readings. ``` RSSI (\(i\)): RSSI value in package (\(i\)) Type (\(i\)): the type of package (\(i\)) ID (\(i\)): Identifier of Package(\(i\)) MP (\(i\)): measured power of package (\(i\)) Input: Package (\(i\)), Beacon_ID, \(I_{(i)}\) Output: Average Distance
1 functionDist (\(i\))
2 Dist (\(i\)) = 10 ^ ( (RSSI (i)- MP (i))/(\(-\)10n))
3 end function
4 Scan BLE Package
5 ifType(i)== 'est_lo' then
6 ifID(i)== Beacon_IDthen
7 ifPackage (10)== Turethen
8\(I_{(1)}\) = Dist(i)
9\(I_{(2)}\) = Dist(i + 1)
10\(I_{(3)}\) = Dist(i + 2)
11\(\ldots\)
12\(I_{(9)}\) = Dist(i + 8)
13\(I_{(10)}\) = Dist(i + 9)
14 Average Distance = \((I_{(1)}+I_{(2)}+I_{(3)}+\ldots+I_{(9)}+I_{(10)})/10\)
15 end
16 end
17 end
18

#### 3.3.2 Cloud Computing-Based Alarm System

In the FCM platform, a project named \"SendTopicTest\" was created. The project is a pivotal online file providing a connection channel between Estimote Cloud and the Android mobile application, and it activates the cloud messaging function. The project generates a unique project ID and project number for Estimote Cloud and the Android application to connect them to the project. FCM also provides a credential key number for Estimote Cloud to adopt the cloud messaging service. A topic is necessary for broadcasting messages to multiple Android applications within an FCM project. For this research, a topic called \"notification\" was created to receive the messages from Estimote Cloud and transfer it to the listed mobile applications.