| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.bluetooth.le; |
| |
| using fuchsia.bluetooth as bt; |
| |
| // The size of the BT-encoded ServiceData field must fit into a uint8, so the max allowed data |
| // size is 255 (uint8::MAX) - 1 byte (field type) - 2 bytes (minimum possible encoded UUID size). |
| const MAX_SERVICE_DATA_LENGTH uint8 = 252; |
| |
| // The size of the BT-encoded ServiceData field must fit into a uint8, so the max allowed data size |
| // is 255 (uint8::MAX) - 1 byte (field type) - 2 bytes (company ID size). |
| const MAX_MANUFACTURER_DATA_LENGTH uint8 = 252; |
| |
| // The size of each BT-encoded URI must fit into a uint8. Recognized encoding schemes are compressed |
| // to 1 encoded byte, so encoded URIs are |original length| - (|encoding scheme| + 1) bytes. This |
| // leads to a formula for the maximum URI length of |longest_scheme_str| - 1 byte (encoding) + |
| // uint8::MAX - 1 byte (field type). The longest_scheme_str is "ms-settings-cloudstorage:", of |
| // length 25, leading to a limit of 25 - 1 + 255 - 1 = 278. |
| const MAX_URI_LENGTH uint16 = 278; |
| |
| // The size of the broadcast name is at least 4 UTF-8 characters (min 4 bytes) |
| // and a max of 32 UTF-8 characters (32 * 4) = 128 |
| @available(added=24) |
| const MAX_BROADCAST_NAME_OCTETS uint8 = 128; |
| |
| /// Entry in the `service_data` field of a [`fuchsia.bluetooth.le/AdvertisingData`]. |
| type ServiceData = struct { |
| uuid bt.Uuid; |
| data vector<uint8>:MAX_SERVICE_DATA_LENGTH; |
| }; |
| |
| /// Entry in the `manufacturer_data` field of a [`fuchsia.bluetooth.le/AdvertisingData`]. |
| type ManufacturerData = struct { |
| company_id uint16; |
| data vector<uint8>:MAX_MANUFACTURER_DATA_LENGTH; |
| }; |
| |
| /// Represents advertising and scan response data that are transmitted by a LE peripheral or |
| /// broadcaster. |
| type AdvertisingData = table { |
| /// Long or short name of the device. |
| 1: name bt.DeviceName; |
| |
| /// The appearance of the device. |
| 2: appearance bt.Appearance; |
| |
| @deprecated("Use include_tx_power_level instead. This value will be ignored.") |
| 3: tx_power_level int8; |
| |
| /// Service UUIDs. |
| 4: service_uuids vector<bt.Uuid>:MAX; |
| |
| /// Service data entries. |
| 5: service_data vector<ServiceData>:MAX; |
| |
| /// Manufacturer-specific data entries. |
| 6: manufacturer_data vector<ManufacturerData>:MAX; |
| |
| /// String representing a URI to be advertised, as defined in [IETF STD 66](https://tools.ietf.org/html/std66). |
| /// Each entry should be a UTF-8 string including the scheme. For more information, see: |
| /// - https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml for allowed schemes; |
| /// - https://www.bluetooth.com/specifications/assigned-numbers/uri-scheme-name-string-mapping |
| /// for code-points used by the system to compress the scheme to save space in the payload. |
| 7: uris vector<string:MAX_URI_LENGTH>:MAX; |
| |
| /// Indicates whether the current TX power level should be included in the advertising data. |
| 8: include_tx_power_level bool; |
| |
| /// Identifies the peer as belonging to a Coordinated Set. |
| /// Resolution and generation of this parameter is defined in the |
| /// Coordinated Set Identification Service Specification. |
| @available(added=24) |
| 9: resolvable_set_identifier array<uint8, 6>; |
| |
| /// The broadcast name string can be used by a user interface on a scanning |
| /// device that displays information on the available broadcast sources. |
| /// |
| /// Multiple devices with the same Broadcast Name may be transmitting the |
| /// same data, allowing devices to choose one. At least 4 unicode characters |
| /// long and no more than 32 characters. |
| /// |
| /// Defined in the Public Broadcast Profile specification. |
| @available(added=24) |
| 10: broadcast_name string:MAX_BROADCAST_NAME_OCTETS; |
| }; |