diff --git a/States/Playing/State_Playing.c b/States/Playing/State_Playing.c index b65b99f..841b105 100644 --- a/States/Playing/State_Playing.c +++ b/States/Playing/State_Playing.c @@ -24,7 +24,7 @@ static TimerHandle_t BLEStatusTimer = NULL; static StaticTimer_t xBLEStatusTimerBuffer; -static TickType_t xBLEStatusTimerPeriod = 3000 / portTICK_PERIOD_MS; +static TickType_t xBLEStatusTimerPeriod = 500 / portTICK_PERIOD_MS; static TimerHandle_t GameDurationTimer = NULL; static StaticTimer_t xGameDurationTimerBuffer; diff --git a/States/Starting_Game/State_Starting_Game__Counting_Down.c b/States/Starting_Game/State_Starting_Game__Counting_Down.c index e5b4164..c352794 100644 --- a/States/Starting_Game/State_Starting_Game__Counting_Down.c +++ b/States/Starting_Game/State_Starting_Game__Counting_Down.c @@ -50,6 +50,7 @@ static void Starting_Game__Counting_Down_Entry(StateMachineContext_T * context) Reset_Shots_Fired(); Reset_Tags_Received(); Reset_Times_Tagged_Out(); + Set_Health(Get_Max_Health()); uint8_t n_bombs; if (SETTINGS_get_uint8_t(SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY, &n_bombs) == SYSTEMK_RESULT_SUCCESS) diff --git a/States/State_Configuring.c b/States/State_Configuring.c index 6142c8e..d9416d1 100644 --- a/States/State_Configuring.c +++ b/States/State_Configuring.c @@ -230,7 +230,12 @@ static void Configuring_Do(StateMachineContext_T *context) break; case KEVENT_BLE_PACKET_RECEIVED: - if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_PARAMETERS) + if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_INSTIGATE_GAME) + { + Transition_For_Event(context, STATE_STARTING_GAME__RESPONDING, &Event); + // Don't free the packet buffer here; it will be freed in Starting_Game__Responding_Entry(). + } + else if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_PARAMETERS) { HandleBLEConfigurationPacket((BLE_ParametersPacket_T *)Event.Data); } diff --git a/States/State_Initializing.c b/States/State_Initializing.c index 1570297..55e2b9f 100644 --- a/States/State_Initializing.c +++ b/States/State_Initializing.c @@ -68,7 +68,7 @@ static void Initializing_Do(StateMachineContext_T * context) { switch (Event.ID) { - case KEVENT_TRIGGER_SWITCH_PRESSED: + case KEVENT_ACCESSORY_SWITCH_PRESSED: Transition_For_Event(context, STATE_REPROGRAMMING, &Event); break; diff --git a/States/State_Ready.c b/States/State_Ready.c index 777e37c..ea86d60 100644 --- a/States/State_Ready.c +++ b/States/State_Ready.c @@ -54,8 +54,6 @@ static void Ready_Entry(StateMachineContext_T * context) } AudioAction_T audio_action = {.ID = AUDIO_PLAY_GAME_ON, .Data = (void *)0x00}; Perform_Audio_Action(&audio_action); - - Set_Health(Get_Max_Health()); } //! Executes the Ready state. @@ -91,6 +89,7 @@ static void Ready_Do(StateMachineContext_T * context) if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_INSTIGATE_GAME) { Transition_For_Event(context, STATE_STARTING_GAME__RESPONDING, &Event); + // Don't free the packet buffer here; it will be freed in Starting_Game__Responding_Entry(). } else if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_EVENT) { diff --git a/States/State_Wrapping_Up.c b/States/State_Wrapping_Up.c index f9bcba7..133e27d 100644 --- a/States/State_Wrapping_Up.c +++ b/States/State_Wrapping_Up.c @@ -109,7 +109,12 @@ static void Wrapping_Up_Do(StateMachineContext_T * context) break; case KEVENT_BLE_PACKET_RECEIVED: - if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_EVENT) + if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_INSTIGATE_GAME) + { + Transition_For_Event(context, STATE_STARTING_GAME__RESPONDING, &Event); + // Don't free the packet buffer here; it will be freed in Starting_Game__Responding_Entry(). + } + else if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_EVENT) { HandleBLEEventPacket((BLE_EventPacket_T *)Event.Data, context); }