BLEFramework.Unity.BLEControllerEventHandler.OnBleDidReceiveData C# (CSharp) Method

OnBleDidReceiveData() public method

public OnBleDidReceiveData ( string message ) : void
message string
return void
        void OnBleDidReceiveData(string message)
        {
            int numOfBytes = 0;
            if (int.TryParse(message, out numOfBytes))
            {
                byte[] data = BLEController.GetData();

                if (OnBleDidReceiveDataEvent!=null)
                {
                    OnBleDidReceiveDataEvent(data, numOfBytes);
                }
            }
        }

Usage Example

Beispiel #1
0
        public static bool ConnectPeripheralAtIndex(int peripheralIndex)
        {
            bool result = false;

            // We check for UNITY_IPHONE again so we don't try this if it isn't iOS platform.
                        #if UNITY_IPHONE
            // Now we check that it's actually an iOS device/simulator, not the Unity Player. You only get plugins on the actual device or iOS Simulator.
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                result = _ConnectPeripheralAtIndex(peripheralIndex);
            }
                        #elif UNITY_ANDROID
            if (Application.platform == RuntimePlatform.Android)
            {
                System.Action <string> disconnectCallback = ((string message) =>
                {
                    BLEControllerEventHandler.OnBleDidDisconnect(message);
                });
                System.Action <string> connectCallback = ((string message) =>
                {
                    Debug.Log("BLE Did Connect but wait for service discover before trasmitting.");
                    //BLEControllerEventHandler.OnBleDidConnect(message);
                });
                System.Action <string> receiveDataCallback = ((string message) =>
                {
                    BLEControllerEventHandler.OnBleDidReceiveData(message);
                });
                System.Action <string> readyForDataCallback = ((string message) =>
                {
                    BLEControllerEventHandler.OnBleDidConnect(message);
                });
                result = PluginInstance.Call <bool>("_ConnectPeripheralAtIndex", new object[] { peripheralIndex, new UnityCallback(connectCallback), new UnityCallback(disconnectCallback), new UnityCallback(receiveDataCallback), new UnityCallback(readyForDataCallback) });
            }
            #endif

            return(result);
        }
All Usage Examples Of BLEFramework.Unity.BLEControllerEventHandler::OnBleDidReceiveData