I'm building a bluetooth project. I select a connected device through a ListView. I want to get the serviceUuid and characteristicUuid from the selected device when I click a button. How can I get that?
How to get serviceUuid and characteristicUuid when I use the bluetoothLE extension?
Use This app to get UUID
I select a connected device through a ListView. I want to get the serviceUuid and characteristicUuid from the selected device by the coding of my own app. Not by the help of other app.
Generally, if there is a specific device your App connects to, you should know the relevant UUIDs (of which there can be many for one device) from the device documentation.
If the device advertises it's Service UUIDs, you can collect them as a list:
Note: The latest MIT BLE Extension version 20200828 is required.
You will find that together with lots of useful links and info on my website:
I tried to show the ServiceUuid in the textbox by the following code, but it does not work. and shows an error (Attempt to invoke virtual method 'android.bluetooth.le.ScanRecord android.bluetooth.le.ScanResult.getScanRecord()' on a null object reference). Why did this happen?
What is the device being selected? Device Type, Manufacturer, model.
hello, the devices are micro: bit and Arduino UNO with HC-05 Bluetooth module.
Right - well the HC05 Module uses Serial Comms on Bluetooth v2 - not BLE, so no UUIDs etc. You can use the built-in App Inventor Bluetooth Blocks to connect with your Arduino and HC05.
Concerning micro-bit, App Inventor has a bespoke extension for it - which unfortunately is a bit of a mess at the moment but basically works once you have developed a certain amount of gray hair. See my website for links:
Thank you ！
Sorry to dig up an old thread but this is the best situation I've found to match mine. I have a BLE device and currently I have manually entered service/characteristic UUID's and my app is working as intended. I'm assuming not all UUID's for various BLE devices are the same (if they are, let me know). I want to collect them as you show and be able to "get" them from the list. I'm having trouble understanding the procedure.
The bottom two lines are my existing "manual" use case. I want the text string to be variables set from the procedure you are referring to.
My understanding: An empty global list is created, procedure sets global empty list with information from call UUIDs but what is the deviceAddress referring to? I'm looking to store these values in a list and set my variables equal to the appropriate needs (service, characteristic). Looking for where to go from here please.
Edit: added my .aia for ease of review.
BT_LED.aia (192.4 KB)
The idea behind a UUID is that because the space is so large (2^128, more than the estimated number of atoms in the universe) that it's basically impossible create a collision when randomly selecting two UUIDs to identify things. If you know what services/characteristics you want to connect to, then it makes sense to encode them into the app. If you're making a more generic UI for people to explore the services available from a BLE advice, then you may want to look at the DeviceCharacteristics property which returns a list of tuples containing the service, characteristic, and a name (if the characteristic name is known by the extension).
The project as a whole is simply sending characters over to the BLE device so my thought is the services/characteristics used won't change but I wasn't sure if the values are different between devices for the same services/characteristics.
When finding the service/characteristic through a BT Scanner app I pulled the Custom Service and Custom Characteristic value and that is what I have defined and working. I'm working with an AT-09 Bluetooth 4.0 BLE module. I was able to get a list with DeviceCharacteristics that you mentioned. But in my app it does say Unknown Characteristic for all of them so I don't think it is going to work as I wanted with no name to reference like the BT Scanner app had. Thanks for the quick reply.