diff --git a/project/ble.c b/project/ble.c index 46065199bc1adffbb19635c0aeef5ea01d116910..03b3e9b0d54e327565c74d0cb9237d64ac20f368 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; }