/** * <summary>The device connection state changed, it is received here as a json</summary> * * <param name="state">Current connection state.</param> */ public void onConnectionStateChanged(string state) { try { // Convert json object to an object format. DeviceState s = JsonUtility.FromJson <DeviceState>(state); // Check if the callback was previously initialized. if (OnDeviceConnectionChange != null) { currState = (DeviceState.States)s.state; OnDeviceConnectionChange(s.identifier, (DeviceState.States)s.state); // Disconnect device is the acquisition stops. if (currState.Equals(DeviceState.States.ACQUISITION_STOPPING)) { // Disconnect device. androidSensorsClass.Call("disconnect", identifier); } } } catch (Exception e) { Debug.Log(e.Message); } }
/** * <summary>Disconnects from a specific device.</summary> * * <param name="id">Id of the device.</param> */ public void Disconnect(string id) { if (androidSensorsClass == null) { return; } // Stop real-time acquisition. if (currState.Equals(DeviceState.States.ACQUISITION_OK)) { Stop(id); } }