Skip to content

Support for reportning devices multiple times during scanning #44

@ghost

Description

The Bleat Classing API reports devices once when found. In for instance beacon applications devices need to be reported multiple times. Can we add support for this? Like a flag, function/setting to control scanning behaviour. I am happy to help with this.

Did a quick experiment, commented out the following line in api.classic.js:

adapter.startScan(serviceUUIDs, function(deviceInfo) {
    var device = new Device(deviceInfo);
    //if (devices[device.address]) return;
    devices[device.address] = device;
    if (foundFn) foundFn(device);

This makes devices being reported multiple times.

One potential problem is if the application expects the device object to be the same between calls to foundFn. For example, the application might add custom properties to the device object. These would be lost with the above code. Properties need to be copied to prevent this problem.

Edit: Been thinking more about the idea of a "persistent" device object that has the same identity between calls to foundFn. Probably this is a bad idea, for example, if device sends multiple packets you would want a guarantee that the data is not overwritten by a concurrent operation. Now, JavaScript is single-threaded, but there may be Worker objects etc, so this could happen. Eddystone is an example of sending multiple packets.

We used this technique ("persistent" device objects) in the Evothings EasyBLE library, but now I realize it is perhaps not the best solution. It would be better to have the application handle this, and this would also make for a cleaner separation between "model and view", so to speak.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions