diff --git a/linux/hci/socket/socket.go b/linux/hci/socket/socket.go index 0a0efae..c2f8fad 100644 --- a/linux/hci/socket/socket.go +++ b/linux/hci/socket/socket.go @@ -104,6 +104,15 @@ func open(fd, id int) (*Socket, error) { if err := unix.Bind(fd, &sa); err != nil { return nil, errors.Wrap(err, "can't bind socket to hci user channel") } + + // poll for 20ms to see if any data becomes available, then clear it + pfds := []unix.PollFd{unix.PollFd{Fd: int32(fd), Events: unix.POLLIN}} + unix.Poll(pfds, 20) + if pfds[0].Revents&unix.POLLIN > 0 { + b := make([]byte, 100) + unix.Read(fd, b) + } + return &Socket{fd: fd}, nil }