@@ -309,6 +309,32 @@ static void identity_resolved(struct bt_conn *conn, const bt_addr_le_t *rpa,
309
309
#endif
310
310
311
311
#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
+
312
338
static void security_changed (struct bt_conn * conn , bt_security_t level ,
313
339
enum bt_security_err err )
314
340
{
@@ -320,8 +346,9 @@ static void security_changed(struct bt_conn *conn, bt_security_t level,
320
346
shell_print (ctx_shell , "Security changed: %s level %u" , addr ,
321
347
level );
322
348
} 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 );
325
352
}
326
353
}
327
354
#endif
@@ -2481,15 +2508,14 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded)
2481
2508
addr );
2482
2509
}
2483
2510
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 )
2486
2512
{
2487
2513
char addr [BT_ADDR_LE_STR_LEN ];
2488
2514
2489
2515
bt_addr_le_to_str (bt_conn_get_dst (conn ), addr , sizeof (addr ));
2490
2516
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 );
2493
2519
}
2494
2520
2495
2521
#if defined(CONFIG_BT_BREDR )
0 commit comments