Commit bc2ad760 authored by jamuraa's avatar jamuraa Committed by Commit bot

Update constants to MACRO_STYLE

BUG=418696

Review URL: https://codereview.chromium.org/643213002

Cr-Commit-Position: refs/heads/master@{#299349}
parent 45bf27b1
......@@ -39,24 +39,24 @@ class BluetoothGattCharacteristic {
// Values representing the possible properties of a characteristic, which
// define how the characteristic can be used. Each of these properties serve
// a role as defined in the Bluetooth Specification.
// |kPropertyExtendedProperties| is a special property that, if present,
// |PROPERTY_EXTENDED_PROPERTIES| is a special property that, if present,
// indicates that there is a characteristic descriptor (namely the
// "Characteristic Extended Properties Descriptor" with UUID 0x2900) that
// contains additional properties pertaining to the characteristic.
// The properties "ReliableWrite| and |WriteAuxiliaries| are retrieved from
// that characteristic.
enum Property {
kPropertyNone = 0,
kPropertyBroadcast = 1 << 0,
kPropertyRead = 1 << 1,
kPropertyWriteWithoutResponse = 1 << 2,
kPropertyWrite = 1 << 3,
kPropertyNotify = 1 << 4,
kPropertyIndicate = 1 << 5,
kPropertyAuthenticatedSignedWrites = 1 << 6,
kPropertyExtendedProperties = 1 << 7,
kPropertyReliableWrite = 1 << 8,
kPropertyWritableAuxiliaries = 1 << 9
PROPERTY_NONE = 0,
PROPERTY_BROADCAST = 1 << 0,
PROPERTY_READ = 1 << 1,
PROPERTY_WRITE_WITHOUT_RESPONSE = 1 << 2,
PROPERTY_WRITE = 1 << 3,
PROPERTY_NOTIFY = 1 << 4,
PROPERTY_INDICATE = 1 << 5,
PROPERTY_AUTHENTICATED_SIGNED_WRITES = 1 << 6,
PROPERTY_EXTENDED_PROPERTIES = 1 << 7,
PROPERTY_RELIABLE_WRITE = 1 << 8,
PROPERTY_WRITABLE_AUXILIARIES = 1 << 9
};
typedef uint32 Properties;
......@@ -66,17 +66,17 @@ class BluetoothGattCharacteristic {
// value permissions are left up to the higher-level profile.
//
// Attribute permissions are distinct from the characteristic properties. For
// example, a characteristic may have the property |kPropertyRead| to make
// example, a characteristic may have the property |PROPERTY_READ| to make
// clients know that it is possible to read the characteristic value and have
// the permission |kPermissionReadEncrypted| to require a secure connection.
// the permission |PERMISSION_READ_ENCRYPTED| to require a secure connection.
// It is up to the application to properly specify the permissions and
// properties for a local characteristic.
enum Permission {
kPermissionNone = 0,
kPermissionRead = 1 << 0,
kPermissionWrite = 1 << 1,
kPermissionReadEncrypted = 1 << 2,
kPermissionWriteEncrypted = 1 << 3
PERMISSION_NONE = 0,
PERMISSION_READ = 1 << 0,
PERMISSION_WRITE = 1 << 1,
PERMISSION_READ_ENCRYPTED = 1 << 2,
PERMISSION_WRITE_ENCRYPTED = 1 << 3
};
typedef uint32 Permissions;
......@@ -106,11 +106,11 @@ class BluetoothGattCharacteristic {
// BluetoothGattService instance, in which case the delegate will handle read
// and write requests.
//
// NOTE: Don't explicitly set |kPropertyExtendedProperties| in |properties|.
// NOTE: Don't explicitly set |PROPERTY_EXTENDED_PROPERTIES| in |properties|.
// Instead, create and add a BluetoothGattDescriptor that represents the
// "Characteristic Extended Properties" descriptor and this will automatically
// set the correspoding bit in the characteristic's properties field. If
// |properties| has |kPropertyExtendedProperties| set, it will be ignored.
// |properties| has |PROPERTY_EXTENDED_PROPERTIES| set, it will be ignored.
static BluetoothGattCharacteristic* Create(const BluetoothUUID& uuid,
const std::vector<uint8>& value,
Properties properties,
......
......@@ -1045,19 +1045,19 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) {
BluetoothGattCharacteristic *characteristic = service->GetCharacteristic(
fake_bluetooth_gatt_characteristic_client_->
GetBodySensorLocationPath().value());
EXPECT_EQ(BluetoothGattCharacteristic::kPropertyRead,
EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_READ,
characteristic->GetProperties());
characteristic = service->GetCharacteristic(
fake_bluetooth_gatt_characteristic_client_->
GetHeartRateControlPointPath().value());
EXPECT_EQ(BluetoothGattCharacteristic::kPropertyWrite,
EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_WRITE,
characteristic->GetProperties());
characteristic = service->GetCharacteristic(
fake_bluetooth_gatt_characteristic_client_->
GetHeartRateMeasurementPath().value());
EXPECT_EQ(BluetoothGattCharacteristic::kPropertyNotify,
EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_NOTIFY,
characteristic->GetProperties());
}
......
......@@ -112,31 +112,31 @@ BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const {
GetProperties(object_path_);
DCHECK(properties);
Properties props = kPropertyNone;
Properties props = PROPERTY_NONE;
const std::vector<std::string>& flags = properties->flags.value();
for (std::vector<std::string>::const_iterator iter = flags.begin();
iter != flags.end();
++iter) {
if (*iter == bluetooth_gatt_characteristic::kFlagBroadcast)
props |= kPropertyBroadcast;
props |= PROPERTY_BROADCAST;
if (*iter == bluetooth_gatt_characteristic::kFlagRead)
props |= kPropertyRead;
props |= PROPERTY_READ;
if (*iter == bluetooth_gatt_characteristic::kFlagWriteWithoutResponse)
props |= kPropertyWriteWithoutResponse;
props |= PROPERTY_WRITE_WITHOUT_RESPONSE;
if (*iter == bluetooth_gatt_characteristic::kFlagWrite)
props |= kPropertyWrite;
props |= PROPERTY_WRITE;
if (*iter == bluetooth_gatt_characteristic::kFlagNotify)
props |= kPropertyNotify;
props |= PROPERTY_NOTIFY;
if (*iter == bluetooth_gatt_characteristic::kFlagIndicate)
props |= kPropertyIndicate;
props |= PROPERTY_INDICATE;
if (*iter == bluetooth_gatt_characteristic::kFlagAuthenticatedSignedWrites)
props |= kPropertyAuthenticatedSignedWrites;
props |= PROPERTY_AUTHENTICATED_SIGNED_WRITES;
if (*iter == bluetooth_gatt_characteristic::kFlagExtendedProperties)
props |= kPropertyExtendedProperties;
props |= PROPERTY_EXTENDED_PROPERTIES;
if (*iter == bluetooth_gatt_characteristic::kFlagReliableWrite)
props |= kPropertyReliableWrite;
props |= PROPERTY_RELIABLE_WRITE;
if (*iter == bluetooth_gatt_characteristic::kFlagWritableAuxiliaries)
props |= kPropertyWritableAuxiliaries;
props |= PROPERTY_WRITABLE_AUXILIARIES;
}
return props;
......@@ -146,7 +146,7 @@ device::BluetoothGattCharacteristic::Permissions
BluetoothRemoteGattCharacteristicChromeOS::GetPermissions() const {
// TODO(armansito): Once BlueZ defines the permissions, return the correct
// values here.
return kPermissionNone;
return PERMISSION_NONE;
}
bool BluetoothRemoteGattCharacteristicChromeOS::IsNotifying() const {
......
......@@ -72,7 +72,7 @@ device::BluetoothGattCharacteristic::Permissions
BluetoothRemoteGattDescriptorChromeOS::GetPermissions() const {
// TODO(armansito): Once BlueZ defines the permissions, return the correct
// values here.
return device::BluetoothGattCharacteristic::kPermissionNone;
return device::BluetoothGattCharacteristic::PERMISSION_NONE;
}
void BluetoothRemoteGattDescriptorChromeOS::ReadRemoteDescriptor(
......
......@@ -61,24 +61,24 @@ const char kTestServiceUuid1[] = "5678";
const char kTestCharacteristicId0[] = "char_id0";
const char kTestCharacteristicUuid0[] = "1211";
const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties0 =
BluetoothGattCharacteristic::kPropertyBroadcast |
BluetoothGattCharacteristic::kPropertyRead |
BluetoothGattCharacteristic::kPropertyWriteWithoutResponse |
BluetoothGattCharacteristic::kPropertyIndicate;
BluetoothGattCharacteristic::PROPERTY_BROADCAST |
BluetoothGattCharacteristic::PROPERTY_READ |
BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE |
BluetoothGattCharacteristic::PROPERTY_INDICATE;
const uint8 kTestCharacteristicDefaultValue0[] = {0x01, 0x02, 0x03, 0x04, 0x05};
const char kTestCharacteristicId1[] = "char_id1";
const char kTestCharacteristicUuid1[] = "1212";
const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties1 =
BluetoothGattCharacteristic::kPropertyRead |
BluetoothGattCharacteristic::kPropertyWrite |
BluetoothGattCharacteristic::kPropertyNotify;
BluetoothGattCharacteristic::PROPERTY_READ |
BluetoothGattCharacteristic::PROPERTY_WRITE |
BluetoothGattCharacteristic::PROPERTY_NOTIFY;
const uint8 kTestCharacteristicDefaultValue1[] = {0x06, 0x07, 0x08};
const char kTestCharacteristicId2[] = "char_id2";
const char kTestCharacteristicUuid2[] = "1213";
const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties2 =
BluetoothGattCharacteristic::kPropertyNone;
BluetoothGattCharacteristic::PROPERTY_NONE;
// Test descriptor constants.
const char kTestDescriptorId0[] = "desc_id0";
......@@ -153,7 +153,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
BluetoothUUID(kTestCharacteristicUuid0),
false /* is_local */,
kTestCharacteristicProperties0,
BluetoothGattCharacteristic::kPermissionNone));
BluetoothGattCharacteristic::PERMISSION_NONE));
default_value.assign(kTestCharacteristicDefaultValue0,
(kTestCharacteristicDefaultValue0 +
sizeof(kTestCharacteristicDefaultValue0)));
......@@ -165,7 +165,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
BluetoothUUID(kTestCharacteristicUuid1),
false /* is_local */,
kTestCharacteristicProperties1,
BluetoothGattCharacteristic::kPermissionNone));
BluetoothGattCharacteristic::PERMISSION_NONE));
default_value.assign(kTestCharacteristicDefaultValue1,
(kTestCharacteristicDefaultValue1 +
sizeof(kTestCharacteristicDefaultValue1)));
......@@ -177,14 +177,14 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
BluetoothUUID(kTestCharacteristicUuid2),
false /* is_local */,
kTestCharacteristicProperties2,
BluetoothGattCharacteristic::kPermissionNone));
BluetoothGattCharacteristic::PERMISSION_NONE));
desc0_.reset(new testing::NiceMock<MockBluetoothGattDescriptor>(
chrc0_.get(),
kTestDescriptorId0,
BluetoothUUID(kTestDescriptorUuid0),
false /* is_local */,
BluetoothGattCharacteristic::kPermissionNone));
BluetoothGattCharacteristic::PERMISSION_NONE));
default_value.assign(
kTestDescriptorDefaultValue0,
(kTestDescriptorDefaultValue0 + sizeof(kTestDescriptorDefaultValue0)));
......@@ -195,7 +195,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
kTestDescriptorId1,
BluetoothUUID(kTestDescriptorUuid1),
false /* is_local */,
BluetoothGattCharacteristic::kPermissionNone));
BluetoothGattCharacteristic::PERMISSION_NONE));
default_value.assign(
kTestDescriptorDefaultValue1,
(kTestDescriptorDefaultValue1 + sizeof(kTestDescriptorDefaultValue1)));
......@@ -539,32 +539,32 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicProperties) {
.WillRepeatedly(Return(chrc0_.get()));
EXPECT_CALL(*chrc0_, GetProperties())
.Times(12)
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyNone))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyBroadcast))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyRead))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_NONE))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_BROADCAST))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_READ))
.WillOnce(
Return(BluetoothGattCharacteristic::kPropertyWriteWithoutResponse))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyWrite))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyNotify))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyIndicate))
Return(BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_WRITE))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_NOTIFY))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_INDICATE))
.WillOnce(Return(
BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites))
BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES))
.WillOnce(
Return(BluetoothGattCharacteristic::kPropertyExtendedProperties))
.WillOnce(Return(BluetoothGattCharacteristic::kPropertyReliableWrite))
Return(BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES))
.WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE))
.WillOnce(
Return(BluetoothGattCharacteristic::kPropertyWritableAuxiliaries))
Return(BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES))
.WillOnce(Return(
BluetoothGattCharacteristic::kPropertyBroadcast |
BluetoothGattCharacteristic::kPropertyRead |
BluetoothGattCharacteristic::kPropertyWriteWithoutResponse |
BluetoothGattCharacteristic::kPropertyWrite |
BluetoothGattCharacteristic::kPropertyNotify |
BluetoothGattCharacteristic::kPropertyIndicate |
BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites |
BluetoothGattCharacteristic::kPropertyExtendedProperties |
BluetoothGattCharacteristic::kPropertyReliableWrite |
BluetoothGattCharacteristic::kPropertyWritableAuxiliaries));
BluetoothGattCharacteristic::PROPERTY_BROADCAST |
BluetoothGattCharacteristic::PROPERTY_READ |
BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE |
BluetoothGattCharacteristic::PROPERTY_WRITE |
BluetoothGattCharacteristic::PROPERTY_NOTIFY |
BluetoothGattCharacteristic::PROPERTY_INDICATE |
BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES |
BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES |
BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE |
BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES));
ExtensionTestMessageListener listener("ready", true);
listener.set_failure_message("fail");
......
......@@ -54,35 +54,36 @@ void PopulateCharacteristicProperties(
std::vector<apibtle::CharacteristicProperty>* api_properties) {
DCHECK(api_properties && api_properties->empty());
if (properties == BluetoothGattCharacteristic::kPropertyNone)
if (properties == BluetoothGattCharacteristic::PROPERTY_NONE)
return;
if (properties & BluetoothGattCharacteristic::kPropertyBroadcast)
if (properties & BluetoothGattCharacteristic::PROPERTY_BROADCAST)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_BROADCAST);
if (properties & BluetoothGattCharacteristic::kPropertyRead)
if (properties & BluetoothGattCharacteristic::PROPERTY_READ)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_READ);
if (properties & BluetoothGattCharacteristic::kPropertyWriteWithoutResponse) {
if (properties &
BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE) {
api_properties->push_back(
apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE);
}
if (properties & BluetoothGattCharacteristic::kPropertyWrite)
if (properties & BluetoothGattCharacteristic::PROPERTY_WRITE)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_WRITE);
if (properties & BluetoothGattCharacteristic::kPropertyNotify)
if (properties & BluetoothGattCharacteristic::PROPERTY_NOTIFY)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_NOTIFY);
if (properties & BluetoothGattCharacteristic::kPropertyIndicate)
if (properties & BluetoothGattCharacteristic::PROPERTY_INDICATE)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_INDICATE);
if (properties &
BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites) {
BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES) {
api_properties->push_back(
apibtle::CHARACTERISTIC_PROPERTY_AUTHENTICATEDSIGNEDWRITES);
}
if (properties & BluetoothGattCharacteristic::kPropertyExtendedProperties) {
if (properties & BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES) {
api_properties->push_back(
apibtle::CHARACTERISTIC_PROPERTY_EXTENDEDPROPERTIES);
}
if (properties & BluetoothGattCharacteristic::kPropertyReliableWrite)
if (properties & BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE)
api_properties->push_back(apibtle::CHARACTERISTIC_PROPERTY_RELIABLEWRITE);
if (properties & BluetoothGattCharacteristic::kPropertyWritableAuxiliaries) {
if (properties & BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES) {
api_properties->push_back(
apibtle::CHARACTERISTIC_PROPERTY_WRITABLEAUXILIARIES);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment