@@ -1009,7 +1009,30 @@ void subrate_changed(struct bt_conn *conn,
10091009 bt_shell_print ("Subrate change failed (HCI status 0x%02x)" , params -> status );
10101010 }
10111011}
1012- #endif
1012+
1013+ #if defined(CONFIG_BT_SHORTER_CONNECTION_INTERVALS )
1014+ void conn_rate_changed (struct bt_conn * conn , const struct bt_conn_le_conn_rate_changed * params )
1015+ {
1016+ if (params -> status == BT_HCI_ERR_SUCCESS ) {
1017+ bt_shell_print ("Connection rate parameters changed: "
1018+ "Connection Interval: 0x%04x (%d us) "
1019+ "Subrate Factor: %d "
1020+ "Peripheral latency: 0x%04x "
1021+ "Continuation Number: %d "
1022+ "Supervision timeout: 0x%04x (%d ms)" ,
1023+ params -> interval ,
1024+ params -> interval * 125 ,
1025+ params -> subrate_factor ,
1026+ params -> peripheral_latency ,
1027+ params -> continuation_number ,
1028+ params -> supervision_timeout ,
1029+ params -> supervision_timeout * 10 );
1030+ } else {
1031+ bt_shell_print ("Connection rate change failed (HCI status 0x%02x)" , params -> status );
1032+ }
1033+ }
1034+ #endif /* CONFIG_BT_SHORTER_CONNECTION_INTERVALS */
1035+ #endif /* CONFIG_BT_SUBRATING */
10131036
10141037#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET )
10151038void read_all_remote_feat_complete (struct bt_conn * conn ,
@@ -1255,6 +1278,9 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
12551278#if defined(CONFIG_BT_SUBRATING )
12561279 .subrate_changed = subrate_changed ,
12571280#endif
1281+ #if defined(CONFIG_BT_SHORTER_CONNECTION_INTERVALS )
1282+ .conn_rate_changed = conn_rate_changed ,
1283+ #endif
12581284#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET )
12591285 .read_all_remote_feat_complete = read_all_remote_feat_complete ,
12601286#endif
@@ -3361,7 +3387,128 @@ static int cmd_subrate_request(const struct shell *sh, size_t argc, char *argv[]
33613387
33623388 return 0 ;
33633389}
3364- #endif
3390+
3391+ #if defined(CONFIG_BT_SHORTER_CONNECTION_INTERVALS )
3392+ static int cmd_read_min_conn_interval_groups (const struct shell * sh , size_t argc , char * argv [])
3393+ {
3394+ int err ;
3395+ struct bt_conn_le_min_conn_interval_info info ;
3396+
3397+ err = bt_conn_le_read_min_conn_interval_groups (& info );
3398+ if (err ) {
3399+ shell_error (sh , "bt_conn_le_read_min_conn_interval_groups returned error %d" , err );
3400+ return - ENOEXEC ;
3401+ }
3402+
3403+ shell_print (sh , "Minimum supported connection interval: 0x%04x (%d us)" ,
3404+ info .min_supported_conn_interval , info .min_supported_conn_interval * 125 );
3405+ shell_print (sh , "Number of groups: %d" , info .num_groups );
3406+
3407+ for (uint8_t i = 0 ; i < info .num_groups ; i ++ ) {
3408+ shell_print (
3409+ sh ,
3410+ " Group %d: min=0x%04x (%d us), max=0x%04x (%d us), stride=0x%04x (%d us)" ,
3411+ i ,
3412+ info .groups [i ].min , info .groups [i ].min * 125 ,
3413+ info .groups [i ].max , info .groups [i ].max * 125 ,
3414+ info .groups [i ].stride , info .groups [i ].stride * 125 );
3415+ }
3416+
3417+ return 0 ;
3418+ }
3419+
3420+ static int cmd_read_min_conn_interval (const struct shell * sh , size_t argc , char * argv [])
3421+ {
3422+ int err ;
3423+ uint8_t min_interval ;
3424+
3425+ err = bt_conn_le_read_min_conn_interval (& min_interval );
3426+ if (err ) {
3427+ shell_error (sh , "bt_conn_le_read_min_conn_interval returned error %d" , err );
3428+ return - ENOEXEC ;
3429+ }
3430+
3431+ shell_print (sh , "Minimum supported connection interval: 0x%04x (%d us)" , min_interval ,
3432+ min_interval * 125 );
3433+ return 0 ;
3434+ }
3435+
3436+ static int cmd_conn_rate_set_defaults (const struct shell * sh , size_t argc , char * argv [])
3437+ {
3438+ int err = 0 ;
3439+
3440+ for (size_t argn = 1 ; argn < argc ; argn ++ ) {
3441+ (void )shell_strtoul (argv [argn ], 10 , & err );
3442+
3443+ if (err ) {
3444+ shell_help (sh );
3445+ shell_error (sh , "Could not parse input number %zu" , argn );
3446+ return SHELL_CMD_HELP_PRINTED ;
3447+ }
3448+ }
3449+
3450+ const struct bt_conn_le_conn_rate_param params = {
3451+ .interval_min = shell_strtoul (argv [1 ], 10 , & err ),
3452+ .interval_max = shell_strtoul (argv [2 ], 10 , & err ),
3453+ .subrate_min = shell_strtoul (argv [3 ], 10 , & err ),
3454+ .subrate_max = shell_strtoul (argv [4 ], 10 , & err ),
3455+ .max_latency = shell_strtoul (argv [5 ], 10 , & err ),
3456+ .continuation_number = shell_strtoul (argv [6 ], 10 , & err ),
3457+ .supervision_timeout = shell_strtoul (argv [7 ], 10 , & err ),
3458+ .min_ce_len = shell_strtoul (argv [8 ], 10 , & err ),
3459+ .max_ce_len = shell_strtoul (argv [9 ], 10 , & err ),
3460+ };
3461+
3462+ err = bt_conn_le_conn_rate_set_defaults (& params );
3463+ if (err ) {
3464+ shell_error (sh , "bt_conn_le_conn_rate_set_defaults returned error %d" , err );
3465+ return - ENOEXEC ;
3466+ }
3467+
3468+ return 0 ;
3469+ }
3470+
3471+ static int cmd_conn_rate_request (const struct shell * sh , size_t argc , char * argv [])
3472+ {
3473+ int err = 0 ;
3474+
3475+ if (default_conn == NULL ) {
3476+ shell_error (sh , "Conn handle error, at least one connection is required." );
3477+ return - ENOEXEC ;
3478+ }
3479+
3480+ for (size_t argn = 1 ; argn < argc ; argn ++ ) {
3481+ (void )shell_strtoul (argv [argn ], 10 , & err );
3482+
3483+ if (err ) {
3484+ shell_help (sh );
3485+ shell_error (sh , "Could not parse input number %zu" , argn );
3486+ return SHELL_CMD_HELP_PRINTED ;
3487+ }
3488+ }
3489+
3490+ const struct bt_conn_le_conn_rate_param params = {
3491+ .interval_min = shell_strtoul (argv [1 ], 10 , & err ),
3492+ .interval_max = shell_strtoul (argv [2 ], 10 , & err ),
3493+ .subrate_min = shell_strtoul (argv [3 ], 10 , & err ),
3494+ .subrate_max = shell_strtoul (argv [4 ], 10 , & err ),
3495+ .max_latency = shell_strtoul (argv [5 ], 10 , & err ),
3496+ .continuation_number = shell_strtoul (argv [6 ], 10 , & err ),
3497+ .supervision_timeout = shell_strtoul (argv [7 ], 10 , & err ),
3498+ .min_ce_len = shell_strtoul (argv [8 ], 10 , & err ),
3499+ .max_ce_len = shell_strtoul (argv [9 ], 10 , & err ),
3500+ };
3501+
3502+ err = bt_conn_le_conn_rate_request (default_conn , & params );
3503+ if (err ) {
3504+ shell_error (sh , "bt_conn_le_conn_rate_request returned error %d" , err );
3505+ return - ENOEXEC ;
3506+ }
3507+
3508+ return 0 ;
3509+ }
3510+ #endif /* CONFIG_BT_SHORTER_CONNECTION_INTERVALS */
3511+ #endif /* CONFIG_BT_SUBRATING */
33653512
33663513#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET )
33673514static int cmd_read_all_remote_features (const struct shell * sh , size_t argc , char * argv [])
@@ -5195,7 +5342,23 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
51955342 "<min subrate factor> <max subrate factor> <max peripheral latency> "
51965343 "<min continuation number> <supervision timeout (seconds)>" ,
51975344 cmd_subrate_request , 6 , 0 ),
5198- #endif
5345+ #if defined(CONFIG_BT_SHORTER_CONNECTION_INTERVALS )
5346+ SHELL_CMD_ARG (read - min - conn - interval - groups , NULL ,
5347+ "Read minimum supported connection interval and groups" ,
5348+ cmd_read_min_conn_interval_groups , 1 , 0 ),
5349+ SHELL_CMD_ARG (read - min - conn - interval , NULL ,
5350+ "Read minimum supported connection interval only" ,
5351+ cmd_read_min_conn_interval , 1 , 0 ),
5352+ SHELL_CMD_ARG (conn - rate - set - defaults , NULL ,
5353+ "<min interval> <max interval> <min subrate> <max subrate> <max latency> "
5354+ "<continuation number> <supervision timeout> <min CE len> <max CE len>" ,
5355+ cmd_conn_rate_set_defaults , 10 , 0 ),
5356+ SHELL_CMD_ARG (conn - rate - request , NULL ,
5357+ "<min interval> <max interval> <min subrate> <max subrate> <max latency> "
5358+ "<continuation number> <supervision timeout> <min CE len> <max CE len>" ,
5359+ cmd_conn_rate_request , 10 , 0 ),
5360+ #endif /* CONFIG_BT_SHORTER_CONNECTION_INTERVALS */
5361+ #endif /* CONFIG_BT_SUBRATING */
51995362#if defined(CONFIG_BT_LE_EXTENDED_FEAT_SET )
52005363 SHELL_CMD_ARG (read - all - remote - features , NULL , "<pages_requested>" ,
52015364 cmd_read_all_remote_features , 2 , 0 ),
0 commit comments