hci_dump.c (128d6c999a4a7cc321497ddbaddd9cd6c8d1edef) | hci_dump.c (cdc66b5eb8d7f9a749c9003bdeb0f95de0a1be78) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 37 unchanged lines hidden (view full) --- 46#include "btstack_config.h" 47#include "btstack_debug.h" 48#include "btstack_bool.h" 49#include "btstack_util.h" 50 51static const hci_dump_t * hci_dump_impl; 52static int max_nr_packets; 53static int nr_packets; | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 37 unchanged lines hidden (view full) --- 46#include "btstack_config.h" 47#include "btstack_debug.h" 48#include "btstack_bool.h" 49#include "btstack_util.h" 50 51static const hci_dump_t * hci_dump_impl; 52static int max_nr_packets; 53static int nr_packets; |
54static bool packet_log_enabled; |
|
54 55// levels: debug, info, error 56static bool log_level_enabled[3] = { 1, 1, 1}; 57 58static bool hci_dump_log_level_active(int log_level){ 59 if (hci_dump_impl == NULL) return false; 60 if (log_level < HCI_DUMP_LOG_LEVEL_DEBUG) return false; 61 if (log_level > HCI_DUMP_LOG_LEVEL_ERROR) return false; 62 return log_level_enabled[log_level]; 63} 64 65void hci_dump_init(const hci_dump_t * impl){ 66 max_nr_packets = -1; 67 nr_packets = 0; 68 hci_dump_impl = impl; | 55 56// levels: debug, info, error 57static bool log_level_enabled[3] = { 1, 1, 1}; 58 59static bool hci_dump_log_level_active(int log_level){ 60 if (hci_dump_impl == NULL) return false; 61 if (log_level < HCI_DUMP_LOG_LEVEL_DEBUG) return false; 62 if (log_level > HCI_DUMP_LOG_LEVEL_ERROR) return false; 63 return log_level_enabled[log_level]; 64} 65 66void hci_dump_init(const hci_dump_t * impl){ 67 max_nr_packets = -1; 68 nr_packets = 0; 69 hci_dump_impl = impl; |
70 packet_log_enabled = true; |
|
69} 70 71void hci_dump_set_max_packets(int packets){ 72 max_nr_packets = packets; 73} 74 | 71} 72 73void hci_dump_set_max_packets(int packets){ 74 max_nr_packets = packets; 75} 76 |
77void hci_dump_enable_packet_log(bool enabled){ 78 packet_log_enabled = enabled; 79} 80 |
|
75void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) { | 81void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) { |
76 if (hci_dump_impl == NULL) return; | 82 if (hci_dump_impl == NULL) { 83 return; 84 } 85 if (packet_log_enabled == false) { 86 return; 87 } 88 |
77 if (max_nr_packets > 0){ 78 if ((nr_packets >= max_nr_packets) && (hci_dump_impl->reset != NULL)) { 79 nr_packets = 0; 80 (*hci_dump_impl->reset)(); 81 } 82 nr_packets++; 83 } 84 (*hci_dump_impl->log_packet)(packet_type, in, packet, len); --- 63 unchanged lines hidden --- | 89 if (max_nr_packets > 0){ 90 if ((nr_packets >= max_nr_packets) && (hci_dump_impl->reset != NULL)) { 91 nr_packets = 0; 92 (*hci_dump_impl->reset)(); 93 } 94 nr_packets++; 95 } 96 (*hci_dump_impl->log_packet)(packet_type, in, packet, len); --- 63 unchanged lines hidden --- |