// Total btsnoop memory log buffer size
#ifndef BTSNOOP_MEM_BUFFER_SIZE
-static const size_t BTSNOOP_MEM_BUFFER_SIZE = (172 * 1024);
+static const size_t BTSNOOP_MEM_BUFFER_SIZE = (128 * 1024);
#endif
// Block size for copying buffers (for compression/encoding etc.)
const uint64_t now = btif_debug_ts();
header.type = REDUCE_HCI_TYPE_TO_SIGNIFICANT_BITS(type);
- header.length = included_length + 1; // +1 for type byte.
+ header.length = included_length + 1; // +1 for type byte
header.packet_length = length + 1; // +1 for type byte.
header.delta_time_ms = last_timestamp_ms ? now - last_timestamp_ms : 0;
last_timestamp_ms = now;
assert(rb_dst != NULL);
assert(rb_src != NULL);
- z_stream zs = {0};
+ z_stream zs = {.zalloc = Z_NULL, .zfree = Z_NULL, .opaque = Z_NULL};
if (deflateInit(&zs, Z_DEFAULT_COMPRESSION) != Z_OK)
return false;
}
void btif_debug_btsnoop_dump(int fd) {
- dprintf(fd, "\n--- BEGIN:BTSNOOP_LOG_SUMMARY (%zu bytes in) ---\n", ringbuffer_size(buffer));
+ dprintf(fd, "--- BEGIN:BTSNOOP_LOG_SUMMARY (%zu bytes in) ---\n", ringbuffer_size(buffer));
ringbuffer_t *ringbuffer = ringbuffer_init(BTSNOOP_MEM_BUFFER_SIZE);
if (ringbuffer == NULL) {
uint8_t b64_in[3] = {0};
char b64_out[5] = {0};
- size_t i = sizeof(btsnooz_preamble_t);
+ size_t line_length = 0;
while (ringbuffer_size(ringbuffer) > 0) {
size_t read = ringbuffer_pop(ringbuffer, b64_in, 3);
- if (i > 0 && i % MAX_LINE_LENGTH == 0)
+ if (line_length >= MAX_LINE_LENGTH) {
dprintf(fd, "\n");
- i += b64_ntop(b64_in, read, b64_out, 5);
+ line_length = 0;
+ }
+ line_length += b64_ntop(b64_in, read, b64_out, 5);
dprintf(fd, "%s", b64_out);
}
- dprintf(fd, "\n--- END:BTSNOOP_LOG_SUMMARY (%zu bytes out) ---\n", i);
+ dprintf(fd, "\n--- END:BTSNOOP_LOG_SUMMARY ---\n");
error:
ringbuffer_free(ringbuffer);