Reorderd hook stubs in header file and fixed up some spacing
This commit is contained in:
parent
49bfccfbd8
commit
ca22cc501e
@ -20,8 +20,8 @@ typedef struct {
|
|||||||
{{- end}}
|
{{- end}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
} {{ .Name }}Payload;
|
} {{ .Name }}Payload;
|
||||||
{{ end }}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
{{define "union"}}
|
{{define "union"}}
|
||||||
typedef union {
|
typedef union {
|
||||||
@ -32,24 +32,24 @@ typedef union {
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "basemessage"}}
|
{{define "basemessage"}}
|
||||||
typdef struct {
|
typedef struct {
|
||||||
uint8_t version;
|
uint8_t Version;
|
||||||
MessageID {{.CenumPCTOESP.EnumName}};
|
{{.CenumPCTOESP.EnumName}} MessageID;
|
||||||
uint8_t length;
|
uint8_t Length;
|
||||||
PayloadUnion payload;
|
PayloadUnion Payload;
|
||||||
} PCTOESPBaseMessage;
|
} PCTOESPBaseMessage;
|
||||||
|
|
||||||
typdef struct {
|
typedef struct {
|
||||||
uint8_t version;
|
uint8_t Version;
|
||||||
MessageID {{.CenumESPTOPC.EnumName}};
|
{{.CenumESPTOPC.EnumName}} MessageID;
|
||||||
uint8_t length;
|
uint8_t Length;
|
||||||
PayloadUnion payload;
|
PayloadUnion Payload;
|
||||||
} ESPTOPCBaseMessage;
|
} ESPTOPCBaseMessage;
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "handler"}}
|
{{define "handler"}}
|
||||||
{{- range . }}
|
{{- range . }}
|
||||||
void (*on_{{ .Name | snake }})({{ .Name }}Payload*) = NULL;
|
void (*on_{{ .Name | snake }})({{ .Name }}Payload*);
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
@ -68,19 +68,38 @@ void dispatch_message(uint8_t msg_id, void *payload) {
|
|||||||
}
|
}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "send_functions"}}
|
{{define "send_function_prototype"}}
|
||||||
|
void send_message(ESP_TO_PC_MESSAGE_IDS msgid, PayloadUnion *payload);
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "send_function_source"}}
|
||||||
|
void send_message(ESP_TO_PC_MESSAGE_IDS msgid, PayloadUnion *payload) {}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "send_functions_prototype"}}
|
||||||
{{- range .}}
|
{{- range .}}
|
||||||
{{ $argLen := len .Payload }}
|
{{- $argLen := len .Payload }}
|
||||||
void send_{{.Name | snake}}({{- range $i, $p := .Payload}}{{$p.DataType}} {{if .ArrayLength}}*{{end}}{{$p.Name}} {{- if not (isLast $argLen $i) }}, {{ end}} {{- end}}) {
|
void send_{{.Name | snake}}({{- range $i, $p := .Payload}}{{$p.DataType}} {{ if .ArrayLength}}*{{end}}{{$p.Name}} {{- if not (isLast $argLen $i) }}, {{ end}} {{- end}});
|
||||||
{{.Name}}Payload payload;
|
|
||||||
|
|
||||||
// Payload-Daten zuweisen
|
|
||||||
{{- range .Payload}}
|
|
||||||
payload.{{.Name}} = {{.Name}};
|
|
||||||
{{- end}}
|
|
||||||
|
|
||||||
// Nachricht senden
|
|
||||||
send_message({{.Name}}, &payload);
|
|
||||||
}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{define "send_functions_source"}}
|
||||||
|
{{- range .}}
|
||||||
|
{{- $argLen := len .Payload }}
|
||||||
|
void send_{{.Name | snake}}({{- range $i, $p := .Payload}}{{$p.DataType}} {{ if .ArrayLength}}*{{end}}{{$p.Name}} {{ if not (isLast $argLen $i) }}, {{ end}} {{- end}}) {
|
||||||
|
{{.Name}}Payload payload;
|
||||||
|
|
||||||
|
// Payload-Daten zuweisen
|
||||||
|
{{- range .Payload}}
|
||||||
|
{{- if .ArrayLength }}
|
||||||
|
memcpy(payload.{{.Name}}, {{.Name}}, {{.ArrayLength}});
|
||||||
|
{{- else }}
|
||||||
|
payload.{{.Name}} = {{.Name}};
|
||||||
|
{{- end}}
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
// Nachricht senden
|
||||||
|
send_message({{.Name}}, (PayloadUnion *)&payload);
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|||||||
@ -4,14 +4,29 @@
|
|||||||
#ifndef _PROTO_HEADER
|
#ifndef _PROTO_HEADER
|
||||||
#define _PROTO_HEADER
|
#define _PROTO_HEADER
|
||||||
|
|
||||||
{{ block "cenum" .CenumPCTOESP }} {{ end }}
|
#include <stdint.h>
|
||||||
{{ block "cenum" .CenumESPTOPC }} {{ end }}
|
|
||||||
|
|
||||||
{{ block "payloads" .PayloadStructs }} {{ end }}
|
// MessageIDs
|
||||||
|
{{- block "cenum" .CenumPCTOESP }} {{- end}}
|
||||||
|
{{- block "cenum" .CenumESPTOPC }} {{- end}}
|
||||||
|
|
||||||
{{ block "union" .PayloadStructs }} {{ end }}
|
// Payloads for single Messages
|
||||||
|
{{- block "payloads" .PayloadStructs }} {{- end}}
|
||||||
|
|
||||||
{{ block "basemessage" . }} {{ end }}
|
// Union for all the Payloads
|
||||||
|
{{- block "union" .PayloadStructs }} {{- end}}
|
||||||
|
|
||||||
|
// Base Message that can hold all Payloads
|
||||||
|
{{- block "basemessage" . }} {{- end}}
|
||||||
|
|
||||||
|
// Generic Send Function Prototype
|
||||||
|
{{- block "send_function_prototype" .MessagesESPtoPC}} {{- end}}
|
||||||
|
|
||||||
|
// Spezific Send Functions Prototype
|
||||||
|
{{- block "send_functions_prototype" .MessagesESPtoPC}} {{- end}}
|
||||||
|
|
||||||
|
// Prototypes for Message Recieve Handler to be set in user code
|
||||||
|
{{- block "handler" .MessagesPCtoESP}} {{ end }}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
{{- define "cpartSource" -}}
|
{{- define "cpartSource" -}}
|
||||||
// AUTO GENERATED DO NOT EDIT!!!
|
// AUTO GENERATED DO NOT EDIT!!!
|
||||||
|
|
||||||
{{ block "handler" .MessagesPCtoESP}} {{ end }}
|
#include "uart_prot.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
{{ block "dispatcher" .MessagesPCtoESP}} {{ end }}
|
// Message Dispatcher
|
||||||
|
{{- block "dispatcher" .MessagesPCtoESP}} {{ end }}
|
||||||
|
|
||||||
{{ block "send_functions" .MessagesESPtoPC}} {{ end }}
|
//Generic Send Function
|
||||||
|
{{- block "send_function_source" .MessagesESPtoPC}} {{ end }}
|
||||||
|
|
||||||
|
// Sepzific Send Functions
|
||||||
|
{{- block "send_functions_source" .MessagesESPtoPC}} {{ end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user