Наследование: UnityEngine.MonoBehaviour
Пример #1
0
 // Now make methods that you can provide the iOS functionality
 public static void InitBLEFramework()
 {
     // 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)
     {
         _InitBLEFramework();
     }
                 #elif UNITY_ANDROID
     if (Application.platform == RuntimePlatform.Android)
     {
         System.Action <string> callback = ((string message) =>
         {
             BLEControllerEventHandler.OnBleDidInitialize(message);
         });
         PluginInstance.Call("_InitBLEFramework", new object[] { new UnityCallback(callback) });
     }
                 #endif
 }
Пример #2
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);
        }
Пример #3
0
 void OnBleDidReceiveDataMessage(string message)
 {
     BLEControllerEventHandler.OnBleDidReceiveData(message);
 }
Пример #4
0
 void OnBleDidDisconnectMessage(string message)
 {
     BLEControllerEventHandler.OnBleDidDisconnect(message);
 }
Пример #5
0
 //Instance methods used by iOS Unity Send Message
 void OnBleDidInitializeMessage(string message)
 {
     BLEControllerEventHandler.OnBleDidInitialize(message);
 }
Пример #6
0
 void OnBleDidCompletePeripheralScanMessage(string message)
 {
     BLEControllerEventHandler.OnBleDidCompletePeripheralScan(message);
 }