// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Next MinVersion: 7 module arc.mojom; [Extensible] enum BluetoothAdapterState { OFF = 0, ON }; [Extensible] enum BluetoothDiscoveryState { STOPPED, STARTED }; [Extensible] enum BluetoothAclState { CONNECTED, DISCONNECTED }; [Extensible] enum BluetoothStatus { SUCCESS = 0, FAIL, NOT_READY, NOMEM, BUSY, DONE, UNSUPPORTED, PARM_INVALID, UNHANDLED, AUTH_FAILURE, RMT_DEV_DOWN, AUTH_REJECTED }; struct BluetoothAddress { array address; }; struct BluetoothUUID { array uuid; }; struct BluetoothServiceRecord { BluetoothUUID uuid; uint16 channel; string name; }; struct BluetoothLocalLEFeatures { uint16 version_supported; uint8 local_privacy_enabled; uint8 max_adv_instance; uint8 rpa_offload_supported; uint8 max_irk_list_size; uint8 max_adv_filter_supported; uint8 activity_energy_info_supported; uint16 scan_result_storage_size; uint16 total_trackable_advertisers; bool extended_scan_support; bool debug_logging_supported; }; [Extensible] enum BluetoothPropertyType { ALL = 0, BDNAME = 1, BDADDR, UUIDS, CLASS_OF_DEVICE, TYPE_OF_DEVICE, SERVICE_RECORD, ADAPTER_SCAN_MODE, ADAPTER_BONDED_DEVICES, ADAPTER_DISCOVERY_TIMEOUT, REMOTE_FRIENDLY_NAME, REMOTE_RSSI, REMOTE_VERSION_INFO, LOCAL_LE_FEATURES, REMOTE_DEVICE_TIMESTAMP = 0xFF, }; [Extensible] enum BluetoothScanMode { NONE = 0x0, CONNECTABLE, CONNECTABLE_DISCOVERABLE }; [Extensible] enum BluetoothDeviceType { BREDR = 0x1, BLE, DUAL }; [Extensible] enum BluetoothBondState { NONE = 0, BONDING, BONDED }; struct BluetoothRemoteVersion { int32 version; int32 sub_ver; int32 manufacturer; }; union BluetoothProperty { string bdname; BluetoothAddress bdaddr; array uuids; uint32 device_class; BluetoothDeviceType device_type; BluetoothServiceRecord service_record; BluetoothScanMode adapter_scan_mode; array bonded_devices; uint32 discovery_timeout; string remote_friendly_name; int32 remote_rssi; BluetoothRemoteVersion remote_version; BluetoothLocalLEFeatures local_le_features; }; // Bluetooth GATT types // Copy from Android API // https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html [Extensible] enum BluetoothGattStatus { GATT_SUCCESS = 0, GATT_READ_NOT_PERMITTED = 0x2, GATT_WRITE_NOT_PERMITTED = 0x3, GATT_INSUFFICIENT_AUTHENTICATION = 0x5, GATT_REQUEST_NOT_SUPPORTED = 0x6, GATT_INVALID_OFFSET = 0x7, GATT_INVALID_ATTRIBUTE_LENGTH = 0xd, GATT_INSUFFICIENT_ENCRYPTION = 0xf, GATT_CONNECTION_CONGESTED = 0x8f, GATT_FAILURE = 0x101, }; // Copy from Android API // https://source.android.com/devices/halref/structbtgatt__gatt__id__t.html struct BluetoothGattID { BluetoothUUID uuid; uint8 inst_id; }; // Copy from Android API // is_primary is not a boolean because Android defines it as uint8_t. // https://source.android.com/devices/halref/structbtgatt__srvc__id__t.html struct BluetoothGattServiceID { BluetoothGattID id; uint8 is_primary; }; struct BluetoothGattValue { BluetoothGattStatus status; array value; }; const int8 kUnknownPower = 127; // Copied from Android Bluetooth package. See AdvertiseManager$AdvertiseNative // http://goo.gl/UnKC5N enum BluetoothAdvertisementType { ADV_TYPE_CONNECTABLE = 0, ADV_TYPE_SCANNABLE = 2, ADV_TYPE_NON_CONNECTABLE = 3, }; // Copy from Bluetooth Assigned Numbers Document, Generic Access Profile // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile [Extensible] enum BluetoothAdvertisingDataType { DATA_TYPE_FLAGS = 0x01, DATA_TYPE_SERVICE_UUIDS_16_BIT_COMPLETE = 0x03, DATA_TYPE_SERVICE_UUIDS_128_BIT_COMPLETE = 0x07, DATA_TYPE_LOCAL_NAME_COMPLETE = 0x09, DATA_TYPE_TX_POWER_LEVEL = 0x0A, DATA_TYPE_SERVICE_DATA = 0x16, DATA_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xff, }; // Copy from Bluetooth Core v4.2 Volume 3 Part C Chapter 11 // and Bluetooth Core Specification Supplement v6 Part A Chapter 1 // https://www.bluetooth.com/specifications/adopted-specifications union BluetoothAdvertisingData { uint8 flags; array service_uuids_16; array service_uuids; string local_name; uint8 tx_power_level; BluetoothServiceData service_data; array manufacturer_data; array other_data; }; struct BluetoothServiceData { uint16 uuid_16bit; array data; }; struct BluetoothAdvertisement { BluetoothAdvertisementType type; bool include_tx_power; array data; // Add more here as Chrome supports it. }; [Extensible] enum BluetoothGattDBAttributeType { BTGATT_DB_PRIMARY_SERVICE = 0, BTGATT_DB_SECONDARY_SERVICE, BTGATT_DB_INCLUDED_SERVICE, BTGATT_DB_CHARACTERISTIC, BTGATT_DB_DESCRIPTOR, }; struct BluetoothGattDBElement { uint8 id; BluetoothUUID uuid; BluetoothGattDBAttributeType type; uint16 attribute_handle; /* * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute * handles. */ uint16 start_handle; uint16 end_handle; /* * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of * the characteristic. */ uint8 properties; }; // Bluetooth SDP types [Extensible] enum BluetoothSdpAttributeType { NULLTYPE = 0, UINT, INT, UUID, STRING, BOOL, SEQUENCE, URL, }; /* * A BluetoothSdpAttribute contains either a value or a sequence, where a * sequence is an array of BluetoothSdpAttribute. A multi-layered attribute * design is intended. Note BluetoothSdpAttribute supports up to depth 32 for * the attribute with multi-layer sequences. The attributes within a sequence * which has the depth beyond the maximum supported depth will be invalidated * and ignored. */ struct BluetoothSdpAttribute { BluetoothSdpAttributeType type; uint32 type_size; array sequence; // Holds the stringified JSON value of this attribute. // If the type is NULLTYPE or SEQUENCE, this is empty. // Explicitly specify the ordinal @3, because introducing this is a breaking // change. This field is introduced between version 7 and 8, though // MinVersion is not annotated because of breaking change, too. // See details in the bug linked below. // TODO(crbug.com/767313): Use mojo/common/values.mojom, when new libmojo // (440057 or later) is rolled to ARC repository. string? json_value@3; }; struct BluetoothSdpRecord { map attrs; }; struct BluetoothCreateSdpRecordResult { BluetoothStatus status; uint32 service_handle; }; // Next Method ID: 43 interface BluetoothHost { EnableAdapter@0() => (BluetoothAdapterState state); DisableAdapter@1() => (BluetoothAdapterState state); GetAdapterProperty@2(BluetoothPropertyType type); SetAdapterProperty@3(BluetoothProperty property); GetRemoteDeviceProperty@4(BluetoothAddress remote_addr, BluetoothPropertyType type); SetRemoteDeviceProperty@5(BluetoothAddress remote_addr, BluetoothProperty property); GetRemoteServiceRecord@6(BluetoothAddress remote_addr, BluetoothUUID uuid); GetRemoteServices@7(BluetoothAddress remote_addr); StartDiscovery@8(); CancelDiscovery@9(); CreateBond@10(BluetoothAddress addr, int32 transport); RemoveBond@11(BluetoothAddress addr); CancelBond@12(BluetoothAddress addr); GetConnectionState@13(BluetoothAddress addr) => (bool connected); // Bluetooth Gatt Client functions [MinVersion=1] StartLEScan@14(); [MinVersion=1] StopLEScan@15(); [MinVersion=1] ConnectLEDevice@16(BluetoothAddress remote_addr); [MinVersion=1] DisconnectLEDevice@17(BluetoothAddress remote_addr); [MinVersion=1] SearchService@18(BluetoothAddress remote_addr); [MinVersion=1] GetGattDB@19(BluetoothAddress remote_addr); [MinVersion=1] StartLEListen@20() => (BluetoothGattStatus status); [MinVersion=1] StopLEListen@21() => (BluetoothGattStatus status); [MinVersion=1] ReadGattCharacteristic@22(BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id) => (BluetoothGattValue value); [MinVersion=1] WriteGattCharacteristic@23(BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id, BluetoothGattValue value) => (BluetoothGattStatus status); [MinVersion=1] ReadGattDescriptor@24(BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id, BluetoothGattID desc_id) => (BluetoothGattValue value); [MinVersion=1] WriteGattDescriptor@25(BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id, BluetoothGattID desc_id, BluetoothGattValue value) => (BluetoothGattStatus status); [MinVersion=1] RegisterForGattNotification@26( BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id) => (BluetoothGattStatus status); [MinVersion=1] DeregisterForGattNotification@27( BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id) => (BluetoothGattStatus status); [MinVersion=1] ReadRemoteRssi@28(BluetoothAddress remote_addr) => (int32 rssi); [MinVersion=2] OpenBluetoothSocket@29() => (handle sock); // Bluetooth Gatt Server functions // Copied from Android API // https://source.android.com/devices/halref/bt__gatt__server_8h.html [MinVersion=3] AddService@30(BluetoothGattServiceID service_id, int32 num_handles) => (int32 service_handle); [MinVersion=3] AddCharacteristic@31(int32 service_handle, BluetoothUUID uuid, int32 properties, int32 permissions) => (int32 characteristic_handle); [MinVersion=3] AddDescriptor@32(int32 service_handle, BluetoothUUID uuid, int32 permissions) => (int32 descriptor_handle); [MinVersion=3] StartService@33(int32 service_handle) => (BluetoothGattStatus status); [MinVersion=3] StopService@34(int32 service_handle) => (BluetoothGattStatus status); [MinVersion=3] DeleteService@35(int32 service_handle) => (BluetoothGattStatus status); [MinVersion=3] SendIndication@36(int32 attribute_handle, BluetoothAddress address, bool confirm, array value) => (BluetoothGattStatus status); // Bluetooth SDP functions [MinVersion=5] GetSdpRecords@37(BluetoothAddress remote_addr, BluetoothUUID target_uuid); [MinVersion=5] CreateSdpRecord@38(BluetoothSdpRecord record) => (BluetoothCreateSdpRecordResult result); [MinVersion=5] RemoveSdpRecord@39(uint32 service_handle) => (BluetoothStatus status); // Multi-advertisement functions [MinVersion=6] ReserveAdvertisementHandle@40() => (BluetoothGattStatus status, int32 adv_handle); [MinVersion=6] BroadcastAdvertisement@41(int32 adv_handle, BluetoothAdvertisement adv) => (BluetoothGattStatus status); [MinVersion=6] ReleaseAdvertisementHandle@42(int32 adv_handle) => (BluetoothGattStatus status); }; // Next Method ID: 18 interface BluetoothInstance { Init@0(BluetoothHost host_ptr); OnAdapterProperties@1(BluetoothStatus status, array properties); OnRemoteDeviceProperties@2(BluetoothStatus status, BluetoothAddress address, array properties); OnDeviceFound@3(array properties); OnDiscoveryStateChanged@4(BluetoothDiscoveryState state); OnBondStateChanged@5(BluetoothStatus status, BluetoothAddress remote_addr, BluetoothBondState state); OnAclStateChanged@6(BluetoothStatus status, BluetoothAddress remote_addr, BluetoothAclState state); // Bluetooth Gatt Client callbacks [MinVersion=1] OnLEDeviceFound@7(BluetoothAddress addr, int32 rssi, array adv_data); [MinVersion=1] OnLEConnectionStateChange@8(BluetoothAddress remote_addr, bool connected); [MinVersion=4] OnLEDeviceAddressChange@16(BluetoothAddress old_addr, BluetoothAddress new_addr); [MinVersion=1] OnSearchComplete@9(BluetoothAddress remote_addr, BluetoothGattStatus status); [MinVersion=1] OnGetGattDB@10(BluetoothAddress remote_addr, array db); [MinVersion=1] OnServicesRemoved@11(BluetoothAddress remote_addr, uint16 start_handle, uint16 end_handle); [MinVersion=1] OnServicesAdded@12(BluetoothAddress remote_addr, array db); [MinVersion=2] OnGattNotify@13(BluetoothAddress remote_addr, BluetoothGattServiceID service_id, BluetoothGattID char_id, bool is_notify, array value); // Bluetooth Gatt Server functions [MinVersion=3] RequestGattRead@14(BluetoothAddress address, int32 attribute_handle, int32 offset, bool is_long) => (BluetoothGattStatus status, array value); [MinVersion=3] RequestGattWrite@15(BluetoothAddress address, int32 attribute_handle, int32 offset, array value) => (BluetoothGattStatus status); // Bluetooth SDP function [MinVersion=5] OnGetSdpRecords@17(BluetoothStatus status, BluetoothAddress remove_addr, BluetoothUUID target_uuid, array records); };