BlueTooth Updating Connection (Block Code Help Needed)

532 views
Skip to first unread message

mykod...@gmail.com

unread,
Apr 20, 2014, 11:24:24 AM4/20/14
to mitappinv...@googlegroups.com
Hello,

How do I get a bluetooth connection update?

I'm using the Bluetooth Client in my App and what Im doing is clicking on the Get Connected Button (ListPicker which is connectButtonList) which brings up a list of bluetooth devices available (on my android) then after clicking the bluetooth device address I want to use (hc-05), the connection is complete and I the text on the screen goes from "connected?" to "Connected!" in green which works great and pairs the android phone with the bluetooth device hc-05 .

The problem Im having is when I turn off the other bluetooth device (hc-05) the text on the android device still says "connected" (in green) instead of "Not connected".

I guess the problem Im having is once I disconnect the hc-05 (bluetooth device) my android device or app doesn't know the connection has been lost and I was hoping to get some help here to see if it may be my code (blocks) and what I can do to try and detect that the connection is no longer available and possibly be prompted to reconnect.

I've added some images from screen1 from the android app (the on and off buttons are not important) and the block code I used.

I seriously appreciate any suggestion, advice or help you can provide.

Sincerely,
Michael



Taifun

unread,
Apr 20, 2014, 11:32:16 AM4/20/14
to mitappinv...@googlegroups.com
The problem Im having is when I turn off the other bluetooth device (hc-05) the text on the android device still says "connected" (in green) instead of "Not connected".


as far as I can see, after client or server disconnected, there is no possibility for the other device to see, that the connection is gone. Therefore currently an "Error 516: Unable to write: Connection reset by peer" will be diplayed after trying to send a text without connection.

Taifun

mykod...@gmail.com

unread,
Apr 20, 2014, 11:56:01 AM4/20/14
to mitappinv...@googlegroups.com
Great Link Taifun thank you. Is there a way to see if the connection is gone without having to click a button? 

(the hc-05 Im using is a slave and only receives information it cannot send information and Im using or trying to use the android as a master to pick up when the connection is lost between the two, is this not possible?)

Michael

Taifun

unread,
Apr 20, 2014, 12:47:56 PM4/20/14
to mitappinv...@googlegroups.com, mykod...@gmail.com
Great Link Taifun thank you. Is there a way to see if the connection is gone without having to click a button? 
well, you always can use the Clock component and send some text to the other device regularly
if you get error 516 you know,that there is no connection anymore
Taifun 

mykod...@gmail.com

unread,
Apr 20, 2014, 2:02:11 PM4/20/14
to mitappinv...@googlegroups.com, mykod...@gmail.com


Is there any change you could provide an example of how to ask for for the error. Im not quite sure how to ask if the error is returned (or if null..) Im sorry but Im just learning this block code and still have a lot of learning to do. I'll keep trying to figure it out though and really thank you for all the help you have provided thus far!

mykod...@gmail.com

unread,
Apr 20, 2014, 2:30:56 PM4/20/14
to mitappinv...@googlegroups.com, mykod...@gmail.com

Taifun

unread,
Apr 20, 2014, 2:56:30 PM4/20/14
to mitappinv...@googlegroups.com, mykod...@gmail.com
you can catch the error in the Screen.ErrorOccurred event
if error = 516
then do something
else do something else
Taifun

mykod...@gmail.com

unread,
Apr 20, 2014, 3:12:14 PM4/20/14
to mitappinv...@googlegroups.com, mykod...@gmail.com
Thank You !!! Very Much Taifun.
:D 

Christopher Brown

unread,
Feb 23, 2015, 9:32:33 PM2/23/15
to mitappinv...@googlegroups.com
Did you ever get your code working for this problem mykod? if so could you post it I'm having a similar problem.
Reply all
Reply to author
Forward
0 new messages