Bluetooth

103 views
Skip to first unread message

daniel...@gmail.com

unread,
May 12, 2016, 7:26:00 PM5/12/16
to DroidScript
Can someone please explain exactly what the bluetooth commands are used for and how? How would I transmit data from one device to another? I saw the example code but it doesn't really explain all the various commands. Also, what are the different bluetooth channels that can be used (the only one I saw was HC-05, but I'm guessing there are others)?
Thanks!

Gerard Hernandez

unread,
May 12, 2016, 9:50:15 PM5/12/16
to DroidScript
Hi Daniel,

I'll try to explain BT implementation as simple I can.

The BT implementation in Ds is sorry a serial port on the regular Serial Port Profile prior BLE or Bluetooth Low energy.

This means that it will behave like full duplex serial port, the same it used to be on old pc's and microcontrollers.

The channel you mentioned is nothing like that, but the device you will be connecting to. You need to make sure it supports SPP. HC-05 is a quite common bluetooth SPP slave to UART to enable BT capabilities on microcontrollers like the arduino.
To use the serial BT, basically yo do the next process.

Instantiate the but serial.
Set callback for OnConnect event
Set callback for On receive event
Set split mode, this means we to make the received data is passed to the on receive method.
CONNECT to a device.
Once connected, you can write data to it. And you can receive data.

What info/data, I don't know, you only know that it will be at string format, it's a stream, you can put anything as long it can be represented using ASCII chars.

The protocol is up to you, there are plenty at arduino page. You can create your own, I have developed different protocols depending on my needs.

sankarshan dudhate

unread,
May 13, 2016, 12:21:12 AM5/13/16
to DroidScript
Wow, that was some lecture ( And I loved it ;)
At the moment, you can't use Bluetooth in between Androids at the moment ( if that's what you meant by 'one device to another' ).

Regards,
Sankarshan

Gerard Hernandez

unread,
May 13, 2016, 9:20:08 AM5/13/16
to DroidScript
Hi, if you follow the bt chat sample, you'll notice there is client/server arrangement. So you can communicate between 2phones. There are a lot of bt apps in market that do that.

I don't know if the Ds implementation is the same or not. Only Dave can tell.

daniel...@gmail.com

unread,
May 13, 2016, 10:24:34 AM5/13/16
to DroidScript
Thanks for your help! Could you please post a link to the bt chat sample code? I can't seem to find it.
Reply all
Reply to author
Forward
0 new messages