-
-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Labels
Description
Library/API/IoT binding
nanoFramework.Device.Bluetooth
Visual Studio version
VS2022 v 17.2.5
.NET nanoFramework extension version
2022.2.0.23
Target name(s)
ESP32_BLE_REV0
Firmware version
1.8.0.362
Device capabilities
No response
Description
System Panics after Starting-> Stopping -> Starting BLE Advertisment.
How to reproduce
GattServiceProviderResult result = GattServiceProvider.Create(serviceUuid);
if (result.Error != BluetoothError.Success)
{
return;
}
GattServiceProvider serviceProvider = result.ServiceProvider;
// Get created Primary service from provider
GattLocalService service = serviceProvider.Service;
DataWriter sw = new DataWriter();
sw.WriteString("This is Bluetooth sample 3");
GattLocalCharacteristicResult characteristicResult = service.CreateCharacteristic(readStaticCharUuid,
new GattLocalCharacteristicParameters()
{
CharacteristicProperties = GattCharacteristicProperties.Read,
UserDescription = "My Static Characteristic",
//ReadProtectionLevel = GattProtectionLevel.EncryptionRequired,
StaticValue = sw.DetachBuffer()
});
if (characteristicResult.Error != BluetoothError.Success)
{
// An error occurred.
return;
}
DeviceInformationServiceService DifService = new DeviceInformationServiceService(
serviceProvider,
"BLE Sensor",
"Model-1",
"989898", // no serial number
"v1.0",
SystemInfo.Version.ToString(),
"");
BatteryService BatService = new BatteryService(serviceProvider);
// Update the Battery service the current battery level regularly. In this case 94%
BatService.BatteryLevel = 94;
Debug.WriteLine("Before Advertise");
serviceProvider.StartAdvertising(new GattServiceProviderAdvertisingParameters()
{
DeviceName = "BLE Sensor",
IsConnectable = true,
IsDiscoverable = true,
});
for (int i = 1; i < 5; i++)
{
Debug.WriteLine("Loop: " + i);
Thread.Sleep(2_000);
if (serviceProvider.AdvertisementStatus == GattServiceProviderAdvertisementStatus.Stopped)
{
Debug.WriteLine("Starting");
serviceProvider.StartAdvertising();
}
else
{
Debug.WriteLine("Stopping");
serviceProvider.StopAdvertising();
}
}
Expected behaviour
Do not crash the system when stopping and starting BLE Advertisment.
Screenshots
No response
Sample project or code
No response
Aditional information
No response