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

OnBleDidConnect() public method

public OnBleDidConnect ( string message ) : void
message string
return void
        void OnBleDidConnect(string message)
        {
            if (message=="Success")
            {
                if (OnBleDidConnectEvent!=null)
                {
                    OnBleDidConnectEvent();
                }
            }
            else if (OnBleDidConnectErrorEvent!=null)
            {
                OnBleDidConnectErrorEvent(message);
            }
        }

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::OnBleDidConnect