Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/btshell/src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,25 @@ static const struct shell_cmd_help gatt_clear_pending_notif_help = {
.usage = NULL,
.params = NULL,
};

#if MYNEWT_VAL(BLE_EATT_CHAN_NUM)
/*****************************************************************************
* $gatt-eatt-connect *
*****************************************************************************/

static const struct shell_param gatt_eatt_connect_params[] = {
{"conn", "connection handle, usage: =<UINT16>" },
{"chan_num", "number of channels to connect, usage =<UINT16>" },
{NULL, NULL }
};

static const struct shell_cmd_help gatt_eatt_connect_help = {
.summary = "Connect EATT channels",
.usage = NULL,
.params = gatt_eatt_connect_params,
};
#endif

#endif

#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
Expand Down Expand Up @@ -4643,6 +4662,13 @@ static const struct shell_cmd btshell_commands[] = {
.sc_cmd_func = cmd_gatt_clear_pending_notif,
#if MYNEWT_VAL(SHELL_CMD_HELP)
.help = &gatt_clear_pending_notif_help,
#endif
},
{
.sc_cmd = "gatt-eatt-connect",
.sc_cmd_func = cmd_gatt_eatt_connect,
#if MYNEWT_VAL(SHELL_CMD_HELP)
.help = &gatt_eatt_connect_help,
#endif
},
Comment on lines +4667 to 4673
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it conditional (on MYNEWT_VAL(BLE_EATT_CHAN_NUM));
It has to be conditionally compiled, otherwise it will fail, because gatt_eatt_connect_help is undefined if BLE_EATT_CHAN_NUM is not set

#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)
Expand Down
35 changes: 35 additions & 0 deletions apps/btshell/src/cmd_gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,38 @@ cmd_gatt_clear_pending_notif(int argc, char **argv)
return ENOTSUP;
#endif
}

/*****************************************************************************
* $gatt-eatt-connect *
*****************************************************************************/

int
cmd_gatt_eatt_connect(int argc, char **argv)
{
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM)
uint16_t conn_handle;
uint16_t chan_num;
int rc;

rc = parse_arg_init(argc - 1, argv + 1);
if (rc != 0) {
return rc;
}

conn_handle = parse_arg_uint16("conn", &rc);
if (rc != 0) {
console_printf("invalid 'conn' parameter\n");
return rc;
}

chan_num = parse_arg_uint16("chan_num", &rc);
if (rc != 0) {
console_printf("invalid 'chan_num' parameter\n");
return rc;
}
return ble_eatt_connect(conn_handle, chan_num);
#else
console_printf("To enable this features set BLE_EATT_CHAN_NUM\n");
return ENOTSUP;
Comment on lines +698 to +699
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO The function should be conditionally compiled as well

#endif
}
1 change: 1 addition & 0 deletions apps/btshell/src/cmd_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ int cmd_gatt_write(int argc, char **argv);
int cmd_gatt_enqueue_notif(int argc, char **argv);
int cmd_gatt_send_pending_notif(int argc, char **argv);
int cmd_gatt_clear_pending_notif(int argc, char **argv);
int cmd_gatt_eatt_connect(int argc, char **argv);

#endif
12 changes: 12 additions & 0 deletions nimble/host/include/host/ble_att.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ uint16_t ble_att_preferred_mtu(void);
*/
int ble_att_set_preferred_mtu(uint16_t mtu);

/**
* Manually establish L2CAP Enhanced Connection
*
* @param conn_handle ACL connection handle
* @param chan_num Number of channels to establish
*
* @return 0 on success;
* NimBLE host core return code on unexpected
* error.
*/
int ble_eatt_connect(uint16_t conn_handle, uint8_t chan_num);

#ifdef __cplusplus
}
#endif
Expand Down
Loading