Updated BLE to spec. version 0.11

This commit is contained in:
Joe Kearney 2025-02-24 19:54:37 -06:00
parent 82ec410264
commit 908bdbba35
4 changed files with 76 additions and 27 deletions

View file

@ -26,7 +26,7 @@ static void Configuring_Entry(StateMachineContext_T *context);
static void Configuring_Do(StateMachineContext_T *context);
static void Configuring_Exit(StateMachineContext_T *context);
static void HandleBLEConfigurationPacket(const BLE_ConfigurationPacket_T *const packet);
static void HandleBLEConfigurationPacket(const BLE_ParametersPacket_T *const packet);
static TimerHandle_t BLEConfigurationResponseTimer = NULL;
static StaticTimer_t xBLEConfigurationResponseTimerBuffer;
@ -229,9 +229,9 @@ static void Configuring_Do(StateMachineContext_T *context)
break;
case KEVENT_BLE_PACKET_RECEIVED:
if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_CONFIGURATION)
if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_PARAMETERS)
{
HandleBLEConfigurationPacket((BLE_ConfigurationPacket_T *)Event.Data);
HandleBLEConfigurationPacket((BLE_ParametersPacket_T *)Event.Data);
}
else if (((BLE_Packet_T *)Event.Data)->Generic.type == BLE_PACKET_TYPE_EVENT)
{
@ -267,11 +267,11 @@ static void Configuring_Exit(StateMachineContext_T *context)
xQueueSend(xQueueNeoPixels, &neopixels_action, 0);
}
static SystemKResult_T HandleParameterChangeRequest(BLE_ConfigurationKey_T key, uint32_t value)
static SystemKResult_T HandleParameterChangeRequest(BLE_ParameterKey_T key, uint32_t value)
{
SystemKResult_T result = SYSTEMK_RESULT_UNSPECIFIED_FAILURE;
if (key == BLE_CONFIGURATION_KEY_TEAM_ID)
if (key == BLE_PARAMETER_KEY_TEAM_ID)
{
uint8_t team_ID = (uint8_t)value;
if (Is_Valid_Team_ID(team_ID))
@ -279,30 +279,35 @@ static SystemKResult_T HandleParameterChangeRequest(BLE_ConfigurationKey_T key,
result = Set_Team_With_Audio_Feedback(team_ID);
}
}
else if (key == BLE_PARAMETER_KEY_PLAYER_ID)
{
uint8_t player_ID = (uint8_t)value;
result = Set_Player_With_Audio_Feedback(player_ID);
}
return result;
}
void HandleBLEConfigurationPacket(const BLE_ConfigurationPacket_T *const packet)
void HandleBLEConfigurationPacket(const BLE_ParametersPacket_T *const packet)
{
if (BLE_IsBLEPacketForMe(packet->target_BD_ADDR))
{
if (BLE_IsPacketNew(packet->BD_ADDR, BLE_PACKET_TYPE_CONFIGURATION, packet->event_number))
if (BLE_IsPacketNew(packet->BD_ADDR, BLE_PACKET_TYPE_PARAMETERS, packet->event_number))
{
if (packet->subtype == BLE_REQUEST_PARAMETER_CHANGE)
{
SystemKResult_T result = SYSTEMK_RESULT_SUCCESS;
BLE_ConfigurationKey_T key_one = BLE_GetValidConfigKey(packet->key_one);
if (key_one != BLE_CONFIGURATION_KEY_NONE)
BLE_ParameterKey_T key_one = BLE_GetValidConfigKey(packet->key_one);
if (key_one != BLE_PARAMETER_KEY_NONE)
{
result = HandleParameterChangeRequest(key_one, packet->value_one);
}
if (result == SYSTEMK_RESULT_SUCCESS)
{
BLE_ConfigurationKey_T key_two = BLE_GetValidConfigKey(packet->key_two);
if (key_two != BLE_CONFIGURATION_KEY_NONE)
BLE_ParameterKey_T key_two = BLE_GetValidConfigKey(packet->key_two);
if (key_two != BLE_PARAMETER_KEY_NONE)
{
result = HandleParameterChangeRequest(key_two, packet->value_two);
}