UnityAndESP32_BLEExamples icon indicating copy to clipboard operation
UnityAndESP32_BLEExamples copied to clipboard

Can not receive the message from unit

Open GIRAFFE-YIN opened this issue 5 years ago • 0 comments

Hi, I'm working on transmitting data from ESP32 to unity, thanks for providing this useful example. I slightly modify your program so It is almost the same and I thought it won't be any problems. But when unity goes to subscribes stage.

`case States.Subscribe: BluetoothLEHardwareInterface.SubscribeCharacteristicWithDeviceAddress(_deviceAddress, ServiceUUID, SubscribeCharacteristic, null, (address, characteristicUUID, bytes) => {

                // we don't have a great way to set the state other than waiting until we actually got
                // some data back. For this demo with the rfduino that means pressing the button
                // on the rfduino at least once before the GUI will update.
                _state = States.None;

                // we received some data from the device
                _dataBytes = bytes;
                float qx = System.BitConverter.ToSingle(bytes, 0);
                float qy = System.BitConverter.ToSingle(bytes, 8);
                float qz = System.BitConverter.ToSingle(bytes, 4);
                float qw = System.BitConverter.ToSingle(bytes, 12)*-1;

                rawQuat = new Quaternion(qx, qy, qz, qw);
                cubeTransform.rotation = quatLookAtCam*rawQuat;

                //DeviceNameFoundedText.text = qx.ToString() + " " + qy.ToString() + " " + qz.ToString() + " " + qw.ToString()+"\n";
                DeviceNameFoundedText.text = "raw : "+rawQuat.ToString()+"\n";
                DeviceNameFoundedText.text += "cube : "+cubeTransform.rotation.ToString();

            });
            break;`

everything in side seems did nothing T_T. and the console shows: 截屏2020-03-26下午8 23 36

Did you met this problem before?

GIRAFFE-YIN avatar Mar 26 '20 20:03 GIRAFFE-YIN