Comments (3)
Hi @bogardani,
I'm the friendly issue checker.
Thanks for using the issue template 🌟
I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.
from dotnet-bluetooth-le.
@bogardani Check if Bluetooth has power prior to running your command.
You should if you followed the tutorials and examined the supplied repository have the following:
public IBluetoothLE Ble { get; set; } <-- Gives you access to the bluetooth state on/off etc.
Ble.StateChanged += (s, e) =>
{
Debug.WriteLine($"The bluetooth state changed to {e.NewState}"); <-- Will let you know if state changes on to off etc.
};
then a quick check like this before running commands will ensure you do not fall over.
if (Ble.State != BluetoothState.On) <-- if bluetoothstate is not on, you can then prompt user to switch it on.
Also remember to use Try Catch throughout your project on all the commands as described at the bottom of the project repository.
Hope this helps.
from dotnet-bluetooth-le.
Checking for Ble state beforehand only shortens the window in which there is a chance we run into ConnectToDeviceAsync.
Subscribing to StateChanged does not solve the problem since ConnectToDeviceAsync already is hanging and cannot be canceled. The only thing you could do is call WaitAsync(token) on the hanging task, and let your code run forward even though that's not optimal.
from dotnet-bluetooth-le.
Related Issues (20)
- `ScanFilterOptions` filter returned devices on WinUI HOT 3
- WinUI AdvertisementRecords missing advertised device records HOT 7
- GetCharacteristicAsync returning null for iOS, not Android. Characteristic missing from iOS only HOT 3
- Grammatical and formatting opportunities HOT 3
- Enable/disable Bluetooth on Android HOT 9
- [Android] IDevice.IsConnected doesnt update when Bluetooth radio is turned off. HOT 4
- WriteAsync does not use the CancellationToken that is given to it HOT 3
- App .NET MAUI Crash on iOS HOT 7
- Windows: More than one lost connection does not work correctly HOT 17
- [WinUI] [3.1.0-beta.1] introduces null IDevice(s) to device lists HOT 9
- [BUG] NET MAUI on iOS, I read a wrong name connectiong to a Linux device HOT 8
- Can't detect device HOT 10
- when "OnConnectionStateChange: GattStatus: InsufficientAuthorization" is shown, the ble will hang forever HOT 5
- Manufacturer data packet is missing from device on iOS HOT 4
- Cannot use the package with Avalonia Cross Platform Project HOT 7
- ConnectToKnownDeviceAsync is giving null as device name HOT 2
- Regarding Plugin.BLE Connection Event HOT 1
- Plugin.BLE - Issue Regarding ambiguous connection HOT 2
- limit of bluetooth device can be connected simultaneous HOT 8
- Ble connected Device Get Service always return null HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotnet-bluetooth-le.