<< "Failed for UUID: " << std::get<Format128>(uuid) << " expected: ("
<< std::get<Format128>(uuid) << ")"
<< " got: (" << uuid_obj->uuid_128_bit;
+ EXPECT_EQ(uuid_obj->uuid_in_source_format, std::get<StringInit>(uuid))
+ << "Failed for UUID: " << std::get<Format128>(uuid) << " expected: ("
+ << std::get<StringInit>(uuid) << ")"
+ << " got: (" << uuid_obj->uuid_in_source_format;
}
}
namespace bluetooth {
-UUID::UUID(std::string&& uuid_128_bit) : uuid_128_bit{uuid_128_bit} {
- ScopeLogger("Input: %s", uuid_128_bit.c_str());
+UUID::UUID(const std::string& uuid_in_source_format, std::string&& uuid_128_bit)
+ : uuid_in_source_format{uuid_in_source_format}, uuid_128_bit{std::move(uuid_128_bit)} {
+ ScopeLogger("UUID in source format: %s; 128 bit UUID: %s", uuid_in_source_format.c_str(),
+ uuid_128_bit.c_str());
}
optional<UUID> UUID::create(const std::string& uuid) {
return NO_UUID;
}
- return UUID{std::move(uuid_128_bit)};
+ return UUID{uuid, std::move(uuid_128_bit)};
}
optional<UUID> UUID::createFromGatt(const bt_gatt_h gatt_handle) {
std::string ShortestPossibleFormat() const;
bool operator==(const UUID&) const;
+
+ /*
+ * Some legacy functions, i.e. implementation of BluetoothLEDevice::getService(),
+ * work in the following manner:
+ * 1. the user passes them a UUID, in any acceptable format, e.g.: "aBcD"
+ * 2. the function performs requested operations using the passed UUID
+ * 3. the function creates an object, e.g. BlueoothGATTService, with the UUID
+ * passed by the user.
+ *
+ * As user may expect an identical UUID in the created object, identical to
+ * the one he passed to the function, we need to store the original format.
+ */
+ const std::string uuid_in_source_format;
/*
* Hexadecimal letter digits are always stored in lower case.
*/
/*
* These functions don't validate passed arguments.
*/
- UUID(std::string&& uuid_128_bit);
+ UUID(const std::string& uuid_in_source_format, std::string&& uuid_128_bit);
static std::string To128Bit(const std::string& uuid);
enum class Format : int { UUID_16_BIT, UUID_32_BIT, UUID_128_BIT, UUID_INVALID };