Skip to first unread message

kurar...@gmail.com

unread,
Jul 25, 2014, 1:59:06 AM7/25/14
to mitappinv...@googlegroups.com
In the BluetoothClient-AddressesAndNames the app will display the discoverable devices nearby. Is it possible to put a specific name of the device to be discovered? Like i only want to discovered a device with a name of "Hello". if the name is not "Hello" it will not display as a discoverable device.

Taifun

unread,
Jul 25, 2014, 9:54:57 AM7/25/14
to mitappinv...@googlegroups.com

AddressesAndNames
The addresses and names of paired Bluetooth devices

if you want to connect only to a specific device, just use a clock component and try to connect let's say every 5 seconds using the Connect method and the MAC address of that device

boolean Connect(text address)
Connect to the Bluetooth device with the specified address and the Serial Port Profile (SPP). Returns true if the connection was successful.

you will get true as result, if the conection was successful, else try again to connect in 5 seconds, etc.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

kurar...@gmail.com

unread,
Jul 26, 2014, 5:25:09 AM7/26/14
to mitappinv...@googlegroups.com
sorry, i'm a noob in App Inventor, where can you get the "boolean Connect" in the Designer and Blocks?

Stephen Zipprich

unread,
Jul 27, 2014, 1:09:20 AM7/27/14
to mitappinv...@googlegroups.com
sorry, i'm a noob in App Inventor, where can you get the "boolean Connect" in the Designer and Blocks?

Taifun

unread,
Jul 27, 2014, 10:24:35 AM7/27/14
to mitappinv...@googlegroups.com
the result is a boolean, which is true or false
see also https://puravidaapps.com/btchat.php how to use it
Taifun

fredm

unread,
Jul 27, 2014, 4:12:38 PM7/27/14
to mitappinv...@googlegroups.com
Hi, you need to know the MAC address of the Bluetooth device you're trying to connect to.

You can install an app that will list for you the MAC addrs of nearby BT devices. I use this one: https://play.google.com/store/apps/details?id=com.ccpcreations.android.bluetoothmacfinder

Fred

fredm

unread,
Jul 28, 2014, 7:09:14 AM7/28/14
to mitappinv...@googlegroups.com
Michael wrote me privately:

Can I only filter the MAC address of the bluetooth? not the bluetooth name i.e. "01:23:45:67:89:10 Arduino" . I only want to dEtect dEvice with a name of "Arduino"

The BluetoothClient.AddressAndNames method returns a list of all BT devices you've ever paired with, and their BT MAC addresses.

Each item in the list is a text string containing the BT device's MAC address followed by its display name. The first seventeen characters of the string are the MAC address -- e.g. the 01:23:45:67:89:10 in your example -- and then the string continues with the display name -- e.g., " Arduino".

You could write some code to walk through this list, and find a device named "Arduino," and then return its MAC address.

See below for some sample code. A couple of notes on the code:

(1) the "contains text" function is case-sensitive, so if your device is called "arduino", it won't find it with "Arduino". (You could change the match term to "rduino" :)
(2) if there is more than one thing called Arduino, this code will only return the last one.

Fred

PS Michael please post any followups to the main group, not me privately.






kurar...@gmail.com

unread,
Jul 29, 2014, 8:01:10 AM7/29/14
to mitappinv...@googlegroups.com

I use this block combination, but i dont know what I will put in the "piece" segment.

Taifun

unread,
Jul 29, 2014, 9:32:56 AM7/29/14
to mitappinv...@googlegroups.com
in my example https://puravidaapps.com/btchat.php you could have learned how to connect to another device

it does not make sense to use a listpicker here, you only want to connect to one device, which is the Arduino, correct? So what is the MAC address of the Arduino, just use that address to try to connect...

and use an if statement to check, if the connection was successful or not

if call BluetoothClieent.Connect <MAC address of the Arduino>
then "success" and stop the timer
else "try again in 5 seconds"

take a look again at my example...
Taifun

fredm

unread,
Jul 30, 2014, 9:24:08 PM7/30/14
to mitappinv...@googlegroups.com
kurar... Taifun's basically correct, you have only one Arduino device, so you only want to connect to that, right?

I'd suggest you install the https://play.google.com/store/apps/details?id=com.ccpcreations.android.bluetoothmacfinder app, which lets you see that MAC address associated with your Bluetooth devices.

Copy down that addr, and then just hard code it into your app. 

Put it in a text string, and give it to the BluetoothClient.Connect block.

Fred

kurar...@gmail.com

unread,
Aug 3, 2014, 2:20:23 AM8/3/14
to mitappinv...@googlegroups.com
sir, my android app will connect to four arduino devices. I want to filter so that the app will only discover the four arduino devices. The arduino devices are in different locations (more than 10mts apart). Since each arduino device have different MAC addresses but have the same ID name.
example:
Arduino1- 00:11:22:33:44:55:66 BTduino
Arduino2- 00:55:55:66:88:99:77 BTduino
Arduino3-:55:66:77:88:44:11:22 BTduino
Arduino4- 55:77:99:66:44:22:33 BTduino

They have different MAC addresses so I want to filter it using the ID name since they have the same.

fredm

unread,
Aug 3, 2014, 11:45:19 AM8/3/14
to mitappinv...@googlegroups.com
Do you have communications working with one of your Arduinos, using a hardcoded (into your app) MAC addr?

I would do that first before working on the code to select among multiple Arduinos.

Fred

Donny S

unread,
Feb 25, 2015, 5:48:47 PM2/25/15
to mitappinv...@googlegroups.com
Taifun - I tried the connect to one of our dedvices at TImex - I did bond first thru settings, it does show up on the list picker but I get this "Error 507: Unable to connect. Is the device turned on?" shows up while trying to connect.
I do strip the name from the MAC address and paasing this 17 char string to Connect There is no other way to connect correct?

Taifun

unread,
Feb 25, 2015, 6:55:24 PM2/25/15
to mitappinv...@googlegroups.com
does the example app run on the second device, too?
Taifun

Donny S

unread,
Feb 26, 2015, 11:04:45 AM2/26/15
to mitappinv...@googlegroups.com
Tai,

I am trying to communicate with a Timex watch. So I am using the client side of it only. the thing is, with Android it is a little shady. I bond using settings and it seems paired to my phone
prior to connecting with my AI2 app. What does 'Connect' do? maybe I need a different Connect that has more arguments - do you have a java script or something we can use - pass it the MAC address?

Taifun

unread,
Feb 26, 2015, 12:01:35 PM2/26/15
to mitappinv...@googlegroups.com
on the other side must be a server component, which can accept your client connection request
it seems to be, a Timex watch is not able to do that
Taifun
Reply all
Reply to author
Forward
0 new messages