I am stuck in determining whether BLE device is connectable or not, by analyzing advertisement data. Here is my code sample and study guide

I am using Ionic React. And Advertising data received from device was in ArrayBuffer format, from ArrayBuffer I took UInt8Array and then parsed it using following function:

function asHexString(i: any) {
    var hex;

    hex = i.toString(16);

    // zero padding
    if (hex.length === 1) {
        hex = "0" + hex;

    return "0x" + hex;

export const parseAdvertisingData = (buffer: any) => {
    var length, type, data, i = 0, advertisementData = {};
    var bytes = new Uint8Array(buffer);

    while (length !== 0) {

        length = bytes[i] & 0xFF;

        // decode type constants from https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
        type = bytes[i] & 0xFF;

        data = bytes.slice(i, i + length - 1).buffer; // length includes type byte, but not length byte
        i += length - 2;  // move to end of data

        // @ts-ignore
        advertisementData[asHexString(type)] = data;

    return advertisementData;

This returned Object of ArrayBuffer, one with key 0x19(APPEARANCE DATA) and other 0xff(MANUFACTURER DATA)

Then I converted both ArrayBuffer->UInt8Array to hex string and got following results:

Advertisement Raw Data Received: 0x031919001AFF580015E8FF000000000C0C0011D40000000000000001010000

Len Type Value
3 0x19 0x1900
26 0x26 0x580015E8FF000000000C0C0011D40000000000000001010000

Now, I wanted to determine whether this device is connectable or not from above results??

Following are study material:

Legacy Advertising PDUs

These are available for all Bluetooth versions – also enables backward compatibility with older versions and are used on the Primary advertising channels.

  • ADV_IND: Connectable Scannable Undirected advertising.
  • ADV_DIRECT_IND: Connectable Directed advertising
  • ADV_NONCONN_IND: Non-Connectable Non-Scannable Undirected advertising
  • ADV_SCAN_IND: Scannable Undirected advertising

enter image description here

enter image description here


  1. BLE GAP CHART: https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/
  2. BLE ADVERTISEMENT: https://www.novelbits.io/bluetooth-low-energy-advertisements-part-1/

Source: Ask Javascript Questions