• Hi All,

    I want, that when I press Puck.js a phone call can be made from android mobile.

    Is this feasible?

    Regards
    Sachin

  • Hi,

    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
    http://daniel-stone.uk/2016/09/27/amazon­-dash-with-tasker.html

    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.

  • I think there are two solutions : a. use Bluetooth phonebook access profile (pbap) when bonding gets implemented. This is the way car stereos do the call. b. use telerik NativeScript that's basically JavaScript doing native API calls to the device. This way you can use puck with the HID profile https://www.npmjs.com/package/nativescri­pt-phone

  • 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" );
    phone.dial("212-555-1234",false);

  • 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:

    • Set Puck.js up to advertise the state of the button - subscribe to BLE advertising events with nativescript and then call the number then.
    • Set Puck.js up as a BLE HID device - you can then just set a listener up for a specific keypress
    • Keep a connection to Puck.js open and set yourself up to be notified if a characteristic changes - that's the way you'd do it with normal BLE devices, but it's a bit more trouble
  • Hi Again,
    After doing some research I came across button (Flic) which is similar to puck.js.
    https://partners.flic.io/partners/develo­pers/android-tutorial
    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.

    Regards

  • 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" );
    
    function OnStart()
    {
      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" );
    }
    
    function OnConnect()
    {
      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:-

    http://forum.espruino.com/conversations/­298102/#comment13448826

  • Thanks Dave, at android side I am using android studio. So is there any link or guide for achieving this using android studio?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Make call from android phone when user click Puck.js button

Posted by Avatar for user71304 @user71304

Actions