How to build BT server to provide battery level to smartwatch

145 views
Skip to first unread message

Alan Buch

unread,
May 20, 2018, 12:09:30 PM5/20/18
to DroidScript
Hello!
Very new to DroidScript and trying to get up to speed.  My purpose for coming here and trying DroidScript is that I've built a watch face for my Samsung Gear S2 smartwatch.  One of the elements on my watch face is intended to show the battery level of my phone, a galaxy S3 running Android 4.3.  I've tried other ways to get the battery level; I've tried using BLE, but I can't get my watch and phone to connect over BLE (I think my phone isn't capable of BLE).  I've tried using classic BT and the Hand Free Profile, but while I can get the watch and phone to connect over BT and the phone includes the HFP service (111F) I get no response when attempting to connect to that service.

And that brings me here... I thought I could build an APP for my phone that would provide the battery level of the phone over BT Serial port profile.  I tried using your BT samples.  While the samples seem to work on the phone, when I connect the watch over BT and then connect over SPP (using the 1101 UUID for the SPP service), it connects to the service - but another app on my phone seems to spring to life, yet your BT samples' "bt_OnConnect" never appears to get executed.

Any help or further examples you can provide a newbie would be greatly appreciated.  Do I have to build the BT sample as an APK in order to connect another device over SPP?  Will using CreateBluetoothSerial() conflict with other apps on my phone that may be using SPP and if so, can I use my own UUID between server and client?  By chance, are there any samples of a BT server capable of providing battery level to a client?

So many questions... I know.  But thanks in advance for any help!
Al

Dave

unread,
May 21, 2018, 7:12:50 AM5/21/18
to DroidScript
Hi Alan,

It sounds like you might already have an app watching the serial port profile on your phone.. what app pops up?

FYI: this is the correct UUID to use:- "00001101-0000-1000-8000-00805F9B34FB"

Regards
David

P.S. You don't need to build an APK during testing

Alan Buch

unread,
May 21, 2018, 12:22:00 PM5/21/18
to DroidScript
That's right, there's another app on my phone that appears to be intercepting the serial connection. It's called "fun run".
The uuid you provided is the one I used when coding my smart watch to connect to spp, so I think I'm good there. But if there can be just one app on the phone listening for an SPP connection, is it possible to make up my own uuid and pass data (ie. Battery level) to/from my smart watch?

Dave

unread,
May 25, 2018, 7:19:57 AM5/25/18
to DroidScript
Are you able to select the port/channel that is used in your the watch code?

Dave

unread,
May 25, 2018, 7:20:48 AM5/25/18
to DroidScript
Or could you use BLE instead?
Reply all
Reply to author
Forward
0 new messages