1 /*
2  * Copyright (c) 2025 Linumiz GmbH
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __OCPP_J_
8 #define __OCPP_J_
9 
10 #define JSON_MSG_BUF_128 128
11 #define JSON_MSG_BUF_256 256
12 #define JSON_MSG_BUF_512 512
13 
14 #define BOOTNOTIF_MIN_FIELDS 2
15 #define BOOTNOTIF_MAX_FIELDS 9
16 
17 #define STOP_TXN_MIN_FIELDS 3
18 #define STOP_TXN_MAX_FIELDS 5
19 
20 #define START_TXN_MIN_FIELDS 4
21 #define START_TXN_MAX_FIELDS 5
22 
23 #define GET_CFG_MAX_FIELDS 1
24 
25 #define SAMPLED_VALUE_MIN_FIELDS 2
26 #define SAMPLED_VALUE_MAX_FIELDS 3
27 
28 struct json_common_payload_field {
29 	int val1;
30 	char *val2;
31 };
32 
33 struct json_common_payload_field_str {
34 	char *val1;
35 	char *val2;
36 };
37 
38 struct json_ocpp_bootnotif_msg {
39 	char *charge_point_model;
40 	char *charge_point_vendor;
41 	char *charge_box_serial_number;
42 	char *charge_point_serial_number;
43 	char *firmware_version;
44 	char *iccid;
45 	char *imsi;
46 	char *meter_serial_number;
47 	char *meter_type;
48 };
49 
50 struct json_ocpp_meter_val_msg {
51 	int connector_id;
52 	int transaction_id;
53 
54 	struct json_ocpp_meter_val {
55 		char *timestamp;
56 
57 		struct json_ocpp_sample_val {
58 			char *measurand;
59 			char *value;
60 			char *unit;
61 		} sampled_value[1];
62 		size_t sampled_value_len;
63 	} meter_value[1];
64 
65 	size_t meter_value_len;
66 };
67 
68 struct json_ocpp_stop_txn_msg {
69 	int transaction_id;
70 	int meter_stop;
71 	char *timestamp;
72 	char *reason;
73 	char *id_tag;
74 };
75 
76 struct json_ocpp_start_txn_msg {
77 	int connector_id;
78 	char *id_tag;
79 	int meter_start;
80 	char *timestamp;
81 	int reservation_id;
82 };
83 
84 struct json_ocpp_getconfig_msg {
85 	struct json_ocpp_key_val {
86 		char *key;
87 		int readonly;
88 		char *value;
89 	} configuration_key[1];
90 
91 	size_t configuration_key_len;
92 	char *unknown_key;
93 };
94 
95 struct json_idtag_info_root {
96 	struct {
97 		char *status;
98 		char *parent_id_tag;
99 		char *expiry_date;
100 	} json_id_tag_info;
101 };
102 
103 struct json_bootnotif_payload {
104 	char *status;
105 	int interval;
106 	char *current_time;
107 };
108 
109 struct json_getconfig_payload {
110 	char *key[1];
111 	size_t key_len;
112 };
113 
114 #endif /* __OCPP_J_ */
115