Question
I'm developing a Bluetooth application for both Android and Tizen (Gear) devices. My application can only establish a connection when using the UUID 00001101-0000-1000-8000-00805F9B34FB (SerialPortServiceClass_UUID) on both platforms. Other UUIDs fail to connect.
My concerns are:
- If other applications use the same UUID, could this cause conflicts similar to port conflicts in TCP/IP?
- How should I determine which UUID to use for my Bluetooth application?
- My application only needs to transfer basic data (similar to a chat application), without using radio, health info, or special services.
Answer
Problem Understanding
The issue involves Bluetooth RFCOMM socket connection between Android and Tizen devices, specifically regarding UUID selection and potential conflicts.
Solution Methods
-
Using Standard UUID:
- The UUID
00001101-0000-1000-8000-00805F9B34FBis widely accepted as the standard for serial port profile (SPP) connections. - This UUID works reliably across platforms, which explains why it's the only one working in your case.
- The UUID
-
Generating Custom UUID:
- While you can generate your own UUID, it must be identical on both client and server sides.
- Custom UUIDs may not work with all Bluetooth stacks, which is why the standard UUID is recommended for basic data transfer.
-
Conflict Resolution:
- UUID conflicts are unlikely to cause issues like TCP/IP port conflicts.
- Bluetooth connections are established between specific device pairs, so multiple applications using the same UUID won't interfere with each other's connections.
Code Examples
Server Side (Tizen):
const char* my_uuid = "00001101-0000-1000-8000-00805F9B34FB";
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 Side (Android):
// Using the same UUID as the server
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothSocket socket = device.createRfcommSocketToServiceRecord(uuid);
socket.connect();
Additional Tips
- For basic data transfer applications, sticking with the standard SPP UUID is recommended.
- If you need to implement specific services, consider registering your own UUID with the Bluetooth SIG.
- Always ensure the same UUID is used on both connecting devices.
- For more information on Bluetooth development in Tizen, refer to the Samsung Tizen OS documentation.