Beispiel #1
0
        private static async Task StartGattServer()
        {
            try
            {
                await _logger.LogMessageAsync("Starting Initializong Jenx.si Bluetooth Gatt service.");

                await _gattServer.Initialize();

                await _logger.LogMessageAsync("Jenx.si Bluetooth Gatt service initialized.");
            }
            catch
            {
                await _logger.LogMessageAsync("Error starting Jenx.si Bluetooth Gatt service.");

                throw;
            }

            await _gattServer.AddReadWriteCharacteristicAsync(GattCharacteristicIdentifiers.DataExchange, "Data exchange");

            await _gattServer.AddReadCharacteristicAsync(GattCharacteristicIdentifiers.FirmwareVersion, "1.0.0.1", "Firmware Version");

            await _gattServer.AddWriteCharacteristicAsync(GattCharacteristicIdentifiers.InitData, "Init info");

            await _gattServer.AddReadCharacteristicAsync(GattCharacteristicIdentifiers.ManufacturerName, "Jenx.si", "Manufacturer");

            _gattServer.Start();
            await _logger.LogMessageAsync("Jenx.si Bluetooth Gatt service started.");
        }
        private async void StartGattServer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await _gattServer.Initialize();
            }
            catch
            {
                return;
            }

            await _gattServer.AddReadWriteCharacteristicAsync(GattCharacteristicIdentifiers.DataExchange, "Data exchange");

            await _gattServer.AddReadCharacteristicAsync(GattCharacteristicIdentifiers.FirmwareVersion, "1.0.0.1", "Firmware Version");

            await _gattServer.AddWriteCharacteristicAsync(GattCharacteristicIdentifiers.InitData, "Init info");

            await _gattServer.AddReadCharacteristicAsync(GattCharacteristicIdentifiers.ManufacturerName, "Jenx.si", "Manufacturer");

            _gattServer.Start();
        }