Bluetooth: Shell: Rework gatt-write-signed
This makes gatt-write-signed to reuse cmd_gatt_write_without_rsp since it is quite similar and that adds the ability to send multiple octecs instead of just a single byte. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
a5aa904f90
commit
da86ae0cb6
|
@ -2007,8 +2007,8 @@ static const struct shell_cmd bt_commands[] = {
|
|||
{ "gatt-write", cmd_gatt_write, "<handle> <offset> <data> [length]" },
|
||||
{ "gatt-write-without-response", cmd_gatt_write_without_rsp,
|
||||
"<handle> <data> [length]" },
|
||||
{ "gatt-write-signed", cmd_gatt_write_signed,
|
||||
"<handle> <data>" },
|
||||
{ "gatt-write-signed", cmd_gatt_write_without_rsp,
|
||||
"<handle> <data> [length]" },
|
||||
{ "gatt-subscribe", cmd_gatt_subscribe,
|
||||
"<CCC handle> <value handle> [ind]" },
|
||||
{ "gatt-unsubscribe", cmd_gatt_unsubscribe, HELP_NONE },
|
||||
|
|
|
@ -351,6 +351,7 @@ int cmd_gatt_write(int argc, char *argv[])
|
|||
int cmd_gatt_write_without_rsp(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
bool sign;
|
||||
u16_t handle;
|
||||
u16_t len;
|
||||
|
||||
|
@ -363,6 +364,7 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
sign = !strcmp(argv[0], "gatt-write-signed");
|
||||
handle = strtoul(argv[1], NULL, 16);
|
||||
gatt_write_buf[0] = strtoul(argv[2], NULL, 16);
|
||||
len = 1;
|
||||
|
@ -378,32 +380,7 @@ int cmd_gatt_write_without_rsp(int argc, char *argv[])
|
|||
}
|
||||
|
||||
err = bt_gatt_write_without_response(default_conn, handle,
|
||||
gatt_write_buf, len, false);
|
||||
printk("Write Complete (err %d)\n", err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_gatt_write_signed(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
u16_t handle;
|
||||
u8_t data;
|
||||
|
||||
if (!default_conn) {
|
||||
printk("Not connected\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
handle = strtoul(argv[1], NULL, 16);
|
||||
data = strtoul(argv[2], NULL, 16);
|
||||
|
||||
err = bt_gatt_write_without_response(default_conn, handle, &data,
|
||||
sizeof(data), true);
|
||||
gatt_write_buf, len, sign);
|
||||
printk("Write Complete (err %d)\n", err);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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_signed(int argc, char *argv[]);
|
||||
int cmd_gatt_subscribe(int argc, char *argv[]);
|
||||
int cmd_gatt_unsubscribe(int argc, char *argv[]);
|
||||
int cmd_gatt_register_test_svc(int argc, char *argv[]);
|
||||
|
|
Loading…
Reference in New Issue