Page 1 of 1
Sending commands via bluetooth serial port
Posted: 10 Aug 2014 11:09
by nanobot
Hi,
I was switching from Tasker to Automagic Premium because of the nice flows, which are a great optical programming help.
Now I have a little problem and hope to get some help here.
I'm using a relay with a bluetooth interface, so I can easily connect to it with my Samsung Tab. But now I wonder how to send commands via bluetooth in order to switch the relay. The commands are already known from the relays user manual. But how to send them? Do I need a plugin or can I do that within Automagic Premium?
Best regards,
nanobot
Re: Sending commands via bluetooth
Posted: 10 Aug 2014 18:03
by nanobot
Maybe I have to go more into detail.
The relay is called TOSR02 from TinySine. There is a separate App which works great - one just have to connect to the bluetooth relay and then can easily toggle the two relays between on and off. I want to use it in my car together with my Samsung Tab 4. Everytime the tabs battery is getting low I want to toggle the relay by Automagic which is installed on the tab. The tab is plugged to the relay at all times and is being charged if the relay is in the state "on". Now I'm in search of a Automagic feature or a compatible plugin to send commands to the relay via bluetooth whenever the battery of the tab is low or even fully charged.
Re: Sending commands via bluetooth
Posted: 10 Aug 2014 22:00
by ZSasha
Hi nanobot, were you able to do that with Tasker? If yes - was it some plugin involved or it was a natively supported in Tasker?
Re: Sending commands via bluetooth
Posted: 11 Aug 2014 06:50
by nanobot
Hi ZSasha,
I didn't try that in Tasker up to now because it's a new project and I don't want to use both apps. If it is not possible with Automagic than I have to try it with Tasker, but I love Automagic!
If there is no Automagic action which can handle bluetooth serial connections than I have to do it by a plugin or by command line. But that's very new for me.
Re: Sending commands via bluetooth serial port
Posted: 12 Aug 2014 16:20
by Martin
Hi,
There's no built-in way to communicate with a BT device directly so you would have to use a plugin for now. Maybe
SL4A also allows to communicate over BT.
BT serial communication is something that is on my list of features under consideration but I did not yet have the time to look at it so I can't promise anything yet.
Regards,
Martin
Re: Sending commands via bluetooth serial port
Posted: 03 Sep 2014 06:44
by nanobot
Hi,
now everythings works great with Automagic Premium and my BT serial connection. I installed SL4A and PY4A and now I can start my script.py by the action "Plugin" very easy.
Here is my script if anyone will be interested in it:
Code: Select all
import android
import time
droid = android.Android()
mac = '01:02:03:04:05:06' #here you have to change the mac address by the one of your paired BT device
uuid = '00001101-0000-1000-8000-00805F9B34FB'
command = 'd'
droid.toggleBluetoothState(True) #if your BT is off you can switch it on
droid.bluetoothConnect(uuid,mac)
droid.bluetoothWrite(command)
time.sleep(2) #the script will pause for 2 seconds
droid.exit()
Bye,
nanobot
Re: Sending commands via bluetooth serial port
Posted: 03 Sep 2014 17:39
by angelatwork
interesting, thank you for sharing