Exemplo n.º 1
0
    public void ReportScan(string Device)
    {
#endif
        if (IsIgnoringScanReport)
        {
            return;
        }

#pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "ReportScan: " + Device);
        }
#pragma warning restore CS0162

        StartRefreshDeviceList();

        //Structure from native connect:[MacAdress or Identifier],[Name from AdvertisementData],[rssi]
        string[] splitString = Device.Split(',');
        string   s_rssi      = splitString[2];
        int      i_rssi      = int.Parse(s_rssi);
        string   serial      = splitString[1].Split(' ')[1];
        string   macID       = splitString[0];

        if (MovesenseDevice.GetConnectingState(macID))
        {
#pragma warning disable CS0162
            if (isLogging)
            {
                Debug.Log(TAG + macID + " is connecting, cancel further processing");
            }
#pragma warning restore CS0162
            return;
        }

        if (!RefresherList.Contains(macID))
        {
            RefresherList.Add(macID);
        }

        if (MovesenseDevice.ContainsMacID(macID))
        {
            if (MovesenseDevice.GetRssi(macID) != i_rssi && !IsRefreshingRssiBlocked)
            {
#pragma warning disable CS0162
                if (isLogging)
                {
                    Debug.Log(TAG + macID + " (" + serial + ") already scanned, refreshing rssi");
                }
#pragma warning restore CS0162
                MovesenseDevice.RefreshRssi(macID, i_rssi);

                if (Event != null)
                {
                    Event(null, new EventArgs(EventType.RSSI, TAG + "ReportScan", macID));
                }
            }
            else
            {
#pragma warning disable CS0162
                if (isLogging)
                {
                    Debug.Log(TAG + macID + " (" + serial + ") already scanned, " + (IsRefreshingRssiBlocked ? "refreshRssi blocked" : "same rssi") + ", cancel further processing");
                }
#pragma warning restore CS0162

                return;
            }
        }
        else
        {
#pragma warning disable CS0162
            if (isLogging)
            {
                Debug.Log(TAG + macID + " (" + serial + ") is new");
            }
#pragma warning restore CS0162

            MovesenseDevice movesenseDevice = new MovesenseDevice(macID, serial, i_rssi, false, false, null);
            MovesenseDevice.Add(movesenseDevice);
            if (Event != null)
            {
                Event(null, new EventArgs(EventType.NEW_DEVICE, TAG + "ReportScan", macID));
            }
        }

        StartRssiRefreshBlocker();
    }