esp_alox/main/uart_prot.h
simon 94b5fd47a4 TMP: Working on a Prototyp of UART Communication
The Prototype will be used as Template for the Code Generation
but first we need an working example
2025-05-20 22:00:33 +02:00

101 lines
2.3 KiB
C

#ifndef _PROTO_HEADER
#define _PROTO_HEADER
#include "freertos/idf_additions.h"
#include <stdint.h>
void message_handler_init(void);
QueueHandle_t message_handler_get_input_queue(void);
QueueHandle_t message_handler_get_output_queue(void);
// MessageIDs
typedef enum {
RequestPing = 0xE1,
RequestStatus = 0xE2,
PrepareFirmwareUpdate = 0xF1,
FirmwareUpdateLine = 0xF2,
} PC_TO_ESP_MESSAGE_IDS;
typedef enum {
Clients = 0xE1,
Status = 0xE2,
Pong = 0xD1,
} ESP_TO_PC_MESSAGE_IDS;
// Payloads for single Messages
typedef struct {
uint8_t clientId;
} RequestPingPayload;
typedef struct {
uint8_t clientId;
} RequestStatusPayload;
typedef struct {
// empty payload
} PrepareFirmwareUpdatePayload;
typedef struct {
uint8_t data[240];
} FirmwareUpdateLinePayload;
typedef struct {
uint8_t clientCount;
uint32_t clientAvaiableBitMask;
} ClientsPayload;
typedef struct {
uint8_t clientId;
uint8_t mac[6];
} StatusPayload;
typedef struct {
uint8_t clientId;
uint32_t ping;
} PongPayload;
// Union for all the Payloads
typedef union {
RequestPingPayload request_ping;
RequestStatusPayload request_status;
PrepareFirmwareUpdatePayload prepare_firmware_update;
FirmwareUpdateLinePayload firmware_update_line;
ClientsPayload clients;
StatusPayload status;
PongPayload pong;
} PayloadUnion;
// Base Message that can hold all Payloads
typedef struct {
uint8_t Version;
PC_TO_ESP_MESSAGE_IDS MessageID;
uint8_t Length;
PayloadUnion Payload;
} PCTOESPBaseMessage;
typedef struct {
uint8_t Version;
ESP_TO_PC_MESSAGE_IDS MessageID;
uint8_t Length;
PayloadUnion Payload;
} ESPTOPCBaseMessage;
// deklarierte Hook-Signatur
void esp_send_message_hook(ESPTOPCBaseMessage *msg);
// Generic Send Function Prototype
void send_message(ESP_TO_PC_MESSAGE_IDS msgid, PayloadUnion *payload);
// Spezific Send Functions Prototype
void send_clients(uint8_t clientCount, uint32_t clientAvaiableBitMask);
void send_status(uint8_t clientId, uint8_t *mac);
void send_pong(uint8_t clientId, uint32_t ping);
// Prototypes for Message Recieve Handler to be set in user code
void (*on_request_ping)(RequestPingPayload *);
void (*on_request_status)(RequestStatusPayload *);
void (*on_prepare_firmware_update)(PrepareFirmwareUpdatePayload *);
void (*on_firmware_update_line)(FirmwareUpdateLinePayload *);
#endif