# Secure Indoor Localization Based on Extracting Trusted Fingerprint
## 4 Secure WiFi Fingerprint Localization
### Offline Update Phase
#### 4.2.2 Voting Mechanism  
In order to distinguish the different effects of environmental and impaired AP on RSSI, we conducted an experimental analysis and comparison of RSSI in the presence of environmental impact and impaired AP. As shown in Figures 4 and 5, when there is an environmental impact, the affected range may be in one or both directions; the fluctuation and RSSI may change in this direction. However, when there is an impaired AP, the volatility and average of RSSI received by all the reference points within that AP range will change. There is a clear distinction of the environmental factors and impaired AP on the impact of RSSI. Therefore, the voting mechanism in this article selects the standard deviation as the voting condition, and it can achieve a better filtering effect.  
When updating the fingerprint database, the reference anchor nodes measure the RSSI several times. The RSSI standard deviation \(B^{{}^{\prime}}\) is recorded according to the multiple measurements.  
\[B^{{}^{\prime}}=\begin{cases}b^{{}^{\prime}}_{1,1}&b^{{}^{\prime}}_{1,2}& \cdots&b^{{}^{\prime}}_{1,N}\\ b^{{}^{\prime}}_{2,1}&b^{{}^{\prime}}_{2,2}&\cdots&b^{{}^{\prime}}_{2,N}\\ \vdots&\vdots&\ddots&\vdots\\ b^{{}^{\prime}}_{L,1}&b^{{}^{\prime}}_{L,2}&\cdots&b^{{}^{\prime}}_{L,N}\\ \end{cases}. \tag{7}\]  
When we update the fingerprint database, we compare the standard deviation before updating. If the standard deviation of the fingerprint that the reference point \(j\) receives from the fingerprint of \(AP_{i}\) is \(b_{ij}^{{}^{\prime}}\) and \(b_{ij}^{{}^{\prime}}>b_{ij}+\Delta\), then it is considered that \(AP_{i}\) is not trusted, and reference point \(j\) is used to vote on \(AP_{i}\), where \(\Delta\) is a trust threshold. Finally, we can obtain the vote matrix of each AP for the weight calculation of the APs' credibility. Each reference point will vote on the APs, if there is an impaired AP. Then, after the end of the algorithm, impaired AP votes are the highest, and the AP that is only affected by the environment has a relatively low number of votes. If an AP is severely affected by the environment, its RSSI is not stable, and it is not suitable for localization. When an AP is seriously affected by the environment, the instability of RSSI will cause the standard deviation to be higher; thus, the number of votes of the AP will be improved. Therefore, the algorithm proposed in this paper can also filter the AP with a serious environmental impact.  
We vote on APs based on the size of the standard deviation of the RSSI of the reference anchor node receiving the APs. We calculate the trust degree \(W=[w_{1},w_{2},\cdots,w_{L}]^{T}\) of the AP according to the voting result obtained by the voting mechanism, which is expressed as \(w_{i}=1-v_{i}/num\); Where \(w_{i}\) represents the trust value of AP, \(v_{i}\) represents the votes of the \(AP_{i}\) and \(num\) refers to the number of reference points within the AP coverage. In the initial phase, the value of the ticket matrix is zero, and the value of \(w_{i}\) is one. The voting mechanism in the algorithm can make the number of impaired AP votes higher and make the weight smaller, so as to achieve the effect of filtering impaired APs. We can also filter out APs that are affected by unstable environmental factors.  
Because the APs have been voted on during the update process, the weight of the APs will change. For untrustworthy fingerprints, the weight of the APs will be reduced. In this way, even if there is an untrustworthy fingerprint in the RSSI matrix, its contribution will be reduced due to its lower weight, and the effect on the overall localization result will be reduced.