INVESTIGATION OF BLUETOOTH LOW ENERGY (BLE) AND WIRELESS LOCAL AREA NETWORK (WLAN)-DERIVED DISTANCE MEASUREMENTS USING MOBILE PHONES FOR INDOOR POSITIONING

: The indoor positioning problem is not the unavailability of indoor positioning technology, but the difficulty of arriving at an acceptable compromise of technical constraints like cost, performance, ease of use, and availability of technologies. In a developing country such as the Philippines, these constraints have more weight and can restrict the advancement of indoor positioning. This study investigates the use of Bluetooth Low Energy (BLE) and Wireless Local Area Network (WLAN) in Euclidean distance computation, which implies prospect use for indoor positioning through trilateration. It is a proof-of-concept study that BLE and WLAN, using readily-available services such as Nearby Application Programming Interface (API) and beacon simulators, can be used for indoor positioning. This method offers a better trade-off between cost, power, and accuracy. Nearby API and a regular beacon simulator application were used as beacons. The received signal strength interface (RSSI) was measured and used to calculate the Euclidean distance. From each beacon were calculated four different distances, Nearby yielding a maximum error of 26% and a minimum of 4%. The beacon simulator was less accurate and had a maximum error of 60.5% and a minimum of 4%. This shows that it is possible to calculate Euclidean distance using WLAN and BLE, and that Nearby API, which uses both, was more accurate than the beacon simulator, which used only BLE.


Internet of Things in the Philippine Context
Indoor navigation systems are used for wayfinding in railway stations, bus stations, shopping malls, museums, airports, and libraries (Kunhoth et al., 2020). According to Kunhoth (2020), it also benefits visually-impaired people, since unlike outdoor areas, indoor areas have more obstacles making it more difficult for them to navigate.
The development of Bluetooth Low Energy (BLE) tags and beacons, and the proliferation of smartphone connected devices, was identified to be a major factor in the growth of the indoor location market from USD 6.1 billion in 2020 to USD 17.0 billion by 2025 (MarketsandMarkets™, 2020). These technologies are used in making an Internet of Things (IoT), which allows devices to connect and exchange data with each other over the internet with limited use of resources, e.g. battery (Hussein, et al., 2020). IoT is the technology used in smart cities and buildings, allowing remote control over a building's operations (Hussein, et al., 2020). IoT coupled with locationbased services, makes tasks more efficient and comfortable to do, and helps in the safety of the environment as it even has security applications (Wang, 2020). An example of an IoT service would be Amazon's voice assistant, Alexa, that allows a user to control compatible IoT devices and their routines (e.g. smart lights, smart TVs, smart thermostats, etc) (Rawes, 2020).
In 2019, Statista determined the smartphone penetration rate in the Philippines to be 57.56%, meaning 57.56% of the Philippine population, according to the survey, owned smartphones. It was also projected that by 2021, the rate would grow to 68.41% (Statista, 2021). Latest smartphones (2012 up to present) are readily available with Wireless Local Area Network (WLAN) and BLE capabilities (Adarsh, 2021). The Philippines was named as the top in the world for social media usage for 6 years in a row since 2015, and also the highest for internet usage (Chua, 2021). The technology that can be used in indoor positioning is already available and widely-used in the Philippines, so IoT would be an inexpensive and effective method for indoor navigation. However, there is no proper documentation of indoor positioning used in the Philippines.

The Indoor Positioning Problem
Samama (2019) defines the "indoor positioning problem" not as the unavailability of indoor positioning technology, but the difficulty of arriving at an acceptable compromise of technical constraints such as cost, performance, ease of use, and availability of technologies. For example, accurate indoor positioning is possible using high-sensitivity Global Positioning System (GPS) receivers, but is impractical due to its high implementation cost in real-world scenarios (Kunhoth et al., 2020). According to Kunhoth (2020), the GPS which are found in devices used for everyday needs cannot offer accurate indoor positioning because of multipath errors. This limits the implementation of GPS as an indoor navigation system. The proponents have not found studies on the implementation of BLE and WLAN for indoor positioning in the Philippine context. Indoor positioning in the Philippines is only a recent research field and the methods used are only done with radio-frequency Identification (RFID), Wi-Fi fingerprinting, or Unmanned Aerial Vehicles (UAV). All of these are medium to high cost (Kunhoth, 2020), or require expensive infrastructure. This study is a proof of concept that RSSI measurements derived from BLE and WLAN can be used to calculate the distance -which is used in trilateration, a method of indoor positioning.

Indoor Positioning
The GPS is a Global Navigation Satellite System (GNSS) operated by the US. It is the collection of satellite positioning systems (Jeffrey, 2012). Some other major systems are the Globalnaya Navigatsionnaya Sputnikovaya Sistema (GLONASS) of the Russian Federation and China's BeiDou.
GNSS uses satellite ranging, a method similar to trilateration, to identify a user's position (Stevens et al., 2012). When distances from three satellites are known, the two-dimensional position can be identified. For a three dimensional fix, four satellites need to be overhead.
Some applications of GNSS are precision agriculture, aircraft navigation, and surface mining (Jeffrey, 2012). Its error sources can come from satellite clocks, orbit errors, ionospheric and tropospheric delay, and multipath (Stevens et al., 2012). Multipath is the most significant to this study. The receivers getting signals that bounced off of buildings and other objects and surfaces causes a multipath. This causes interference and an error of up to ±1 m. This error is common in urban environments and is why GNSS has a low signal or none inside buildings and forests. Although this can be solved with high-sensitivity GPS receivers, it is not feasible because of the implementation cost in real-world scenarios (Kunhoth et al., 2020). Thus, despite advancing technology, indoor positioning has not been solved with Global Navigation Satellite Systems (GNSS) (Samama, 2019).
With the increasing accessibility and usage of smartphones, location-based services (LBS) used in indoor navigation systems have become more in-demand. According to Liu et al. (2019), LBS provides users with location identification, navigation, and other services according to personalized demands. It is widely used in navigation in railway stations, bus stations, malls, airports, museums, and libraries and is also used by visuallyimpaired people (Kunhoth et al., 2020). See section 2.2.1. for more details on LBS.
According to Kunhoth et al. (2020), a human indoor navigation system mainly consists of three modules: Indoor positioning system module, navigation modules, and Human-machine interaction (HMI) module. The indoor positioning system module approximates the user's position, which can be done using RF signals, Bluetooth, or WLAN/WIFI. Navigation modules identify routes from the user's current location to the destination. The HMI, the interface that helps the user interact with the system, also gives directions to the user.
Indoor navigation systems can be classified based on adopted positioning technology: computer vision-based systems, communication technology, and pedestrian dead reckoning (PDR) (Kunhoth et al., 2020).
Computer vision-based systems use cameras to capture images of the indoor environment, which go through image processing algorithms for feature extraction. Recently, deep learning methods have also been utilized for object detection and classification. PDR methods take advantage of the user's last known coordinates and use the data from accelerometers and gyroscopes, among others, to estimate the current position. This method, on its own, results in a significant number of position errors, so it is integrated into other positioning technologies. Some communication-based technologies are radio-frequency identification (RFID), Wi-Fi, visible light communication (VLC), Ultra-wideband (UWB), and Bluetooth (Kunhoth et al., 2020).
RFID-based systems use received signal strength indicator (RSSI), time of arrival (TOA), time difference of arrival (TDOA), and angle of arrival (AOA), or the signal arrival angle for positioning (Kunhoth et al., 2020). This technology is widely implemented because of the cost-efficiency and extended range of effectiveness. Wi-Fi-based systems are utilized indoors, where there is a sufficient number of Wi-Fi access points. They apply RSS fingerprinting, triangulation, or trilateration methods for positioning. See Section 2.1. Bluetooth-systems use Bluetooth low energy (BLE) beacons. See Section 2.2. They utilize the BLE beacons as RF signal sources for proximity sensing or RSSI fingerprinting. Currently, smartphones can receive both Bluetooth and Wi-Fi signals. Among the five technologies, BLE is the lowest in terms of cost and power consumption. VLCbased systems are low-cost because they use existing LEDs and fluorescent lamps in the building. Smartphone cameras or independent photodetectors detect the light they emit. VLCbased positioning systems use TOA, AOA, and TDOA for position estimation, while UWB-based positioning systems use TOA, AOA, TDOA, and RSS-based methods.
Among the technologies mentioned, UWB-based positioning systems are the most accurate, with centimeter-level accuracy, but also the most expensive. BLE and Wi-Fi-based systems have similar accuracy in position estimation. BLE is the lowest in terms of cost and power consumption. Along with PDR, Wi-Fi is next at the lowest cost. Although it consumes high power, Wi-Fi can utilize existing building infrastructure since most buildings have been or will be equipped with Wi-Fi access points (Kunhoth et al., 2020), and therefore is widely used.

Internet of Things (IoT)
The Internet of Things (IoT) is a technology used for interconnecting static and mobile devices such as sensors, communication, and actuator modules through the Internet (Villamil et al., 2020). This system can collect data remotely and is used in device modeling, device control, data publishing, data analysis, and device detection. The devices in this system have independent communication with each other and can exchange information. A recent development in IoT platforms is the system's ability to analyze the conditions for the network and the gathered data, then make decisions and adapt to demand changes. This development "targets the maximization of the performance of the entire network." (Villamil et al. 2020). It connects many devices and does all these with limited processing, storage, and battery abilities (Hussein et al., 2020).
The IoT field is still a recent research area but already has many applications such as smart homes and cities, drone applications, and agriculture (Hussein et al. 2020). IoT can be incredibly beneficial in the context of smart cities, since in the future, especially in industrial environments, robots, sensors, and other devices will have to communicate efficiently and autonomously through wireless communication links. This will supplement the existing wired/Ethernet connections (Hussein et al., 2020). As the development of IoT technology and smartphones continues, smart homes/buildings are becoming more popular. In the field of smart homes and cities, "indoor positioning is the key to improve the comfort, safety, and intelligence of the home environment and build an efficient smart home system" (Wang, 2020). In a study by Mahida et al. (2019), the proponents developed a framework for the navigation of visually-impaired people indoors. The study utilized IoT devices such as beacons and inertial sensors found in smartphones to determine the user's position. Their step detection algorithm yielded an accuracy of 95%, with a mean error of 1.5-2m.
Positioning algorithms can currently be classified into two categories: based on ranging positioning algorithm and no ranging positioning algorithm (Wang, 2019). Ranging positioning includes algorithms based on RSSI, TOA, TDA, and AOA. No ranging positioning algorithms do not need distance and angle information. Instead, it implements node positioning using information like network connectivity.

Wireless Local Area Network (WLAN)
Wireless Local Area Network (WLAN) provides the benefits of Local Area Network technologies such as Ethernet without the hassle of cables and other wiring devices. (Shourbaji, 2010). It links two or more devices using a wireless communication method. It usually connects through an Access Point (AP) to the broader internet (Putman, 2005). It is also defined as a data communication network, typically a packet communication network, limited in geographic scope (Clark et al., 1978). This gives users the ability to roam around a limited but wide coverage area while having their devices connected to the network. It also eases network sharing among devices. While it reduces the range of connectivity wired networks offer, WLAN gives us the comfort of mobility, and infrastructures are not needed to be buried to the ground or walls just to establish connections (Shourbaji, 2010).

Bluetooth Low Energy (BLE)
Mobile applications, technologies, and devices use various nodes of the Internet of Things such as Bluetooth Low Energy (BLE), Radio Frequency Identification (RFID), Near Field Communication (NFC), Wireless Sensors Networks (WSN), and Konnex (KNX). These nodes are used to establish connections and relationships between devices and users to make different applications such as data transfer, proximity and location detection, APIs usage, among others (Caione, 2017). Such applications have been utilized to create applications and platforms for different needs. For public safety, applications are developed to create networks among devices to quickly assess risks in overpopulation in infrastructures, such as building collapse, and public places such as pickpocketing (Alam, 2016). Various technologies have also been developed for data management to efficiently distribute advertisements (Wolf, 2016) and public health where probable sick individuals can easily be traced for emergencies (Alam, 2016;Zhang, 2018).
Among these, Bluetooth is one technology that is considered as a Personal Area Network, where two or more devices interconnect with one another wirelessly on a short-range. However, unlike WLAN, Bluetooth connections can only be made with short ranges (Bensky, 2019). Among the nodes, Bluetooth has one of the higher ranges of proximity needed for connection. Unlike RFID or NFC, where their ranges fall shorter than 5 meters, Bluetooth connections can be established within 10 meters (Caoine, 2017).  (Pandey, 2018). BLE can also serve as beacons that can send bursts of data within a range without consuming power on the device. (Bensky, 2019). BLE was already included in Bluetooth 4.0 in 2010 and all other Bluetooth revisions after it (Le, 2017). In Bluetooth v. 5.1, a new direction finding capability was added, allowing the device to determine the direction of a signal from another device, which could significantly enhance Bluetooth's location services (Hollander, 2019). This new feature supports angle of arrival (AoA) and angle of departure (AoD) methods to determine the direction of the signal (Hollander, 2019). Currently, RSSI is used to estimate distance between two devices, and then trilateration to determine its position (Hollander, 2019).
Compared to other technologies, BLE offers a trade-off between energy consumption and latency, and throughput mainly relies on parameters. This allows devices to broadcast data as packets without losing data and consuming less energy at the same time (Gomez et al., 2012).

Nearby API
Nearby API is a relatively new technology developed by Google to make it easier for devices to establish connections. The API uses both WLAN and BLE technologies without the inconvenience of turning them on to discover and connect to quickly and exchange data with nearby devices in real-time, regardless of network connectivity. Users can connect and send data without needing a Bluetooth and internet connection as the API simply leverages each other's connection strengths to establish one with another device. Connections between devices are ensured to be fully encrypted, with high bandwidth and low latency for fast and secure data transfers. It has a similar system with Airdrop but is used for both IOS and Android users' convenience (Permissions).
The API offers different services such as sending payload data and beacon messages and measuring distances between connected devices. Devices can either exchange files, streams, or beacon messages once each device is discoverable by each other within a specific range.

Data and Signal Flow
The program is set up in a way that a device can act both as a beacon and a client, so data travels two-way. Both devices can send messages to each other. These devices emit BLE and WLAN signal waves so that other devices can detect them once they are within its range.

Figure 1. Flowchart of the data flow between devices
The BLE and WLAN signal from the device will prompt the device designated as a server beacon to send a message back to the device. Once the user's device receives the message from the beacon, the application on the beacon should receive information about when the device received the message. A message could be in the form of a website Uniform Resource Locator (URL), or simply the beacon's Universally Unique Identifier (UUID).

Figure 2. Data flow in the device acting as a beacon
When a device is detected through the BLE and WLAN signal waves it produces, the API sends out a message to the device. The application prompts when the device receives the message, and from there it sends these details to the API. In turn, the client device that receives the message should have the beacon where the message came from listed where its device details, including RSSI values, would appear.
For this application, the message that would be sent out to devices would be its UUID. For the client device, once the message from the beacon is received, the API should return the beacon details such as its UUID message, Media Access Control (MAC) Address, and its RSSI value.

System Setup
To use Nearby API, the researchers created an application for devices that would utilize the functionalities the API can offer for sending beacon messages, detecting nearby devices, and so on. The user interface is simple and has no additional designs since the researchers focused on creating the functionalities more. The application is allowed to run in the background. Phones without the application are able to receive beacon messages from other devices but would not be able to process them.
The researchers used Native Java for the application. Java, an Object-Oriented programming language that was originally developed by Sun Microsystems in 1995, is considered as the official programming language for mobile development as it is often used for such. While other languages for mobile development emerged, Java has the most complete libraries and specifications for creating all kinds of applications.

3.2.1
Enabling and using the application: To enable the server beacon, the application is simply opened on the device. It enables detection and measurements that it is programmed to do. With the feature of WLAN signals having a large range, it enables a beacon to have a range of at most 100 meters. Since BLE signals don't depend on connection strengths unlike with internet connections, as long as the devices are within the beacon's range, they are able to communicate and exchange information without much interference.

3.2.2
Beacon Simulation: For comparison, the researchers also simulated an iBeacon, a type of beacon designed and developed by Apple, on the same server beacon device where the Nearby application is installed. This beacon was set up through a third-party software called Beacon Simulator, where you can simulate different kinds of beacons such as Eddystone and iBeacon. Do take note that this kind of beacon is not exclusive for apple devices.

Measurements
Due to limitations caused by factors such as COVID-19 restrictions and lockdowns, measurements were limited to distances not exceeding 2-meters. A standard distance is used for calibrating the distances that would be computed later on. The RSSI values from both the Nearby application and the simulated iBeaco will be measured from four (4) different distances: 0.5meters, 1.0-meters, 1.5-meters, and 2-meters. 1-meter will serve as the standard distance where the RSSI values from there would be used for calibration.

Figure 6. Diagram of phone placement marks for RSSI measurement
To detect the phone with the application as a Nearby beacon, as well as the other beacon being simulated, the same third-party software used for simulation was used. The software detects all existing beacons broadcasting within a radius and gives the RSSI measurement values real-time.
Since both beacons are detected at the same time, and both beacons can run at the same device at the same time, measurement recording was done for both beacons together. One measurement per second is recorded for two (2) minutes, with a one (1) minute mark to compare whether time of measurement matters or not. Measurements are taken by recording the screen for at least two (2) minutes.

Computations
The RSSI value that Nearby returns is inputted to the equation provided by Lee, et al. (2016): where d0 = standard distance (1-meter) PRX(d0) = RSSI value at standard distance PRX(d) = RSSI value at distance being measured n = path loss exponent In this study, d0 is 1-meter, and n is assumed to be equal to 2, which is the path loss exponent for a free space environment (Rappaport, 2021), since there were no obstructions between the mobile devices.

RSSI Values
RSSI values were measured for two (2) minutes with devices 1meter apart. the average RSSI value for each beacon is shown in Table 1.

Distance RSSI for Calibration (dBm)
Beacon Simulator Nearby 1m -86.4 -70.5 Table 1. RSSI values from 1-meter from simulated beacon and Nearby beacon for calibration These values were used in the equation to get the calculated distance. This would become PRX (d0) with d0 being 1-meter. It could be seen from here that the average RSSI value given out by the Nearby beacon is greater than that of a normal beacon simulated in the same device.

Figure 7. Raw RSSI values of beacon simulator vs Nearby beacon for 1m
In the graph, it can be seen that the RSSI values obtained from the Nearby beacon are much more stable and consistent than those from the Bluetooth Low Energy (BLE) beacon at 1-meter. The values of those from the BLE beacon reach up to -100 dBm, which is an indication of a bad signal strength. This means that it has a greater signal power than that of a beacon simulator since the Nearby beacon has a greater broadcasting power than the BLE beacon since it also utilizes the Wireless Fidelity (WiFi) signal strength the devices have. This behavior can also be seen with the RSSI values from the simulated beacon and Nearby beacon (as labeled) taken from other distances as seen below.

Figure 8. RSSI values of beacon simulator
The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLVI-4/W6-2021 Philippine Geomatics Symposium 2021, 17-19 November 2021, virtual meeting Figure 9. RSSI values of the Nearby beacon The signal from the BLE Beacon is unstable even if the distance is only 0.5-meters apart while the signals from the Nearby beacon only gets unstable when the distance is farther, such as 2meters, which is a predicted behavior since more interferences can get through the farther the devices are.

Calculated distances
The average calculated distances computed using the calibration value and the average RSSI values are shown. This was calculated with the assumption that n, the path loss exponent, is constant at 2, which is the path loss exponent for free space (i.e. there are no obstructions between devices). The path loss exponent minimizes error due to multipath. Without the correct path loss equation, there would be higher error due to signals bouncing off of surfaces then arriving at the receiver in multiple copies with different RSSI values (Golestanian et al., 2017). Also, a significant difference in accuracy is noted between the 1 minute and 2 minute measurements from the BLE beacon, while Nearby returned more stable and consistent values. These can also be attributed to Nearby having a greater broadcasting power. Nearby also returns the weighted average sightings of RSSI, with more weight to latter sightings (Google Developers, n.d.), as opposed to the raw values of the beacon. The high error that was observed in the 1.5m measurement from Nearby, which is 26%, can be attributed to the minimal movements around the devices during that time.
An inversely proportional trend can be observed in Nearby's values, where the measurement becomes more accurate the farther the devices are from one another. However, there are not enough measurements to support this due to limited space and quarantine restrictions, and it can only be confirmed in future studies.

CONCLUSION
The researchers were able to implement a cost-free workflow for calculating distances that consisted of creating an application that would act as a beacon to be detected by another device (in this case, using Nearby API), measuring RSSI using a third party application (Beacon simulator), and inputting values to the equation by Lee, et. al. (2016) to calculate distance.
Wireless Local Area Network (WLAN) and Bluetooth Low Energy (BLE)-derived distance measurements yielded accurate results from the Nearby application, with a maximum error of 26%, and a minimum of 4%. The beacon simulator yielded less favorable results, with a maximum of 60.5% and a minimum of 4%. The accuracy of the distance measurements from Nearby prove that it is possible to use the widely-available and free technology in the future for indoor positioning, at least in a setting where GPS is not available, or WLAN and BLE are the only options to navigate and very high accuracy isn't required. It also proves that a combination of WLAN and BLE in measuring received signal strength indicator (RSSI) is more accurate than using BLE only, which is what the beacon simulator used.
In this study, a free beacon simulator application was used due to unforeseen circumstances. The application did not have documentation, and it is the only application that works as it is created as a proof of concept. The proponents would recommend repeating the study with more reliable, well-documented physical or virtual beacons. Future studies may also compare the results from BLE tags, and to test with longer distances and different scenarios (i.e. in multi-level structures, with obstructions, crowds). It is also recommended to improve on the algorithm measuring RSSI; the proponents manually recorded all 120 values of RSSI measurements by taking a recording of the client device's screen and checking the frame per second. Future studies may also use machine learning to detect changes in the environment (e.g. temporary structures or decorations added, etc.) and adjust the path loss equation accordingly to minimize multipath fading more efficiently and obtain more accurate results. The maximum distance measured was only 2m, so it is recommended to study the effects of greater distances. Additionally, future studies may also check whether transmitter powers may affect RSSI values and experiment on the configuration of the power settings of the transmitters, which may help boost the signal.
This study has already shown that Euclidean distance measurement can be done by using only BLE and WLAN of mobile phones. Future studies may extend the methodology into location-estimation in a large structure. With a beacon of known position, the position of the devices can be determined through trilateration.