@@ -508,206 +508,4 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
508508#endif // #if defined(CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT)
509509} // gapEventToString
510510
511-
512- /* *
513- * @brief Utility function to log an array of bytes.
514- * @param [in] bytes The buffer to print.
515- * @param [in] len The length of the buffer.
516- */
517- void print_bytes (const uint8_t *bytes, int len)
518- {
519- int i;
520-
521- for (i = 0 ; i < len; i++) {
522- NIMBLE_LOGD (LOG_TAG, " %s0x%02x" , i != 0 ? " :" : " " , bytes[i]);
523- if (i % 30 == 0 ){
524- NIMBLE_LOGD (LOG_TAG, " \n " );
525- }
526- }
527-
528- NIMBLE_LOGD (LOG_TAG, " \n " );
529- }
530-
531-
532- /* *
533- * @brief Utility function to log an os_mbuf.
534- * @param [in] om The buffer to print.
535- */
536- void print_mbuf (const struct os_mbuf *om)
537- {
538- int colon;
539-
540- colon = 0 ;
541- while (om != NULL ) {
542- if (colon) {
543- MODLOG_DFLT (DEBUG, " :" );
544- } else {
545- colon = 1 ;
546- }
547- print_bytes (om->om_data , om->om_len );
548- om = SLIST_NEXT (om, om_next);
549- }
550- }
551-
552- char *addr_str (const void *addr)
553- {
554- static char buf[6 * 2 + 5 + 1 ];
555- const uint8_t *u8p;
556-
557- u8p = (const uint8_t *)addr;
558- sprintf (buf, " %02x:%02x:%02x:%02x:%02x:%02x" ,
559- u8p[5 ], u8p[4 ], u8p[3 ], u8p[2 ], u8p[1 ], u8p[0 ]);
560-
561- return buf;
562- }
563-
564- void print_uuid (const ble_uuid_t *uuid)
565- {
566- char buf[BLE_UUID_STR_LEN];
567-
568- MODLOG_DFLT (DEBUG, " %s" , ble_uuid_to_str (uuid, buf));
569- }
570-
571- void print_adv_fields (const struct ble_hs_adv_fields *fields)
572- {
573- char s[BLE_HS_ADV_MAX_SZ];
574- const uint8_t *u8p;
575- int i;
576-
577- if (fields->flags != 0 ) {
578- MODLOG_DFLT (DEBUG, " flags=0x%02x\n " , fields->flags );
579- }
580-
581- if (fields->uuids16 != NULL ) {
582- MODLOG_DFLT (DEBUG, " uuids16(%scomplete)=" ,
583- fields->uuids16_is_complete ? " " : " in" );
584- for (i = 0 ; i < fields->num_uuids16 ; i++) {
585- print_uuid (&fields->uuids16 [i].u );
586- MODLOG_DFLT (DEBUG, " " );
587- }
588- MODLOG_DFLT (DEBUG, " \n " );
589- }
590-
591- if (fields->uuids32 != NULL ) {
592- MODLOG_DFLT (DEBUG, " uuids32(%scomplete)=" ,
593- fields->uuids32_is_complete ? " " : " in" );
594- for (i = 0 ; i < fields->num_uuids32 ; i++) {
595- print_uuid (&fields->uuids32 [i].u );
596- MODLOG_DFLT (DEBUG, " " );
597- }
598- MODLOG_DFLT (DEBUG, " \n " );
599- }
600-
601- if (fields->uuids128 != NULL ) {
602- MODLOG_DFLT (DEBUG, " uuids128(%scomplete)=" ,
603- fields->uuids128_is_complete ? " " : " in" );
604- for (i = 0 ; i < fields->num_uuids128 ; i++) {
605- print_uuid (&fields->uuids128 [i].u );
606- MODLOG_DFLT (DEBUG, " " );
607- }
608- MODLOG_DFLT (DEBUG, " \n " );
609- }
610-
611- if (fields->name != NULL ) {
612- assert (fields->name_len < sizeof s - 1 );
613- memcpy (s, fields->name , fields->name_len );
614- s[fields->name_len ] = ' \0 ' ;
615- MODLOG_DFLT (DEBUG, " name(%scomplete)=%s\n " ,
616- fields->name_is_complete ? " " : " in" , s);
617- }
618-
619- if (fields->tx_pwr_lvl_is_present ) {
620- MODLOG_DFLT (DEBUG, " tx_pwr_lvl=%d\n " , fields->tx_pwr_lvl );
621- }
622-
623- if (fields->slave_itvl_range != NULL ) {
624- MODLOG_DFLT (DEBUG, " slave_itvl_range=" );
625- print_bytes (fields->slave_itvl_range , BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN);
626- MODLOG_DFLT (DEBUG, " \n " );
627- }
628-
629- if (fields->svc_data_uuid16 != NULL ) {
630- MODLOG_DFLT (DEBUG, " svc_data_uuid16=" );
631- print_bytes (fields->svc_data_uuid16 , fields->svc_data_uuid16_len );
632- MODLOG_DFLT (DEBUG, " \n " );
633- }
634-
635- if (fields->public_tgt_addr != NULL ) {
636- MODLOG_DFLT (DEBUG, " public_tgt_addr=" );
637- u8p = fields->public_tgt_addr ;
638- for (i = 0 ; i < fields->num_public_tgt_addrs ; i++) {
639- MODLOG_DFLT (DEBUG, " public_tgt_addr=%s " , addr_str (u8p));
640- u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN;
641- }
642- MODLOG_DFLT (DEBUG, " \n " );
643- }
644-
645- if (fields->appearance_is_present ) {
646- MODLOG_DFLT (DEBUG, " appearance=0x%04x\n " , fields->appearance );
647- }
648-
649- if (fields->adv_itvl_is_present ) {
650- MODLOG_DFLT (DEBUG, " adv_itvl=0x%04x\n " , fields->adv_itvl );
651- }
652-
653- if (fields->svc_data_uuid32 != NULL ) {
654- MODLOG_DFLT (DEBUG, " svc_data_uuid32=" );
655- print_bytes (fields->svc_data_uuid32 , fields->svc_data_uuid32_len );
656- MODLOG_DFLT (DEBUG, " \n " );
657- }
658-
659- if (fields->svc_data_uuid128 != NULL ) {
660- MODLOG_DFLT (DEBUG, " svc_data_uuid128=" );
661- print_bytes (fields->svc_data_uuid128 , fields->svc_data_uuid128_len );
662- MODLOG_DFLT (DEBUG, " \n " );
663- }
664-
665- if (fields->uri != NULL ) {
666- MODLOG_DFLT (DEBUG, " uri=" );
667- print_bytes (fields->uri , fields->uri_len );
668- MODLOG_DFLT (DEBUG, " \n " );
669- }
670-
671- if (fields->mfg_data != NULL ) {
672- MODLOG_DFLT (DEBUG, " mfg_data=" );
673- print_bytes (fields->mfg_data , fields->mfg_data_len );
674- MODLOG_DFLT (DEBUG, " \n " );
675- }
676- }
677-
678-
679- /* *
680- * @brief Logs information about a connection to the console.
681- * @param [in] desc The connection description struct to print.
682- */
683- void print_conn_desc (const struct ble_gap_conn_desc *desc)
684- {
685- NIMBLE_LOGD (LOG_TAG, " handle=%d our_ota_addr_type=%d our_ota_addr=%s " ,
686- desc->conn_handle , desc->our_ota_addr .type ,
687- addr_str (desc->our_ota_addr .val ));
688- NIMBLE_LOGD (LOG_TAG, " our_id_addr_type=%d our_id_addr=%s " ,
689- desc->our_id_addr .type , addr_str (desc->our_id_addr .val ));
690- NIMBLE_LOGD (LOG_TAG, " peer_ota_addr_type=%d peer_ota_addr=%s " ,
691- desc->peer_ota_addr .type , addr_str (desc->peer_ota_addr .val ));
692- NIMBLE_LOGD (LOG_TAG, " peer_id_addr_type=%d peer_id_addr=%s " ,
693- desc->peer_id_addr .type , addr_str (desc->peer_id_addr .val ));
694- NIMBLE_LOGD (LOG_TAG, " conn_itvl=%d conn_latency=%d supervision_timeout=%d "
695- " encrypted=%d authenticated=%d bonded=%d" ,
696- desc->conn_itvl , desc->conn_latency ,
697- desc->supervision_timeout ,
698- desc->sec_state .encrypted ,
699- desc->sec_state .authenticated ,
700- desc->sec_state .bonded );
701- }
702-
703-
704- void print_addr (const void *addr)
705- {
706- const uint8_t *u8p;
707-
708- u8p = (uint8_t *)addr;
709- MODLOG_DFLT (INFO, " %02x:%02x:%02x:%02x:%02x:%02x" ,
710- u8p[5 ], u8p[4 ], u8p[3 ], u8p[2 ], u8p[1 ], u8p[0 ]);
711- }
712-
713511#endif // CONFIG_BT_ENABLED
0 commit comments