if (data_len == 0) {
BT_ERR("No data");
- g_variant_unref(var);
+ g_variant_unref(var);
return;
}
_bt_common_event_cb(BLUETOOTH_EVENT_OTP_SERVER_STATE_CHANGED,
result, &status, event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_READ_CHAR_VAL) == 0) {
+ BT_DBG("OTP Read Data received");
+ const char *handle = NULL;
+ char *data;
+ int data_len = 0;
+ GVariant *var = NULL;
+ bluetooth_otp_resp_info_t *info = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&sn@ay)", &result, &handle, &data_len, &var);
+ data = (char *)g_variant_get_data(var);
+
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Data len [%d]", data_len);
+
+ if (data_len == 0) {
+ BT_ERR("No data");
+ if (var)
+ g_variant_unref(var);
+ return;
+ }
+
+ info = g_malloc0(sizeof(bluetooth_otp_resp_info_t));
+ info->data_length = data_len;
+ info->data = g_memdup(data, data_len);
+ info->handle = g_strdup(handle);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_READ_CHAR_VAL,
+ result, info,
+ event_info->cb, event_info->user_data);
+
+ if (info->handle) {
+ g_free(info->handle);
+ }
+
+ if (info->data) {
+ g_free(info->data);
+ g_free(info);
+ }
+ if (var)
+ g_variant_unref(var);
+ } else if (strcasecmp(signal_name, BT_OTP_NOTIFICATION_ENABLED) == 0) {
+ BT_DBG("OTP Notification Enabled event");
+ char *handle = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &handle);
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Result [%d]", result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_NOTIFICATION_ENABLED,
+ result, handle,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_WRITE_CHAR_VAL) == 0) {
+ BT_DBG("OTP Control point Activation result");
+ char *handle = NULL;
+
+ /* Extract data from DBUS params */
+ g_variant_get(parameters, "(i&s)", &result, &handle);
+ BT_DBG("Handle [%s]", handle);
+ BT_DBG("Result [%d]", result);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL,
+ result, handle,
+ event_info->cb, event_info->user_data);
+ } else if (strcasecmp(signal_name, BT_OTP_INDICATION) == 0) {
+ BT_DBG("OTP Control point Indication Response");
+ bluetooth_otp_resp_info_t *ind_res = NULL;
+ char *buffer = NULL;
+ GVariant *byte_var = NULL;
+ char *handle = NULL;
+
+ g_variant_get(parameters, "(i&s@ay)", &result, &handle, &byte_var);
+
+ ind_res = g_malloc0(sizeof(bluetooth_otp_resp_info_t));
+ ind_res->data_length = g_variant_get_size(byte_var);
+ buffer = (char *)g_variant_get_data(byte_var);
+ ind_res->data = g_memdup(buffer, ind_res->data_length);
+ ind_res->handle = g_strdup(handle);
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_OTP_INDICATION,
+ result, ind_res,
+ event_info->cb, event_info->user_data);
+
+ if (ind_res->handle) {
+ g_free(ind_res->handle);
+ }
+
+ if (ind_res->data) {
+ g_free(ind_res->data);
+ g_free(ind_res);
+ }
+ if (byte_var)
+ g_variant_unref(byte_var);
}
BT_DBG("-");