nimble/host: Fix initialization order
Transport should be configured after default queue is set.
Callbacks set by host handle data by putting them on queue and use
event queue to notify host. If queue is not set (which can happen if
transport sends data immediately after callbacks are registered),
we'll have crash.
@@ -781,15 +781,15 @@ ble_hs_init(void)
ble_hs_dbg_mutex_locked = 0;
#endif
- /* Configure the HCI transport to communicate with a host. */
- ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
-
#ifdef MYNEWT
ble_hs_evq_set((struct ble_npl_eventq *)os_eventq_dflt_get());
#else
ble_hs_evq_set(nimble_port_get_dflt_eventq());
#endif
+ /* Configure the HCI transport to communicate with a host. */
+ ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
+
#if BLE_MONITOR
rc = ble_monitor_init();
SYSINIT_PANIC_ASSERT(rc == 0);
