Giter Site home page Giter Site logo

Comments (6)

Danappelxx avatar Danappelxx commented on September 9, 2024

This is a pretty serious issue. Since it's doesn't seem to be fixed in the firmware, what would be a "good enough" workaround on the application side? Wrap all ble calls in a 0-delay timer? Add a simple delay(<some reasonable amount>) after ble.init?

from firmware.

filipnavara avatar filipnavara commented on September 9, 2024

Unfortunately due to the way the callback registration works there's no reliable workaround from application code. You cannot register callbacks before ble.init because it resets them. At the same time it also starts the Bluetooth module and the background thread, so by registering them later you may miss some of the events. There are ways to call the ble functions on the right worker thread, but none of them are reliable during the initialization.

I managed to fry one of my boards by accident so I don't have a way to test this anymore.

from firmware.

Danappelxx avatar Danappelxx commented on September 9, 2024

Appreciate the quick response. So you're saying there's not really a way to prevent race conditions? That's pretty unfortunate...

from firmware.

filipnavara avatar filipnavara commented on September 9, 2024

I recompiled my firmware to solve this, but obviously that's not a solution for everyone. There were other problems which I submitted pull requests for (#40, #41) and the latest version of the firmware solves at least that bits. Then RedBear was acquired by Particle and this whole repository was scheduled to get merged into the official Particle firmware (particle-iot#1505). So far that didn't happen. My hope was that the BLE API gets more attention as Particle is going to release their own Bluetooth products (https://www.particle.io/mesh/).

from firmware.

Danappelxx avatar Danappelxx commented on September 9, 2024

Are your modifications by any chance open source? I’m already recompiling the firmware to get around other limitations (#45) so it wouldn’t be a huge leap for me.

Edit: Also, I mirror your wishes for the future of particle Bluetooth, hopefully it gets more attention!

from firmware.

filipnavara avatar filipnavara commented on September 9, 2024

I am afraid I never pushed that branch to my GitHub, so it's probably lost for good :-/ I tried all the three approaches above, but in the end I settled on implementing ble.waitForEvents and getting rid of the worker thread. It was by far the easiest one to implement and to reason about its correctness.

from firmware.

Related Issues (7)

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.