Skip to content

Commit 211c1e0

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 952b562 commit 211c1e0

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

apps/btshell/src/cmd.c

Lines changed: 28 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) > 0
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)
@@ -4645,6 +4664,15 @@ static const struct shell_cmd btshell_commands[] = {
46454664
.help = &gatt_clear_pending_notif_help,
46464665
#endif
46474666
},
4667+
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0
4668+
{
4669+
.sc_cmd = "gatt-eatt-connect",
4670+
.sc_cmd_func = cmd_gatt_eatt_connect,
4671+
#if MYNEWT_VAL(SHELL_CMD_HELP)
4672+
.help = &gatt_eatt_connect_help,
4673+
#endif
4674+
},
4675+
#endif
46484676
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
46494677
{
46504678
.sc_cmd = "l2cap-update",

apps/btshell/src/cmd_gatt.c

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

apps/btshell/src/cmd_gatt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ 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+
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0
42+
int cmd_gatt_eatt_connect(int argc, char **argv);
43+
#endif
4144

4245
#endif

0 commit comments

Comments
 (0)