| // Copyright 2018 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.bredr; |
| |
| using fuchsia.bluetooth; |
| |
| /// Authentication and permission requirements to access an advertised service. |
| table SecurityRequirements { |
| /// If present and true, the physical link must be authenticated with man-in-the-middle attack |
| /// protection to access this service. If missing, authentication is not required. |
| 1: bool authentication_required; |
| |
| /// If present and true, the physical link must be encrypted with a Secure Connections key to |
| /// access this service if the host is capable. Advertisement will fail if the host does not |
| /// support Secure Connections. See Bluetooth Spec v5.2, Vol 3, Part C, Sec 5.2.2.8. |
| 2: bool secure_connections_required; |
| }; |
| |
| /// Used to specify preferred and accepted L2CAP channel modes. If the peer rejects a non-BASIC |
| /// mode, the Bluetooth system will attempt to open the channel in BASIC mode instead. For a |
| /// description of each mode, see Bluetooth Spec v5.2, Vol 3, Part A, Sec 2.4. |
| enum ChannelMode { |
| BASIC = 1; |
| ENHANCED_RETRANSMISSION = 2; |
| }; |
| |
| /// Used to specify preferred L2CAP channel parameters. |
| table ChannelParameters { |
| /// Optional. If not provided, BASIC will be used. |
| 1: ChannelMode channel_mode; |
| /// Maximum SDU size this profile is capable of accepting. Must be >= 48. Optional. If not |
| /// provided, the size will be determined by the Bluetooth system. No guarantees are given |
| /// regarding the size selected. |
| 2: uint16 max_rx_sdu_size; |
| }; |
| |
| /// Used to return an opened channel. If there was an error in opening the channel, `Channel` will |
| /// be empty. Otherwise, all fields will be present. |
| table Channel { |
| /// Socket interface for sending/receiving SDUs on the channel. |
| 1: handle<socket> socket; |
| /// Channel mode accepted by the peer. |
| 2: ChannelMode channel_mode; |
| /// Maximum SDU size the peer is capable of accepting. |
| 3: uint16 max_tx_sdu_size; |
| }; |
| |
| /// Represents a service which is registered by this profile. Closing this protocol will remove the |
| /// service registration. |
| protocol ConnectionReceiver { |
| /// Called when a peer connects to this service. The channel connected is delivered |
| /// with parameters in `channel`. |
| /// `protocol` will contain a protocol list up to the point connected (for example, if |
| /// L2CAP is connected, it will contain the L2CAP protocol and specify the PSM connected) |
| Connected(fuchsia.bluetooth.PeerId peer_id, Channel channel, ProtocolDescriptorList protocol); |
| }; |
| |
| /// Maximum number of attributes returned or allowed in a search request. |
| const uint16 MAX_ATTRIBUTES = 512; |
| |
| /// Represents an active search which can produce results when peers are connected. Closing this |
| /// protocol will result in the associated search not being performed on new connected peers. |
| protocol SearchResults { |
| /// Called when a search this client added finds a matching service on a peer. |
| /// `peer_id` is the peer the service was found on. |
| /// `protocol` includes the ProtocolDescriptorList in the service record if it exists |
| /// (it is also included in `attributes`.) |
| /// `attributes` contains all attributes requested from the search that are present on the |
| /// peer record. It may also include additional attributes. |
| /// Each ServiceFound call should be acknowledged by replying. |
| /// A limited amount of unacknowledged results will be sent on the channel. Results may be |
| /// dropped if results are received while too many results are unacknowledged. |
| ServiceFound(fuchsia.bluetooth.PeerId peer_id, ProtocolDescriptorList? protocol, |
| vector<Attribute>:MAX_ATTRIBUTES attributes) -> (); |
| }; |
| |
| /// Maximum service records that can be advertised at once. |
| const uint8 MAX_SERVICES_PER_ADVERTISEMENT = 32; |
| |
| /// Service provides Bluetooth BR/EDR profiles a way to register a service definition, making a |
| /// profile discoverable by peers. Registered services can receive L2CAP connections made to the |
| /// advertised records, and can open new connections on peers. |
| [Discoverable] protocol Profile { |
| /// Register a set of services. |
| /// These services will be discoverable via Service Discovery Protocol server. |
| /// All services advertising the same channel must be added at once - if services are already |
| /// registered on any channel advertised, registration will fail and the receiver will be closed |
| /// with ZX_ERR_ALREADY_BOUND. |
| /// The ConnectionReceiver will get calls for connections to the channels included in the |
| /// `protocol_descriptor` or `alternative_protocol_descriptors` in the services advertised. |
| /// The `requirements` provided here will be attempted with the peer before a connection is |
| /// established. If a peer cannot provide the requirements before connecting, the connection is |
| /// closed and nothing is delivered to the receiver. |
| /// The receiver will be closed if the advertisement cannot be made for any reason with a |
| /// suitable epitaph. |
| Advertise(vector<ServiceDefinition>:MAX_SERVICES_PER_ADVERTISEMENT services, |
| SecurityRequirements requirements, ChannelParameters parameters, |
| ConnectionReceiver receiver); |
| |
| /// Register a search for services on newly connected peers. The SearchResults protocol will be |
| /// used to report results for this search. Any service result with a service matching |
| /// `service_uuid` will be returned with the additional attributes in `attr_ids`. If `attr_ids` |
| /// is empty, all attributes will be requested. The additional attribute |
| /// BLUETOOTH_PROTOCOL_DESCRIPTOR_LIST is always requested. See the Bluetooth Spec v5.2, Vol 3, |
| /// Part B, Section 5) and relevant profile specification documents. |
| Search(ServiceClassProfileIdentifier service_uuid, vector<uint16>:MAX_ATTRIBUTES attr_ids, |
| SearchResults results); |
| |
| /// Connect an L2CAP channel to the connected peer identified by `peer_id` using the desired |
| /// channel `parameters` listed. Dynamic PSMs can be specified for the `psm` to connect to. |
| /// See also the defined PSMs in `service.fidl` Returns the channel connected once established, |
| /// or an error code if the channel could not be connected. |
| Connect(fuchsia.bluetooth.PeerId peer_id, uint16 psm, ChannelParameters parameters) |
| -> (Channel channel) error fuchsia.bluetooth.ErrorCode; |
| }; |