I am searching for a bluetooth scan for my auto connect script
http://automagic4android.com/flow.php?i ... e8bc7e8619
Or even better a function "connect to any/first paired device in reach"
Bluetooth scan
Moderator: Martin
Bluetooth scan
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.
Re: Bluetooth scan
Hi,
There's no built in action to execute a scan since a scan is very heavyweight and can cause interruptions to already connected BT devices.
You can create your own action with action Script:
You can handle the found devices with trigger General Broadcast. You can use example Bluetooth Device found as the base configuration but add following line in the Access intent extras field:
The device will contain the address of the device which can be used in action Connect/Disconnect Bluetooth Device.
According to the documentation you should not attempt to create a connection as long as the discovery process is running so you might have to stop discovery first with another action Script:
Entry point for documentation can be found here:
https://developer.android.com/reference ... othAdapter
I hope this helps.
Regards,
Martin
There's no built in action to execute a scan since a scan is very heavyweight and can cause interruptions to already connected BT devices.
You can create your own action with action Script:
Code: Select all
bta=callJavaStaticMethod("android.bluetooth.BluetoothAdapter", "getDefaultAdapter()");
callJavaMethod(bta, "android.bluetooth.BluetoothAdapter", "startDiscovery()")
Code: Select all
device = getParcelable("android .bluetooth.device.extra.DEVICE");
According to the documentation you should not attempt to create a connection as long as the discovery process is running so you might have to stop discovery first with another action Script:
Code: Select all
bta=callJavaStaticMethod("android.bluetooth.BluetoothAdapter", "getDefaultAdapter()");
callJavaMethod(bta, "android.bluetooth.BluetoothAdapter", "cancelDiscovery()")
https://developer.android.com/reference ... othAdapter
I hope this helps.
Regards,
Martin