//private functions private async Task UpdateFoundMipRobotList() { string deviceSelector = GattDeviceService.GetDeviceSelectorFromUuid(BluetoothRobotConstants.SEND_DATA_SERVICE_UUID); DeviceInformationCollection collection = await DeviceInformation.FindAllAsync(deviceSelector); foreach (DeviceInformation info in collection) { //exclude any found mip if (FoundRobotList.FirstOrDefault(m => m.SendDataServiceInfo == info) == null) { T robot = new T(); robot.SendDataServiceInfo = info; //callback when mip was connected robot.DidConnectedEvent += (sender, connectedMipRobot) => { //prevent any duplicated mip if (ConnectedRobotList.FirstOrDefault(m => m == connectedMipRobot) == null) { ConnectedRobotList.Add((T)connectedMipRobot); } }; //callback when mip was disconnected robot.DidDisconnectedEvent += (sender, disconnectedMipRobot) => { ConnectedRobotList.Remove((T)disconnectedMipRobot); FoundRobotList.Remove((T)disconnectedMipRobot); }; //TODO: show log for found new mip FoundRobotList.Add(robot); } } }
public void ClearFoundRobotList() { ConnectedRobotList.Clear(); FoundRobotList.Clear(); }