g_clear_error(&error);
status = BLUETOOTH_ERROR_INTERNAL;
}
- }
-
- if (result) {
+ } else {
g_variant_get(result, "(i)", &status);
+ g_variant_unref(result);
}
BT_DBG("Status [%d]", status);
param);
out_param = g_variant_new_from_data((const GVariantType*)"i",
- result, sizeof(int), TRUE, NULL, NULL);
+ &status, sizeof(int), TRUE, NULL, NULL);
if (req_info) {
g_dbus_method_invocation_return_value(req_info->context,
_bt_delete_request_list(req_info->req_id);
}
-
- g_variant_unref(result);
}
int bt_otp_server_init(int request_id, const char *directory)
g_clear_error(&error);
status = BLUETOOTH_ERROR_INTERNAL;
}
- }
-
- if (result) {
+ } else {
g_variant_get(result, "(i)", &status);
+ g_variant_unref(result);
}
BT_DBG("Status [%d]", status);
if (req_info) {
out_param = g_variant_new_from_data((const GVariantType*)"i",
- result, sizeof(int), TRUE, NULL, NULL);
+ &status, sizeof(int), TRUE, NULL, NULL);
g_dbus_method_invocation_return_value(req_info->context,
g_variant_new("(iv)", status, out_param));
_bt_delete_request_list(req_info->req_id);
}
- g_variant_unref(result);
-
if (otp_gproxy) {
g_object_unref(otp_gproxy);
otp_gproxy = NULL;
int __get_handle_length(char *handle)
{
int i = 0;
- while (handle && (handle[i] != '\0')) {
+
+ while (handle && (handle[i] != '\0'))
i++;
- }
+
return i;
}
_bt_send_event_to_dest(info->sender, BT_OTP_EVENT,
BLUETOOTH_EVENT_OTP_READ_CHAR_VAL,
param);
+ req_info = _bt_get_request_info(info->req_id);
+ __bt_otp_remove_read_info(info);
}
- req_info = _bt_get_request_info(info->req_id);
- __bt_otp_remove_read_info(info);
-
if (req_info == NULL) {
BT_ERR("OTP data read Request not found!!");
goto done;
{
GDBusConnection *conn;
bt_otp_read_req_info *info = NULL;
- char *charc_handle = g_strdup(handle);
+ char *charc_handle = NULL;
GVariantBuilder *builder = NULL;
guint16 offset = 0;
/* If OTP data read already pending on same Server, then return In progress */
if (__bt_otp_get_read_info(handle) != NULL) {
- BT_ERR("Read Req is ongoing in remote server [%s]", charc_handle);
- g_free(charc_handle);
+ BT_ERR("Read Req is ongoing in remote server [%s]", handle);
return BLUETOOTH_ERROR_IN_PROGRESS;
}
g_variant_builder_add(builder, "{sv}", "offset",
g_variant_new("q", offset));
+ charc_handle = g_strdup(handle);
+
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
handle,
int _bt_otp_enable_notification(int request_id, char *sender, char *handle)
{
bt_otp_notification_info *info = NULL;
- char *charc_handle = g_strdup(handle);
+ char *charc_handle = NULL;
GDBusConnection *conn;
BT_CHECK_PARAMETER(handle, return);
if (__bt_otp_get_notification_info(handle) != NULL) {
BT_ERR("Activation is already ongoing for same remote server");
- g_free(charc_handle);
return BLUETOOTH_ERROR_IN_PROGRESS;
}
+ charc_handle = g_strdup(handle);
+
BT_INFO("Start Notify to Bluez");
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
guint16 offset = 0;
bt_otp_notification_info *info = NULL;
GDBusConnection *conn;
- char *charc_handle = g_strdup(handle);
+ char *charc_handle = NULL;
int i;
BT_DBG("+");
info = __bt_otp_get_notification_info(handle);
if (info && info->notification_timeout_id > 0) {
BT_ERR("Write Request is already ongoing in remote server");
- g_free(charc_handle);
return BLUETOOTH_ERROR_IN_PROGRESS;
}
builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
- for (i = 0; i < length; i++) {
+ for (i = 0; i < length; i++)
g_variant_builder_add(builder1, "y", param[i]);
- }
val = g_variant_new("ay", builder1);
builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
options = g_variant_new("a{sv}", builder2);
+ charc_handle = g_strdup(handle);
+
/* Activate Control Point */
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
info = __bt_otp_get_notification_info((char *)path);
if (info) {
- g_variant_get(msg, "(is@ay)", NULL, NULL, &value);
- len = g_variant_get_size(value);
- BT_DBG("Indication data from Server len[%d]", len);
- if (len > 0) {
- buffer = (unsigned char *)g_variant_get_data(value);
- /* DEBUG */
- for (i = 0; i < len; i++)
- BT_DBG("%.2x", buffer[i]);
- }
-
/* Reset Timer */
if (info->notification_timeout_id > 0)
g_source_remove(info->notification_timeout_id);
- /* Send Indication & info removed internally */
- __bt_otp_send_indication_event(info, buffer, len, BLUETOOTH_ERROR_NONE);
+ g_variant_get(msg, "(is@ay)", NULL, NULL, &value);
+
+ if (value) {
+ len = g_variant_get_size(value);
+ BT_DBG("Indication data from Server len[%d]", len);
+ if (len > 0) {
+ buffer = (unsigned char *)g_variant_get_data(value);
+ /* DEBUG */
+ for (i = 0; i < len; i++)
+ BT_DBG("%.2x", buffer[i]);
+ }
+
+ /* Send Indication & info removed internally */
+ __bt_otp_send_indication_event(info, buffer, len, BLUETOOTH_ERROR_NONE);
- if (value)
g_variant_unref(value);
+ } else {
+ BT_ERR("No Indication data from Server");
+ /* Send Error Indication & info removed internally */
+ __bt_otp_send_indication_event(info, NULL, 0, BLUETOOTH_ERROR_INTERNAL);
+ }
}
BT_DBG("-");
}