#define DELIMETER_START '@'
#define DELIMETER_END '$'
#define MAX_STRING_LENGTH 32
// Funkcja do przetwarzania ciągu znaków
char* ParseValue(char *input) {
int8_t startDetect = 100;
int8_t endDetect = 0;
int8_t len = 0;
int8_t size = strlen(input);
if(size > MAX_STRING_LENGTH) return NULL;
char *p = malloc(strlen(input));
// Sprawdź, czy ciąg rozpoczyna się od '@' i kończy '$'
for (int i = 0; i < strlen(input); i++) {
if (input[i] == DELIMETER_START) {
startDetect = i;
}
if (input[i] == DELIMETER_END) {
endDetect = i;
}
}
if (startDetect > 99 || endDetect < 1) {
return NULL;
}
if (startDetect > endDetect) {
return NULL;
}
len = (endDetect - startDetect);
if (len < MAX_STRING_LENGTH) {
// Wyczysc znaki
memset(p, '\0', MAX_STRING_LENGTH);
strncpy(p, input + startDetect + 1, len - 1);
}
return p;
}
char *result = ParseValue("@1234$");
/// TODO: Send via UART
free(result);