in src/Covi.Android/Features/Bluetooth/Gatt/BtGattServer.cs [48:83]
public void Start(Context context, TracingInformation tracingInformation)
{
if (!Initialized)
{
_logger.LogError("Advertiser - Starting failed - not initialized.");
return;
}
_tracingInformation = tracingInformation;
try
{
_logger.LogDebug("Advertiser - starting.");
var serviceUuid = ParcelUuid.FromString(_tracingInformation.ServiceId);
var characteristicUuid = ParcelUuid.FromString(_tracingInformation.CharacteristicId);
_logger.LogDebug($"Advertiser - initializing. ServiceId: {_tracingInformation.ServiceId}. CharacteristicId: {_tracingInformation.CharacteristicId}");
BtGattServerCallback bluetoothGattServerCallback = new BtGattServerCallback(_tracingInformation);
_gattServer = _bluetoothManager.OpenGattServer(context, bluetoothGattServerCallback);
bluetoothGattServerCallback._gattServer = _gattServer;
BluetoothGattService service = new BluetoothGattService(serviceUuid.Uuid, GattServiceType.Primary);
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(characteristicUuid.Uuid, GattProperty.Read, GattPermission.Read);
service.AddCharacteristic(characteristic);
_gattServer.AddService(service);
_logger.LogDebug("Advertiser - started.");
}
catch (Exception ex)
{
_logger.LogError(ex, "Advertiser - failed advertising initialization.");
}
}