cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Bluetooth

ZhaohuaS_76
Employee

Overview

On WICED Smart device, the default advertising data includes Flags,Local Name, Class of Device and Service UUID, etc. Developer can customize the advertising data, this document introduce how to make a customized advertising.

Advertising Data Format

The format of advertising data is shown in the follow figure. The data consist of a significant part and a non-significant part. The significant part contains a sequence of AD structure, the non-significant part extends the advertising to 31 octets and shall contain all-zero octets.

Untitled.png

Advertising Data Type

About AD type definition, please refer to https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile .

The following AD types are defined in SDK, it’s in bleprofile.h.

// ADV flag values

enum ble_adv_flag_value

{

    ADV_FLAGS                             = 0x01,

    ADV_SERVICE_UUID16_MORE              = 0x02,

    ADV_SERVICE_UUID16_COMP              = 0x03,

    ADV_SERVICE_UUID32_MORE              = 0x04,

    ADV_SERVICE_UUID32_COMP              = 0x05,

    ADV_SERVICE_UUID128_MORE             = 0x06,

    ADV_SERVICE_UUID128_COMP             = 0x07,

    ADV_LOCAL_NAME_SHORT                 = 0x08,

    ADV_LOCAL_NAME_COMP                  = 0x09,

    ADV_TX_POWER_LEVEL                   = 0x0A,

    ADV_CLASS_OF_DEVICE                  = 0x0D,

    ADV_SIMPLE_PAIRING_HASH_C            = 0x0E,

    ADV_SIMPLE_PAIRING_RANDOMIZER_R   = 0x0F,

    ADV_TK_VALUE                          = 0x10,

    ADV_OOB_FLAGS                         = 0x11,

    ADV_SLAVE_CONNECTION_INTERVAL_RANGE = 0x12,

    ADV_SERVICE_UUID16                   = 0x14,

    ADV_SERVICE_UUID128                  = 0x15,

    ADV_SERVICE_DATA                     = 0x16,

    ADV_SERVICE_TARGET_PUBLIC_ADR        = 0x17,

    ADV_SERVICE_TARGET_RANDOM_ADR     = 0x18,

    ADV_APPEARANCE                       = 0x19,

    ADV_ADVERTISING_INTERVAL             = 0x1A,

    ADV_3D_INFORMATION_DATA              = 0x3D,

    ADV_MANUFACTURER_DATA                = 0xFF,

};

Flags

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.1.

Value

Description

Bit

Information

0x01

Flags

0

LE Limited  Discoverable Mode

1

LE General  Discoverable Mode

2

BR/EDR Not  Supported

3

Simultaneous LE  and BR/EDR to Same Device Capable (Controller)

4

Simultaneous LE  and BR/EDR to Same Device Capable (Host)

5..7

Reserved

Service UUIDs

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.2.

A device may list the service UUIDs that it implements in its advertising data.

Value

Description

Information

0x02

16-bit Service UUIDs

More 16-bit UUIDs  available

0x03

16-bit Service UUIDs

Complete list of 16-bit  UUIDs available

0x04

32-bit Service UUIDs

More 32-bit UUIDs  available

0x05

32-bit Service UUIDs

Complete list of 32-bit  UUIDs available

0x06

128-bit Service UUIDs

More 128-bit UUIDs  available

0x07

128-bit Service UUIDs

Complete list of 128-bit UUIDs available

Local Name

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.3.

The Local Name ADtype contains the device name, either complete or shortened. If the name is shortened, the complete device name can be read by reading the device name characteristic.

Value

Description

Information

0x08

Local Name

Shortened local name

0x09

Local Name

Complete local name

Tx Power Level

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.4.

The TX PowerLevel AD type indicates the transmitted power level of the advertising packet.

Value

Description

Information

0x0A

TX Power Level (1 byte)

0xXX:-127  to +127dBm

Note:  when the TX Power Level tag is not present, the TX power level of the packet  is unknown.

Class of Device

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.5.

Value

Description

Information

0x0D

Class of device (3 octets)

Format defined in Assigned Numbers.

Assigned Numbers Specification:

https://www.bluetooth.org/Technical/AssignedNumbers/home.htm

Simple Pairing Hash C-192

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.5.

Value

Description

Information

0x0E

Simple Pairing Hash C (16  octets)

Format defined in Core  Spec V4.0 [Vol. 2], Part H Section 7.2.2

Simple Pairing Randomizer R-192

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.5.

Value

Description

Information

0x0F

Simple Pairing Randomizer R (16 ctets)

Format  defined in Core Spec V4.0 [Vol. 2], Part H Section 7.2.2

Security Manager TK Value

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.6.

The Security Manager TK Value only be used over an out-of-band mechanism,the definition as below.

Value

Description

Information

0x10

TK Value

Value as used in pairing  over LE Physical channel.

Format defined in Core  Spec V4.0 [Vol. 3], Part H Section 2.3

 

Security Manager Out of Band (OOB)

Refer to Core  Spec V4.0 [Vol.3], Part C Section 18.7.

An out of bandmechanism is used by the Security Manager to communicate discovery information as well as other information related to the pairing process.

Value

Description

Bit

Information

0x11

Flag  (1 octet)

0

OOB  Flags Field

(0  = OOB data not present, 1 = OOB data present)

1

LE  supported (Host) (i.e. bit 65 of LMP Extended

Feature  bits Page 1

2

Simultaneous  LE and BR/EDR to Same Device Capable  (Host) (i.e. bit 66 of LMP Extended Feature bits Page 1)

3

Address  type (0 = Public Address, 1 = Random Address)

4..7

Reserved

Slave Connection Interval Range

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.8.

The Slave Connection Interval Range AD type contains the Peripheral’s preferred connection interval range, for all logical connections.

Value

Description

Information

0x12

Slave  Connection Interval Range

The  first 2 octets defines the minimum value for the   connection interval in the following manner:


connInterval_min=  Conn_Interval_Min * 1.25 ms

Conn_Interval_Min  range: 0x0006 to 0x0C80

Value  of 0xFFFF indicates no specific minimum.

Values  outside the range are reserved. (excluding 0xFFFF)

The  second 2 octets defines the maximum value for the connection interval in the   following manner:

connInterval_max=   Conn_Interval_Max * 1.25 ms

Conn_Interval_Max   range: 0x0006 to 0x0C80

Conn_Interval_Max   shall be equal to or greater than the onn_Interval_Min.

Value of 0xFFFF indicates no specific maximum.

Values outside the range are reserved (excluding 0xFFFF)

Service Solicitation

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.9.

One of the Service Solicitation AD types may be sent to invite other devices that expose one or more of the services specified in the Service Solicitation data to connect. This enables a Central providing one or more of these services to connect to this Peripheral.

Value

Description

Information

x14

Service UUIDs

List of 16 bit Service UUIDs

0x15

Service UUIDs

List of 128 bit Service UUID

Service Data

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.10.

The Service Data AD type consists of a service UUID with the data associated with that service.

Value

Description

Information

0x16

Service Data (2 or more
  octets)

The first 2 octets   contain the 16 bit Service UUID followed by  additional service data

Public Target Address

Refer to Supplement to Core Spec V4.0, Part A Section 1.13.

The public device address is divided into the following two fields:

• company_assigned field is contained in the 24 least significant bits

• company_id field is contained in the 24 most significant bits

Value

Description

0x17

Size: Multiples of 6 octets

The format of each 6 octet address is the same as the Public Device Address defined in Core Spec V4.0 [Vol. 6], Part B, Section 1.3.

The Public Target Address value shall be the enumerated value as   defined by Bluetooth Assigned Numbers.

Assigned Numbers Specification:  https://www.bluetooth.org/Technical/AssignedNumbers/home.htm

Random Target Address

Refer to Supplement to Core Spec V4.0, Part A Section 1.14.

The random device address is divided into the following two fields:

• hash field is contained in the 24 least significant bits, as defined in [Vol. 3] Part C, Section 10.8.2.3.

• random field is contained in the 24 most significant bits, as defined in [Vol. 3] Part C, Section 10.8.2.2.

Value

Description

0x18

Size: Multiples of 6   octets

The format of each 6   octet address is the same as the Random Device Address defined in Core Spec   V4.0 [Vol. 6], Part B, Section 1.3.

The Random Target Address   value shall be the enumerated value as defined by Bluetooth Assigned Numbers.

Assigned Numbers   Specification: https://www.bluetooth.org/Technical/AssignedNumbers/home.htm

Appearance

Refer to Supplement to Core Spec V4.0, Part A Section 1.12.

Value

Information

0x19

The   Appearance value shall be the enumerated value as defined by Bluetooth   Assigned Numbers.

Assigned   Numbers Specification: https://www.bluetooth.org/Technical/AssignedNumbers/home.htm

Advertising Interval

The advertising Interval shall be an integer multiple of 0.625ms in the range of 20ms to 10.24s.
If the advertising event type is either a scannable undirected event type or a non-connectable undirected event type, the advertising Interval shall not be less than 100ms. If the advertising event type is a connectable undirected event type, the advertising Interval can be 20ms or greater.

Value

Information

0x1A

Size:   2 octets (UINT16)

Units:   0.625ms

Manufacturer Specific Data

Refer to Core Spec V4.0 [Vol.3], Part C Section 18.11.

The Manufacturer Specific AD type is used for manufacturer specific data.

Value

Description

Information

0xFF

Manufacturer   Specific Data (2 or more octets)

The   first 2 octets contain the Company Identifier Code followed by additional   manufacturer specific data

Sample Code

The follow sample code is in hello_sensor.c.

void hello_sensor_create(void)
{
    …
    // Read value of the service from GATT DB.
    bleprofile_ReadHandle(HANDLE_HELLO_SENSOR_SERVICE_UUID, &db_pdu);

    if (db_pdu.len != 16)
    {
        ble_trace1("hello_sensor bad service UUID len: %d\n", db_pdu.len);
    }
    else
    {
        BLE_ADV_FIELD adv[3];

        //Advertising data type: Flags
        adv[0].len     = 1 + 1;
        adv[0].val     = ADV_FLAGS;
        adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;

       //Advertising data type: service UUIDs
        adv[1].len     = 16 + 1;
        adv[1].val     = ADV_SERVICE_UUID128_COMP;
        memcpy(adv[1].data, db_pdu.pdu, 16);

        //Advertising data type: Name
        adv[2].len      = strlen(bleprofile_p_cfg->local_name) + 1;
        adv[2].val      = ADV_LOCAL_NAME_COMP;
        memcpy(adv[2].data, bleprofile_p_cfg->local_name, adv[2].len - 1);

        //Generate the advertising packet by above three data types
        bleprofile_GenerateADVData(adv, 3);
}

//Start to advertising
    bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, hello_sensor_remote_addr);
}

1 Reply
ZhaohuaS_76
Employee

Hi All,

Welcome your comments.