Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Lucrare de Licenţă
Localizare Folosind
Dispozitive Mobile
Alexandru Popa
Coordonatori Ştiinţifici
Prof. Dr. Ing. Nicolae Ţăpuş
As. Drd. Ing. Silvia Cristina Stegaru
Diploma Thesis
Indoor Localization
Using Mobile Devices
by
Alexandru Popa
Contents i
List of Figures ii
1 Introduction 1
4 Case study 47
4.1 Results based only on raw RSS values . . . . . . . . . . . . . . . . 48
4.2 Results based on RSS measurement collection . . . . . . . . . . . . 50
Bibliography 54
Listings 56
i
List of Figures
ii
List of Tables
iii
Chapter 1
Introduction
Indoor localization represents a topic that aims to create systems and solu-
tions which can locate people or objects within an indoor environment. Although
there is no standard or best solution for indoor localization, systems have been
developed using a range of technologies such as optical, radio, magnetic or even
acoustic systems.
Regarding positioning in an outdoor environment, Global Positioning System
(GPS) is the technology developed by the United States of Defense and mainly
used for military purposes in navigation and coordinate measurements [13]. Other
applications of global navigation satellite systems have been deployed in a wide
range of domains such as tracking and asset management systems, transport
navigation and guidance or synchronization of telecommunications networks.
However, using GPS, the optimum signal performance can only be achieved
in an outdoor environment and not within an indoor environment. GPS is not
effective in urban areas, close to walls, buildings, trees, interiors and in under-
ground environments as the signal from the GPS satellites is too weak to come
across most buildings. This happens because the signal transmitted by a satellite
is affected by multiple reflections including roofs, walls and other objects causing
multi-path interference in an indoor setup.
Indoor localization can be defined as any system that provides a reliable
solution for acquiring a precise position in a closed area such as airports, hospitals
or shopping malls. Due to the nature of a closed structure, the development of
indoor positioning solutions raises a number of issues such as creating floor plan
based maps of indoor environments, using an appropriate and effective technology
and deploying the most suitable positioning devices.
In the present thesis, the main objective is implementing a cost-effective solu-
tion for indoor positioning using the trilateration method based on measurement
collection from two access points.
1
Chapter 2
Positioning
Systems
Wireless LAN
RFID
Bluetooth
ZigBee
UWB
FM
2
CHAPTER 2. STATE OF THE ART AND RELATED WORK 3
Position
Detection
with the purpose of finding the location [10]. In this approach, only the receiving
nodes are synchronized, and when a signal with unknown starting time arrives at
the receivers, the algorithm uses the difference of arrival to estimate the target’s
position.
If ToF and TDoA are based on time measurements from the source to the
receiver, Round Trip Time (RTT) method calculates the time of flight from the
transmitter to the receiver node and back. Thus, the increased complexity of the
location scheme development for time synchronization between wireless nodes is
avoided [1].
Signal property based methods are mostly applied in wireless positioning sys-
tems and calculate the distance to the mobile device using properties of the re-
ceived signal such as the received signal strength indicator (RSSI) which is highly
influenced by the environmental interference. To deploy methods based on the
signal properties, access points are generally preferred rather than WiFi routers
as they represent a less expensive solution.
WiFi RSS methods can be divided into two main categories: radio propaga-
tion based methods and fingerprint based methods [22]. The radio propagation
model-based methods deploy at least three access points whose coordinates are
known to approximate position with triangulation.
Fingerprint based methods use the RSS values to construct a fingerprint map
which is then used for real-time localization. The positioning process has two
phases: an offline phase in which a set of RSS values is collected by a measurer
with a mobile device in distinct locations. A fingerprint map is then constructed
based on this set of RSS values. The second phase is the online phase which
CHAPTER 2. STATE OF THE ART AND RELATED WORK 7
uses the RSS values of the target device and determines the best match in the
fingerprint map. However this method poses issues for different mobile devices
which can scan different RSS values in the same physical location [3].
Therefore, WiFi positioning systems are the most advantageous technology
for localization of easily accessible devices among the population such as smart-
phones. The idea of tracking smartphones through WiFi systems implies the
deployment of access points along with WiFi enabled mobile devices to locate
the approximate position. The implemented algorithm will use the user’s sig-
nal strength and frequency to determine the position through the trilateration
techniques.
Chapter 3
8
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 9
Software Hardware
Role Components
Samsung Galaxy
Client
S4 Mini
Raspberry PI 3
Server
Model B
ESP8266-01,
Access Points
Arduino Uno
Table 3.1: Hardware Components
Apart from the positioning goals, the localization system needs to meet several
other requirements:
in order to acquire precise and sufficient measurement for positioning the mobile
device.
The mobile device will scan the connectivity data of all available access points
within range periodically at a configured refresh rate. Each scan result describes
information about an available access point such as the MAC address of the
network, the name of the network, the capabilities of the network (encryption
schemes, authentication, key management), the access point channel bandwidth,
the frequency of the channel, the received signal level and a time stamp in mi-
croseconds of the moment the respective result was last seen.
Out of all the detected access points, only the scan results of the two config-
ured access points will be analyzed and sent to the server for further analysis and
computation. However, these measurements may be erroneous and the algorithm
needs to account for these issues.
The properties of the underlying electromagnetic wave produced by the access
points is prone to reflections, scattering and diffraction. When there exists an
unimpeded line of sight (LOS) between the receiver and the transmitter, the
received signal strength is estimated using the free space propagation model.
This model states that the received signal power decreases with the square of the
distance [2] as shown in (3.1) . However, unobstructed LOS paths are rarely met
in real indoor or even outdoor environments.
1
RSSr ∼ , d - distance; RSSr - received signal power (3.1)
d2
The distance travelled by the signal from transmitter to receiver can be de-
termined by comparing the transmitter power and the receiver power. This dif-
ference is called ”path loss”. In real world situations, the path loss has a different
path loss - distance dependence in different environments. Because of that, the
received signal strength is also a function of the path loss exponent (symbolized
as n) as seen in (3.2):
RSSd0
RSSr = (3.2)
(d/d0 )n
where RSSd0 represents the received power at the distance d0 , which is gen-
erally a fixed constant. The distance is usually estimated using the log-normal
path loss model which is described in equation (3.3):
λ 1
RSSr = RSSt + 20 log + 10n log (3.3)
4π d
2
4πd
RSSF SP L =
λ
2 (3.4)
4πdf
=
c
where f is the frequency of the signal (expressed in Hertz) and c is the speed
of light in vacuum (expressed in meters per second). From (3.4), the received
signal strength can be expressed in dBm as follows:
Frequency Distance
k
Unit Unit
Hz m -147.55
kHz m -87.55
MHz m -27.55
MHz km 32.45
GHz km 92.45
Table 3.2: FSPL constant dependence on units as computed in (3.5)
In Android systems, the WiFi Manager measures the frequency of the received
signal in MHz and the distance will be measured in terms of meters. Therefore,
from Table 3.2, the third constant will be used in the proposed solution:
The distance between the access point and the mobile device can then be
expressed in meters as follows:
However, this estimation needs to address several issues that can lead to errors
in the approximation of the distance.
Practically, when a radio wave comes across another wave with distinctive
electrical properties, the radio wave is either partially reflected and in some mea-
sure absorbed. As such, the reflection is generally determined by frequency, the
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 12
(a − rx )2 + (b − ry )2 = r2 (3.8)
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 13
• y
AP2
•
AP2
AP1
•
x
AP1
•
x
As seen in Figure 3.3, the equation (3.8) can be particularized for the two
circles defined by the signal received from the two access points:
x2 + y 2 = r12 (3.9)
Substracting equation (3.10) from (3.9), the value of the y coordinate is de-
termined:
r12 − r22 + L2
y= (3.11)
2L
(0,L)
•
AP2
r2
(x, y)
•
r1
AP1
•
(0, 0) x
This result in equation (3.13) explains why the two access points had to be
positioned on the same axis. The negative solution is not a valid one as 0 ≤ x.
Therefore:
p
2r12 r22 + 2r12 L2 + 2r22 L2 − r14 − r24 − L4
x= (3.14)
2L
The identity (3.15) proves that if r1 , r2 and L are the side lengths of a triangle,
which means that r1 + r2 > L, r1 + L > r2 and r2 + L > r1 , then the expression
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 15
2(r12 r22 + r12 L2 + r22 L2 ) − r14 − r24 − L4 is positive. In Figure 3.3, it can be observed
that r1 , r2 and L form indeed a triangle.
Another condition for y to be positive (inside the localization area) is that
This translates into the fact that the angle between r1 and the y-axis needs
to be acute or right (lower than or equal to 90◦ ). Similarly, y ≤ L is equivalent
with:
r12 − r22 + L2
≤ L ⇔ r22 + L2 ≥ r12 (3.17)
2L
which means that the angle between r2 and the y-axis also need to be acute
or right. These assertions can be observed in Figure 3.4 and 3.5. For example, if
the angle between r1 and the y-axis is obtuse, then y is negative, and the point
(x, y) is outside the localization area as shown in Figure 3.4. The other invalid
case, r22 + L2 < r12 is presented in Figure 3.5.
y (x, y)
•
•
(0,L) AP2
y
(0,L)
•
AP2 AP1
•
(0, 0) x
AP1
•
(0, 0)• x
(x, y)
Figure 3.4: Invalid Case:r12 +L2 < r22 Figure 3.5: Invalid Case:r22 +L2 < r12
The equality cases r12 + L2 = r2 or r22 + L2 = r12 are reached when the triangle
is right angled. This means that either y = 0 or y = L and these cases correspond
to the situation where the target device lies on the border of the localization area.
The above conditions cover the cases when the calculated position is not
contained by the upper and lower sides and by the left side of the localization
area.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 16
•
(0,L) AP2
• (x, y)
AP1
•
(0, 0) x
hL ≤ l (3.18)
L · hL
A= (3.19)
2
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 17
p
A= s(s − r1 )(s − r2 )(s − L) (3.20)
r1 + r2 + L
where s = is the semiperimeter, equation (3.18) can be rewritten
2
as:
p
2 s(s − r1 )(s − r2 )(s − L)
≤l (3.21)
L
Conditions (3.15), (3.16), (3.17) and (3.21) ensure that the determined posi-
tion will be contained in the localization area. As such, the position of the mobile
device has the following coordinates:
p
2r12 r22 + 2r12 L2 + 2r22 L2 − r14 − r24 − L4
x
=
2L (3.22)
y r12 − r22 + L2
=
2L
(0,L)
•
AP2
AP1
•
(0, 0) x
The positioning algorithm will find the coordinates of the mobile device based
on the received signal strength and the frequency of the signal captured by the
mobile device. Furthermore, in order to improve the accuracy of the localization,
the position will be estimated as an average of measurements stored in a queue
by the server.
The queue size is proportional with the accuracy of the positioning algorithm.
As the size increases, so does the precision of the localization. However, the size of
the queue is also directly proportional with the processing time of the information
by the server. Hence, a more accurate positioning will take a longer time and
will use more CPU time on the server. This could prove costly if there are more
client devices connected to the server which run the positioning algorithm at the
same time on different threads.
In order to improve the localization algorithm and to decrease the number of
the ”blind spots” described in the previous section, signal strengths levels of the
two access points deployed in the room have to be measured in positions where
the algorithm is not accurate enough.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 19
The main hardware components of the localization system are the ESP8266-
01, a WiFi module used to design an access point, the Raspberry PI 3, which
plays the role of the server and a Samsung Galaxy S4 Mini device to run the
client application.
This section describes the hardware configuration of these elements.
3.3.1 ESP8266-01
ESP8266 [7] is a high integration wireless SoC which has been designed for
mobile and Internet of Things applications. It can host the application by itself
or the Wireless networking functions can be offloaded from another application
processor. In such applications, in order to boost the system’s performance a
cache memory was integrated. Using the module as a WiFi adapter, any mi-
crocontroller based design with connectivity interfaces (such as UART/I2C or
SDIO/SPI) can obtain wireless internet access.
WiFi location-aware devices, WiFi position system beacons and security ID
tags are important domains of ESP8266 Internet of Things applications.
ESP8266 is one of the most integrated WiFi chip in the SoC’s industry. It
requires minimal external circuitry and it integrates the power management mod-
ules, low noise receive amplifier, power amplifier, RF balun, antenna switches.
The entire structure, along with the front-end module, is devised for the purpose
of occupying a minimal PCB area.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 20
• It can operate as a station (STA), access point (AP) or both (STA + AP)
ESP8266-01 has only 8 pins and is the smallest module in the ESP8266 family.
The ESP8266-01 pin configuration can be seen in Figure 3.8 [6].
The RST (reset), VCC, GND and CH PD (chip select) are pins needed for the
operation of the module, while the other four pins can be used as I/O pins,
although they also have specific functions. The RX/TX pins are used for the serial
I/O communication and to program the chip, while the GPIO0 and GPIO2 set the
mode in which the module powers in. Each pins role can be seen in Table 3.3.
3.3.2 Raspberry PI 3
Option Function
The OS can use all
Expand File System
the card storage space
Password reset
Change User Password
option
Enable Boot to Boot into Scratch, Command
Desktop/Scratch line or Desktop
Regional and
Internationalisation Options
language settings
Sets up Raspberry
Enable camera
PI camera
Add to online map
Add to Rastrack
(Rastrack)
Overclock CPU
Overclock
up to 1000 MHz
Overscan, Hostname,
Memory Split, SSH,
Advanced Options
Device Tree, SPI,
Serial, Audio
About ’raspi-config’ Tool Help
Table 3.4: raspi-config Options
The file config.txt is a configuration file that stores parameters which would
be found in BIOS on a conventional PC. Several low level parameters of the
Raspberry PI 3 subsystems can be modified through this file such as memory
parameters, network parameters, boot and overclocking options.
In the present localization system, the operating system used is the Raspbian
Jessie, released in May 2016 and with the 4.4 kernel version. The operating
system was installed using the NOOBS package, an easy to use OS installer for
the Raspberry PI, which incorporates Raspbian.
The client device on which this system was tested is a Samsung Galaxy S4
Mini GT-I9195 smartphone running the 4.2.2 JellyBean version of the Android
operating system. The main technical specifications of the device can be seen in
Table 3.5.
The smartphone runs the client application which was developed using the
Android Studio IDE. The application can be run successfully on any Android-
based smartphone which has wireless capabilities and runs any version of Android
OS 4.2.2 or higher.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 24
Technical Specifications
Battery 1,900 mAh
124.6 x 61.3 x 8.94mm,
Size
107g
Android OS
Operating System
JellyBean 4.2.2
Memory 8GB memory
Wi-FI 802.11a/b/g/n, GPS,
Connectivity
Bluetooth 4.0, NFC
CPU Clock 1728 MHz
RAM Capacity 1.5GB (1.3GB accessible)
Display resolution 540 x 960
Table 3.5: Samsung Galaxy S4 Mini Technical Specifications
indicating the height and width of the real room in meters and by using a unique
suggestive name for the map.
The server program runs on a Raspberry PI 3 model B, presented above. Its
main purpose is to use the frequency and RSSI measurements received from the
client application in the positioning algorithm. Based on the input data, the
algorithm calculates the current location of the mobile device. The data is then
sent to the Android application.
The server also stores maps uploaded by the users in a local MySQL database.
The client application can see all the available maps, and the user can select any
desired map.
The client-server communication was done using the KryoNet API. KryoNet
represents a Java library used for implementing the client-server model over a
network using TCP and UDP packets for communication.
The system’s architecture is shown in Figure 3.10.
• A sniffing service - the component which collects information from the access
point
• User interface activities - several activities which display access points mea-
surements, the current location of the device, configuration and available
maps information
Each of the above components communicate with the server through the Kry-
oNet API and between each other.
The sniffing service uses the WifiManager, a primary class which manages the
WiFi connectivity in Android OS, in order to collect all positioning information
from the access points. This data is used to display access points measurements
to the user in real time and it is also sent to the server in order to calculate the
current position.
The UI activities use controls of the Android framework to display the cur-
rently selected map, the position on the map in real time, access points data,
configuration settings in a user-friendly interface.
Each class, activity and service contains a private static final string named
TAG which is initialized with the name of the class. This field was used during
development to write log statements.
Call to
startService()
onCreate()
onStartCommand()
Service
running
onDestroy()
Service
shutdown
An instance of Timer class is also created. This instance is used for scheduling
a TimerTask to be executed in a background thread at a regular interval of time.
The TimerTask class runs an update task in a separate thread which uses the
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 28
WifiManager instance to request a scan of the available access points with the
startScan() method.
The Timer instance plans the update task to be run at a periodic interval
of time with the schedule() method. This method receives as parameters the
TimerTask object, a delay (set to zero) and the refresh rate in milliseconds.
During the testing of the localization system, the refresh rate was set to
10000, meaning the client application scans the access points every 10 seconds.
This interval ensured a satisfying usage of the smartphone’s battery as well as
updating the UI in a user appeasing time interval.
The WifiScanning class also has a private nested class named WifiReceiver
which extends the BroadcastReceiver class.
BroadcastReceiver is a class which responds to broadcast messages sent by the
system or by other application components. Once a broadcast message arrives,
the onReceive() method is executed.
The WifiReceiver is instantiated during the service’s onCreate() method.
After the object is created, the WifiReceiver also needs to be registered in order
to listen to specific intents.
For receiving data, a IntentFilter was created to filter only for broadcast
messages from the WifiManager which announce that the scan results requested
by the WifiManager.startScan() are available. This is done by specifying the
constant WifiManager.SCAN RESULTS AVAILABLE ACTION as parameter in Intent-
Filter’s constructor.
The last step in the onCreate() method is to register the WifiReceiver. This
is achieved by calling the registerReceiver() method with the WifiReceiver
instance and the IntentFilter object as parameters.
After the onCreate() method is completed, the TimerTask scans the ac-
cess points periodically at every 10 seconds. When the scan is completed, the
system sends a broadcast message which is caught by the WifiReceiver. In the
onReceive() method, the data is collected and then filtered for the access points
required by the positioning system.
The WifiManager.getScanResults() returns an ArrayList of ScanResult ob-
jects for each of the available access points.
The ScanResult class contains information about an access point discovered
by the WifiManager. The main fields of class and the data stored in them are
detailed in Table 3.6.
Since in the application, not all the available fields of ScanResult class will be
required, a separate class named WifiMeasurement was implemented. This class
contains the SSID, BSSID, frequency, level and timestamp fields.
The ArrayList of ScanResults is then looped through and, by checking the
SSIDs, only the configured access points are selected. For each of them, a new
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 29
the access points, processing it and then forwarding the data to the application
components which require this information at a periodical interval of time.
• MapActivity - component which displays the map and the current location
on the map
• SelectMapActivity - displays all maps available on the server and the user
can select the current map in this activity
When the user starts the application, MainActivity is launched and from this
activity the user can access the other components of the application as seen in
Figure 3.12.
In the onCreate(), apart from configuring the interface controls, the applica-
tion sends a ping message to the server to check that the server is available and
within range for a wireless connection. If the ping is successful, the application
tries to establish a connection to the access point’s network configured on the
server.
This is achieved again using an instance of WifiManager which is created as
shown in Listing 3.1. The next step is to create a WifiConfiguration object and
to set the SSID and the preshared key because the server is using the WPA-PSK
encryption protocol.
Once the configuration is created, the network needs to be added to the
set of configured networks. This is accomplished by invoking the WifiMan-
ager.addNetwork() method which returns an ID of the newly created network.
The last step is to effectively connect to this new network as shown in Listing 3.2
(serverWifiManager is the WifiManager object).
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 31
The mobile device is now connected to the network of the server. Another
information the client sends to the server is the ID of the current map. The server
uses this ID to acquire map information (access points location, map dimensions)
from the database. This is called the initialization step: the server now only needs
access point Wifi measurements in real-time to run the positioning algorithm.
The WifiActivity displays real-time measurements of the two access points
using a ListView and a custom adapter named ScannedNetworksAdapter. Using
a local BroadcastReceiver, the activity catches AP scan results. The Scanned-
NetworksAdapter displays the information as shown in Figure 3.13.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 32
rentPositionCircle (in blue) for the two access point are drawn. Also, a Broad-
castReceiver is instantiated in order to catch the POSITION DATA messages from
the WifiScanning service.
Each time data is received from the WifiScanning service, the coordinates are
scaled for the mapView object as shown in Listing 3.3.
Using mapX and mapY, a new Position object is created. Then, the method
MapView.showPosition() is invoked. This function adds a new PositionMarker
for the new Position and removes from the container all previous markers, ex-
cepting the access points as seen in Listing 3.4.
From SettingsActivity the user can edit server connection information such
as:
• IP of the server
The SelectMapActivity allows the user to select which map to display in the
MapActivity. It sends a DownloadMap packet message to the server and the
server responds with a list of all available maps in the database.
All the maps are displayed using a ListView control and when the user selects
an item, the application sends another DownloadMap packet message with the
ID of the map. This time, the server responds with the information configured
for the map.
% RX − d i g i t a l p i n 2 ( c o n n e c t with TX o f t h e o t h e r d e v i c e )
% TX − d i g i t a l p i n 3 ( c o n n e c t with RX o f t h e o t h e r d e v i c e )
SoftwareSerial serialESP8266 ( 2 , 3 ) ;
void setup ( )
{
Serial . begin ( 9 6 0 0 ) ;
serialESP8266 . begin ( 9 6 0 0 ) ;
}
• Station - the module acts as a client and can connect to an access point;
• Access point - other clients can connect to the module, including another
ESP8266 module which operates as a station;
• Station and access point - the module operates in both modes simultane-
ously.
To set the operating mode of the ESP8266, the command in Listing 3.8 can
be used:
In order to establish how fast the serial data is transmitted, the baud rate
has to be set as shown in Listing 3.9.
and for the changes to take effect, the following command resets the ESP8266
module.
SSID represents the name of the network that the client will see when connect-
ing to the network. The password is used to guarantee the security of the network
according to the encryption mode. If the encryption mode is set as Open, then
any user can connect to the network without providing a correct password. The
third parameter specifies what network channel is used by the ESP8266 module.
The encryption parameter sets the security mode as described in Table 3.8.
Out of these security modes, the safest and the most commonly used is the
WPA2-PSK protocol.
The IP address of the access point is set as in command 3.12.
and the setup of the MAC address is the last configuration step:
The next step is to configure the hostapd service. For this purpose, the
configuration file /etc/hostapd/hostapd.conf was created.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 40
The options in the hostapd.conf configure the main parameters of the access
point. The option ignore broadcast ssid = 0 is used to allow only users which
know the network name to connect. macaddr acl = 0 specifies that there is no
filtering after the MAC address. The hw mode = g option indicates that the
access point uses a 2.4GHz band.
The next four lines, specify that the encryption protocol used by the network is
WPA2 with a preshared key. rsn pairwise = CCMP indicate that the Advanced
Encryption Standard (AES) should be used, while wmm enabled = 1 indicates the
use of Wi-Fi Multimedia (WMM) to register data packets in order to enhance
the quality of service over the network.
In order for hostapd service to use this configuration file, the line 3.17 was
added in the default file /etc/default/hostapd.
The above configurations are enough to start the access point, but in order
to connect to it and receive an IP address, the dnsmasq service needs to be
configured. To that end, the /etc/dnsmasq.conf config file was edited as shown
in 3.18.
listen−address = 1 9 2 . 1 6 8 . 3 5 . 1
server = 8 . 8 . 8 . 8
dhcp−range = 1 9 2 . 1 6 8 . 3 5 . 5 0 , 1 9 2 . 1 6 8 . 1 . 2 0 0 , 6h
The first line specifies that the wlan0 is the interface used by the access point
and bind-interfaces attaches the interface to ensure that the packets are sent
on the wlan0 interface.
The listen-address setting indicates explicitly the IP address to listen on.
The last line from the /etc/dnsmasq.conf sets the range of assignable IP ad-
dresses between 192.168.35.50 and 192.168.35.200 with a lease time of 6h for each
IP address.
To complete the configuration of the server as an access point, one more step
was required: to enable packet forwarding. In order to acquire IPv4 forwarding,
in the /etc/sysctl.conf, the following line was added:
After these commands the server works as an access point and the client
application can connect to the server.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 42
The server runs a Java Application which uses the KryoNet library to com-
municate with the client applications. Also, the server uses a MySQL database
to store the available maps and to log any connection and any information sent
between the client and the server.
MySQL is installed on the server as follows:
The setup of the server using KryoNet is described in the Client-Server Model
section and the packet classes used to send response and request message between
the client and the server are described in Table 3.10.
In order to connect to the database, the JDBC:MySQL driver was used. This
driver comes in a Connector/J package which has to be added as an external
library to the server application. The Connector/J package used on Raspberry
PI was mysql-connector-java-5.1.6-bin.jar.
The connection to the MySQL database in the application is created using the
DriverManager.getConnection() function. This method requires three parame-
ters: the user, the password and the URL (which is ”jdbc:mysql://localhost:3306”
since the database is on the same host as the server application and 3306 is the
designated port to communicate data).
The server also uses a DbHelper class to facilitate the access to the MySQL
database. This class defines several functions to ease INSERT and SELECT opera-
tions with the database. All these methods are described in Table 3.9.
Apart from querying the database for logging information and map data, the
server implements the positioning algorithm. The input required by the algorithm
consists of the level and frequency fields for the two configured access points
and the output it produces are the two coordinates of the mobile device. Also,
the length L of the real localization area is required and this is acquired from
the database, after the client sends the Initialization packet with the currently
selected map ID.
The first step in the algorithm is evaluating the radius of the two circles
using the formula in 3.7. For this purpose, a new method getDistance() was
implemented which receives the frequency and level of one access point and
returns the radius of the circle as a double.
The next step is checking the validity of these radii. For this sake, a separate
method validityCheck() was created. This function requires the two radii r1
and r2 as input parameters and returns a boolean.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 43
Method Details
Saves the client IP
logPing() and current time
in the Pings table
Saves the client IP
logInitialization() and the map ID
it currently uses
Saves the measurements
logLocalizationRequest()
received from a client device
Saves the positioning
logLocalizationResponse()
algorithm output
If the client uploads a
insertMap() map to the server,
it is saved in the database
If the client selects a new map,
selectMap() the server acquires the blob
of the map from the database
Selects the names of all
getAllMaps()
maps available in the database
Table 3.9: DbHelper Methods
Communication between client and server was handled using the KryoNet
API. This API is comprised of Kryo, the serialization framework, and a series of
functions designed for transferring serialized objects across the network.
In order to run a server, an instance of the Server class has to be created and
the method start() creates a new thread which handles any connection request
from a client and notifies the listeners.
The Server constructor can customize the buffer sizes, an object buffer and
a write buffer. When the server, receives an object, the bytes are queued in the
object buffer until the transfer is complete and after that the deserialization of
the object begins. The write buffer is used to serialize objects that are send over
the network.
Because of that, the size of the two buffers need to be greater than the largest
incoming and outgoing objects. In the localization system, the server was instan-
tiated as shown in Listing 3.23.
as the map sent over the network can have a significant size in bytes. The
same principles are applied for the client component.
Before any network communication occurs, a necessary step is registering
the classes of the objects sent over the network. This step has to be done on
both the client and the server and it is mandatory that the same classes are
registered on both sides and in the same order. As such, a separate method
named registerPackets() was created for both the client and the server.
One class is registered creating a Kryo object by calling Server.getKryo() and
then invoking the Kryo.register() method. The register() method receives
as parameter the class to register and this registration step needs to be done for
all classes used in sending data between client and server.
The classes in Table 3.10 were registered in registerPackets().
For the sake of handling incoming packets, a Listener has to be implemented.
The Listener can then be instantiated and added to server using the method
Server.addListener(). The Listener class has the following important methods
which can be overriden:
The received() handles the capture of objects send over the network by
clients. This method usually contains checks over the received object using the
instanceof keyword. Once the type of packet is determined, the server casts
the object to the corresponding class and saves a log in the database.
Depending on the type of packet, the server may respond to client or just
save the data in the database. For example, if the server receives an UploadMap
packet, he saves the map in the database and does not send a response back. If
the server receives a LocalizationRequest packet, after the positioning algorithm
it will respond with a LocalizationResponse packet. Figure 3.16 emphasises all
the packets sent between server and client.
Both the client and the server send data across the network using the sendTCP()
method. The last step in configuring the server is to bind the TCP and UDP
port. This is accomplished by invoking the Server.bind(tcpPort, udpPort).
A Client is set up in a similar manner. The main difference is that instead of
binding the TCP and UDP ports, the client will connect to the server over the
same ports by invoking the connect() method as shown in Listing 3.24.
CHAPTER 3. HARDWARE AND SOFTWARE CONFIGURATION 46
Client Server
Ping
Ping
Initialization
UploadMap
DownloadMap[All]
MapDatabase
DownloadMap[Map]
UploadMap
LocalizationRequest
LocalizationResponse
Case study
47
CHAPTER 4. CASE STUDY 48
Firstly, there is a bunk bed between the two access points which distorts
the received signal strength of the access point which sits on the opposite of
the client device with respect to the bed. There are also two partial false walls
which separate the upper part of the room from the rest and several other objects
standing near the edge of the room.
Although any device which was using electromagnetic waves in the room was
disabled during the testing of the localization system, there were other devices
such as wireless routers and other mobile devices which were operating in nearby
rooms and could not be disabled due to obvious reasons.
Initially, the localization system was tested storing only perfect solutions in
server queue. Imperfect measurements that do not pass the validityCheck()
function are discarded. If any of the conditions in (3.15), (3.16), (3.17) or (3.21)
are not true, then coordinates are not assessed for the respective set of r1 and r2 .
The results are presented in Table 4.1 and Figure 4.2. The green nodes are
the real positions, while the red nodes are the measurements provided by the
localization algorithm.
Real Measured
position coordinates
(1, 1) (2.28, 0.86)
(0, 0.2) (0.3, 0.01)
(2.7, 0.8) (1.52, 2.41)
(2.6, 3) (2.35, 2.78)
(1.5, 2.5) (2.11, 2.04)
(2, 5) (2.08, 3.34)
(3, 0) (1.87, 1.01)
(2.5, 2) (1.84, 1.67)
(0, 5) (0.13, 4.13)
(1, 4) (2.11, 3.87)
Table 4.1: Results based only on raw RSS values
It can be observed in Figure 4.2 that the points which are close to the walls,
or points for which the line of sight with one of the access points is obstructed
by the bunk bed or other object, have a greater error.
For example, it took ten measurements for the point (0, 0.2) (which means 100
seconds, since the refresh rate is 10 seconds) to find a valid pair (r1 , r2 ). This is
CHAPTER 4. CASE STUDY 49
•
•9 •6
AP2
•9
•10
•10
•6
•4
•4
•5
•3
•5 •8
•8
•1 •7
•1 •3
•2
AP1
• •2 •7 x
due to the fact that the bunk bed represents an obstruction in the line of sight be-
tween AP2 and the client device, resulting in a r2 value significantly greater than
r1 + L, which fails the side lengths condition in the method validityCheck().
The points in the center which have an unimpeded LOS with the access points
are generally better estimated.
The average error is presented in (4.1).
10
1 Xp
∆= |xmeasured − xreal |2 + |ymeasured − yreal |2 ≈ 1.57m (4.1)
10
1
CHAPTER 4. CASE STUDY 50
• If r1 + r2 < L (the circles do not intersect), then x gets the average value
r1 + L − r2
of previous measurements and y = (the point which lies at an
2
equal distance from the two circles).
10
1 Xp
∆= |xmeasured − xreal |2 + |ymeasured − yreal |2 ≈ 0.67m (4.2)
10
1
CHAPTER 4. CASE STUDY 51
•
•9 •6
AP2
•9 •6
•10
•10
•4 •4
•5
•5
•8
•3 •8
•1
•1
•3
•2 •7
•2
AP1
• •7 x
Real Measured
position coordinates
(1, 1) (1.65, 1.47)
(0, 0.2) (0.24, 0.61)
(2.7, 0.8) (1.62, 1.83)
(2.6, 3) (2.25, 2.91)
(1.5, 2.5) (1.85, 2.25)
(2, 5) (1.92, 4.67)
(3, 0) (2.41, 0.61)
(2.5, 2) (2.24, 1.79)
(0, 5) (0.06, 4.58)
(1, 4) (0.88, 4.15)
Table 4.2: Results based on RSS measurement collection
Chapter 5
52
CHAPTER 5. CONCLUSIONS AND FUTURE WORK 53
Future work will be focused on how the system behaves when there are several
mobile devices in the localization area, and what is the overhead at which the
server can assess multiple positions for different devices in the same localization
area at the same time.
In order to obtain a better precision in the localization algorithm, the number
of considered measurements needs to be increased. As such, future research will
study the effect of increasing the queue size and will aim to determine a satisfying
precision-time ratio.
Also, the system will try to use other technologies to acquire localization
information from multiple sources. The positioning can be improved significantly
by using various technologies such as RFID or bluetooth.
For the sake of improving the localization accuracy, other signal propagation
models will be tested and the system’s performance will be compared with the
same system when acquiring wireless data from three or more access points.
Other further work for the indoor localization system may include implement-
ing a WiFi fingerprinting in all the positions of the localization area.
Bibliography
[1] A. Bahillo and S. Mazuelas, Indoor Location based on IEEE 802.11 Roundtrip Time
Measurements with two-steps NLOS mitigation, (2009).
[2] Atreyi Bose and Chuan Heng Foh, A Practical Path Loss Model For Indoor WiFi
Positioning Enhancement, (2007), 2.
[3] B. Viel and M. Asplund, Why is fingerprint-based indoor localization still so hard?,
Proceedings of the IEEE International Conference on Pervasive Computing and
Communication Workshops (PERCOM WORKSHOPS ’14), March 2014, pp. 443–
448.
[4] B.H. Fleury, P.E. Leuthold, Radiowave propagation in mobile communications, 72–
85.
[5] Claire Swedberg, Lipa Betoni Uses Bluetooth-Based RTLS to Manage Production,
(January 2012).
[9] H. Liu, H. Darabi, P. Banerjee, and J. Liu, Survey of wireless indoor positioning
techniques and systems, (2007), 1067–1080.
[10] Hesham Ibrahim Ahmed, Ping Wei, Imran Memon, Yanshen Du, Wei Xie, Estima-
tion of Time Difference of Arrival (TDOA) for the Source Radiates BPSK Signal,
(May 2013).
54
BIBLIOGRAPHY 55
[13] National Research Council (U.S.). Committee on the Future of the Global Posi-
tioning System; National Academy of Public Administration, The global positioning
system: a shared national asset: recommendations for technical improvements and
enhancements, National Academies Press, 2013.
[16] Ravindra S and Jagadeesha S N, Time of arrival based localization in wireless sensor
networks: a linear approach, (August 2013).
[18] Waleed Alsalih, Abdallah Almaaitah, and Wadha Alkhater, RFID Localization Us-
ing Angle of Arrival Cluster Forming, (2014).
[19] X. Hu, L. Cheng, and G. Zhang, A Zigbee-based localization algorithm for indoor
environments, Proceedings of the International Conference on Computer Science
and Network Technology (ICCSNT 11), December 2011, pp. 1776–1781.
[20] Z. Li, W. Dehaene, and G. Gielen, System design for ultra-low-power UWB-based
indoor localization, Proceedings of the IEEE International Conference on Ultra-
Wideband (ICUWB ’07), September 2007, pp. 580–585.
[21] Zack Epstein, Apples mobile market share sees big drop
in May as Android skyrockets, http://bgr.com/2016/06/02/
apples-mobile-market-share-sees-big-drop-in-may-as-android-skyrockets/,
As seen in June 2016.
[22] Zengwei Zheng, Yuanyi Chen, Tao He, Fei Li, and Dan Chen, Weight-RSS: A
Calibration-Free and Robust Method for WLAN-Based Indoor Positioning, (2015),
1–3.
Listings
56