Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE - finding UUIDs of unknown GATT services and characteristics #233

Closed
Adarkazanli96 opened this issue Jul 18, 2019 · 1 comment
Closed

Comments

@Adarkazanli96
Copy link

Hi, I’m working with a bluetooth peripheral device that is programmed to use custom gatt services and characteristics. I’m trying to see if it might be possible to find out what the UUIDs for them are by first calling device.discoverAllPrimaryServices() and then having each service in the array print out it’s uuid as well as all of it’s characteristics UUIDs using a function like this:

const getAllUUIDs = (arr) =>{
    for(let i = 0; i<arr.length; i++){
        trace(UUID is ${arr[i].uuid})
    }
}

But the output is [object ArrayBuffer]
I’ve tried various methods to convert it into a string but none of them have worked

If I can get some pointers on how this might be done please let me know, thanks!

@phoddie
Copy link
Collaborator

phoddie commented Jul 18, 2019

In JavaScript, an ArrayBuffer is an array of bytes. You wrap it in a TypedArray to access the content. Here's a small example that outputs the bytes of an ArrayBuffer as hex bytes:

let bytes = new Uint8Array(arr[i].uuid);
bytes.forEach(value => trace(value.toString(16).padStart(2, "0")), "\n");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants