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

OnBleDidCompletePeripheralScan() public method

public OnBleDidCompletePeripheralScan ( string message ) : void
message string
return void
        void OnBleDidCompletePeripheralScan(string message)
        {
            if (message != "Success")
            {
                if (OnBleDidCompletePeripheralScanErrorEvent!=null)
                {
                    OnBleDidCompletePeripheralScanErrorEvent(message);
                }
            }
            else
            {
                string peripheralJsonList = BLEController.GetListOfDevices();
                Dictionary<string, object> dictObject = Json.Deserialize(peripheralJsonList) as Dictionary<string, object>;

                object receivedByteDataArray;
                List<object> peripheralsList = new List<object>();
                if (dictObject.TryGetValue ("data", out receivedByteDataArray))
                {
                    peripheralsList = (List<object>) receivedByteDataArray;
                }

                if (OnBleDidCompletePeripheralScanEvent!=null)
                {
                    OnBleDidCompletePeripheralScanEvent(peripheralsList);
                }
            }
        }

Usage Example

Beispiel #1
0
 public static void ScanForPeripherals()
 {
     // 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)
     {
         _ScanForPeripherals();
     }
                 #elif UNITY_ANDROID
     if (Application.platform == RuntimePlatform.Android)
     {
         System.Action <string> callback = ((string message) =>
         {
             BLEControllerEventHandler.OnBleDidCompletePeripheralScan(message);
         });
         PluginInstance.Call("_ScanForPeripherals", new object[] { new UnityCallback(callback) });
     }
                 #endif
 }
All Usage Examples Of BLEFramework.Unity.BLEControllerEventHandler::OnBleDidCompletePeripheralScan