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:
Joe Kearney 2025-06-08 22:05:06 +00:00
parent af01bfed91
commit 7a7ce06d66
46 changed files with 2364 additions and 1531 deletions

View file

@ -24,10 +24,7 @@
#include <string.h>
#include <errno.h>
#include <SystemK.h>
#define MAX_LINE_LENGTH 140
#define MAX_KEY_LENGTH 64
#define MAX_VALUE_LENGTH 64
#include "Key_Value.h"
static const char *TAG = "NVM KV";
static const char *TEMP_FILE = "/usb/esp/temp.txt";
@ -52,10 +49,10 @@ static int KV_Parse_Line(char *line, char *key, char *value)
if (delimiter == NULL)
return 0;
*delimiter = '\0';
strncpy(key, line, MAX_KEY_LENGTH - 1);
strncpy(value, delimiter + 1, MAX_VALUE_LENGTH - 1);
key[MAX_KEY_LENGTH - 1] = '\0';
value[MAX_VALUE_LENGTH - 1] = '\0';
strncpy(key, line, KV_MAX_KEY_LENGTH - 1);
strncpy(value, delimiter + 1, KV_MAX_VALUE_LENGTH - 1);
key[KV_MAX_KEY_LENGTH - 1] = '\0';
value[KV_MAX_VALUE_LENGTH - 1] = '\0';
KV_Trim(key);
KV_Trim(value);
return 1;
@ -70,8 +67,8 @@ SystemKResult_T KV_Get_Value_string(const char *filename, const char *search_key
return SYSTEMK_RESULT_FILE_NOT_FOUND;
}
char line[MAX_LINE_LENGTH];
char key[MAX_KEY_LENGTH];
char line[KV_MAX_LINE_LENGTH];
char key[KV_MAX_KEY_LENGTH];
while (fgets(line, sizeof(line), file))
{
@ -104,16 +101,16 @@ SystemKResult_T KV_Set_Value_string(const char *filename, const char *set_key, c
return SYSTEMK_RESULT_WRITE_FAILED;
}
char line[MAX_LINE_LENGTH];
char line_copy[MAX_LINE_LENGTH];
char key[MAX_KEY_LENGTH];
char value[MAX_VALUE_LENGTH];
char line[KV_MAX_LINE_LENGTH];
char line_copy[KV_MAX_LINE_LENGTH];
char key[KV_MAX_KEY_LENGTH];
char value[KV_MAX_VALUE_LENGTH];
int found = 0;
while (fgets(line, sizeof(line), file))
{
strncpy(line_copy, line, MAX_LINE_LENGTH);
line_copy[MAX_LINE_LENGTH - 1] = '\0'; // Ensure null-termination
strncpy(line_copy, line, KV_MAX_LINE_LENGTH);
line_copy[KV_MAX_LINE_LENGTH - 1] = '\0'; // Ensure null-termination
if (KV_Parse_Line(line, key, value) && strcmp(key, set_key) == 0)
{
@ -142,7 +139,7 @@ SystemKResult_T KV_Set_Value_string(const char *filename, const char *set_key, c
SystemKResult_T KV_Get_Value_uint32(const char *filename, const char *search_key, uint32_t *value)
{
char value_str[MAX_VALUE_LENGTH];
char value_str[KV_MAX_VALUE_LENGTH];
SystemKResult_T result = KV_Get_Value_string(filename, search_key, value_str);
if (result != SYSTEMK_RESULT_SUCCESS)
@ -179,10 +176,10 @@ SystemKResult_T KV_Get_Value_uint32(const char *filename, const char *search_key
SystemKResult_T KV_Set_Value_uint32(const char *filename, const char *set_key, uint32_t *set_value)
{
char value_str[MAX_VALUE_LENGTH];
int written = snprintf(value_str, MAX_VALUE_LENGTH, "%lu", *set_value);
char value_str[KV_MAX_VALUE_LENGTH];
int written = snprintf(value_str, KV_MAX_VALUE_LENGTH, "%lu", *set_value);
if (written < 0 || written >= MAX_VALUE_LENGTH)
if (written < 0 || written >= KV_MAX_VALUE_LENGTH)
{
KLOG_ERROR(TAG, "Error converting uint32_t to string for key %s!", set_key);
return SYSTEMK_RESULT_WRONG_DATATYPE;
@ -215,10 +212,10 @@ SystemKResult_T KV_Get_Value_uint8(const char *filename, const char *search_key,
SystemKResult_T KV_Set_Value_uint8(const char *filename, const char *set_key, uint8_t *set_value)
{
char value_str[MAX_VALUE_LENGTH];
int written = snprintf(value_str, MAX_VALUE_LENGTH, "%u", *set_value);
char value_str[KV_MAX_VALUE_LENGTH];
int written = snprintf(value_str, KV_MAX_VALUE_LENGTH, "%u", *set_value);
if (written < 0 || written >= MAX_VALUE_LENGTH)
if (written < 0 || written >= KV_MAX_VALUE_LENGTH)
{
KLOG_ERROR(TAG, "Error converting uint8_t to string for key %s!", set_key);
return SYSTEMK_RESULT_WRONG_DATATYPE;