/**@brief Function for handling button events. * * @param[in] pin_no The pin number of the button pressed. * @param[in] button_action The action performed on button. */ static void button_event_handler(uint8_t pin_no, uint8_t button_action) { uint32_t err_code; #ifdef COMMISSIONING_ENABLED if ((button_action == APP_BUTTON_PUSH) && (pin_no == ERASE_BUTTON_PIN_NO)) { APPL_LOG("[APPL]: Erasing all commissioning settings from persistent storage... \r\n"); commissioning_settings_clear(); return; } #endif // COMMISSIONING_ENABLED // Check if interface is UP. if(mp_interface == NULL) { return; } if (button_action == APP_BUTTON_PUSH) { switch (pin_no) { case START_BUTTON_PIN_NO: { APPL_LOG("[APPL]: Start button has been pushed.\r\n"); // Change application state in case being in IDLE state. if(m_app_state == APP_STATE_IDLE) { m_app_state = APP_STATE_QUERYING; // Start application state machine timer. err_code = app_timer_start(m_app_timer, APP_STATE_INTERVAL, NULL); APP_ERROR_CHECK(err_code); } break; } case STOP_BUTTON_PIN_NO: { APPL_LOG("[APPL]: Stop button has been pushed.\r\n"); LEDS_OFF((LED_THREE | LED_FOUR)); // Back to IDLE state. m_app_state = APP_STATE_IDLE; // Stop application state machine timer. err_code = app_timer_stop(m_app_timer); APP_ERROR_CHECK(err_code); break; } default: break; } } }
/**@brief Function for handling button events. * * @param[in] pin_no The pin number of the button pressed. * @param[in] button_action The action performed on button. */ static void button_event_handler(uint8_t pin_no, uint8_t button_action) { #ifdef COMMISSIONING_ENABLED if ((button_action == APP_BUTTON_PUSH) && (pin_no == ERASE_BUTTON_PIN_NO)) { APPL_LOG("[APPL]: Erasing all commissioning settings from persistent storage... \r\n"); commissioning_settings_clear(); return; } #endif // COMMISSIONING_ENABLED return; }
/**@brief Function for handling button events. * * @param[in] pin_no The pin number of the button pressed. * @param[in] button_action The action performed on button. */ static void button_event_handler(uint8_t pin_no, uint8_t button_action) { if (mp_interface == NULL) { if ((button_action == APP_BUTTON_PUSH) && (pin_no == BUTTON_ONE)) { APPL_LOG("[APPL]: Erasing all commissioning settings from persistent storage... \r\n"); commissioning_settings_clear(); return; } return; } }
/**@brief Function for handling button events. * * @param[in] pin_no The pin number of the button pressed. * @param[in] button_action The action performed on button. */ static void button_event_handler(uint8_t pin_no, uint8_t button_action) { #ifdef COMMISSIONING_ENABLED if ((button_action == APP_BUTTON_PUSH) && (pin_no == ERASE_BUTTON_PIN_NO)) { APPL_LOG("[APPL]: Erasing all commissioning settings from persistent storage... \r\n"); commissioning_settings_clear(); return; } #endif // COMMISSIONING_ENABLED uint32_t err_code; // Check if interface has been established. if(m_interface_state == false) { return; } if (button_action == APP_BUTTON_PUSH) { switch (pin_no) { case BSP_BUTTON_0: { if (m_connection_state == false) { err_code = app_timer_start(m_mqtt_conn_timer_id, APP_XIVELY_CONNECT_DELAY, NULL); APP_ERROR_CHECK(err_code); } break; } case BSP_BUTTON_1: { if (m_connection_state == true) { err_code = mqtt_disconnect(&m_app_mqtt_id); APP_ERROR_CHECK(err_code); } break; } default: break; } } }