@@ -309,6 +309,32 @@ static void identity_resolved(struct bt_conn *conn, const bt_addr_le_t *rpa,
309309#endif
310310
311311#if defined(CONFIG_BT_SMP ) || defined(CONFIG_BT_BREDR )
312+ static const char * security_err_str (enum bt_security_err err )
313+ {
314+ switch (err ) {
315+ case BT_SECURITY_ERR_SUCCESS :
316+ return "Success" ;
317+ case BT_SECURITY_ERR_AUTH_FAIL :
318+ return "Authentication failure" ;
319+ case BT_SECURITY_ERR_PIN_OR_KEY_MISSING :
320+ return "PIN or key missing" ;
321+ case BT_SECURITY_ERR_OOB_NOT_AVAILABLE :
322+ return "OOB not available" ;
323+ case BT_SECURITY_ERR_AUTH_REQUIREMENT :
324+ return "Authentication requirements" ;
325+ case BT_SECURITY_ERR_PAIR_NOT_SUPPORTED :
326+ return "Pairing not supported" ;
327+ case BT_SECURITY_ERR_PAIR_NOT_ALLOWED :
328+ return "Pairing not allowed" ;
329+ case BT_SECURITY_ERR_INVALID_PARAM :
330+ return "Invalid parameters" ;
331+ case BT_SECURITY_ERR_UNSPECIFIED :
332+ return "Unspecified" ;
333+ default :
334+ return "Unknown" ;
335+ }
336+ }
337+
312338static void security_changed (struct bt_conn * conn , bt_security_t level ,
313339 enum bt_security_err err )
314340{
@@ -320,8 +346,9 @@ static void security_changed(struct bt_conn *conn, bt_security_t level,
320346 shell_print (ctx_shell , "Security changed: %s level %u" , addr ,
321347 level );
322348 } else {
323- shell_print (ctx_shell , "Security failed: %s level %u reason %d" ,
324- addr , level , err );
349+ shell_print (ctx_shell , "Security failed: %s level %u "
350+ "reason: %s (%d)" ,
351+ addr , level , security_err_str (err ), err );
325352 }
326353}
327354#endif
@@ -2481,15 +2508,14 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded)
24812508 addr );
24822509}
24832510
2484- static void auth_pairing_failed (struct bt_conn * conn ,
2485- enum bt_security_err reason )
2511+ static void auth_pairing_failed (struct bt_conn * conn , enum bt_security_err err )
24862512{
24872513 char addr [BT_ADDR_LE_STR_LEN ];
24882514
24892515 bt_addr_le_to_str (bt_conn_get_dst (conn ), addr , sizeof (addr ));
24902516
2491- shell_print (ctx_shell , "Pairing failed with %s reason %d " , addr ,
2492- reason );
2517+ shell_print (ctx_shell , "Pairing failed with %s reason: %s (%d) " , addr ,
2518+ security_err_str ( err ), err );
24932519}
24942520
24952521#if defined(CONFIG_BT_BREDR )
0 commit comments