Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        //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);
            }
        }
Esempio n. 3
0
        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;
                    }
                }
            }
        }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
0
        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();
            }
        }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        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();
            }
        }
Esempio n. 8
0
        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();
                }
            }
        }