• Hi Guys, You can easily do this in DroidScript with the BLE plugin

    Here is the Puck.js code:-

    function advertise(url) {
      var d = [0x03, 0x03, 0xAA, 0xFE, 0x13, 0x16,  0xAA, 0xFE, 0x10,  0xF8, 0x03 ];
      d.push.apply(d,url.toString().split(""))­;
      d[4] = d.length-5;
      NRF.setAdvertising(d, {interval:100});
    }
    
    advertise( "call.false");
    
    function makeCall( call ) {
        advertise( "call."+call  );
        digitalWrite( LED3, call?1:0 );
    }
    
    setWatch(function() {
       makeCall( true );
       setTimeout( function() { makeCall(false) }, 5000 );
    }, BTN, {edge:"rising", debounce:50, repeat:true});
    
    
    

    And Here is the DroidScript code:-

    app.LoadPlugin( "BluetoothLE" );
    
    function OnStart()
    {
      //Create a text control to show debug log.
      lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
      txt = app.CreateText( "", 1, 1, "Log" );
      lay.AddChild( txt );
      app.AddLayout( lay );
    
      //Create Bluetooth LE object.
      ble = app.CreateBluetoothLE();
      ble.SetOnDevice( OnDevice );
      
      //Check for Puck button presses every 3 seconds
      setInterval( CheckForButtonPress, 3000 );
      txt.Log( "ready" );
      calling = false;
    }
    
    function CheckForButtonPress()
    {
        //Do a brief scan to check for puck button press.
        ble.StartScan();
        setTimeout( function(){ble.StopScan()}, 1000 );
    }
    
    //Called when any BLE device is found by the scan.
    function OnDevice( name, address, bonded, rssi, data )
    {
      txt.Log( name + ": " + data.url );
      if( data.url=="https://call.true" ) MakeCall();
    }
    
    //Make the call (limit to one every 5 seconds).
    function MakeCall()
    {
        if( calling ) return;
        txt.Log( "calling", "red" );
        
        calling = true;
        app.Call( "01359555222" );
        setTimeout( function(){calling=false;}, 5000 )
    }
    
    

    You could optionally put the DroidScript code inside a DroidScript service and have it always running in the background on your phone too :)

About

Avatar for Dave_Smart @Dave_Smart started