Languages

Menu
Sites
Language
uuid with android.

Hi, I'm making bluetooth application on android and gear.

I have to connect in this application using bluetooth stack so I'm refering to below site.

https://developer.tizen.org/development/api-references/native-application?redirect=https%3A//developer.tizen.org/dev-guide/2.4.0/org.tizen.native.mobile.apireference/group__CAPI__NETWORK__BLUETOOTH__SOCKET__MODULE.html&langredirect=1

 

But my apps can connect only when I use 00001101-0000-1000-8000-00805F9B34FB as uuid on both android and gear app.

I can't use any other uuid.  If so, they can't connect.

And my question is that if the other app use same uuid(00001101-0000-1000-8000-00805F9B34FB), are there any conflict because 00001101-0000-1000-8000-00805F9B34FB is SerialPortServiceClass_UUID.

I think may other apps can use the UUID and conflict occur like port in TCP/IP.  Is it right?

Then how can I decide what UUID my bluetooth apps can use?

Plus, my apps just want to transfer their data like chatting app(don't use radio, health info or speical information).

Edited by: An on 20 Mar, 2017

Responses

3 Replies
Armaan-Ul- Islam

You may have checked this documentation,

Link:

https://developer.tizen.org/development/api-tutorials/native-application/network/bluetooth#connect

It says:

"The first parameter is the UUID of the service, which uniquely identifies which service to provide. The UUID must match with the UUID in the client's incoming connection for the connection to be accepted."

 

Server:

const char* my_uuid="00001101-0000-1000-8000-00805F9B34FB";            // or any other ID
int server_socket_fd = -1;
bt_error_e ret;
 
ret = bt_socket_create_rfcomm(my_uuid, &server_socket_fd);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "bt_socket_create_rfcomm() failed.");
}

 

Client:

const char *service_uuid="00001101-0000-1000-8000-00805F9B34FB";        //same as the server
 
ret = bt_socket_connect_rfcomm(bt_server_address, service_uuid);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_ERROR, LOG_TAG, "[bt_socket_connect_rfcomm] failed.");
    return;
} else {
    dlog_print(DLOG_INFO, LOG_TAG, "[bt_socket_connect_rfcomm] Succeeded. bt_socket_connection_state_changed_cb will be called.");
}

 

00001101-0000-1000-8000-00805F9B34FB is most commonly used UUID. Anyways you may generate your own unique UUID. I hope these Links would give you sound understanding on generating unique UUID in Android.

 

http://stackoverflow.com/questions/14071131/android-find-the-uuid-of-a-specific-bluetooth-device

http://stackoverflow.com/questions/5088474/how-can-i-get-the-uuid-of-my-android-phone-in-an-application

https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#createRfcommSocketToServiceRecord%28java.util.UUID%29

 

Now you can use that same android UUID for Tizen or vice versa.

An

But if I use another same uuid in both side(android and tize), they can't connect.  Just 00001101-0000-1000-8000-00805F9B34FB is work well.

Armaan-Ul- Islam

I also checked the accepted response here:

 

https://stackoverflow.com/questions/1953888/bluetooth-rfcomm-sdp-connection-to-a-rs232-adapter-in-android?rq=1

 

Seems like '00001101-0000-1000-8000-00805F9B34FB' is the magic number. All the developers in the Links referred are using 00001101-0000-1000-8000-00805F9B34FB, so I would say you may carry on with this UUID.