From 9c1d566ea23c222a75cfd9a845a7579044e5611e Mon Sep 17 00:00:00 2001 From: Aapo Torkkeli <aamato@utu.fi> Date: Tue, 12 Nov 2019 12:44:53 +0200 Subject: [PATCH] Fix sending orientation by timer. --- project/ble.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/project/ble.c b/project/ble.c index 4606519..03b3e9b 100644 --- a/project/ble.c +++ b/project/ble.c @@ -125,7 +125,6 @@ APP_TIMER_DEF(send_orientation_timer_id); extern uint32_t orientation; -uint32_t previous_orientation; NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/ @@ -139,6 +138,8 @@ BLE_BAS_DEF(m_bas); // Macro for defining a ble_bas instance // Flag to keep track of when an indication confirmation is pending bool m_hts_meas_ind_conf_pending = false; +bool hts_indication_set = false; + // Function declarations void on_hts_evt(ble_hts_t * p_hts, ble_hts_evt_t * p_evt); void temperature_measurement_send(void); @@ -190,6 +191,7 @@ void on_hts_evt(ble_hts_t * p_hts, ble_hts_evt_t * p_evt) { case BLE_HTS_EVT_INDICATION_ENABLED: // Indication has been enabled, send a single temperature measurement temperature_measurement_send(); + hts_indication_set = true; break; case BLE_HTS_EVT_INDICATION_CONFIRMED: m_hts_meas_ind_conf_pending = false; @@ -262,7 +264,9 @@ void pm_evt_handler(pm_evt_t const * p_evt) { * @brief Handler for timer events. */ void send_orientation_timer(void* p_context) { - temperature_measurement_send(); + if(hts_indication_set){ + temperature_measurement_send(); + } } /**@brief Function for the Timer initialization. @@ -663,13 +667,7 @@ void bsp_event_handler(bsp_event_t event) { APP_ERROR_CHECK(err_code); } } - break; // BSP_EVENT_KEY_0 - case BSP_EVENT_KEY_0: - if (m_conn_handle != BLE_CONN_HANDLE_INVALID) { - temperature_measurement_send(); - } break; - default: break; } -- GitLab