Giter Site home page Giter Site logo

Comments (3)

smsissuechecker avatar smsissuechecker commented on June 3, 2024

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.

Andy-Donegan avatar Andy-Donegan commented on June 3, 2024

@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.

bogardani avatar bogardani commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.