Git Product home page Git Product logo

Comments (3)

ukBaz avatar ukBaz commented on May 26, 2024

Hi @JiaGuoWMU ,

I took a quick look at this and I think all the errors you are seeing are from when you restart the cpu_temperature.py script.
The failure to register the advertisement is because the advertisement wasn't unregistered when the cpu_temperature script was stopped.
One of my goals with the example scripts is to keep them as simple as possible to help aid understanding. I find lots of error checking (while good for production) isn't that helpful when people are trying to learn.
The other comment I would make is that usually when people are making their board/RPi3 a peripheral they are not very often stopping and starting the script.
During development (when there is likely to be lots of stopping and starting) I recommend people restart the bluetoothd anyway so that it is starting in a known state. Basically I am saying that it is unlikely I will update this example.

If I was looking to make this script more robust I would look to put the pi_cpu_monitor.start_bt() statement in a try:except: so that when the script is interrupted you can clean things up.
To clean things up I think you need to do an UnregisterAdvertisement and to stop the mainloop. Maybe creating a stop_bt method in the ble class would be a good way to do this. Although I'm sure there could be a few ways of doing it. Does that help?

I would also like to point you to issue #126 to highlight that it is likely Bluezero will move away from using python-dbus to using pydbus. This is another reason why I am reluctant to invest too much time in improving the current examples.
Development of Bluezero has stalled/slowed while a couple of issues with pydbus are worked out.

from python-bluezero.

jguodev avatar jguodev commented on May 26, 2024

@ukBaz Hi Barry, thanks for your prompt response. It is a good idea to use a try:except: and add UnregisterAdvertisement.

Besides, I also found out the issue is partly because of the version of the bluez. I updated from v5.43 to v5.45, and the issue is solved.

from python-bluezero.

ukBaz avatar ukBaz commented on May 26, 2024

Really appreciate you coming back and adding what you've learnt.

Sounds like I can close this issue for now.

from python-bluezero.

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.