How to get correct coordinates from BLE trained data based on RSSI value?

73 Views Asked by At

I've 3 G1-C-ADVANCED gateways placed in Triangle's direction. I want to get the correct coordinates of a beacon device and display its location on the floor plan image.

I've created Trained data with all the coordinates.

I've Implemented KNN Positioning algorithm from this project but its working properly. and also I've implemented dictionary-based searching from trained data below is the demo code.

static string LocateTarget(Dictionary<string, Dictionary<string, int>> fingerprintDb, Dictionary<string, int> targetRssi, double n = 2.0)
        {
            string bestLocation = string.Empty;
            double bestDistance = double.PositiveInfinity;

            foreach (var fingerprint in fingerprintDb)
            {
                var distances = new List<double>();

                foreach (var fingerprintRssi in fingerprint.Value)
                {
                    if (targetRssi.TryGetValue(fingerprintRssi.Key, out int targetDeviceRssi))
                    {
                        double distance = CalculateDistance(targetDeviceRssi, fingerprintRssi.Value, n);
                        distances.Add(distance);
                    }
                }

                if (distances.Count == fingerprint.Value.Count)
                {
                    double averageDistance = distances.Average();
                    if (averageDistance < bestDistance)
                    {
                        bestDistance = averageDistance;
                        bestLocation = fingerprint.Key;
                    }
                }
            }

            return bestLocation;
        }


static double CalculateDistance(int rssi, int tx_power, double n)
        {
            // Calculate the distance based on RSSI using the Log-Distance Path Loss Model
            return Math.Pow(10, (tx_power - rssi) / (10 * n));
        }

I want to get the correct coordinates from trained data based on realtime gateway rssi values. Any feasible solution for this? Working from last 2 weeks I didn't get the proper solution.

I've searched on chatGBT, but chatGBT's answer is also not working.

0

There are 0 best solutions below