[Bluetooth][OTP-Client] Handle GATT operations for OTP
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-request-handler.c
index c017876..162e94a 100644 (file)
@@ -2359,6 +2359,54 @@ int __bt_bluez_request(int function_name,
                result = bt_otp_server_deinit(request_id);
                break;
        }
+       case BT_OTP_READ_VALUE: {
+               char *handle;
+               char *data = NULL;
+               guint data_len = 0;
+
+               char *sender = NULL;
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               data_len = g_variant_get_size(in_param1);
+               data = (char *)g_variant_get_data(in_param1);
+
+               handle = g_strndup(data, data_len);
+               BT_DBG("Read OTP Characteristic Value [%s]", handle);
+
+               result = _bt_otp_read_characteristic_value(request_id, sender, handle);
+
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("Reading OTP Characteristic Value failed result [%d]", result);
+                       g_array_append_vals(*out_param1, handle, data_len);
+               }
+               if (handle)
+                       g_free(handle);
+               break;
+       }
+       case BT_OTP_ENABLE_NOTIFICATION: {
+               char *handle;
+               char *data = NULL;
+               guint data_len = 0;
+
+               char *sender = NULL;
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               data_len = g_variant_get_size(in_param1);
+               data = (char *)g_variant_get_data(in_param1);
+
+               handle = g_strndup(data, data_len);
+               BT_DBG("OTP Control point CCCD handle [%s]", handle);
+
+               result = _bt_otp_enable_notification(request_id, sender, handle);
+
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("Enabling OTP CCCD failed result [%d]", result);
+                       g_array_append_vals(*out_param1, handle, data_len);
+               }
+               if (handle)
+                       g_free(handle);
+               break;
+       }
        default:
                result = BLUETOOTH_ERROR_INTERNAL;
                break;
@@ -3205,6 +3253,8 @@ gboolean __bt_service_check_privilege(int function_name,
        /* OTP Server */
        case BT_OTP_SERVER_INIT:
        case BT_OTP_SERVER_DEINIT:
+       case BT_OTP_READ_VALUE:
+       case BT_OTP_ENABLE_NOTIFICATION:
 
        case BT_MAP_CREATE_SESSION:
        case BT_MAP_DESTROY_SESSION: