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 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 }