public static void Disconnect(string MacID) { // mds checks, if device is connected string serial = MovesenseDevice.GetSerial(MacID); #pragma warning disable CS0162 if (isLogging) { Debug.Log(TAG + "Disconnect: " + MacID + " (" + serial + ")"); } #pragma warning restore CS0162 #if UNITY_ANDROID && !UNITY_EDITOR movesensePlugin.Call("disconnect", MacID); #elif UNITY_IOS && !UNITY_EDITOR DisConnectMDS(MacID); if (MovesenseDevice.GetConnectingState(MacID)) { // connection has not been completed => there will be no callback if disconnect is called MovesenseDevice.SetConnectionState(MacID, false); #pragma warning disable CS0162 if (isLogging) { Debug.Log(TAG + "Disconnect, while connecting, raising Disconnect-event"); } #pragma warning restore CS0162 if (Event != null) { Event(null, new EventArgs(EventType.DISCONNECTED, TAG + "Disconnect", new List <System.EventArgs> { new ConnectCallback.EventArgs(false, MacID, serial) })); } } #elif UNITY_STANDALONE_OSX || UNITY_EDITOR #endif }
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(); }