Does peripheral ad data need to be ASCII text?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Or, can the ad data be binary bytes.

Obviously, more information can be packed into bytes than represented by ASCII text.

What's the maximum ad size in bytes?

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

> What's the maximum ad size in bytes?

An advertisement packet is limited to 31 bytes by the spec.

> can the ad data be binary bytes.

There is a specific formatting requirement for the advertisement packet. See Bluetooth Specification, Volume 3, Part C (Generic Access Protocol), Section 11 (Advertising and scan response data format). There is also an example in 11.2.

In summary:

pastedImage_0.png

All valid AD Types are listed in the assigned numbers document (for GAP assigned numbers, see English Generic Access Profile). If you use a manufacturer specific data AD type, then the first two bytes of AD Data should be the company identifier, followed by any (including binary) data you want.

View solution in original post

0 Likes
6 Replies
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

> What's the maximum ad size in bytes?

An advertisement packet is limited to 31 bytes by the spec.

> can the ad data be binary bytes.

There is a specific formatting requirement for the advertisement packet. See Bluetooth Specification, Volume 3, Part C (Generic Access Protocol), Section 11 (Advertising and scan response data format). There is also an example in 11.2.

In summary:

pastedImage_0.png

All valid AD Types are listed in the assigned numbers document (for GAP assigned numbers, see English Generic Access Profile). If you use a manufacturer specific data AD type, then the first two bytes of AD Data should be the company identifier, followed by any (including binary) data you want.

0 Likes
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

There is some sample code which shows how to generate advertisement data in the hello_sensor and mybeacon applications.

0 Likes
Anonymous
Not applicable

Does there have to be at least one byte of insignificant data, or can significant data take up all 31 bytes of the ad?

0 Likes

Significant data can take up all 31 bytes.

Anonymous
Not applicable

So then, the maximum binary advertisement data would be 29 bytes:

1 Length octet

1 AD Type octet = Mfg Specific Data

29 AD Data octets = any binary 29 bytes

Will this work in SDK 2.x  ?

0 Likes

The Flags AD type is mandatory (BR/EDR is not supported by 2073x). So you have to include that in your advertisement data. From section 11.1.3 in Volume 3, Part C:

11.1.3 Flags

The Flags AD type contains several flag bits interpreted as boolean values.

Flags used over the LE physical channel are:

• Limited Discoverable Mode

• General Discoverable Mode

• BR/EDR Not Supported

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

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

The Flags AD type shall not be included in the scan response data. The advertising

data shall not contain more than one instance of the Flags AD type. The

Flags AD type shall be included in the advertising data if any of the bits are

non-zero. The Flags AD type may be omitted from the advertising data if all of

the bits are zero. The format of Flags AD type is defined in Table 18.1. [Emphasis added]



And from section 18.11, the manufacturer specific data should also include a 2 byte company identifier:

pastedImage_3.png

2 1 byte length (=2)

1 byte AD type = Flags (= 0x01)

1 byte Flags value

X 1 byte length (=X)

1 byte AD type = Manufacturer Specific Data (= 0xFF)

2 bytes Company identifier

X-3 bytes data

The max value of X will then be 26 27 and you can have 23 24 binary octets (X - 3 data bytes).

[EDIT]: Updated some of the fields old values with new ones. Yes, this will work with SDK 1.1.0 and SDK 2.0.1.