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); } } }
public static void OnBleDidCompletePeripheralScan(string message) { string errorMessage = message != "Success" ? message : null; List <object> peripheralsList = new List <object>(); string peripheralJsonList = (errorMessage == null) ? BLEController.GetListOfDevices() : null; if (peripheralJsonList != null) { Dictionary <string, object> dictObject = Json.Deserialize(peripheralJsonList) as Dictionary <string, object>; object receivedByteDataArray; if (dictObject.TryGetValue("data", out receivedByteDataArray)) { peripheralsList = (List <object>)receivedByteDataArray; } } OnBleDidCompletePeripheralScanEvent?.Invoke(peripheralsList, errorMessage); }