From bad4051ca8884c899a42358f351121981350da8c Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 9 Jul 2020 10:59:08 -0600 Subject: [PATCH] Cleanup --- .github/FUNDING.yml | 3 - src/NimBLEUtils.cpp | 202 -------------------------------------------- src/NimBLEUtils.h | 8 -- 3 files changed, 213 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 2a34d9a..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -custom: ["https://paypal.me/h2zero"] diff --git a/src/NimBLEUtils.cpp b/src/NimBLEUtils.cpp index 8a4d60a..7a1f55b 100644 --- a/src/NimBLEUtils.cpp +++ b/src/NimBLEUtils.cpp @@ -508,206 +508,4 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) { #endif // #if defined(CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT) } // gapEventToString - -/** - * @brief Utility function to log an array of bytes. - * @param [in] bytes The buffer to print. - * @param [in] len The length of the buffer. - */ -void print_bytes(const uint8_t *bytes, int len) -{ - int i; - - for (i = 0; i < len; i++) { - NIMBLE_LOGD(LOG_TAG, "%s0x%02x", i != 0 ? ":" : "", bytes[i]); - if(i % 30 == 0){ - NIMBLE_LOGD(LOG_TAG, "\n"); - } - } - - NIMBLE_LOGD(LOG_TAG, "\n"); -} - - -/** - * @brief Utility function to log an os_mbuf. - * @param [in] om The buffer to print. - */ -void print_mbuf(const struct os_mbuf *om) -{ - int colon; - - colon = 0; - while (om != NULL) { - if (colon) { - MODLOG_DFLT(DEBUG, ":"); - } else { - colon = 1; - } - print_bytes(om->om_data, om->om_len); - om = SLIST_NEXT(om, om_next); - } -} - -char *addr_str(const void *addr) -{ - static char buf[6 * 2 + 5 + 1]; - const uint8_t *u8p; - - u8p = (const uint8_t*)addr; - sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", - u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]); - - return buf; -} - -void print_uuid(const ble_uuid_t *uuid) -{ - char buf[BLE_UUID_STR_LEN]; - - MODLOG_DFLT(DEBUG, "%s", ble_uuid_to_str(uuid, buf)); -} - -void print_adv_fields(const struct ble_hs_adv_fields *fields) -{ - char s[BLE_HS_ADV_MAX_SZ]; - const uint8_t *u8p; - int i; - - if (fields->flags != 0) { - MODLOG_DFLT(DEBUG, " flags=0x%02x\n", fields->flags); - } - - if (fields->uuids16 != NULL) { - MODLOG_DFLT(DEBUG, " uuids16(%scomplete)=", - fields->uuids16_is_complete ? "" : "in"); - for (i = 0; i < fields->num_uuids16; i++) { - print_uuid(&fields->uuids16[i].u); - MODLOG_DFLT(DEBUG, " "); - } - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->uuids32 != NULL) { - MODLOG_DFLT(DEBUG, " uuids32(%scomplete)=", - fields->uuids32_is_complete ? "" : "in"); - for (i = 0; i < fields->num_uuids32; i++) { - print_uuid(&fields->uuids32[i].u); - MODLOG_DFLT(DEBUG, " "); - } - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->uuids128 != NULL) { - MODLOG_DFLT(DEBUG, " uuids128(%scomplete)=", - fields->uuids128_is_complete ? "" : "in"); - for (i = 0; i < fields->num_uuids128; i++) { - print_uuid(&fields->uuids128[i].u); - MODLOG_DFLT(DEBUG, " "); - } - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->name != NULL) { - assert(fields->name_len < sizeof s - 1); - memcpy(s, fields->name, fields->name_len); - s[fields->name_len] = '\0'; - MODLOG_DFLT(DEBUG, " name(%scomplete)=%s\n", - fields->name_is_complete ? "" : "in", s); - } - - if (fields->tx_pwr_lvl_is_present) { - MODLOG_DFLT(DEBUG, " tx_pwr_lvl=%d\n", fields->tx_pwr_lvl); - } - - if (fields->slave_itvl_range != NULL) { - MODLOG_DFLT(DEBUG, " slave_itvl_range="); - print_bytes(fields->slave_itvl_range, BLE_HS_ADV_SLAVE_ITVL_RANGE_LEN); - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->svc_data_uuid16 != NULL) { - MODLOG_DFLT(DEBUG, " svc_data_uuid16="); - print_bytes(fields->svc_data_uuid16, fields->svc_data_uuid16_len); - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->public_tgt_addr != NULL) { - MODLOG_DFLT(DEBUG, " public_tgt_addr="); - u8p = fields->public_tgt_addr; - for (i = 0; i < fields->num_public_tgt_addrs; i++) { - MODLOG_DFLT(DEBUG, "public_tgt_addr=%s ", addr_str(u8p)); - u8p += BLE_HS_ADV_PUBLIC_TGT_ADDR_ENTRY_LEN; - } - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->appearance_is_present) { - MODLOG_DFLT(DEBUG, " appearance=0x%04x\n", fields->appearance); - } - - if (fields->adv_itvl_is_present) { - MODLOG_DFLT(DEBUG, " adv_itvl=0x%04x\n", fields->adv_itvl); - } - - if (fields->svc_data_uuid32 != NULL) { - MODLOG_DFLT(DEBUG, " svc_data_uuid32="); - print_bytes(fields->svc_data_uuid32, fields->svc_data_uuid32_len); - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->svc_data_uuid128 != NULL) { - MODLOG_DFLT(DEBUG, " svc_data_uuid128="); - print_bytes(fields->svc_data_uuid128, fields->svc_data_uuid128_len); - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->uri != NULL) { - MODLOG_DFLT(DEBUG, " uri="); - print_bytes(fields->uri, fields->uri_len); - MODLOG_DFLT(DEBUG, "\n"); - } - - if (fields->mfg_data != NULL) { - MODLOG_DFLT(DEBUG, " mfg_data="); - print_bytes(fields->mfg_data, fields->mfg_data_len); - MODLOG_DFLT(DEBUG, "\n"); - } -} - - - /** - * @brief Logs information about a connection to the console. - * @param [in] desc The connection description struct to print. - */ -void print_conn_desc(const struct ble_gap_conn_desc *desc) -{ - NIMBLE_LOGD(LOG_TAG, "handle=%d our_ota_addr_type=%d our_ota_addr=%s ", - desc->conn_handle, desc->our_ota_addr.type, - addr_str(desc->our_ota_addr.val)); - NIMBLE_LOGD(LOG_TAG, "our_id_addr_type=%d our_id_addr=%s ", - desc->our_id_addr.type, addr_str(desc->our_id_addr.val)); - NIMBLE_LOGD(LOG_TAG, "peer_ota_addr_type=%d peer_ota_addr=%s ", - desc->peer_ota_addr.type, addr_str(desc->peer_ota_addr.val)); - NIMBLE_LOGD(LOG_TAG, "peer_id_addr_type=%d peer_id_addr=%s ", - desc->peer_id_addr.type, addr_str(desc->peer_id_addr.val)); - NIMBLE_LOGD(LOG_TAG, "conn_itvl=%d conn_latency=%d supervision_timeout=%d " - "encrypted=%d authenticated=%d bonded=%d", - desc->conn_itvl, desc->conn_latency, - desc->supervision_timeout, - desc->sec_state.encrypted, - desc->sec_state.authenticated, - desc->sec_state.bonded); -} - - -void print_addr(const void *addr) -{ - const uint8_t *u8p; - - u8p = (uint8_t*)addr; - MODLOG_DFLT(INFO, "%02x:%02x:%02x:%02x:%02x:%02x", - u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]); -} - #endif //CONFIG_BT_ENABLED diff --git a/src/NimBLEUtils.h b/src/NimBLEUtils.h index babc12b..acbc93e 100644 --- a/src/NimBLEUtils.h +++ b/src/NimBLEUtils.h @@ -27,14 +27,6 @@ typedef struct { std::string *buf; } ble_task_data_t; -extern "C"{ -char *addr_str(const void *addr); -void print_conn_desc(const struct ble_gap_conn_desc *desc); -void print_adv_fields(const struct ble_hs_adv_fields *fields); -void print_addr(const void *addr); -void print_bytes(const uint8_t *bytes, int len); -} - /** * @brief A BLE Utility class with methods for debugging and general purpose use.