Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions port/drivers/bluetooth/hci/h4.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,23 @@ static int h4_open(const struct device *dev, bt_hci_recv_t recv, void *hci_data)
return ret;
}

static int h4_close(const struct device *dev)
{
struct h4_data *h4 = dev->data;

LOG_DBG("close h4");

k_thread_abort(&h4->rx_thread_data);

close(h4->fd);
h4->fd = -1;

return 0;
}

static const struct bt_hci_driver_api h4_drv_api = {
.open = h4_open,
.close = h4_close,
.send = h4_send,
};

Expand Down
8 changes: 8 additions & 0 deletions port/kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,12 @@ void k_thread_resume(k_tid_t thread)

void k_thread_abort(k_tid_t thread)
{
pthread_t pid = (pthread_t)thread->init_data;

if (sys_dnode_is_linked(&thread->base.qnode_dlist)) {
sys_dlist_remove(&thread->base.qnode_dlist);
}

pthread_cancel(pid);
pthread_detach(pid);
}