private async void ConnectButton_Clicked(object sender, EventArgs e) { ConnectionProfile profile = new ConnectionProfile(); var dict = new Dictionary <Guid, List <CharacteristicProfile> >(); dict.Add(BatteryServiceWrapper.BATTERY_SERVICE_UUID, new List <CharacteristicProfile>() { new CharacteristicProfile { Notified = true, Guid = BatteryLevelCharacteristicWrapper.BATTERY_LEVEL_UUID } }); dict.Add(DeviceInfomationServiceBuilder.SERVICE_DEVICE_INFORMATION, new List <CharacteristicProfile>() { new CharacteristicProfile { Notified = false, Guid = DeviceInfomationServiceBuilder.CHARACTERISTIC_MANUFACTURER_NAME, } }); profile.RequiredCharacteristicGuids = dict; profile.RequiredServiceGuids = new List <Guid>() { Guid.Parse("4fb996ea-01dc-466c-8b95-9a018c289cef") }; ConnectionBuilder builder = new ConnectionBuilder(BluetoothManager, profile, DeviceListView.SelectedItem as IBluetoothDevice); var result = await builder.StartAsync(); result[BatteryServiceWrapper.BATTERY_SERVICE_UUID, BatteryLevelCharacteristicWrapper.BATTERY_LEVEL_UUID].OnNotified += DeviceListPage_OnNotified; RfcommConnectionHandler = new RfcommFixedLengthConnectionHandler(result[Guid.Parse("4fb996ea-01dc-466c-8b95-9a018c289cef")].RfcommConnection, 6); RfcommConnectionHandler.OnReceived += RfcommConnectionHandler_OnReceived; //await (DeviceListView.SelectedItem as IBluetoothDevice).GattClient.ConnectToServerAsync(); }
public GyroscopeRfcommServiceConnectionWrapper(IRfcommConnection connection) { LatestReading = Vector3.Zero; TestJitterFixer = new TestJitterFixer(); ConnectionHandler = new RfcommFixedLengthConnectionHandler(connection, EncodedLatestReading.Length); ConnectionHandler.OnReceived += ConnectionHandler_OnReceived; TestJitterFixer.DataEmited += TestJitterFixer_DataEmited; }
public MouseServiceWrapper(IRfcommConnection connection) { RfcommConnection = connection; ConnectionHandler = new RfcommFixedLengthConnectionHandler(RfcommConnection, EncodedLatestReading.Length); ConnectionHandler.OnReceived += ConnectionHandler_OnReceived; }