Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57206644 authored by Arman Uguray's avatar Arman Uguray
Browse files

service: Add various LE advertising constants

Added several constants that are used in LE advertising. Added
constants for the exposed EIR fields here as well so that clients
can use it.

Bug: 23793954
Change-Id: Ib6a97d6beb1a31c9c3ea7ed468167dab627d7d32
parent f8ff4126
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -22,9 +22,51 @@ namespace bluetooth {
// BLE operations.
enum BLEStatus {
  BLE_STATUS_SUCCESS = 0,
  BLE_STATUS_ADV_ERROR_DATA_TOO_LARGE = 1,
  BLE_STATUS_ADV_ERROR_TOO_MANY_ADVERTISERS = 2,
  BLE_STATUS_ADV_ERROR_ALREADY_STARTED = 3,
  BLE_STATUS_ADV_ERROR_FEATURE_UNSUPPORTED = 5,
  BLE_STATUS_FAILURE = 0x101,

  // TODO(armansito): Add ATT protocol error codes
};

// Advertising interval for different modes.
const int kAdvertisingIntervalHighMs = 1000;
const int kAdvertisingIntervalMediumMs = 250;
const int kAdvertisingIntervalLowMs = 100;

// Add some randomness to the advertising min/max interval so the controller can
// do some optimization.
// TODO(armansito): I took this directly from packages/apps/Bluetooth but based
// on code review comments this constant and the accompanying logic doesn't make
// sense. Let's remove this constant and figure out how to properly calculate
// the Max. Adv. Interval. (See http://b/24344075).
const int kAdvertisingIntervalDeltaUnit = 10;

// Advertising types (ADV_IND, ADV_SCAN_IND, etc.) that are exposed to
// applications.
const int kAdvertisingEventTypeConnectable = 0;
const int kAdvertisingEventTypeScannable = 2;
const int kAdvertisingEventTypeNonConnectable = 3;

// Advertising channels. These should be kept the same as those defined in the
// stack.
const int kAdvertisingChannel37 = (1 << 0);
const int kAdvertisingChannel38 = (1 << 1);
const int kAdvertisingChannel39 = (1 << 2);
const int kAdvertisingChannelAll =
    (kAdvertisingChannel37 | kAdvertisingChannel38 | kAdvertisingChannel39);

// Various Extended Inquiry Response fields types that are used for advertising
// data fields as defined in the Core Specification Supplement.
const uint8_t kEIRTypeFlags = 0x01;
const uint8_t kEIRTypeIncomplete16BitUUIDs = 0x02;
const uint8_t kEIRTypeComplete16BitUUIDs = 0x03;
const uint8_t kEIRTypeIncomplete32BitUUIDs = 0x04;
const uint8_t kEIRTypeComplete32BitUUIDs = 0x05;
const uint8_t kEIRTypeIncomplete128BitUUIDs = 0x06;
const uint8_t kEIRTypeComplete128BitUUIDs = 0x07;
const uint8_t kEIRTypeManufacturerSpecificData = 0xFF;

}  // namespace bluetooth