## 3 Metrics for Geofence Digital Signature (GDS) Generation  
### Metrics for Signature Generation  
The system idea needed to be robust and ideal for any environment without the effort to make any sort of infrastructure. Different metrics that can be accessed from any traditional commercial smartphone were studied and collected. Various smartphone  
Figure 2: Functional block diagram for the proposed approach.  
sensor-based metrics were used to indicate the IO state as in [20], but these sensor-based metrics such as the light sensor and GPS have many disadvantages. The light sensor lacks the generalization on the same environment, the GPS is not an optimal indication for indoor environments with high battery consumption and both provides a low accuracy of detection in general [21]. Then, we decided to work on the metrics that would be specific to each workplace, will not change with time and have the optimal battery consumption.  
In this subsection, different metrics are studied for generating the digital signature for any geofence in the workplace environment. First, Wi-Fi wireless metrics such as Wi-Fi basic service set identifier and Wi-Fi received signal strength indication parameters are used for GDS generation. This is due to the availability of them, as they can be collected in smartphones without any requirement for additional hardware installation. Wi-Fi BSSID can be considered as a distinctive identifier for each Wi-Fi AP [22] that characterizes the medium access control (MAC) address for the Wi-Fi AP. However, Wi-Fi BSSID can be collected even if the person is far from the AP with an appropriate distance. Therefore, Wi-Fi RSSI parameters are essential to be used along with the Wi-Fi BSSID to indicate the distance from the Wi-Fi AP for any person. The used Wi-Fi wireless metrics of all neighboring Wi-Fi APs can be collected by scanning the smartphone's Wi-Fi to be used in digital signature generation for any geofence in the workplaces.  
To increase the GDS robustness, the magnetic field can be used along with the Wi-Fi wireless metrics to uniquely identify each geofence and detect the crossing of its virtual borders. The magnetic field can be sensed by the magnetometer equipped in smartphones. The magnets affect the Earth's magnetic field and construct a unique signature that can be detected by the smartphone's magnetometer and used to track the geofences violation. The magnetic field of the magnets depends on the magnetic moment of the magnet, relative position to the smartphone's magnetometer, and the magnetic permeability. Therefore, the three-axis parameters of the magnetic field \(S_{x}\), \(S_{y}\) and \(S_{z}\) sensed by the magnetometer can be given by [23].  
\[\begin{pmatrix}S_{x}\\ S_{y}\\ S_{z}\end{pmatrix}=\frac{\mu_{0}}{4\pi r^{5}}\begin{pmatrix}3x^{2}-r^{2}&3 xy&3 xz\\ 3 yx&3y^{2}-r^{2}&3 yz\\ 3 zx&3 zy&3z^{2}-r^{2}\end{pmatrix}\begin{pmatrix}M_{x}\\ M_{y}\\ M_{z}\end{pmatrix}, \tag{9}\]  
where \(x\), \(y\) and \(z\) are the distance between the magnet and the magnetometer in the \(x\)-axis, \(y\)-axis, and \(z\)-axis, respectively. Meanwhile, \(r\) denotes the norm distance from the magnet to the smartphone's magnetometer and \(\mu_{0}\) represents the magnetic permeability. Moreover, \(M_{x}\), \(M_{y}\) and \(M_{z}\) denote the magnetic moment of the magnet.