blob: a59d8e504965ca216e00e89edb6b3e0c3651db4a [file] [log] [blame]
// Copyright 2017 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.control;
using fuchsia.bluetooth;
// Possible values for the LE Appearance property which describes the external
// appearance of a
// device at a high level.
// (See the Bluetooth assigned-numbers document:
// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml)
enum Appearance {
UNKNOWN = 0;
PHONE = 64;
COMPUTER = 128;
WATCH = 192;
WATCH_SPORTS = 193;
CLOCK = 256;
DISPLAY = 320;
REMOTE_CONTROL = 384;
EYE_GLASSES = 448;
TAG = 512;
KEYRING = 576;
MEDIA_PLAYER = 640;
BARCODE_SCANNER = 704;
THERMOMETER = 768;
THERMOMETER_EAR = 769;
HEART_RATE_SENSOR = 832;
HEART_RATE_SENSOR_BELT = 833;
BLOOD_PRESSURE = 896;
BLOOD_PRESSURE_ARM = 897;
BLOOD_PRESSURE_WRIST = 898;
HID = 960;
HID_KEYBOARD = 961;
HID_MOUSE = 962;
HID_JOYSTICK = 963;
HID_GAMEPAD = 964;
HID_DIGITIZER_TABLET = 965;
HID_CARD_READER = 966;
HID_DIGITAL_PEN = 967;
HID_BARCODE_SCANNER = 968;
GLUCOSE_METER = 1024;
RUNNING_WALKING_SENSOR = 1088;
RUNNING_WALKING_SENSOR_IN_SHOE = 1089;
RUNNING_WALKING_SENSOR_ON_SHOE = 1090;
RUNNING_WALKING_SENSOR_ON_HIP = 1091;
CYCLING = 1152;
CYCLING_COMPUTER = 1153;
CYCLING_SPEED_SENSOR = 1154;
CYCLING_CADENCE_SENSOR = 1155;
CYCLING_POWER_SENSOR = 1156;
CYCLING_SPEED_AND_CADENCE_SENSOR = 1157;
PULSE_OXIMETER = 3136;
PULSE_OXIMETER_FINGERTIP = 3137;
PULSE_OXIMETER_WRIST = 3138;
WEIGHT_SCALE = 3200;
PERSONAL_MOBILITY = 3264;
PERSONAL_MOBILITY_WHEELCHAIR = 3265;
PERSONAL_MOBILITY_SCOOTER = 3266;
GLUCOSE_MONITOR = 3328;
SPORTS_ACTIVITY = 5184;
SPORTS_ACTIVITY_LOCATION_DISPLAY = 5185;
SPORTS_ACTIVITY_LOCATION_AND_NAV_DISPLAY = 5186;
SPORTS_ACTIVITY_LOCATION_POD = 5187;
SPORTS_ACTIVITY_LOCATION_AND_NAV_POD = 5188;
};
enum TechnologyType {
LOW_ENERGY = 0;
CLASSIC = 1;
DUAL_MODE = 2;
};
// Input and Output Capabilities for pairing exchanges.
// See Volume 3, Part C, Table 5.3 and 5.4
enum InputCapabilityType {
NONE = 0;
CONFIRMATION = 1;
KEYBOARD = 2;
};
enum OutputCapabilityType {
NONE = 0;
NUMERIC = 1;
};
// Different types required by the Security Manager for pairing methods.
// Bluetooth SIG has different requirements for different device capabilities.
enum PairRequestType {
PIN_ENTRY = 0;
PIN_DISPLAY = 1;
PASSKEY_ENTRY = 2;
CONSENT = 3;
};
// Represents a remote BR/EDR, LE, or dual-mode BR/EDR/LE device.
struct RemoteDevice {
// Uniquely identifies this device on the current system.
string identifier;
// Bluetooth device address that identifies this remote device. Clients
// should display this field to the user when |name| is not available.
//
// NOTE: Clients should use the |identifier| field to distinguish between
// remote devices instead of using their address.
string address;
// The Bluetooth technologies that are supported by this device.
TechnologyType technology;
// The name of the remote device if present or known.
string? name;
// The LE appearance property. Present if this is a LE device and the
// appearance information was obtained over advertising and/or GATT.
Appearance appearance;
// The most recently obtained advertising signal strength for this device.
fuchsia.bluetooth.Int8? rssi;
// The most recently obtained transmission power for this device.
fuchsia.bluetooth.Int8? tx_power;
// Whether or not a BR/EDR and/or LE connection exists between the local
// adapter and this device.
bool connected;
// Whether or not a bond exists between the local adapter and this device.
bool bonded;
// The list of service UUIDs known to be published on this remote device.
vector<string> service_uuids;
};
// Contains state information for a particular Bluetooth adapter.
struct AdapterState {
// The local name of the local adapter, visible to other devices when
// discoverable.
string? local_name;
// Whether or not the local adapter is currently discoverable over BR/EDR and
// LE physical channels.
fuchsia.bluetooth.Bool? discoverable;
// Whether or not device discovery is currently being performed.
fuchsia.bluetooth.Bool? discovering;
// Service UUIDs of all local services that are published and available to
// other devices via this adapter. These services are usually registered
// using the GATT and the classic profile APIs.
vector<string>? local_service_uuids;
};
// Contains static global information about a local Bluetooth adapter,
// including its current state. Each adapter instance represents a physical
// Bluetooth controller and its associated host-subsystem state that is present
// on the current platform.
struct AdapterInfo {
// UUID that uniquely identifies this adapter on the current system.
string identifier;
// The Bluetooth technologies that are supported by this adapter.
TechnologyType technology;
// Public Bluetooth device address which can be displayed to the user.
string address;
// The current adapter state. This field is only present when an AdapterInfo
// is obtained via the Control and ControlDelegate interfaces. If present,
// all optional members of |state| will also be present.
AdapterState? state;
};
interface PairingDelegate {
// If |pin| is not null, |response| must match to accept the pairing request.
// Otherwise if |response| is present, pairing is accepted and the response
// is used as the passkey or pin if necessary.
1: OnPairRequest(RemoteDevice device, PairRequestType type, string? pin) ->
(string? response);
};
// Primary Bluetooth control service to access bluetooth
[Discoverable]
interface Control {
// Returns whether or not Bluetooth is currently available on the system.
1: IsBluetoothAvailable() -> (bool available);
// Registers a delegate to handle pairing requests.
// Indicate the capability type of the PairingDelegate using |in| and |out|.
// If your input/output capability is variable, call this function when it
// changes to update.
// Setting a pairing delegate closes the previously assigned pairing Delegate.
//
// To disable pairing, set |delegate| to null.
3: SetPairingDelegate(InputCapabilityType in, OutputCapabilityType out,
PairingDelegate? delegate);
// Returns information about all local adapters that are known to the system.
4: GetAdapters() -> (vector<AdapterInfo>? adapters);
// Sets the local adapter with the given |identifier| to act as the backing
// adapter for all Bluetooth interfaces.
5: SetActiveAdapter(string identifier) -> (fuchsia.bluetooth.Status @status);
// Returns information on the current active adapter, if it exists.
6: GetActiveAdapterInfo() -> (AdapterInfo? @adapter);
// If |discovery| is true, active discovery is requested.
// When requesting discovery, general discovery for BR/EDR and LE will be
// active and newly discovered devices will be reported via
// RemoteDeviceDelegate.OnDeviceUpdate().
//
// Discovery may be active when not reqested.
// If an error occurs when starting discovery, it is reflected in |status|.
8: RequestDiscovery(bool discovery) -> (fuchsia.bluetooth.Status @status);
// Retrieve the set of known remote devices.
// Note: These devices are not guaranteed to still be reachable.
9: GetKnownRemoteDevices() -> (vector<RemoteDevice> devices);
// Sets the public Bluetooth name for this device, or resets to the default
// name if |name| is not present.
10: SetName(string? name) -> (fuchsia.bluetooth.Status @status);
// Set the discoverability of this device.
11: SetDiscoverable(bool discoverable) -> (fuchsia.bluetooth.Status @status);
// Attempt to connect to the remote |device_id|.
// If |bond| is set, try to bond to this device as well.
12: Connect(string device_id, bool bond) -> (fuchsia.bluetooth.Status @status);
// Disconnect a previously-connected device.
// Note: This does not remove a device bond, see Control::Forget.
13: Disconnect(string device_id) -> (fuchsia.bluetooth.Status @status);
// Forgets |device_id| completely, removing all bonding information.
// This will disconnect a device if it is connected.
14: Forget(string device_id) -> (fuchsia.bluetooth.Status @status);
// Events
// Sent when the active adapter has been updated. If |active_adapter| is
// null, then no adapter is currently active.
10100: -> OnActiveAdapterChanged(AdapterInfo? adapter);
// Sent when an adapter has been updated.
10101: -> OnAdapterUpdated(AdapterInfo adapter);
// Sent when an adapter with the given |identifier| has been removed from
// the system.
10102: -> OnAdapterRemoved(string identifier);
// Sent when a Host Device is Updated
10700: -> OnDeviceUpdated(RemoteDevice device);
// Sent when a Host Device is removed
10701: -> OnDeviceRemoved(string identifier);
};