diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 979f3479df2..d2e0dc46643 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2111,6 +2111,20 @@ static void hci_cmd_status(struct net_buf *buf) } } +static inline void mynewt_rand_delay(void) +{ +#if defined(CONFIG_BOARD_ARDUINO_101) + /* FIXME: Temporary hack for MyNewt HCI firmware which + * crashes if it receives too rapid LE_Rand commands. + */ + if (sys_execution_context_type_get() == NANO_CTX_FIBER) { + fiber_sleep(MSEC(30)); + } else { + task_sleep(MSEC(30)); + } +#endif +} + static int prng_reseed(struct tc_hmac_prng_struct *h) { uint8_t seed[32]; @@ -2121,6 +2135,11 @@ static int prng_reseed(struct tc_hmac_prng_struct *h) struct bt_hci_rp_le_rand *rp; struct net_buf *rsp; + /* FIXME: Temporary hack for MyNewt HCI firmware which + * crashes if it receives too rapid LE_Rand commands. + */ + mynewt_rand_delay(); + ret = bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, NULL, &rsp); if (ret) { return ret; @@ -2150,6 +2169,11 @@ static int prng_init(struct tc_hmac_prng_struct *h) struct net_buf *rsp; int ret; + /* FIXME: Temporary hack for MyNewt HCI firmware which + * crashes if it receives too rapid LE_Rand commands. + */ + mynewt_rand_delay(); + ret = bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, NULL, &rsp); if (ret) { return ret;