andrzej-kaczmarek closed pull request #789: nimble: Fix for invalid handling of
missed connection event
URL: https://github.com/apache/mynewt-core/pull/789
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/hw/drivers/nimble/nrf51/src/ble_phy.c
b/hw/drivers/nimble/nrf51/src/ble_phy.c
index 22d3d230b..e22257b26 100644
--- a/hw/drivers/nimble/nrf51/src/ble_phy.c
+++ b/hw/drivers/nimble/nrf51/src/ble_phy.c
@@ -274,10 +274,20 @@ nrf_wait_disabled(void)
{
uint32_t state;
- state = NRF_RADIO->STATE;
+ /*
+ * RX and TX states have the same values except for 3rd bit (0=RX, 1=TX) so
+ * we use RX symbols only.
+ */
+ state = NRF_RADIO->STATE & 0x07;
+
if (state != RADIO_STATE_STATE_Disabled) {
- if ((state == RADIO_STATE_STATE_RxDisable) ||
- (state == RADIO_STATE_STATE_TxDisable)) {
+ /* If PHY is in idle state for whatever reason, disable it now */
+ if (state == RADIO_STATE_STATE_RxIdle) {
+ NRF_RADIO->TASKS_DISABLE = 1;
+ STATS_INC(ble_phy_stats, radio_state_errs);
+ }
+
+ if (state == RADIO_STATE_STATE_RxDisable) {
/* This will end within a short time (6 usecs). Just poll */
while (NRF_RADIO->STATE == state) {
/* If this fails, something is really wrong. Should last
diff --git a/net/nimble/controller/src/ble_ll_conn.c
b/net/nimble/controller/src/ble_ll_conn.c
index 03930660f..9552d0927 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -1542,6 +1542,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
if (rc == BLE_LL_SCHED_STATE_DONE) {
ble_ll_event_send(&connsm->conn_ev_end);
+ ble_phy_disable();
ble_ll_state_set(BLE_LL_STATE_STANDBY);
g_ble_ll_conn_cur_sm = NULL;
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services