Bluetooth: Shell: Remove gatt-write-without-response-repeated

This removes gatt-write-without-response-repeated and makes
gatt-write-without-response similar to gatt-write which was the
intention of gatt-write-without-response-repeated.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2017-05-29 13:45:24 +03:00 committed by Johan Hedberg
commit 26eae70da2
3 changed files with 12 additions and 49 deletions

View file

@ -2006,10 +2006,7 @@ static const struct shell_cmd bt_commands[] = {
{ "gatt-read-multiple", cmd_gatt_mread, "<handle 1> <handle 2> ..." },
{ "gatt-write", cmd_gatt_write, "<handle> <offset> <data> [length]" },
{ "gatt-write-without-response", cmd_gatt_write_without_rsp,
"<handle> <data>" },
{ "gatt-write-without-response-repeated",
cmd_gatt_write_without_rsp_repeated,
"Send write without response <handle> <octets> [repeat]" },
"<handle> <data> [length]" },
{ "gatt-write-signed", cmd_gatt_write_signed,
"<handle> <offset> <data>" },
{ "gatt-subscribe", cmd_gatt_subscribe,

View file

@ -352,7 +352,7 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
{
int err;
u16_t handle;
u8_t data;
u16_t len;
if (!default_conn) {
printk("Not connected\n");
@ -364,55 +364,22 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
}
handle = strtoul(argv[1], NULL, 16);
data = strtoul(argv[2], NULL, 16);
err = bt_gatt_write_without_response(default_conn, handle, &data,
sizeof(data), false);
printk("Write Complete (err %d)\n", err);
return 0;
}
int cmd_gatt_write_without_rsp_repeated(int argc, char *argv[])
{
int err = 0;
u16_t handle;
u16_t octets;
u16_t repeat;
if (!default_conn) {
printk("Not connected\n");
return 0;
}
if (argc < 2) {
return -EINVAL;
}
handle = strtoul(argv[1], NULL, 16);
if (argc > 2) {
octets = min(strtoul(argv[2], NULL, 16), CHAR_SIZE_MAX);
} else {
octets = 1;
}
gatt_write_buf[0] = strtoul(argv[2], NULL, 16);
len = 1;
if (argc > 3) {
repeat = strtoul(argv[3], NULL, 16);
} else {
repeat = 1;
}
int i;
while (repeat--) {
err = bt_gatt_write_without_response(default_conn, handle,
gatt_write_buf, octets,
false);
if (err) {
break;
len = min(strtoul(argv[3], NULL, 16), sizeof(gatt_write_buf));
for (i = 1; i < len; i++) {
gatt_write_buf[i] = gatt_write_buf[0];
}
}
printk("Repeated Write Complete (err %d).\n", err);
err = bt_gatt_write_without_response(default_conn, handle,
gatt_write_buf, len, false);
printk("Write Complete (err %d)\n", err);
return 0;
}

View file

@ -19,7 +19,6 @@ int cmd_gatt_read(int argc, char *argv[]);
int cmd_gatt_mread(int argc, char *argv[]);
int cmd_gatt_write(int argc, char *argv[]);
int cmd_gatt_write_without_rsp(int argc, char *argv[]);
int cmd_gatt_write_without_rsp_repeated(int argc, char *argv[]);
int cmd_gatt_write_signed(int argc, char *argv[]);
int cmd_gatt_subscribe(int argc, char *argv[]);
int cmd_gatt_unsubscribe(int argc, char *argv[]);