diff --git a/BLE/BLE_Utils.c b/BLE/BLE_Utils.c index ebce04b..234ba62 100644 --- a/BLE/BLE_Utils.c +++ b/BLE/BLE_Utils.c @@ -102,6 +102,22 @@ SystemKResult_T BLE_HandleCommonEvents(KEvent_T *event) } result = SYSTEMK_RESULT_SUCCESS; } + else if (event_packet->event_ID == BLE_EVENT_FORCE_STATE) + { + uint32_t requested_state = event_packet->event_data; + + if (requested_state < STATE_IS_OUT_OF_RANGE) + { + Transition_For_Event(GetContext(), (StateID_T)requested_state, event); + KLOG_INFO("BLE", "State %lu forced.", requested_state); + result = SYSTEMK_RESULT_SUCCESS; + } + else + { + KLOG_ERROR("BLE", "Attempted to force unknown state %lu.", requested_state); + result = SYSTEMK_RESULT_OVERFLOW; + } + } } } } diff --git a/States/State_Configuring.c b/States/State_Configuring.c index 71b0eaf..6142c8e 100644 --- a/States/State_Configuring.c +++ b/States/State_Configuring.c @@ -400,6 +400,12 @@ void HandleBLEConfigurationPacket(const BLE_ParametersPacket_T *const packet) BLE_RespondToConfigurationPacket(packet, BLE_ERROR_CHANGING_PARAMETERS); } + // A parameters request addressed to this device or broadcast will end a BLE Quiet. + if (BLE_Unquiet() != SYSTEMK_RESULT_SUCCESS) + { + KLOG_ERROR(KLOG_TAG, "Couldn't Unquiet to respond to a Parameters request!"); + } + if (xTimerStart(BLEConfigurationResponseTimer, 0) != pdPASS) { KLOG_ERROR(KLOG_TAG, "Couldn't start the BLEConfigurationResponseTimer!");