I created an App that connects to an HC-06 bluetooth module. This app is gonna be used in multiple devices to connect to different modules (they are all gonna be HC-06). Do I need to create a special UUID for every single phone? or can I hard code one that will work fine in every phone??
UUID in bluetooth in most cases refers to id of service that bluetooth devices offers.
Here are examples of UUIDs: https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery
So to answer your questions you can hardcoded it, it won't change as long as device that you connect to is serving the same service.
Related
is it possible to send data (e.g. a textfile) directly from one android wearable to another wearable - for example via bluetooth? Or is it required to communicate over the two associated handhelds?
Many thanks!
Henriette
Yes, it is possible since Android Wear fully support the Bluetooth library. You may not use the Android Wear Library that for NOW only connect ONE Wearable to ONE Smartphone.
You need to implement a wearable application managing bluetooth discovery and pairing, then by opening a connection socket you can exchange the data you want.
From the second part of your question, it seems you are referring to two wearable devices that are paired with two separate phones. In that case, there is no connectivity or association between these two devices and you can only achieve communication between them by, say, using the phones and handling the communication over there; that may happen in a variety of ways depending on your requirements
I am developing a client-server bluetooth chat app where multiple clients can connect with the server. If I have multiple servers, I want the client the choose which server it can connect nearby to but I am having problems in knowing which device has the app installed and it is a server. There are multiple bluetooth profiles and I am not sure which one to use it and how. Pre-Storing the MAC id's of the devices with server is one solution but I don't want to do that. Please suggest something. Thanks a lot :)
I assume the intention is to avoid an insecure connection attempt with listenUsingInsecureRfcommWithServiceRecord/createInsecureRfcommSocketToServiceRecord(1).
If you don't mind changing friendly name of the device, just during the device discovery period, you can rename your servers to a pattern of yours with setName(2). On device discovery, you can get the remote device name(3), followed by pattern matching before initiating the connection.
And revert the name, once you are done with discovery.
You use a UUID to create the BluetoothServerSocket. This UUID identifies YOUR application and is retrievable by the bluetooth discovery. This UUID is used to connect to your server device as well so you don't need to encode your app's name in the service name.
Check this answer for a detailed description:
How do Bluetooth SDP and UUIDs work? (specifically for Android)
I am using bluetooth adapter to discover bluetooth devices. The search displays all devices (iOS , Android, Speakers etc) which are available in surrounding with Bluetooth turned ON.
My App sends and receive data, so installed on two different Android Devices, app can perform a chat functionality, provided both apps are using same App UUID.
Is it possible that when I perform the device discovery/search, I only limit discovery to those devices which are Android and are using my App i.e. my App UUID and not to show all other bluetooth devices.
I know this happens in iOS using characteristic UUID.
Appreciate Response.
1) First you're doing an Inquiry (search) of all nearby devices
2) for each device enumerated, do a Discovery (SDP) on it to gather all its services/profiles; If you found the one you're searchnign for, display it, otherwise forget it...
PS: I have no idea about selecting Android devices only... You can use the CoD (Class Of Device) but not sure that you can separate Android from other "smartphones"...
So far what I know that its possible to communicate to multiple devices from your android phone. But my case is that I want to connect two 'similar' devices.
My understanding is that, I need to use different UUID if I need to connect 2 devices, the bluetooth chat application suggest to hardcoding the UUID.
Now scenario is that, I m programing for a game, where physical gun will be connected to phone via bluetooth (to track shots etc). Ok here I can ask gun vendor to hard-code a UUID for all guns and phone can connect to 1 gun at a time.. its easy.
The requirement is that, user may have more then 1 gun! Can somebody tell me how to manage this, if I m hardcoding a single UUID for all guns then I m not sure how to connect multiple guns. And if I m not hardcoding the UUID in gun chip, how I can find the UUID to connect?
A UUID is not a unique device identifier; UUIDs are unique identifiers used by the Bluetooth Service Discover Protocol to identify the protocol a Bluetooth device is using. Bluetooth.org has a list of common UUIDs.
Assuming you know or can control the UUID in the guns (it sounds like you can), then you can set up the phone as the Bluetooth server (using the same UUID that the guns use). The guns would then connect as the clients using the same UUID (I know the guns are probably not using Android, but there's some example code there that might be helpful).
Of course, you may need to flip the client/server model around to fit your specific needs. You should be able to make as many of those server and client threads as you need (within the limits of the number of connected devices that your hardware imposes).
Can any one describe what is wrong with this code. It didn't search devices, and it showed some paired devices.
Project hosted here in Github.
think of the UUID as one identifier for a particular kind of service your device is advertising or accepting. It could have many such identifiers for many different services it can offer or use. It's not an identifier for the actual device.
The UUID you are quoting is the same one I found here and use too. it seems to be the UUID for generic bluetooth SPP service. (but haven't found much actual proof like an official published document quot8ing this number, just posts on here with no refrence) This UUID will allow your android device to connect to things like bluetooth serial port adapters, or anything expecting a generic serial port device... so it's a good one to start with.
If you plan to create a special service that's not the same as bluetooth SPP or has a different reason to exist, like android chat does, then it's a good idea to create your own UUID. Of course all devices to connect your service will have to understand this same special number.