Bluetooth Classic, BLE, UUID, and ChatGPT answer

I am using many ESP32 boards and like to use Bluetooth Classic instead of BLE. I also want to have a unique UUID in all of my ESP32 so that my app will ignore other devices that do not have this UUID. I was going to use the command 'ConnectWithUUID' in the BluetoothClient1. However according to ChatGPT that is "odd". Here is the answer from ChatGPT regarding this issue:

I understand the confusion. You're right; the documentation you provided indicates that the BluetoothClient in MIT App Inventor is for Classic Bluetooth using the Serial Port Profile (SPP). However, the presence of ConnectWithUUID is indeed odd since UUIDs are prominently used with BLE.

In Classic Bluetooth, the concept of UUIDs does exist but not in the same extensive way as in BLE. For example, the Serial Port Profile (SPP) itself has a specific UUID: 00001101-0000-1000-8000-00805F9B34FB.

When using Classic Bluetooth with SPP, sometimes devices can use this UUID to advertise their services, so other devices can specifically connect to those offering the SPP service.

In the context of BluetoothClient.ConnectWithUUID, it's possible that this function is designed to connect specifically to devices that are advertising a certain service (represented by the UUID). For the SPP, you'd use the aforementioned UUID.

  1. I like to ask if that ChatGPT answer is accurate.
  2. Is it true that if I want to use UUID, I better use BLE instead of Bluetooth Classic?

Thank you!

There was the expectation / hope that these OpenAIs could and will do the work for us (especially power users). The opposite seems to be happening.

"Maybe one day OpenAI can do better than the rest of the Power Users. :)"
(Quote from a PU)

1 Like

I guess that answers my question number 1. :slightly_smiling_face:

Could you also answer my question number 2?

Thank you. But I could not find the answer I am looking for in those links. I am looking for a way to use Classic Bluetooth to assign one unique UUID (my own generated UUID) to all of my ESP32 devices. Is it possible to do that in Classic Bluetooth?

Apparently you've already tried without success. Correct?
So maybe the question could be directed to @ewpatton.

I need to dig deeper and get more things to try before I can say without success. I will get it updated once I try enough. Thanks Anke!

In bluetooth classic, uuid is the profile of the module. And is assigned to the module profile. HC05 uses the SPP profile so it has the appropriate uuid assigned to it. If the module used e.g. A2DP profile it would have a different UUID. If you want the app to connect to only one module, I think you should use an individual name, or read the address from the module and store it permanently in the app.

If you wanted to use a different uuid, I think I'd have to change it in the bt module with the AT command.

There are two problems that concern me if I assign names for this purpose:

  1. The names can be changed by the users from their phone settings.
  2. There is a chance that the names will not be unique.

Also I am wondering what the command ConnectWithUUID is specifically for in BluetoothClient when you can just use Connect with address only. As far as I know, BluetoothClient is for Bluetooth Classic only, not for BLE.

Does it make sense?

I am having a problem with your attempt to use UUID's in classic BT.
UUID's are to indicate a functionality or a specific service, and NOT for device adresses.
You could have multiple devices offering the same UUID's, which one to connect then?
Also, UUID's are predefined, if you search the web, you will see long lists of definitiions.

That's exactly what my point is. If that's the case, that means I will not be able to do this with Classic Bluetooth. I guess the answer of the ChatGPT to me is valid. That also means I will have to use BLE instead to get what I need.

But in the same time, I have a question of what the command BluetoothClient.ConnectWithUUID is for. And according to ChatGPT this command is odd.

I think that you should not do this with BLE either. What you are trying to do is to use UUID's as device address. What you can do, is find out if a certain BLE device offers a specific UUID service, such as a temperature service, and then connect to it, but still, as I said, if there are 10 microbits in my surroundings, all offering a specific UUID service, to which one should I connect then?
What you should do is find out the device address of your device, the first time you are trying to connect, save that and use it to connect to that specific device afterwards.

I am not trying to use UUID as device address. I will still use the MAC address to call for the connection. I will only use the UUID to identify which paired devices are mine.

But why could you not save the device addresses upon connection and know in this way which devices are yours?

I'm not sure what you want to do is possible depending on what particular Bluetooth module you are using. Most people who want to use Bluetooth Classic tend to use the HM-05, but as far as I have read, it isn't possible to alter the UUID broadcast by the module (i.e., it always broadcasts SPP).

Assuming you can coerce your Bluetooth module to use a different UUID, then it's possible to do what you want. The BluetoothServer component effectively does this and that was the purpose of having the mirror Accept/Connect with UUID blocks. In particular, you need to have a MAC address (who to connect to) and UUID (how to talk to them).

However, as pointed out by multiple folks (as well as in your Chat GPT answer), classic Bluetooth tended to not make much use of UUIDs whereas BLE does and in a way that is much more in line with what you're trying to do. Essentially, devices running your firmware broadcast a custom UUID and then apps that understand how to talk to your devices can connect on that UUID. BLE also tends to be lower energy cost so it tends to be a more economical option if you're using battery operated devices.

1 Like

I need my devices to be identified as "my device" before any connection is established. To better understand why I need this, let me explain in more detail what I am trying to achieve:
It's actually a very simple logic. I want the users of my app to be able to open a ListPicker that lists /shows ONLY all of "my devices" that are paired and in range.

I can save all of my device addresses and check for these addresses upon connection but that means the users will have to update my app whenever I release new devices in the future. Moreover, there are more than one thousand of my device to be released.

I was trying to get it done with Classic Bluetooth just because I thought I would not need what BLE has to offer that Classic Bluetooth does not have; and because of the advantages of Classic Bluetooth over BLE (i.e. higher data rate, better coverage, less impacted by surrounding, etc.) Because all of my devices are designed to be home-electric powered, not battery powered.

Does it make sense? Do you have a better idea how I can implement this with MIT App Inventor?

It explains what I need to know. Thank you!

It might be better to express the idea in terms of "devices that speak my protocol" since that is really the purpose that the UUID serves. For example, the SPP UUID indicates that the peripheral communicates using that particularly defined protocol. Then, you are scanning for devices that speak your protocol and saving their MAC addresses for later connections. This is a valid way to do it, except as has been noted custom UUIDs are not a common thing in Bluetooth classic. However, it would make total sense in the BLE ecosystem (and the BLE extension even has blocks to do this).

1 Like

That makes sense. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.