Bluetooth: shell: gatt-write-without-response with repeat

Add a repeat param to gatt-write-without-response so that
it covers what gatt-write-without-response-repeated was
doing. gatt-write-without-response was removed in the
commit 26eae70da.

gatt-write-signed too will have repeat param with this
change.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2017-06-02 11:21:44 +02:00 committed by Johan Hedberg
commit 0998cdfba1
2 changed files with 21 additions and 4 deletions

View file

@ -2006,9 +2006,9 @@ 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> [length]" },
"<handle> <data> [length] [repeat]" },
{ "gatt-write-signed", cmd_gatt_write_without_rsp,
"<handle> <data> [length]" },
"<handle> <data> [length] [repeat]" },
{ "gatt-subscribe", cmd_gatt_subscribe,
"<CCC handle> <value handle> [ind]" },
{ "gatt-unsubscribe", cmd_gatt_unsubscribe, HELP_NONE },

View file

@ -354,6 +354,7 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
bool sign;
u16_t handle;
u16_t len;
u16_t repeat;
if (!default_conn) {
printk("Not connected\n");
@ -379,8 +380,24 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
}
}
err = bt_gatt_write_without_response(default_conn, handle,
gatt_write_buf, len, sign);
repeat = 0;
if (argc > 4) {
repeat = strtoul(argv[4], NULL, 16);
}
if (!repeat) {
repeat = 1;
}
while (repeat--) {
err = bt_gatt_write_without_response(default_conn, handle,
gatt_write_buf, len, sign);
if (err) {
break;
}
}
printk("Write Complete (err %d)\n", err);
return 0;