NordicSemiconductor / Nordic-Thingy52-FW

Nordic Thingy:52 software development kit. This kit is designed to assist users in developing their own custom firmware for Thingy. Please see http://www.nordicsemi.com/thingy for the latest news and software releases.
Other
210 stars 133 forks source link

unreachable statement in ble_app_thingy example #3

Closed AryanNordic closed 7 years ago

AryanNordic commented 7 years ago
    case thingy_ble_evt_timeout:
        (void)SEGGER_RTT_WriteString(0, RTT_CTRL_TEXT_BRIGHT_GREEN"Thingy_ble_evt_timeout"RTT_CTRL_RESET"\n");
        nrf_delay_ms(5);
        sleep_mode_enter();
        NVIC_SystemReset();   // <- This statement is unreachable
        break;

sleep_mode_enter will never return as it makes the chip go to system off. wakeup will automatically cause a system reset.

AryanNordic commented 7 years ago

in m_batt_meas_handler() everything after sd_power_system_off is unreachable. Probably should delete it.

joakimtoe commented 7 years ago

Hi, and thank you for the feedback. We have the system reset there for the error case if sleep mode enter fails. If that happens something is terrible wrong, and the best solution would be to reset.

AryanNordic commented 7 years ago

The only way this could happen is when you are debugging, where system off is emulated. In those cases it is best to add a while(1); after the sleep function as suggested by specs. Nevertheless, this is just a nitpick and not a bug, so it is OK, if you want to keep it as it is.