From 49ca58d6a255bbdff307fd25bf27610074f14d66 Mon Sep 17 00:00:00 2001 From: "mila@ringwald.ch" Date: Fri, 15 Aug 2014 22:04:48 +0000 Subject: [PATCH] remove hexdump2, use printf_hexdump instead --- MSP-EXP430F5438-CC256x/example-ant/ant-test.c | 11 ++--------- MSP-EXP430F5438-CC256x/example-ble/ble_server.c | 8 -------- example/l2cap-server.c | 2 +- example/libusb/ancs_client.c | 2 +- example/libusb/ble_client.c | 15 +++------------ example/libusb/ble_peripheral.c | 6 +++--- example/libusb/gatt_browser.c | 2 +- example/libusb/spp_and_le_counter.c | 2 +- example/rfcomm-cat.c | 2 +- example/rfcomm-echo.c | 2 +- example/rfcomm-test.c | 2 +- include/btstack/utils.h | 1 + src/hci_dump.c | 2 +- src/sdp_util.c | 2 +- src/utils.c | 9 +++++++++ test/ble_client/advertising_data_parser.c | 4 ++-- test/security_manager/security_manager.c | 12 +++--------- 17 files changed, 32 insertions(+), 52 deletions(-) diff --git a/MSP-EXP430F5438-CC256x/example-ant/ant-test.c b/MSP-EXP430F5438-CC256x/example-ant/ant-test.c index 84a2f48b9..e0110193d 100644 --- a/MSP-EXP430F5438-CC256x/example-ant/ant-test.c +++ b/MSP-EXP430F5438-CC256x/example-ant/ant-test.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "hci.h" #include "l2cap.h" @@ -38,14 +39,6 @@ static uint8_t rfcomm_channel_nr = 1; static uint16_t rfcomm_channel_id = 0; static uint8_t spp_service_buffer[100]; -void hexdump2(void const *data, int size){ - int i; - for (i=0; iblob , value_event->blob_length); + printf_hexdump(value_event->blob , value_event->blob_length); } break; default: diff --git a/example/libusb/ble_client.c b/example/libusb/ble_client.c index b56da7b36..abd77adc8 100644 --- a/example/libusb/ble_client.c +++ b/example/libusb/ble_client.c @@ -75,15 +75,6 @@ typedef struct ad_event { void (*ble_client_packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = NULL; static void ble_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); -static void hexdump2(void *data, int size){ - if (size <= 0) return; - int i; - for (i=0; ievent_type, e->address_type, bd_addr_to_str(e->address), e->rssi, e->length); - hexdump2(e->data, e->length); + printf_hexdump(e->data, e->length); } @@ -143,13 +134,13 @@ static void dump_descriptor(le_event_t * event){ le_characteristic_descriptor_event_t * devent = (le_characteristic_descriptor_event_t *) event; le_characteristic_descriptor_t descriptor = devent->characteristic_descriptor; printf(" *** descriptor *** handle 0x%02x, value ", descriptor.handle); - hexdump2(devent->value, devent->value_length); + printf_hexdump(devent->value, devent->value_length); printUUID(descriptor.uuid128, descriptor.uuid16); } static void dump_characteristic_value(le_characteristic_value_event_t * event){ printf(" *** characteristic value of length %d *** ", event->blob_length ); - hexdump2(event->blob , event->blob_length); + printf_hexdump(event->blob , event->blob_length); printf("\n"); } diff --git a/example/libusb/ble_peripheral.c b/example/libusb/ble_peripheral.c index 76090bff8..f1adba9f2 100644 --- a/example/libusb/ble_peripheral.c +++ b/example/libusb/ble_peripheral.c @@ -363,7 +363,7 @@ static uint16_t att_read_callback(uint16_t con_handle, uint16_t attribute_handle att_value_len = att_attributes[index].len; } printf("Attribute len %u, data: ", att_value_len); - hexdump(att_value, att_value_len); + printf_hexdump(att_value, att_value_len); // assert offset <= att_value_len if (offset > att_value_len) { @@ -381,7 +381,7 @@ static uint16_t att_read_callback(uint16_t con_handle, uint16_t attribute_handle // write requests static int att_write_callback(uint16_t con_handle, uint16_t attribute_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){ printf("WRITE Callback, handle %04x, mode %u, offset %u, data: ", handle, transaction_mode, offset); - hexdump(buffer, buffer_size); + printf_hexdump(buffer, buffer_size); uint16_t uuid16 = att_uuid_for_handle(handle); switch (uuid16){ @@ -617,7 +617,7 @@ void show_usage(){ printf("\n--- CLI for LE Peripheral ---\n"); printf("GAP: discoverable %u, connectable %u, bondable %u, directed connectable %u, random addr %u, ads enabled %u, adv type %u \n", gap_discoverable, gap_connectable, gap_bondable, gap_directed_connectable, gap_random, gap_advertisements, gap_adv_type()); - printf("ADV: "); hexdump(adv_data, adv_data_len); + printf("ADV: "); printf_hexdump(adv_data, adv_data_len); printf("SM: %s, MITM protection %u, OOB data %u, key range [%u..16]\n", sm_io_capabilities, sm_mitm_protection, sm_have_oob_data, sm_min_key_size); printf("Default value: '%s'\n", att_default_value_long ? default_value_long : default_value_short); diff --git a/example/libusb/gatt_browser.c b/example/libusb/gatt_browser.c index 37b52b492..b8efa5350 100644 --- a/example/libusb/gatt_browser.c +++ b/example/libusb/gatt_browser.c @@ -104,7 +104,7 @@ static void printUUID(uint8_t * uuid128, uint16_t uuid16){ static void dump_advertising_report(advertising_report_t * e){ printf(" * adv. event: evt-type %u, addr-type %u, addr %s, rssi %u, length adv %u, data: ", e->event_type, e->address_type, bd_addr_to_str(e->address), e->rssi, e->length); - hexdump(e->data, e->length); + printf_hexdump(e->data, e->length); } diff --git a/example/libusb/spp_and_le_counter.c b/example/libusb/spp_and_le_counter.c index 4a857a060..adab8390c 100644 --- a/example/libusb/spp_and_le_counter.c +++ b/example/libusb/spp_and_le_counter.c @@ -178,7 +178,7 @@ static uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint // write requests static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){ // printf("WRITE Callback, handle %04x, mode %u, offset %u, data: ", handle, transaction_mode, offset); - // hexdump(buffer, buffer_size); + // printf_hexdump(buffer, buffer_size); if (att_handle != ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE) return 0; le_notification_enabled = READ_BT_16(buffer, 0) == GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION; return 0; diff --git a/example/rfcomm-cat.c b/example/rfcomm-cat.c index 36ccbe6b6..6cf463a39 100644 --- a/example/rfcomm-cat.c +++ b/example/rfcomm-cat.c @@ -68,7 +68,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case RFCOMM_DATA_PACKET: printf("Received RFCOMM data on channel id %u, size %u\n", channel, size); - hexdump(packet, size); + printf_hexdump(packet, size); break; case HCI_EVENT_PACKET: diff --git a/example/rfcomm-echo.c b/example/rfcomm-echo.c index eb0e6180e..c974b3c20 100644 --- a/example/rfcomm-echo.c +++ b/example/rfcomm-echo.c @@ -146,7 +146,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case RFCOMM_DATA_PACKET: printf("Received RFCOMM data on channel id %u, size %u\n", channel, size); - hexdump(packet, size); + printf_hexdump(packet, size); bt_send_rfcomm(channel, packet, size); break; diff --git a/example/rfcomm-test.c b/example/rfcomm-test.c index 13c6f597b..c08e39fd6 100644 --- a/example/rfcomm-test.c +++ b/example/rfcomm-test.c @@ -150,7 +150,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case RFCOMM_DATA_PACKET: printf("Received RFCOMM data on channel id %u, size %u\n", channel, size); - hexdump(packet, size); + printf_hexdump(packet, size); bt_send_rfcomm(channel, packet, size); break; diff --git a/include/btstack/utils.h b/include/btstack/utils.h index 94d21437f..89cbde04d 100644 --- a/include/btstack/utils.h +++ b/include/btstack/utils.h @@ -130,6 +130,7 @@ void swap56(const uint8_t src[7], uint8_t dst[7]); void swap64(const uint8_t src[8], uint8_t dst[8]); void swap128(const uint8_t src[16], uint8_t dst[16]); +void printf_hexdump(const void *data, int size); void hexdump(const void *data, int size); void printUUID128(uint8_t *uuid); void log_key(const char * name, sm_key_t key); diff --git a/src/hci_dump.c b/src/hci_dump.c index d6bf0ddcc..a55b7e77e 100644 --- a/src/hci_dump.c +++ b/src/hci_dump.c @@ -171,7 +171,7 @@ void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t default: return; } - hexdump(packet, len); + printf_hexdump(packet, len); break; } diff --git a/src/sdp_util.c b/src/sdp_util.c index 3e55e8e7a..ad537d769 100644 --- a/src/sdp_util.c +++ b/src/sdp_util.c @@ -597,7 +597,7 @@ static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_ break; } printf("len %u (0x%02x)\n", len, len); - hexdump(&element[pos], len); + printf_hexdump(&element[pos], len); } else { uint32_t value = 0; switch (de_size) { diff --git a/src/utils.c b/src/utils.c index e002ef506..ad85a93eb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -106,6 +106,15 @@ char char_for_nibble(int nibble){ return '?'; } +void printf_hexdump(const void *data, int size){ + if (size <= 0) return; + int i; + for (i=0; ievent_type, e->address_type, bd_addr_to_str(e->address), e->rssi, e->length); - hexdump(e->data, e->length); + printf_hexdump(e->data, e->length); } @@ -98,7 +98,7 @@ void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){ printf("\ndata: \n"); - hexdump(packet, size); + printf_hexdump(packet, size); printf("\n"); } diff --git a/test/security_manager/security_manager.c b/test/security_manager/security_manager.c index aed267b9d..7e8a240e1 100644 --- a/test/security_manager/security_manager.c +++ b/test/security_manager/security_manager.c @@ -15,6 +15,7 @@ #include "CppUTest/CommandLineTestRunner.h" #include +#include #include "btstack_memory.h" #include "hci.h" @@ -111,21 +112,14 @@ uint8_t * mock_packet_buffer(void); uint16_t mock_packet_buffer_len(void); void mock_clear_packet_buffer(void); -void hexdump2(void const *data, int size){ - int i; - for (i=0; i