/WiFi_Positioning_Server_go

Experimental project for WiFi Positioning Technology with golang

Primary LanguageGoMIT LicenseMIT

WiFi_Positioning_Server_go

Golang conversion of Gachon Univefrsity Sensor and Wireless Network Class Term Project.
This is a project for the experimental implementation of WiFi Indoor Positioning technology and golang.

We used WiFi Fingerprinting technique to implement WiFi Positioning. This is for more general use as there are APs that do not yet support WiFi RTT.

Original version is developed with Node.js
https://github.com/chromato99/WiFi_Positioning_Server

This is a repository for server, and the client implementation can be found at the link below.
Client App : https://github.com/chromato99/WiFi_Positining

Server App

This server was written in Go language and developed in the form of RESTful API using Gin Web Framework.

The project structure consists of main, core module, and result module.

Main is written for the entry point when a client connects, and the main processing is written in the core module. In the result module, a struct containing result data and a priority queue used in the result list are defined.

In addition, the server runs in an isolated container environment using docker, and it automatically builds and runs the server using docker compose.

Run Server

# Set password (Optional, If this process is omitted, no password is set.)
cd <project dir>/generator
go build password-generator.go
./password-generator

# Run server with docker compose
cd <project dir>
docker compose up -d

Implementation

We used MySQL database and implemented two functions except for test.

Database

MySQL database is created automatically as set in docker compose. It creates a table like below in MySQL database.

Database Table

/add

This is a function that adds data to the database. It receives data in json format and inserts it into the database. In addition, a password function was implemented to prevent anyone from adding data and to prevent the case of adding data incorrectly.

Input Data Format (JSON)

{
    "position" : "Gachon AI 311",
    "password" : "password"
    "wifi_data" : [
        {
            "bssid" : "xx:xx:xx:xx:xx:xx",
            "rssi" : -60
        },
        {
            "bssid" : "xx:xx:xx:xx:xx:xx",
            "rssi" : -30
        },
        {
            "bssid" : "xx:xx:xx:xx:xx:xx",
            "rssi" : -55
        },
    ]
}

For password, you can get the encrypted password as password.json file by executing the password-generator.go code in the generator directory.

/findPosition

This function receives input data and estimates the current location by comparing it with data previously stored in the database.

Firstly, the comparison is done in a brute force way with all data in the database. So, for speed, it uses a multi-threading technique. In the comparison process, the difference between the data is calculated by subtracting the rssi value. (In this case, only data with the same bssid are compared.)

Then, add up all the differences of the rssi values and divide by the number of the same bssid to find the average difference. Lastly, it is further divided by the count value, which is to reflect the number of the same bssid in the value.

After that, the final result is derived by comparing the four values in the order of the smallest among these finally calculated values. (In this process, priority queue is used.)

Tech Stack

Go
Gin Web Framework
MySQL