How to get UUID from advertising data using Ionic?

Hi,

I’m trying to get the UUID from my nRF52840 BLE device with my Ionic Angular App without connecting to the device.

For this I’m using the Bluetooth Low Energy Central Plugin and i already get advertising data as a string, but i don’t know how to get the UUID from this string.

Here is the data i found:
image
When i try searching with the nRF connect app I’ll find the UUID so it should be possible
image
This is my code so far for the BluetoothService

export class BluetoothService {

 public logmsg: string[] = [];

 constructor(private bluetoothle : BluetoothLE, public alertController: AlertController) {
    console.log("init bluetooth");
    bluetoothle.initialize({ request: true, statusReceiver: false, restoreKey: "smartbuoyrestorekey"}).subscribe(result => {
      console.log("bluetooth init done");
      this.initializeSuccess(result);
    }, error => this.handleError(error));
  }

  public initializeSuccess(result) {
    if (result.status === "enabled") {
        console.log("Bluetooth is enabled.");
        this.log(result);

        this.startScan();
    } else {
      this.log("Bluetooth is not enabled:", "status");
      this.log(result, "status");
    }
  }

  startScanSuccess(result) {
    if (result.status === "scanStarted") {
        this.log("Scanning for devices (will continue to scan until you select a device)...", "status");
    }
    else if (result.status === "scanResult" && result.address === 'F2:AE:E5:72:6A:94') {
        if (!this.devices.some((device) =>{
            return device.address === result.address;

        })) {
            this.log('FOUND DEVICE ADVERTISMENT');
            this.log(result.advertisement);
        }
    }
  }
  
  public log(msg, level?) {
    level = level || "log";
    if (typeof msg === "object") {
        msg = JSON.stringify(msg, null, "  ");
    }
        this.logmsg.push(msg);
  }
}

Sorry if the answer is obvious but it is my first time working with BLE.

Thanks for every response.

Best regards

Niglmon

I assume you’re using cordova-plugin-bluetoothle?

On Android you get the raw advertisement data. There is a helper function bluetoothle.encodedStringToBytes to decode the string. Then you need to parse the bytes. There are some links on how you could do that in the README of cordova-plugin-ble-central.