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) {
		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);
}