Move bt_bdaddr_t operator to global header file
This is to simplify bt_bdaddr_t handling
Test: compilation
Change-Id: I06ac6c2f0402ed13a2c04f86494d3c4fd0165963
diff --git a/service/gatt_server.cc b/service/gatt_server.cc
index e4a6ec5..79d9c35 100644
--- a/service/gatt_server.cc
+++ b/service/gatt_server.cc
@@ -18,24 +18,13 @@
#include "service/common/bluetooth/util/address_helper.h"
#include "service/logging_helpers.h"
+#include "stack/include/bt_types.h"
using std::lock_guard;
using std::mutex;
namespace bluetooth {
-namespace {
-
-bool operator==(const bt_bdaddr_t& lhs, const bt_bdaddr_t& rhs) {
- return memcmp(&lhs, &rhs, sizeof(lhs)) == 0;
-}
-
-bool operator!=(const bt_bdaddr_t& lhs, const bt_bdaddr_t& rhs) {
- return !(lhs == rhs);
-}
-
-} // namespace
-
// GattServer implementation
// ========================================================
diff --git a/stack/include/bt_types.h b/stack/include/bt_types.h
index 5540a7e..8ccd48a 100644
--- a/stack/include/bt_types.h
+++ b/stack/include/bt_types.h
@@ -540,6 +540,26 @@
typedef uint8_t BD_ADDR[BD_ADDR_LEN]; /* Device address */
typedef uint8_t* BD_ADDR_PTR; /* Pointer to Device Address */
+#ifdef __cplusplus
+#include <base/strings/stringprintf.h>
+#include <hardware/bluetooth.h>
+
+inline bool operator==(const bt_bdaddr_t& lhs, const bt_bdaddr_t& rhs) {
+ return memcmp(&lhs, &rhs, sizeof(lhs)) == 0;
+}
+
+inline bool operator!=(const bt_bdaddr_t& lhs, const bt_bdaddr_t& rhs) {
+ return !(lhs == rhs);
+}
+
+inline std::ostream& operator<<(std::ostream& os, const bt_bdaddr_t& a) {
+ os << base::StringPrintf("%02x:%02x:%02x:%02x:%02x:%02x", a.address[0],
+ a.address[1], a.address[2], a.address[3],
+ a.address[4], a.address[5]);
+ return os;
+}
+#endif
+
#define AMP_KEY_TYPE_GAMP 0
#define AMP_KEY_TYPE_WIFI 1
#define AMP_KEY_TYPE_UWB 2