private void TrReadingStarted(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); //TODO HAS CHANGED if (device != null) { device.IsReading = true; if (OnReadingStarted != null) { OnReadingStarted(device); } device.RaiseOnReadingStarted(); if (device.ReadingCoroutine != null && device.WillRead) { device.last_started_couroutine = device.ReadingCoroutine(device); StartCoroutine(device.last_started_couroutine); } } }
//Replacement for TrModuleOFF and TrModuleNotFound private void TrConnectionError(string m2) { string m; //regular first message string e; //error message string[] split = m2.Split(new string[] { "#$" }, StringSplitOptions.None); if (split.Length != 2) { Debug.LogError("Argument 'm2' should only contains one '#$' seperator"); return; } m = split[0]; e = split [1]; int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); if (device != null) { if (OnConnectionError != null) { OnConnectionError(device, e); } device.RaiseOnConnectionError(e); } }
private void TrDisconnect(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); //making sure that OnDisconnected called once if (device != null) { if (device.IsConnected) { device.IsConnected = false; if (OnDisconnected != null) { OnDisconnected(device); } device.RaiseOnDisconnected(); if (device.IsReading) { TrReadingStopped(m); device.IsReading = false; } } } }
private void TrEmptiedData(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); if (device != null) { device.IsDataAvailable = false; } }
private void TrReadingError(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); if (device != null) { if (OnReadingError != null) { OnReadingError(device); } device.RaiseOnReadingError(); } }
private void TrModuleOFF(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); if (device != null) { if (OnDeviceOFF != null) { OnDeviceOFF(device); } device.RaiseOnDeviceOFF(); } }
private void TrReadingStopped(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); if (device != null) { device.IsReading = false; if (OnReadingStoped != null) { OnReadingStoped(device); } device.RaiseOnReadingStoped(); } }
private void TrConnect(string m) { int deviceID; if (!int.TryParse(m, out deviceID)) { return; } BluetoothDevice device = BluetoothDevice.GET_DEVICE_OF_ID(deviceID); //making sure that OnConnected called once if (device != null) { if (!device.IsConnected) { device.IsConnected = true; if (OnConnected != null) { OnConnected(device); } device.RaiseOnConnected(); } } }