feat: create firmware skeleton and reproducible build
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
idf_component_register(
|
||||
SRCS "maze32_health.c"
|
||||
INCLUDE_DIRS "include"
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef MAZE32_HEALTH_H
|
||||
#define MAZE32_HEALTH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MAZE32_HEALTH_BOOTING = 0,
|
||||
MAZE32_HEALTH_FILESYSTEM_READY,
|
||||
MAZE32_HEALTH_SERVING,
|
||||
MAZE32_HEALTH_ERROR,
|
||||
} maze32_health_state_t;
|
||||
|
||||
typedef struct {
|
||||
const char *version;
|
||||
maze32_health_state_t state;
|
||||
int error_code;
|
||||
} maze32_health_t;
|
||||
|
||||
void maze32_health_init(maze32_health_t *health, const char *version);
|
||||
void maze32_health_set(maze32_health_t *health, maze32_health_state_t state, int error_code);
|
||||
const char *maze32_health_state_name(maze32_health_state_t state);
|
||||
int maze32_health_is_healthy(const maze32_health_t *health);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "maze32_health.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void maze32_health_init(maze32_health_t *health, const char *version)
|
||||
{
|
||||
if (health == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
health->version = version;
|
||||
health->state = MAZE32_HEALTH_BOOTING;
|
||||
health->error_code = 0;
|
||||
}
|
||||
|
||||
void maze32_health_set(maze32_health_t *health, maze32_health_state_t state, int error_code)
|
||||
{
|
||||
if (health == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
health->state = state;
|
||||
health->error_code = error_code;
|
||||
}
|
||||
|
||||
const char *maze32_health_state_name(maze32_health_state_t state)
|
||||
{
|
||||
switch (state) {
|
||||
case MAZE32_HEALTH_BOOTING:
|
||||
return "booting";
|
||||
case MAZE32_HEALTH_FILESYSTEM_READY:
|
||||
return "filesystem_ready";
|
||||
case MAZE32_HEALTH_SERVING:
|
||||
return "serving";
|
||||
case MAZE32_HEALTH_ERROR:
|
||||
return "error";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int maze32_health_is_healthy(const maze32_health_t *health)
|
||||
{
|
||||
return health != NULL && health->state == MAZE32_HEALTH_SERVING;
|
||||
}
|
||||
Reference in New Issue
Block a user