50ButtonsEach / fliclib-linux-hci

Flic SDK for Linux
307 stars 53 forks source link

How to Force disconnect via nodejs? #79

Closed gizus closed 6 years ago

gizus commented 6 years ago

Hi there, I need to command 18 flic buttons with a raspberry (only 10 concurrent session).

Due to the fact that i DON'T need a high sensitivity or more than 10 concurrent actions, I could disconnect a button after a press event, so that it frees up a channel and next time will follow the "connected"-"ready" sequence.

Can't find the right syntax for doing that, I need some help, please.

Emill commented 6 years ago

If you set the auto disconnect time parameter to for example 10, the Flic will disconnect after 10 seconds of timeout.

gizus commented 6 years ago

Right, that was the other way, but I tried via simpleclient with no result (probably wrong syntax). Would please state the right syntax for this command? es. changeModeParameters 80:e4:da:73:6b:83 NormalLatency 2

Emill commented 6 years ago

That's correct but replace the full address with your connection id.

gizus commented 6 years ago

the connection UUID of the single button? Like getButtonUUID 80:e4:da:73:6b:83 Button UUID response: 80:e4:da:73:6b:83 687f0b3933f54385bf7ee9228db1f51c

Or my session?

Emill commented 6 years ago

Note that the auto disconnect time is applied the next time it connects (you need to go out and in range first).

If you specify the auto disconnect time at the creation of the connection channel then you don't have that problem. However simple client doesn't support that, while the js lib supports that.

Emill commented 6 years ago
connect 80:e4:da:73:6b:83 0
changeModeParameters 0 NormalLatency 2
gizus commented 6 years ago

ah ok button per button What is the js equivalent? I could insert in the initial loop (taken form example.js)

client.once("ready", function() { var ora=new Date(); console.log("Connesso a "+ora.getHours()+":"+ora.getMinutes()+":"+ora.getSeconds()); client.getInfo(function(info) { info.bdAddrOfVerifiedButtons.forEach(function(bdAddr) {

             // HERE //

        listenToButton(bdAddr);
    });
});

});

gizus commented 6 years ago

Or, may I directly change it in the sqlite param file?

Emill commented 6 years ago

In the example, replace

var cc = new FlicConnectionChannel(bdAddr);

with

var cc = new FlicConnectionChannel(bdAddr, {autoDisconnectTime:2});
gizus commented 6 years ago

IT WORKS! 👍 Thank you for your marvellous support!

Emill commented 6 years ago

No prob ;)