Skip to content

Commit a4c3fc3

Browse files
btshell: Add EATT connect shell command
Introduc a new shell command `gatt_eatt_connect` to allow manual connection of multiple EATT channels per connection. The command parses the connection handle and requested number of channels, displays basic usage help, and calls the internal `ble_eatt_connect()` API. Register the command in the shell, add parameter descriptions and declaration in `cmd_gatt.h`.
1 parent 0f66e8b commit a4c3fc3

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

apps/btshell/src/cmd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,25 @@ static const struct shell_cmd_help gatt_clear_pending_notif_help = {
35683568
.usage = NULL,
35693569
.params = NULL,
35703570
};
3571+
3572+
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM)
3573+
/*****************************************************************************
3574+
* $gatt-eatt-connect *
3575+
*****************************************************************************/
3576+
3577+
static const struct shell_param gatt_eatt_connect_params[] = {
3578+
{"conn", "connection handle, usage: =<UINT16>"},
3579+
{"chan_num", "number of channels to connect, usage =<UINT16>"},
3580+
{NULL, NULL}
3581+
};
3582+
3583+
static const struct shell_cmd_help gatt_eatt_connect_help = {
3584+
.summary = "Connect EATT channels",
3585+
.usage = NULL,
3586+
.params = gatt_eatt_connect_params,
3587+
};
3588+
#endif
3589+
35713590
#endif
35723591

35733592
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
@@ -4643,6 +4662,13 @@ static const struct shell_cmd btshell_commands[] = {
46434662
.sc_cmd_func = cmd_gatt_clear_pending_notif,
46444663
#if MYNEWT_VAL(SHELL_CMD_HELP)
46454664
.help = &gatt_clear_pending_notif_help,
4665+
#endif
4666+
},
4667+
{
4668+
.sc_cmd = "gatt-eatt-connect",
4669+
.sc_cmd_func = cmd_gatt_eatt_connect,
4670+
#if MYNEWT_VAL(SHELL_CMD_HELP)
4671+
.help = &gatt_eatt_connect_help,
46464672
#endif
46474673
},
46484674
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)

apps/btshell/src/cmd_gatt.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,37 @@ cmd_gatt_clear_pending_notif(int argc, char **argv)
664664
return ENOTSUP;
665665
#endif
666666
}
667+
668+
/*****************************************************************************
669+
* $gatt-eatt-connect *
670+
*****************************************************************************/
671+
672+
int cmd_gatt_eatt_connect(int argc, char **argv)
673+
{
674+
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM)
675+
uint16_t conn_handle;
676+
uint16_t chan_num;
677+
int rc;
678+
679+
rc = parse_arg_init(argc - 1, argv + 1);
680+
if (rc != 0) {
681+
return rc;
682+
}
683+
684+
conn_handle = parse_arg_uint16("conn", &rc);
685+
if (rc != 0) {
686+
console_printf("invalid 'conn' parameter\n");
687+
return rc;
688+
}
689+
690+
chan_num = parse_arg_uint16("chan_num", &rc);
691+
if (rc != 0) {
692+
console_printf("invalid 'chan_num' parameter\n");
693+
return rc;
694+
}
695+
return ble_eatt_connect(conn_handle, chan_num);
696+
#else
697+
console_printf("To enable this features set BLE_EATT_CHAN_NUM\n");
698+
return ENOTSUP;
699+
#endif
700+
}

apps/btshell/src/cmd_gatt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ int cmd_gatt_write(int argc, char **argv);
3838
int cmd_gatt_enqueue_notif(int argc, char **argv);
3939
int cmd_gatt_send_pending_notif(int argc, char **argv);
4040
int cmd_gatt_clear_pending_notif(int argc, char **argv);
41+
int cmd_gatt_eatt_connect(int argc, char **argv);
4142

4243
#endif

0 commit comments

Comments
 (0)