oyooyo / keyble

Command line tools and library for controlling eqiva eQ-3 Bluetooth smart locks
90 stars 28 forks source link

Implement the "toggle" command (locked to unlocked and viceversa) #16

Closed Ircama closed 3 years ago

Ircama commented 5 years ago

Introducing the new command “toggle”, that allows switching from locked to unlocked state and viceversa.

The “toggle” command supports installations of the eqiva eQ-3 Bluetooth smart lock where the requirement is to switch from one state to the other, regardless the initial state (locked or unlocked). This command is not available on the smartphone: the only way to manually switch between states with a smartphone is to check the currently enabled icon (right or left one), showing the available operation (lock or unlock), and press it. Through the “toggle” command, keyble allows automating this.

I recall that, while the “open” command is always available on the smartphone, “lock” and “unlock” operations will become enabled on the smartphone after the device learns the exact number of needed turns and angle, and this can be automatically achieved by the device during the “open” operation, when the end of rotations of the lock blocks the motor (there is no smartphone setting for this operation: the motor simply forces the lock and stops after exceeding a predefined torque); alternatively this learning feature can be manually performed through the handwheel, by blocking it with forceful torque while it is turning.

Note: to keep compliance with the existing code, I compiled the cofeescripts through the following commands:

coffee -cmb --no-header keyble.coffee
coffee -cmb --no-header sendcommand.coffee
oyooyo commented 3 years ago

I just added an initial implemented of the the toggle() command, even though it may not work 100% yet. Since I've meanwhile switched to directly using Javascript instead of CoffeeScript, I'm afraid I couldn't use your PR anymore, but I sticked closely to your suggested changes. Thanks for all the work you've put into this, @Ircama. I'm sorry that I somehow overlooked this PR back when you published it and just saw it now while trying to clean up the project.