コード例 #1
0
        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();
        }
コード例 #2
0
 public GyroscopeRfcommServiceConnectionWrapper(IRfcommConnection connection)
 {
     LatestReading                 = Vector3.Zero;
     TestJitterFixer               = new TestJitterFixer();
     ConnectionHandler             = new RfcommFixedLengthConnectionHandler(connection, EncodedLatestReading.Length);
     ConnectionHandler.OnReceived += ConnectionHandler_OnReceived;
     TestJitterFixer.DataEmited   += TestJitterFixer_DataEmited;
 }
コード例 #3
0
 public MouseServiceWrapper(IRfcommConnection connection)
 {
     RfcommConnection              = connection;
     ConnectionHandler             = new RfcommFixedLengthConnectionHandler(RfcommConnection, EncodedLatestReading.Length);
     ConnectionHandler.OnReceived += ConnectionHandler_OnReceived;
 }