Pulled in the latest SystemK (with new BLE). (#2)
The new spec is here: [KTag Beacon Specification v0.11](https://ktag.clubk.club/Technology/BLE/KTag%20Beacon%20Specification%20v0.11.pdf) Co-authored-by: Joe Kearney <joe@clubk.club> Reviewed-on: #2
This commit is contained in:
parent
af01bfed91
commit
7a7ce06d66
46 changed files with 2364 additions and 1531 deletions
|
@ -19,6 +19,7 @@
|
|||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <SystemK.h>
|
||||
#include <NVM.h>
|
||||
|
||||
|
@ -27,6 +28,8 @@ static const uint8_t UNINTIALIZED_UINT8 = UINT8_MAX;
|
|||
static uint8_t Cached_Team_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Player_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Weapon_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Max_Health = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_N_Special_Weapons_On_Reentry = UNINTIALIZED_UINT8;
|
||||
|
||||
SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
||||
{
|
||||
|
@ -55,7 +58,6 @@ SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
|||
key = "Team_ID";
|
||||
cached_value = &Cached_Team_ID;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_PLAYERID:
|
||||
|
@ -84,6 +86,32 @@ SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
|||
}
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_MAX_HEALTH:
|
||||
if (Cached_Max_Health != UNINTIALIZED_UINT8)
|
||||
{
|
||||
*value = Cached_Max_Health;
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "Max_Health";
|
||||
cached_value = &Cached_Max_Health;
|
||||
}
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY:
|
||||
if (Cached_N_Special_Weapons_On_Reentry != UNINTIALIZED_UINT8)
|
||||
{
|
||||
*value = Cached_N_Special_Weapons_On_Reentry;
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "N_Special_Weapons_On_Reentry";
|
||||
cached_value = &Cached_N_Special_Weapons_On_Reentry;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -142,6 +170,16 @@ SystemKResult_T SETTINGS_set_uint8_t(SystemKSettingID_T id, uint8_t value)
|
|||
result = KV_Set_Value_uint8(CONFIG_FILE, "Weapon_ID", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_MAX_HEALTH:
|
||||
Cached_Max_Health = value;
|
||||
result = KV_Set_Value_uint8(CONFIG_FILE, "Max_Health", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY:
|
||||
Cached_N_Special_Weapons_On_Reentry = value;
|
||||
result = KV_Set_Value_uint8(CONFIG_FILE, "N_Special_Weapons_On_Reentry", &value);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -157,10 +195,19 @@ SystemKResult_T SETTINGS_get_uint32_t(SystemKSettingID_T id, uint32_t *value)
|
|||
|
||||
switch (id)
|
||||
{
|
||||
case SYSTEMK_SETTING_DEVICE_TYPE:
|
||||
*value = BLE_DEVICE_TYPE_32ESPECIAL;
|
||||
return result;
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_T_START_GAME_in_ms:
|
||||
key = "T_Start_Game_in_ms";
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_T_GAME_LENGTH_in_ms:
|
||||
key = "T_Game_Length_in_ms";
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -194,6 +241,10 @@ SystemKResult_T SETTINGS_set_uint32_t(SystemKSettingID_T id, uint32_t value)
|
|||
result = KV_Set_Value_uint32(CONFIG_FILE, "T_Start_Game_in_ms", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_T_GAME_LENGTH_in_ms:
|
||||
result = KV_Set_Value_uint32(CONFIG_FILE, "T_Game_Length_in_ms", &value);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -202,6 +253,26 @@ SystemKResult_T SETTINGS_set_uint32_t(SystemKSettingID_T id, uint32_t value)
|
|||
return result;
|
||||
}
|
||||
|
||||
SystemKResult_T SETTINGS_get_device_name(char* name)
|
||||
{
|
||||
char buffer[KV_MAX_VALUE_LENGTH];
|
||||
SystemKResult_T result = KV_Get_Value_string(CONFIG_FILE, "Device_Name", buffer);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
memcpy(name, buffer, SYSTEMK_MAX_CHARS_IN_DEVICE_NAME);
|
||||
buffer[SYSTEMK_MAX_CHARS_IN_DEVICE_NAME] = 0x00;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SystemKResult_T SETTINGS_set_device_name(char* name)
|
||||
{
|
||||
SystemKResult_T result = KV_Set_Value_string(CONFIG_FILE, "Device_Name", name);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Settings are saved on change in this implementation.
|
||||
SystemKResult_T SETTINGS_Save(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue