[Bluetooth] Added logs in methods onEntered and onReturn
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 27 May 2015 10:49:05 +0000 (12:49 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 28 May 2015 09:36:42 +0000 (18:36 +0900)
Change-Id: I422333daff0b546265291035304b51dd1033ab5b
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/bluetooth/bluetooth_class.cc
src/bluetooth/bluetooth_gatt_service.cc
src/bluetooth/bluetooth_health_channel.cc
src/bluetooth/bluetooth_health_profile_handler.cc
src/bluetooth/bluetooth_instance.cc
src/bluetooth/bluetooth_le_adapter.cc
src/bluetooth/bluetooth_le_device.cc

index 2eb8f52..6ac9f75 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "bluetooth_class.h"
+#include "common/logger.h"
 
 #include <map>
 
@@ -123,6 +124,7 @@ std::map<bt_major_service_class_e, unsigned long> g_service_enum_map = {
 
 unsigned long BluetoothClass::GetMajorValue(bt_major_device_class_e major)
 {
+  LoggerD("Enter");
   auto iter = g_major_enum_map.find(major);
   if (iter != g_major_enum_map.end()) {
     return iter->second;
@@ -133,6 +135,7 @@ unsigned long BluetoothClass::GetMajorValue(bt_major_device_class_e major)
 
 unsigned long BluetoothClass::GetMinorValue(bt_minor_device_class_e minor)
 {
+  LoggerD("Enter");
   auto iter = g_minor_enum_map.find(minor);
   if (iter != g_minor_enum_map.end()) {
     return iter->second;
@@ -143,6 +146,7 @@ unsigned long BluetoothClass::GetMinorValue(bt_minor_device_class_e minor)
 
 std::vector<unsigned long> BluetoothClass::getServiceValues(int serviceMask)
 {
+  LoggerD("Enter");
   std::vector<unsigned long> ret;
   for (auto iter = g_service_enum_map.begin(); iter != g_service_enum_map.end(); iter++) {
     if (iter->first & serviceMask) {
index 090174b..f6f8d7f 100644 (file)
@@ -179,6 +179,7 @@ PlatformResult BluetoothGATTService::GetServicesHelper(bt_gatt_h handle,
         return true;
       }, static_cast<void*>(&user_data));
   if (BT_ERROR_NONE != ret) {
+    LoggerE("Failed bt_gatt_service_foreach_included_services() (%d)", ret);
     return util::GetBluetoothError(ret, "Failed to set a service's GATT callback");
   }
 
@@ -258,6 +259,7 @@ PlatformResult BluetoothGATTService::GetCharacteristicsHelper(bt_gatt_h handle,
             }, static_cast<void*>(&desc_array));
         if (BT_ERROR_NONE != ret) {
           *platform_result = util::GetBluetoothError(ret, "Failed to get descriptors");
+          LoggerE("Failed bt_gatt_characteristic_foreach_descriptors() (%d)", ret);
           return false;
         }
 
@@ -291,6 +293,7 @@ PlatformResult BluetoothGATTService::GetCharacteristicsHelper(bt_gatt_h handle,
     return platform_result;
   }
   if (BT_ERROR_NONE != ret) {
+    LoggerE("Failed (%d)", ret);
     return util::GetBluetoothError(ret, "Failed while getting characteristic");
   }
 
index 695ec55..9826666 100644 (file)
@@ -82,6 +82,7 @@ void BluetoothHealthChannel::SendData(const picojson::value& data, picojson::obj
 void BluetoothHealthChannel::ToJson(unsigned int channel,
                                     bt_hdp_channel_type_e type,
                                     picojson::object* out) {
+  LoggerD("Enter");
   const char* type_str = "UNKNOWN";
 
   switch (type) {
@@ -108,6 +109,7 @@ void BluetoothHealthChannel::ToJson(unsigned int channel,
                                     bt_device_info_s* device_info,
                                     const char* app_id,
                                     picojson::object* out) {
+  LoggerD("Enter");
   ToJson(channel, type, out);
   auto& device = out->insert(
       std::make_pair(kPeer, picojson::value(picojson::object()))) .first->second.get<picojson::object>();
index ae1bd31..fb0ff0f 100644 (file)
@@ -46,6 +46,7 @@ const std::string kChangeCallback = "BluetoothHealthChannelChangeCallback";
 BluetoothHealthProfileHandler::BluetoothHealthProfileHandler(BluetoothInstance& instance)
     : instance_(instance) {
   // initialize listeners
+  LoggerD("Entered");
   if (BT_ERROR_NONE != bt_hdp_set_connection_state_changed_cb(OnConnected, OnDisconnected, this)) {
     LoggerE("bt_hdp_set_connection_state_changed_cb() failed");
   }
@@ -56,6 +57,7 @@ BluetoothHealthProfileHandler::BluetoothHealthProfileHandler(BluetoothInstance&
 }
 
 BluetoothHealthProfileHandler::~BluetoothHealthProfileHandler() {
+  LoggerD("Entered");
   bt_hdp_unset_connection_state_changed_cb();
   bt_hdp_unset_data_received_cb();
 
@@ -174,7 +176,7 @@ void BluetoothHealthProfileHandler::OnDisconnected(int result,
   BluetoothHealthProfileHandler* object = static_cast<BluetoothHealthProfileHandler*>(user_data);
 
   if (!object) {
-    LoggerW("user_data is NULL");
+    LoggerE("user_data is NULL");
     return;
   }
 
@@ -199,7 +201,7 @@ void BluetoothHealthProfileHandler::OnDataReceived(unsigned int channel,
   BluetoothHealthProfileHandler* object = static_cast<BluetoothHealthProfileHandler*>(user_data);
 
   if (!object) {
-    LoggerW("user_data is NULL");
+    LoggerE("user_data is NULL");
     return;
   }
 
index 5ac3edf..4cbf580 100644 (file)
@@ -169,12 +169,14 @@ const char* JSON_DATA = "args";
 } // namespace
 
 void BluetoothInstance::AsyncResponse(double callback_handle, const std::shared_ptr<picojson::value>& response) {
+  LoggerD("Entered");
   common::TaskQueue::GetInstance().Async<picojson::value>([this, callback_handle](const std::shared_ptr<picojson::value>& response) {
     SyncResponse(callback_handle, response);
   }, response);
 }
 
 void BluetoothInstance::AsyncResponse(double callback_handle, const PlatformResult& result) {
+  LoggerD("Entered");
   std::shared_ptr<picojson::value> response =
       std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
 
@@ -190,23 +192,27 @@ void BluetoothInstance::AsyncResponse(double callback_handle, const PlatformResu
 }
 
 void BluetoothInstance::SyncResponse(double callback_handle, const std::shared_ptr<picojson::value>& response) {
+  LoggerD("Entered");
   auto& obj = response->get<picojson::object>();
   obj[JSON_CALLBACK_ID] = picojson::value(callback_handle);
   PostMessage(response->serialize().c_str());
 }
 
 void BluetoothInstance::FireEvent(const std::string& event, picojson::value& value) {
+  LoggerD("Entered");
   auto& obj = value.get<picojson::object>();
   obj[JSON_LISTENER_ID] = picojson::value(event);
   PostMessage(value.serialize().c_str());
 }
 
 void BluetoothInstance::FireEvent(const std::string& event, const picojson::value& value) {
+  LoggerD("Entered");
   picojson::value v{value};
   FireEvent(event, v);
 }
 
 void BluetoothInstance::FireEvent(const std::string& event, const std::shared_ptr<picojson::value>& value) {
+  LoggerD("Entered");
   FireEvent(event, *value.get());
 }
 
index d51ac3d..ca28988 100644 (file)
@@ -75,6 +75,7 @@ class BluetoothLEServiceData : public ParsedDataHolder {
  private:
   static bool ParseUUID(const picojson::value& obj,
                         BluetoothLEServiceData* out) {
+    LoggerD("Entered");
     const auto& uuid = obj.get("serviceuuid");
     if (uuid.is<std::string>()) {
       out->uuid_ = uuid.get<std::string>();
@@ -87,6 +88,7 @@ class BluetoothLEServiceData : public ParsedDataHolder {
 
   static bool ParseData(const picojson::value& obj,
                         BluetoothLEServiceData* out) {
+    LoggerD("Entered");
     const auto& data = obj.get("data");
     if (data.is<std::string>()) {
       out->data_ = data.get<std::string>();
@@ -118,6 +120,7 @@ class BluetoothLEManufacturerData : public ParsedDataHolder {
 
   static bool Construct(const picojson::value& obj,
                         BluetoothLEManufacturerData* out) {
+    LoggerD("Entered");
     if (!obj.is<picojson::object>() ||
         !ParseId(obj, out) ||
         !ParseData(obj, out)) {
@@ -132,6 +135,7 @@ class BluetoothLEManufacturerData : public ParsedDataHolder {
  private:
   static bool ParseId(const picojson::value& obj,
                       BluetoothLEManufacturerData* out) {
+    LoggerD("Entered");
     const auto& id = obj.get("id");
     if (id.is<std::string>()) {
       try {
@@ -149,6 +153,7 @@ class BluetoothLEManufacturerData : public ParsedDataHolder {
 
   static bool ParseData(const picojson::value& obj,
                         BluetoothLEManufacturerData* out) {
+    LoggerD("Entered");
     const auto& data = obj.get("data");
     if (data.is<std::string>()) {
       out->data_ = data.get<std::string>();
@@ -202,6 +207,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool Construct(const picojson::value& obj,
                         BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     if (!obj.is<picojson::object>() ||
         !ParseIncludeName(obj, out) ||
         !ParseServiceUUIDs(obj, out) ||
@@ -221,6 +227,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
  private:
   static bool ParseIncludeName(const picojson::value& obj,
                                BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& include_name = obj.get("includeName");
     if (include_name.is<bool>()) {
       out->include_name_ = include_name.get<bool>();
@@ -233,6 +240,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseServiceUUIDs(const picojson::value& obj,
                                 BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& service_uuids = obj.get("serviceuuids");
     if (service_uuids.is<picojson::array>()) {
       for (const auto& i : service_uuids.get<picojson::array>()) {
@@ -251,6 +259,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseSolicitationUUIDs(const picojson::value& obj,
                                      BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& solicitation_uuids = obj.get("solicitationuuids");
     if (solicitation_uuids.is<picojson::array>()) {
       for (const auto& i : solicitation_uuids.get<picojson::array>()) {
@@ -269,6 +278,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseAppearance(const picojson::value& obj,
                               BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& appearance = obj.get("appearance");
     if (appearance.is<double>()) {
       out->appearance_ = static_cast<decltype(appearance_)>(appearance.get<double>());
@@ -281,6 +291,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseIncludeTxPowerLevel(const picojson::value& obj,
                                        BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& include_tx_power_level = obj.get("includeTxPowerLevel");
     if (include_tx_power_level.is<bool>()) {
       out->include_tx_power_level_ = include_tx_power_level.get<bool>();
@@ -293,6 +304,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseServiceData(const picojson::value& obj,
                                BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& service_data = obj.get("serviceData");
     if (service_data.is<picojson::array>()) {
       for (const auto& i : service_data.get<picojson::array>()) {
@@ -312,6 +324,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder {
 
   static bool ParseManufacturerData(const picojson::value& obj,
                                     BluetoothLEAdvertiseData* out) {
+    LoggerD("Entered");
     const auto& manufacturer_data = obj.get("manufacturerData");
     BluetoothLEManufacturerData data;
     if (BluetoothLEManufacturerData::Construct(manufacturer_data, &data)) {
@@ -395,6 +408,7 @@ BluetoothLEAdapter::BluetoothLEAdapter(BluetoothInstance& instance)
 }
 
 BluetoothLEAdapter::~BluetoothLEAdapter() {
+  LoggerD("Entered");
   bt_adapter_le_unset_state_changed_cb();
   if (scanning_) {
     bt_adapter_le_stop_scan();
@@ -475,6 +489,7 @@ void BluetoothLEAdapter::StartAdvertise(const picojson::value& data, picojson::o
     } else if ("SCAN_RESPONSE" == str_packet_type) {
       packet_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE;
     } else {
+      LoggerE("Fail: json_packet_type.get");
       ReportError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Unexpected value of packet type"), &out);
       return;
     }
index 655b49e..1bde58e 100644 (file)
@@ -57,6 +57,7 @@ BluetoothLEDevice::BluetoothLEDevice(BluetoothInstance& instance,
     : instance_(instance),
       service_(service),
       is_listener_set_(false) {
+  LoggerD("Entered");
   int ret = bt_gatt_set_connection_state_changed_cb(GattConnectionState, this);
   if (BT_ERROR_NONE != ret && BT_ERROR_ALREADY_DONE != ret) {
     LoggerE("Can't add connection state listener: %d", ret);
@@ -64,6 +65,7 @@ BluetoothLEDevice::BluetoothLEDevice(BluetoothInstance& instance,
 }
 
 BluetoothLEDevice::~BluetoothLEDevice() {
+  LoggerD("Entered");
   int ret = bt_gatt_unset_connection_state_changed_cb();
   if (ret != BT_ERROR_NONE) {
     LoggerW("Failed to unset listener: %d", ret);
@@ -120,6 +122,7 @@ static void ManufacturerToJson(int manufacturer_id, char *manufacturer_data,
 PlatformResult BluetoothLEDevice::ToJson(
     bt_adapter_le_device_scan_result_info_s* info,
     picojson::object* le_device) {
+
   LoggerD("Entered");
 
   le_device->insert(