private void ValidateClientMap (BlePeripheralMap map) { if (!ProtocolServices.ALL_SERVICES.All (service => map.Services.Any (mapService => mapService.ServiceUUID.Equals (service)))) { throw new Exception ("Not all expected services found on the device!"); } if (ProtocolServices.ALL_CHARACTERISTICS.Any (charac => map.FindCharacteristicByUUID (charac) == null)) { throw new Exception ("Not all expected characteristics found on the device!"); } }
public BlePeripheralMap Execute () { this.PeripheralMap = new BlePeripheralMap (); this.FindServices (); foreach (BlePeripheralService service in this.PeripheralMap.Services) { this.FindAttributes (service); this.ConvertAttributesToCharacteristics (service); } return this.PeripheralMap; }
public BlePeripheralMap Connect () { // Init BgLib, open port, and start receiving thread this.InitTools (); BleDiscoverService discoverBlock = new BleDiscoverService (Ble, Port, Config.ServiceUUID); ScanResponseEventArgs found = discoverBlock.Execute (); BleConnectToService connectBlock = new BleConnectToService (Ble, Port, found.sender, found.address_type); this.ConnectionHandle = connectBlock.Execute ().connection; BleFindServicesAndCharacteristics infoBlock = new BleFindServicesAndCharacteristics (Ble, Port, this.ConnectionHandle); this.PeripheralMap = infoBlock.Execute (); this.InitializeCharacteristicNotifications (); this.Ble.Lib.BLEEventConnectionDisconnected += DisconnectedHandler; return this.PeripheralMap; }