Giter VIP home page Giter VIP logo

Comments (9)

mrstegeman avatar mrstegeman commented on September 7, 2024

Why is your scanStart handler using this.log rather than console? this.log doesn't appear to exist.

from noble.

hannseman avatar hannseman commented on September 7, 2024

@mrstegeman you're right. That was a bad case of copy and paste from the actual implementation where I encountered this. I've fixed the example now, thanks!

(Note that this does not affect anything as that line is never run because of the crash).

Scratch that, looks like the this.log being undefined might be the cause of this anyway.

from noble.

mrstegeman avatar mrstegeman commented on September 7, 2024

So no crash anymore?

from noble.

hannseman avatar hannseman commented on September 7, 2024

No crash by using:

const noble = require("@abandonware/noble");
class Scanner {
  constructor() {
    noble.on("discover", this.onDiscover.bind(this));
    noble.on("scanStart", this.onScanStart.bind(this));
    noble.on("stateChange", () => {
      noble.startScanning([], true);
    });
  }

  onScanStart() {
    console.debug("Started scanning.");
  }

  onDiscover(peripheral) {
    console.log(peripheral);
  }
}
const scanner = new Scanner();

from noble.

mrstegeman avatar mrstegeman commented on September 7, 2024

Great! Can you go ahead and close?

from noble.

rzr avatar rzr commented on September 7, 2024

Si please close the issue if no more relevant

Eventually you can try to submit your example to upstream ?
That could be useful to have some CLI BLE utilities as part of package.

Relate-to: #9

from noble.

hannseman avatar hannseman commented on September 7, 2024

@mrstegeman thanks for the feedback.

from noble.

geovie avatar geovie commented on September 7, 2024

@hannseman Yes any exception thrown in the event handler will abort the node process.

from noble.

hannseman avatar hannseman commented on September 7, 2024

@geovie good to know, found the cause now in my actual implementation. Thanks for the help. I got a bit thrown of by the hard crash and missed the actual error message Cannot read property 'find' of undefined.

from noble.

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.