Updated BLE to spec. version 0.11
This commit is contained in:
parent
82ec410264
commit
908bdbba35
4 changed files with 76 additions and 27 deletions
|
@ -257,7 +257,7 @@ void BLE_UpdateTagPacket(int16_t damage, color_t color, uint8_t target_BD_ADDR[B
|
|||
}
|
||||
}
|
||||
|
||||
void BLE_RespondToConfigurationPacket(const BLE_ConfigurationPacket_T *const packet, BLE_ConfigurationSubtype_T response)
|
||||
void BLE_RespondToConfigurationPacket(const BLE_ParametersPacket_T *const packet, BLE_ConfigurationSubtype_T response)
|
||||
{
|
||||
static uint8_t EventNumber = 0;
|
||||
|
||||
|
@ -272,7 +272,7 @@ void BLE_RespondToConfigurationPacket(const BLE_ConfigurationPacket_T *const pac
|
|||
Advertising_Data.data[5] = 'T';
|
||||
Advertising_Data.data[6] = 'a';
|
||||
Advertising_Data.data[7] = 'g';
|
||||
Advertising_Data.data[8] = BLE_PACKET_TYPE_CONFIGURATION;
|
||||
Advertising_Data.data[8] = BLE_PACKET_TYPE_PARAMETERS;
|
||||
Advertising_Data.data[9] = EventNumber++;
|
||||
Advertising_Data.data[10] = packet->BD_ADDR[0];
|
||||
Advertising_Data.data[11] = packet->BD_ADDR[1];
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef enum
|
|||
BLE_PACKET_TYPE_TAG = 3,
|
||||
BLE_PACKET_TYPE_CONSOLE = 4,
|
||||
BLE_PACKET_TYPE_STATUS = 5,
|
||||
BLE_PACKET_TYPE_CONFIGURATION = 6,
|
||||
BLE_PACKET_TYPE_PARAMETERS = 6,
|
||||
BLE_PACKET_TYPE_HELLO = 7,
|
||||
BLE_LAST_VALID_PACKET_TYPE = BLE_PACKET_TYPE_HELLO,
|
||||
BLE_PACKET_TYPE_UNKNOWN
|
||||
|
@ -178,27 +178,50 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
BLE_CONFIGURATION_KEY_NONE = 0x0000,
|
||||
BLE_CONFIGURATION_KEY_TEAM_ID = 0x0001,
|
||||
BLE_FIRST_VALID_CONFIGURATION_KEY = BLE_CONFIGURATION_KEY_TEAM_ID,
|
||||
BLE_LAST_VALID_CONFIGURATION_KEY = BLE_CONFIGURATION_KEY_TEAM_ID,
|
||||
BLE_DEVICE_TYPE_UNUSED = 0xFFFF
|
||||
} BLE_ConfigurationKey_T;
|
||||
BLE_PARAMETER_KEY_NONE = 0,
|
||||
BLE_PARAMETER_KEY_TEAM_ID = 1,
|
||||
BLE_PARAMETER_KEY_PLAYER_ID = 2,
|
||||
BLE_PARAMETER_KEY_GAME_LENGTH = 3,
|
||||
BLE_PARAMETER_KEY_MAX_HEALTH = 4,
|
||||
BLE_PARAMETER_KEY_SECONDARY_COLOR = 5,
|
||||
BLE_PARAMETER_KEY_SPECIAL_WEAPONS_ON_REENTRY = 6,
|
||||
BLE_FIRST_VALID_CONFIGURATION_KEY = BLE_PARAMETER_KEY_TEAM_ID,
|
||||
BLE_LAST_VALID_CONFIGURATION_KEY = BLE_PARAMETER_KEY_SPECIAL_WEAPONS_ON_REENTRY,
|
||||
BLE_PARAMETER_KEY_SHOTS_FIRED_THIS_GAME = 10001,
|
||||
BLE_PARAMETER_KEY_TAGS_RECEIVED_THIS_GAME = 10002,
|
||||
BLE_PARAMETER_KEY_TIMES_TAGGED_OUT_THIS_GAME = 10003,
|
||||
BLE_FIRST_VALID_GAME_RESULT_KEY = BLE_PARAMETER_KEY_SHOTS_FIRED_THIS_GAME,
|
||||
BLE_LAST_VALID_GAME_RESULT_KEY = BLE_PARAMETER_KEY_TIMES_TAGGED_OUT_THIS_GAME,
|
||||
BLE_PARAMETER_KEY_UNUSED = 65535
|
||||
} BLE_ParameterKey_T;
|
||||
|
||||
inline BLE_ConfigurationKey_T BLE_GetValidConfigKey(uint16_t key)
|
||||
inline BLE_ParameterKey_T BLE_GetValidConfigKey(uint16_t key)
|
||||
{
|
||||
BLE_ConfigurationKey_T result = BLE_CONFIGURATION_KEY_NONE;
|
||||
BLE_ParameterKey_T result = BLE_PARAMETER_KEY_NONE;
|
||||
|
||||
if ((key >= BLE_FIRST_VALID_CONFIGURATION_KEY) &&
|
||||
(key <= BLE_LAST_VALID_CONFIGURATION_KEY))
|
||||
{
|
||||
result = (BLE_ConfigurationKey_T)key;
|
||||
result = (BLE_ParameterKey_T)key;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Contents of the BLE packet #BLE_PACKET_TYPE_CONFIGURATION.
|
||||
inline BLE_ParameterKey_T BLE_GetValidGameResultKey(uint16_t key)
|
||||
{
|
||||
BLE_ParameterKey_T result = BLE_PARAMETER_KEY_NONE;
|
||||
|
||||
if ((key >= BLE_FIRST_VALID_GAME_RESULT_KEY) &&
|
||||
(key <= BLE_LAST_VALID_GAME_RESULT_KEY))
|
||||
{
|
||||
result = (BLE_ParameterKey_T)key;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//! Contents of the BLE packet #BLE_PACKET_TYPE_PARAMETERS.
|
||||
typedef struct
|
||||
{
|
||||
BLE_PacketType_T type;
|
||||
|
@ -213,7 +236,7 @@ typedef struct
|
|||
uint16_t key_two;
|
||||
uint32_t value_two;
|
||||
uint8_t unused[2];
|
||||
} __attribute__((packed, aligned(1))) BLE_ConfigurationPacket_T;
|
||||
} __attribute__((packed, aligned(1))) BLE_ParametersPacket_T;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -247,7 +270,7 @@ typedef union
|
|||
BLE_TagPacket_T Tag;
|
||||
BLE_ConsolePacket_T Console;
|
||||
BLE_StatusPacket_T Status;
|
||||
BLE_ConfigurationPacket_T Configuration;
|
||||
BLE_ParametersPacket_T Configuration;
|
||||
BLE_HelloPacket_T Hello;
|
||||
} BLE_Packet_T;
|
||||
|
||||
|
@ -271,7 +294,7 @@ BLE_Packet_T *BLE_DecodeKTagPacket(const uint8_t *received_data, uint8_t receive
|
|||
void BLE_UpdateInstigationPacket(uint32_t Game_Length_in_ms, uint32_t Time_Remaining_Until_Countdown_in_ms);
|
||||
void BLE_UpdateStatusPacket(uint8_t current_state);
|
||||
void BLE_UpdateTagPacket(int16_t damage, color_t color, uint8_t target_BD_ADDR[BD_ADDR_SIZE]);
|
||||
void BLE_RespondToConfigurationPacket(const BLE_ConfigurationPacket_T *const packet, BLE_ConfigurationSubtype_T response);
|
||||
void BLE_RespondToConfigurationPacket(const BLE_ParametersPacket_T *const packet, BLE_ConfigurationSubtype_T response);
|
||||
void BLE_UpdateHelloPacket();
|
||||
bool BLE_IsBLEPacketForMe(const uint8_t BD_ADDR[BD_ADDR_SIZE]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue