Example #1
0
void write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
                  gpointer user_data)
{
    cb_ctx_t *cb_ctx = user_data;

    printf_dbg("[CB] IN write_req_cb\n");
    if (status) {
        cb_ctx->cb_ret_val = BL_REQUEST_FAIL_ERROR;
        sprintf(cb_ctx->cb_ret_msg, "Write request callback: Failure: %s\n",
                att_ecode2str(status));
        goto end;
    }

    if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
        cb_ctx->cb_ret_val = BL_PROTOCOL_ERROR;
        printf("Write request callback: Protocol error\n");
        goto end;
    }

    cb_ctx->cb_ret_val = BL_NO_ERROR;
    strcpy(cb_ctx->cb_ret_msg, "Write request callback: Success\n");
end:
    g_mutex_unlock(&cb_ctx->pending_cb_mtx);
    printf_dbg("[CB] OUT write_req_cb\n");
}
Example #2
0
static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
							gpointer user_data)
{
	if (status != 0) {
		resp_error(err_COMM_ERR); // Todo: status
		return;
	}

	if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
		resp_error(err_PROTO_ERR);
		return;
	}

        resp_begin(rsp_WRITE);
        resp_end();
}
Example #3
0
static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
							gpointer user_data)
{
	if (status != 0) {
		error("Characteristic Write Request failed: "
						"%s\n", att_ecode2str(status));
		return;
	}

	if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
		error("Protocol error\n");
		return;
	}

	rl_printf("Characteristic value was written successfully\n");
}
Example #4
0
//callback for when a ble write is complete
static void char_write_cb(guint8 status, const guint8 *pdu, guint16 plen,
							gpointer user_data)
{
	if (status != 0) {
		printf("Characteristic Write Request failed: "
						"%s\n", att_ecode2str(status));
		ble_disconnect();
		return;
	}

	if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
		printf("Protocol error\n");
		ble_disconnect();
		return;
	}
	ble_write = 1;
}
Example #5
0
static void gatt_write_char_cb(
	guint8 status,
	guint8 const* pdu,
	guint16 plen,
	gpointer user_data) {
	if (status != 0) {
		std::cout << "Characteristic Write Request failed: " << att_ecode2str(status) << std::endl;
		goto done;
	}

	if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
		std::cout << "Protocol error" << std::endl;
		goto done;
	}

	std::cout << "Characteristic value was written successfully" << std::endl;
done:
	g_main_loop_quit(event_loop);
}
Example #6
0
static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
                              gpointer user_data)
{
    if (status != 0) {
        printf("Characteristic Write Request failed: "
               "%s\n", att_ecode2str(status));
        goto done;
    }

    if (!dec_write_resp(pdu, plen)) {
        printf("Protocol error\n");
        goto done;
    }

    printf("Characteristic value was written successfully\n");

done:
    printf("\r%s", get_prompt());
    fflush(stdout);
}
Example #7
0
static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
							gpointer user_data)
{
	if (status != 0) {
		g_printerr("Characteristic Write Request failed: "
						"%s\n", att_ecode2str(status));
		goto done;
	}

	if (!dec_write_resp(pdu, plen) && !dec_exec_write_resp(pdu, plen)) {
		g_printerr("Protocol error\n");
		goto done;
	}

	g_print("Characteristic value was written successfully\n");

done:
	if (opt_listen == FALSE)
		g_main_loop_quit(event_loop);
}
Example #8
0
static void linkloss_written(guint8 status, const guint8 *pdu, guint16 plen,
							gpointer user_data)
{
	struct monitor *monitor = user_data;
	struct btd_device *device = monitor->device;
	const char *path = device_get_path(device);

	if (status != 0) {
		error("Link Loss Write Request failed: %s",
							att_ecode2str(status));
		return;
	}

	if (!dec_write_resp(pdu, plen)) {
		error("Link Loss Write Request: protocol error");
		return;
	}

	DBG("Link Loss Alert Level written");

	g_dbus_emit_property_changed(btd_get_dbus_connection(), path,
				PROXIMITY_INTERFACE, "LinkLossAlertLevel");
}