1

Why hardcode instead of doing something like in this SO post? And what is supposed to be the difference between the secure and insecure uuid?
Heres a link to the BluetoothService class in which the code below resides.

// Unique UUID for this application
    private static final UUID MY_UUID_SECURE =
            UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
    private static final UUID MY_UUID_INSECURE =
            UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
Community
  • 1
  • 1
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109

1 Answers1

0

The link you provided gives an answer of how to find the device's id, the accepted answer gets the device id (IMEI, if a GSM phone), a per device unique identifier. This is not a UUID it can be transformed into one but that does not solve the problem Bluetooth Chat example application presents. The key to understanding why Bluetooth Chat is using a static UUID is to understand Bluetooth Service Discover Protocol. UUID's in SDP declare what protocol or service is available and are well known. If random UUID's were used and no one shared their meaning other devices would not know how to interact with that Bluetooth Service. This is roughly similar to putting a random schema in a URI. For example browsers know http and https (https is understood to use TLS) but not foop or barp. And, to represent a specific device Bluetooth uses a MAC Address, which is a 48-bit unique number.

Community
  • 1
  • 1
Dan S
  • 9,139
  • 3
  • 37
  • 48
  • Thanks for the informative answer. In the 2nd answer here http://stackoverflow.com/questions/13964342/android-how-do-bluetooth-uuids-work the user says you can use an arbitrary id from a generator if both applications are using the same protocol. Im confused by this since you say these UUIDs are meant to specify predetermined protocols. – Daniel Kobe Dec 09 '15 at 03:01
  • Both applications would still be using the same UUID. Generating a UUID is a completely separate step. – Dan S Dec 09 '15 at 20:03