예제 #1
0
    private void OnDataReceived(BLEService.Data data)
    {
        byte[] bytes = data.RawData;

        if (bytes.Length == 8)
        {
            uint   millis = (uint)((bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]);
            ushort ecg    = (ushort)((bytes[4] << 8) | bytes[5]);
            ushort emg    = (ushort)((bytes[6] << 8) | bytes[7]);

            Debug.Log($"### ECG: {ecg}");

            if (ecg == 0)
            {
                ecg = (ushort)Random.Range(0, 50);
            }
            _chart.Insert(ecg);
            s = $"{millis} : {ecg} : {emg}";
        }
        else
        {
            s = $"-{bytes.Length}-";
            foreach (byte b in bytes)
            {
                s += (int)b;
                s += " ";
            }
        }
    }
예제 #2
0
    private void OnDataReceived(BLEService.Data data)
    {
        byte[] bytes = data.RawData;

        if (bytes.Length == 8)
        {
            uint   millis = (uint)((bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]);
            ushort ecg    = (ushort)((bytes[4] << 8) | bytes[5]);
            ushort emg    = (ushort)((bytes[6] << 8) | bytes[7]);

            s = $"{millis} : {ecg} : {emg}";
        }
        else
        {
            s = $"-{bytes.Length}-";
            foreach (byte b in bytes)
            {
                s += (int)b;
                s += " ";
            }
        }
    }