diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-10-03 14:32:02 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-12-03 16:32:48 +0200 |
commit | fd61d4719ec19e9e4ea6cfbad613de811c071399 (patch) | |
tree | 9e074aec9112312bfd454525e03548a6e3adacd5 /emulator/bthost.c | |
parent | 4fe7df6972530285f4bd96fffb11ae0ecfd3cd38 (diff) | |
download | bluez-fd61d4719ec19e9e4ea6cfbad613de811c071399.tar.gz |
emulator/bthost: Add API to wait for bthost readiness
Diffstat (limited to 'emulator/bthost.c')
-rw-r--r-- | emulator/bthost.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c index 4390082af..9079dceec 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -191,6 +191,8 @@ struct rfcomm_connection_data { }; struct bthost { + bool ready; + bthost_ready_cb ready_cb; uint8_t bdaddr[6]; uint8_t features[8]; bthost_send_func send_handler; @@ -741,6 +743,23 @@ static void read_bd_addr_complete(struct bthost *bthost, const void *data, return; memcpy(bthost->bdaddr, ev->bdaddr, 6); + + bthost->ready = true; + + if (bthost->ready_cb) { + bthost->ready_cb(); + bthost->ready_cb = NULL; + } +} + +void bthost_notify_ready(struct bthost *bthost, bthost_ready_cb cb) +{ + if (bthost->ready) { + cb(); + return; + } + + bthost->ready_cb = cb; } static void read_local_features_complete(struct bthost *bthost, |