Example #1
0
        private async Task ProcessHeartbeat(RemoteScale remoteScale)
        {
            remoteScale.AliveTimestamp = Stopwatch.GetTimestamp();

            if (remoteScale.AliveTimestamp - m_WiFiScanTimestamp > Stopwatch.Frequency * 5)
            {
                await NetClient.PublishAsync($"scale/{remoteScale.DeviceId}/wifi/scan");

                m_WiFiScanTimestamp = remoteScale.AliveTimestamp;
            }

            if (!remoteScale.HasGlobalPosition || remoteScale.IsGlobalPositionCoarse)
            {
                var coarsePosition = Beacon.ComputeGlobalPosition(m_Beacons);
                if (coarsePosition != null)
                {
                    remoteScale.GlobalPosition         = coarsePosition;
                    remoteScale.IsGlobalPositionCoarse = true;
                }
            }
        }