Exemple #1
0
static void cmd_mtu(int argcp, char **argvp)
{
	if (conn_state != STATE_CONNECTED) {
		resp_error(err_BAD_STATE);
		return;
	}

	assert(!opt_psm);

	if (argcp < 2) {
		resp_error(err_BAD_PARAM);
		return;
	}

	if (opt_mtu) {
		resp_error(err_BAD_STATE);
                /* Can only set once per connection */
		return;
	}

	errno = 0;
	opt_mtu = strtoll(argvp[1], NULL, 16);
	if (errno != 0 || opt_mtu < ATT_DEFAULT_LE_MTU) {
		resp_error(err_BAD_PARAM);
		return;
	}

	gatt_exchange_mtu(attrib, opt_mtu, exchange_mtu_cb, NULL);
}
Exemple #2
0
static void cmd_mtu(int argcp, char **argvp)
{
	if (conn_state != STATE_CONNECTED) {
		failed("Disconnected\n");
		return;
	}

	if (opt_psm) {
		failed("Operation is only available for LE transport.\n");
		return;
	}

	if (argcp < 2) {
		rl_printf("Usage: mtu <value>\n");
		return;
	}

	if (opt_mtu) {
		failed("MTU exchange can only occur once per connection.\n");
		return;
	}

	errno = 0;
	opt_mtu = strtoll(argvp[1], NULL, 0);
	if (errno != 0 || opt_mtu < ATT_DEFAULT_LE_MTU) {
		error("Invalid value. Minimum MTU size is %d\n",
							ATT_DEFAULT_LE_MTU);
		return;
	}

	gatt_exchange_mtu(attrib, opt_mtu, exchange_mtu_cb, NULL);
}
Exemple #3
0
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data) {
	if (err) {
		std::cout <<  err->message << std::endl;
		return;
	}
	user_data_t* ud = static_cast<user_data_t*>(user_data);
	GAttrib* attrib = g_attrib_new(io);
	if (ud->mtu < ATT_DEFAULT_LE_MTU) {
		std::cout << "Invalid value. Minimum MTU size is " << ATT_DEFAULT_LE_MTU;
		g_main_loop_quit(event_loop);
		return;
	}
	ud->attrib = attrib;
	gatt_exchange_mtu(attrib, ud->mtu, exchange_mtu_cb, ud);
}
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data) {
	if (err) {
		std::cout <<  err->message << std::endl;
		return;
	}
	user_data_t* ud = static_cast<user_data_t*>(user_data);
	GAttrib* attrib = g_attrib_new(io);
	g_attrib_register(attrib, ATT_OP_HANDLE_NOTIFY, GATTRIB_ALL_HANDLES,
						notify_cb, ud, NULL);
	g_attrib_register(attrib, ATT_OP_HANDLE_IND, GATTRIB_ALL_HANDLES,
						indicate_cb, ud, NULL);

	if (ud->mtu < ATT_DEFAULT_LE_MTU) {
		std::cout << "Invalid value. Minimum MTU size is " << ATT_DEFAULT_LE_MTU;
		disconnect(ud->attrib, ud->chan);
		g_main_loop_quit(event_loop);
		return;
	}
	ud->attrib = attrib;
	gatt_exchange_mtu(attrib, ud->mtu, exchange_mtu_cb, ud);
}
Exemple #5
0
static void cmd_mtu(int argcp, char **argvp)
{
    if (conn_state != STATE_CONNECTED) {
        printf("Command failed: not connected.\n");
        goto done;
    }

    if (opt_psm) {
        printf("Command failed: operation is only available for LE"
               " transport.\n");
        goto done;
    }

    if (argcp < 2) {
        printf("Usage: mtu <value>\n");
        goto done;
    }

    if (opt_mtu) {
        printf("Command failed: MTU exchange can only occur once per"
               " connection.\n");
        goto done;
    }

    errno = 0;
    opt_mtu = strtoll(argvp[1], NULL, 0);
    if (errno != 0 || opt_mtu < ATT_DEFAULT_LE_MTU) {
        printf("Invalid value. Minimum MTU size is %d\n",
               ATT_DEFAULT_LE_MTU);
        goto done;
    }

    gatt_exchange_mtu(attrib, opt_mtu, exchange_mtu_cb, NULL);
    return;

done:
    printf("\r%s", get_prompt());
    fflush(stdout);
}