summaryrefslogtreecommitdiffstats
path: root/hci/src/btsnoop.c
diff options
context:
space:
mode:
authorZach Johnson <zachoverflow@google.com>2014-09-08 18:31:39 -0700
committerAndre Eisenbach <eisenbach@google.com>2015-03-16 16:51:33 -0700
commit733a06ed9c38fc7f3b00cece9c88ac72b6cc3d98 (patch)
tree555c757845a3a7427544c525eabcdfbe722d27c3 /hci/src/btsnoop.c
parentbb9b7170d8dba6a41b828fb2a349b8edd418dcfa (diff)
downloadandroid_system_bt-733a06ed9c38fc7f3b00cece9c88ac72b6cc3d98.tar.gz
android_system_bt-733a06ed9c38fc7f3b00cece9c88ac72b6cc3d98.tar.bz2
android_system_bt-733a06ed9c38fc7f3b00cece9c88ac72b6cc3d98.zip
Refactor bte_main into more of a shell.
Moves all HCI initialization into hci_layer. Removes superfluous exposed functionality on the HCI layer (like turning the chip on/off and logging) Also reorganizes some of hci_layer to group related functions together.
Diffstat (limited to 'hci/src/btsnoop.c')
-rw-r--r--hci/src/btsnoop.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.c
index 3bd5ef489..c16e26c11 100644
--- a/hci/src/btsnoop.c
+++ b/hci/src/btsnoop.c
@@ -49,6 +49,8 @@ static const uint64_t BTSNOOP_EPOCH_DELTA = 0x00dcddb30f2f8000ULL;
// File descriptor for btsnoop file.
static int hci_btsnoop_fd = -1;
+static bool is_logging = false;
+static const char *logging_path;
void btsnoop_net_open();
void btsnoop_net_close();
@@ -147,6 +149,24 @@ static void btsnoop_close(void) {
btsnoop_net_close();
}
+static void btsnoop_set_logging_path(const char *path) {
+ assert(!is_logging);
+ logging_path = path;
+}
+
+static void btsnoop_set_is_running(bool should_log) {
+ if (should_log == is_logging)
+ return;
+
+ is_logging = should_log;
+ if (should_log) {
+ assert(logging_path != NULL);
+ btsnoop_open(logging_path);
+ } else {
+ btsnoop_close();
+ }
+}
+
static void btsnoop_capture(const BT_HDR *buffer, bool is_received) {
const uint8_t *p = buffer->data + buffer->offset;
@@ -172,8 +192,8 @@ static void btsnoop_capture(const BT_HDR *buffer, bool is_received) {
}
static const btsnoop_t interface = {
- btsnoop_open,
- btsnoop_close,
+ btsnoop_set_logging_path,
+ btsnoop_set_is_running,
btsnoop_capture
};