I want, that when I press Puck.js a phone call can be made from android mobile.
Is this feasible?
If you can find a way of sending a call from a keyboard shortcut (or sequence of keys) then it should be pretty easy to set Puck.js up as a keyboard to make the required keypresses.
Otherwise you'll need an app - you could make your own, or there's almost certainly a keyboard shortcut app available.
Wat about the DroidScript app?
Making a call from within your DroidScript app seems built in, using BLE API s could require paid plugins.
Yes, I forgot about that - that'd be a nice easy solution.
If your phone is rooted, and you have installed Tasker, (and understood its' complexities) then I would think what you want to achieve might be possible. Bluetooth Tasker Wiki search - might lead to some recipes, or maybe onto other clues.
+1 for Tasker - I did something similar with the amazon dash buttons
You'd have to work out how to get the puck to post some sort of notification to your phone, or maybe Tasker can listen for bluetooth messages..
The reason I piped up was one of the most useful Tasker recipes I found was "disable wifi if out of range of either home wifi or office wifi". Given the plethora of MITM (Man in the middle) attacks and access point spoofing, this stuck in my mind. I am guessing its the same with Tasker and Bluetooth. "When x happens send SMS" features quite a lot on Tasker, so I'd be surprised if you couldn't make a call.
It works with an APP. You simply need to listen for advertising. Take a look at stackoverflow for working code.
Just to add: Can Android be set up to associate a long-press of a key with calling someone in particular like you used to be able to do with older phones? Puck.js acting as a HID device could easily long-press a number key.
Cool - thanks! I wonder whether PBAP works over Bluetooth LE? If so that'd be excellent
I have used below code, that was mentioned in this link npmjs.com/package/nativescript-phone but I am getting error - execution interrupted.
var phone = require( "nativescript-phone" );
Are you trying to run that on Espruino? If so that won't work - NativeScript is meant to run on phones: https://www.nativescript.org/
Ok, how I will know in my nativescript app that puck is clicked and now app should call the number.
There are a whole lot of threads on this kind of thing already. Either:
After doing some research I came across button (Flic) which is similar to puck.js.
We can integrate this with our android app but the problem with this is we have to install its default app to integrate it with android phone, which I don't want to use.
I want to know is there a similar way to just listen when Puck button is clicked? If got when button is clicked at my android app then I can write code in my android app which can make phone call.
Yes. See the post I wrote above.
The Puck plugin (BLE) is free in DroidScript. It should be very easy in DroidScript too. Probably take about 5 mins to write
OK, I was wrong. It took 2 minutes :)
Here is the code:-
app.LoadPlugin( "PuckJS" );
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
txt = app.CreateText( "Press your puck" );
lay.AddChild( txt );
app.AddLayout( lay );
puck = app.CreatePuckJS();
puck.SetOnConnect( OnConnect );
puck.SetOnButton( OnButton );
puck.Scan( "Puck" );
puck.WatchButton( true );
function OnButton( state )
app.Call( "01359555555" );
You could also build a DroidScript service which stays always running in the background and watches for the button presses.
Here is a more sophisticated solution that does not require a constant (battery draining) connection:-
Thanks Dave, at android side I am using android studio. So is there any link or guide for achieving this using android studio?
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem