Coder Social home page Coder Social logo

Comments (5)

Lalufu avatar Lalufu commented on June 8, 2024

That doesn't look like a ruuvitag advertisement (it doesn't look like a valid BLE advertisement at all unless there's some data getting lost somewhere). From the code, this should just cause the sending MAC to be blacklisted, but the process as a whole should move on.
How many tags do you have? Are you losing data from all of them after this?

from ruuvitag-sensor.

eRazeri avatar eRazeri commented on June 8, 2024

Thank you for your reply!
I have only one tag in that location.
This was happening before and after upgrading the firmware of the ruuvitag to the latest.
So if it blacklists the MAC, then I understand that it stops to read data from this tag.
For now I just restart the container manually and all seems to work after it.
Could I somehow set the process to restart, exit the process or to crash the container when this happens?

from ruuvitag-sensor.

ttu avatar ttu commented on June 8, 2024

Hi @eRazeri!

This sounds like a docker / system specific problem, so I wouldn't add any custom functionality for this case.

We can utilize Python log's custom handlers to make the process to exit when specific MAC is blacklisted. Handler will listen for all log events and will exit when we receive a log message that matches the condition.

from ruuvitag_sensor.ruuvi import RuuviTagSensor
import ruuvitag_sensor.log

from logging import StreamHandler

class ExitHandler(StreamHandler):

    def emit(self, record):
        if (record.levelname != "DEBUG"):
            return
        msg = self.format(record)
        if "Blacklisting MAC AA:BB:CC:DD:EE:FF" in msg:
            exit(1)


#ruuvitag_sensor.log.enable_console()

exit_handler = ExitHandler()
ruuvitag_sensor.log.log.addHandler(exit_handler)

if __name__ == "__main__":
    RuuviTagSensor.get_data_for_sensors()

Let me know if this solution solves your problem. I will close this issue, but if this solution doesn't work, please reopen the issue.

from ruuvitag-sensor.

eRazeri avatar eRazeri commented on June 8, 2024

Hi @ttu!

Thank you very much!
Sorry for the long delay in answering, it took me a long time to verify because the error is very random.
With your code as base, I was able to catch the error and restart the container.
I did change your code a little to work for me. I'm checking for the "Invalid advertisement data", because I never encountered this "Blacklisting MAC" message in my enviroment.

from ruuvitag-sensor.

Lalufu avatar Lalufu commented on June 8, 2024

I'm still confused as to how we get this data in the first place, as it doesn't seem to conform to the specification for BLE messages. Maybe parsing the output from hcitool goes wrong somewhere?
If you can turn up the debug level in your application to debug you should get some useful output. Unfortunately it'll be a lot of output, so I'm not sure whatever system you're using can store this.

from ruuvitag-sensor.

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.