Connection via Blue Tooth

3,460 views
Skip to first unread message

aumandg

unread,
Jan 23, 2015, 12:09:28 PM1/23/15
to mitappinv...@googlegroups.com
I have looked and looked and tried many examples with in this forum and on you tube.  Every single example that I have tried I get the same problem.  I get error 507 unable to connect is device turned on.  What am I missing?  

Can this work with App Inventor or Not.

What makes no sense to me is that the device I am trying to connect to is connect to the phone when you go to the blue tooth settings.  
bt connection.png

aumandg

unread,
Jan 23, 2015, 12:13:33 PM1/23/15
to mitappinv...@googlegroups.com
Here is another one that doesn't work, same error.

Help please
bt connection2.png

Taifun

unread,
Jan 23, 2015, 6:40:47 PM1/23/15
to mitappinv...@googlegroups.com
see here how to connect correctly

which device and Android version are you using?
did you try another device?
see also 

A simple Bluetooth Chat with App Inventor 2

Taifun

aumandg

unread,
Jan 24, 2015, 5:54:45 PM1/24/15
to mitappinv...@googlegroups.com
Taifun,

I Looked at and tried your link about "A simple Bluetooth Caht with App Inventor 2".  The devices are HTC1 M8 and Samsung galaxy Tab 2.

When I select connect on the HTC1 I get "error 509 AcceptConectioin: Unable to accept a connection from a bluetooth device".  On the Tab 2 I see connection accepted.  When I connect via the Tab 2, I get the same messages just opposite messages.  So I typed in data and select send on either device it works.  So there is a connection between the two device.

So maybe there was a connection in my previous tries and I did not know about it.  Why would the Error 509 come up.

aumandg

unread,
Jan 24, 2015, 6:52:01 PM1/24/15
to mitappinv...@googlegroups.com
More food for thought,  I just created and download into each device, your lp connect blocks.  When I try to connect I get connection was NOT successful and see the error 507 unable to connect. is the device turned on?  And I get the same result when I try it on both devices.

Enis

unread,
Jan 24, 2015, 11:05:24 PM1/24/15
to mitappinv...@googlegroups.com
Is Bluetooth ON on the devices?

aumandg

unread,
Jan 24, 2015, 11:55:58 PM1/24/15
to mitappinv...@googlegroups.com
yes it is BT is on, on both devices

aumandg

unread,
Jan 25, 2015, 6:25:25 PM1/25/15
to mitappinv...@googlegroups.com
all i am looking to do is connect to another BT device get a confirmation that it is connected and if the connection fails to get a response back that it has failed.  That's it, i don't need to communicate with the device any further than that.  Not sure if that info helps.

aumandg

unread,
Jan 26, 2015, 1:32:31 PM1/26/15
to mitappinv...@googlegroups.com
Any one any ideas?  Help please.

aumandg

unread,
Jan 26, 2015, 7:14:00 PM1/26/15
to mitappinv...@googlegroups.com
I tried on a different android phone and a different bluetooth device, a 

DKnight Magicbox Ultra-Portable Wireless Bluetooth Speaker

  still the same results.

aumandg

unread,
Jan 27, 2015, 12:20:11 PM1/27/15
to mitappinv...@googlegroups.com
I still get the 507 error,  I wanted to see if the app was even getting the address of the bluetooth device that I was selecting and post the selection after picking, it does get the address and post it.  Any other idea?
BT.png

Taifun

unread,
Jan 28, 2015, 8:37:54 AM1/28/15
to mitappinv...@googlegroups.com
see Evan's answer here https://groups.google.com/d/msg/app-inventor-open-source-dev/C2wGI8jwCV4/oYsp_QaqDEAJ
and as Evan said, you need this app on both devices for this example to work 

 but the device I wish to truely connect to would be like a blue tooth speaker or something link that.
as far as I know this is not possible with App Inventor
Taifun 

aumandg

unread,
Jan 30, 2015, 8:10:06 AM1/30/15
to mitappinv...@googlegroups.com
UPDATE

I found this page http://www.whatakuai.com/bluetooth-and-app-inventor/ I downloaded the aia file and installed it on my device.   It does not have a disconnect button so if you look at the attached design and block I have added one.

Did some test, when I try to connect to my Tab 2 and other devices, I immediately get the 507 error.  I have a HDE Slim BT 4.0 USB 2.0 Adapter Dongle with CSR Harmony Wireless software driver on my pc.  I try to connect to this and it connects no errors. I got it here BT Device.

With in the software for this device, there is a check box that I can check that says "automatically accept connections from this device" which is the phone I am trying to connect with.  When it is checked and I select connect, with in the APP all works and I connect.  If the box is unchecked and I select connect with in the APP, I then get a pop up message on the pc indicating that the device is trying to connect and if I do not click that message, I will then get the 507 error.  But If I do select the message it connects.

Taifun, so I tried to connect with your blocks above to the HDE Slim.  Guess what it works, I get the message "Connection was successful".

What is the difference between this device and all others?  Why does it let me connect and the others don't?
blocks.png
design.png

aumandg

unread,
Jan 31, 2015, 10:07:48 PM1/31/15
to mitappinv...@googlegroups.com
any one have any ideas 

aumandg

unread,
Feb 4, 2015, 12:15:55 AM2/4/15
to mitappinv...@googlegroups.com
ok i have been playing and thinking about this more.  I believe the problem is Server / Client.  I see in your app Taifun that there is a call for both server and client, as the device listens it then makes a selection of which one is going to be the server and witch one is the client.  If your device is making the call it is the client.

So when I try to connect to other devices, I have been doing it as a client and not a server so you get the 507 Error.  I have created a test by having an app on one device that uses the client side and on the other device the server side, just as in Taifun's app but not have the device looking for both.  I did this to try to understand this issue more.

I am now at a point that I would like the server device to know when the connection side has been disconnected.  Of course the client device knows as there is a disconnect button.  To do this I have tried the following, I have placed a timer in the client app to send a byte ever 500 ms, how do I get the server device to see this byte received and when it stop receiving it to let me know.
client.png
server.png

SteveJG

unread,
Feb 4, 2015, 10:42:17 AM2/4/15
to mitappinv...@googlegroups.com
The solution for detecting disconnect by MartynC in this AI2 Forum disscussion might help: 

  https://groups.google.com/forum/#!searchin/mitappinventortest/bluetooth%7Csort:date/mitappinventortest/x1WlaMcNk4g/MFEOQPn-qYEJ   

I have no idea whether it will work in your situation .. it did allow him to discern absence of a connection in his case.

Try some blocks; perhaps this will work for you.

Regards,
Steve

aumandg

unread,
Feb 6, 2015, 7:45:32 AM2/6/15
to mitappinv...@googlegroups.com
Steve, thanks for finding that.  I have looked at it and I can not see how it works to check the connection with out selection of a botton.  I am looking for the app to do this with out any user interaction.

SteveJG

unread,
Feb 6, 2015, 9:25:36 AM2/6/15
to mitappinv...@googlegroups.com
If you can not use a button, you need to look for a control with an event handler.   Possibly you could poll with a Clock.Timer ... keep checking and if the connection disappears, us a Notifier to let the user know.   Otherwise the route is probably Eclipse or Android Studio. Martyn's solution is very clever; users have been searching for over a year about how to do even that.

aumandg

unread,
Feb 7, 2015, 10:16:46 AM2/7/15
to mitappinv...@googlegroups.com
Steve, 

Thank you for the incite. I have add a timer and it works.
timerBT.png
Reply all
Reply to author
Forward
0 new messages