private void SetMovesenseDeviceConnectState(string macID, string serial, bool isConnect) { #pragma warning disable CS0162 if (isLogging) { Debug.Log(TAG + "SetMovesenseDeviceConnectState: " + macID + " (" + serial + "): " + (isConnect ? "connected" : "disconnected")); } #pragma warning restore CS0162 // NOTE: sometimes there is no onConnectionComplete-Callback and the library is trying to reconnect without success. // depends on which mobile android device is used. // take a look at https://bitbucket.org/suunto/movesense-docs/wiki/Mobile/Movesense%20compatible%20mobile%20devices.md // Fix: sometimes whiteboard reconnects a device if (!MovesenseDevice.ContainsMacID(macID) && isConnect) { MovesenseDevice movesenseDevice = new MovesenseDevice(macID, serial, -600, false, false, null); Debug.Log(TAG + "onConnectionComplete: " + serial + " added on reconnect"); MovesenseDevice.Add(movesenseDevice); } if (MovesenseDevice.SetConnectionState(macID, isConnect) || isConnect) { if (Event != null) { Event(null, new EventArgs(isConnect, macID, serial)); } } }
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(); }