DroidScript code to search and add bluetooth devices seemless

507 views
Skip to first unread message

Fabio Almeida

unread,
Apr 27, 2016, 8:10:57 PM4/27/16
to DroidScript
I am building a device for power outlet control with Arduino which will be controlled by DroidScript app through bluetooth. The main road block that i have right now with DroidScript is that I need that after touch a button, the code will automatically check if bluetooth is ON (this function is available), if not ON, try to turn bluetooth ON, search for nearby bluetooth devices and add to Android trusted bluetooth list. While search, the code needs to retrieve MAC address from bluetooth and its name. After this the DroidScript will communicate with Arduino (This part is available in DroidScript and I already tested it). I took a look in CreateBluetoothList function, but the problem is that show the details for the bluetooth device. I would like to do something that the user does not bother in search the device.

Dave Smart

unread,
Apr 28, 2016, 4:08:20 AM4/28/16
to DroidScript
Hi Fabio,

You are going to need to write a DroidScript plugin for this.  It won't be hard if you use the latest beta for DroidScript which can generate an AIDE plugin for you.

You need to look up the BluetoothAdapter class on StackOverflow and find a code example that looks something like this:-

        mBtAdapter = BluetoothAdapter.getDefaultAdapter();
     Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
     :
     :
     mBtAdapter.startDiscovery();

Alternatively you can put a request in the 'Tell us what you want', thread, but that could take a while to get done.

Regards
David



sankarshan dudhate

unread,
Apr 29, 2016, 12:25:38 AM4/29/16
to DroidScript
Hi guys,
Incidentally, I was building a plugin for this but I got stuck at a point. You can enable Bluetooth through the plugin but whenever you do, app lags ( or so it seems ). I'll soon get back to it again.

Regards,
Sankarshan

Steve Garman

unread,
Apr 29, 2016, 12:47:54 PM4/29/16
to DroidScript
Sankarshan,
Have you tried using
app.SetBluetoothEnabled(true);
in your .inc file?

Reply all
Reply to author
Forward
0 new messages