-
Notifications
You must be signed in to change notification settings - Fork 3
ocpp: Replaced JSON-C implementation with native Zephyr JSON #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/ev/ocpp
Are you sure you want to change the base?
Conversation
8e04b49
to
af62e5d
Compare
subsys/net/lib/ocpp/ocpp_j.h
Outdated
#ifndef __OCPP_J_ | ||
#define __OCPP_J_ | ||
|
||
#define MAX_UID_LEN 38 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a common macro with size limitation of 128, 256, 512 bytes
subsys/net/lib/ocpp/ocpp_j.h
Outdated
#define MAX_GETCONFIGURATION_RESP_LEN 92 | ||
#define MAX_OCPP_RPC_MESSAGE_LEN 512 | ||
|
||
#define BOOTNOTIF_REQ_FIELDS 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/REQ/MIN
subsys/net/lib/ocpp/ocpp_j.h
Outdated
#define MAX_OCPP_RPC_MESSAGE_LEN 512 | ||
|
||
#define BOOTNOTIF_REQ_FIELDS 2 | ||
#define BOOTNOTIF_TOTAL_FIELDS 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/TOTAL/MAX
subsys/net/lib/ocpp/ocpp_j.h
Outdated
struct ocpp_meter_val_msg { | ||
int connector_id; | ||
int transaction_id; | ||
struct ocpp_meter_value meter_value[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode struct ocpp_meter_value
here
subsys/net/lib/ocpp/ocpp_j.h
Outdated
|
||
struct ocpp_meter_value { | ||
char *timestamp; | ||
struct ocpp_sampled_value sampled_value[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode struct ocpp_sampled_value
inside here
subsys/net/lib/ocpp/ocpp_j.c
Outdated
.dummy = true, | ||
}; | ||
|
||
ret = json_obj_encode_buf(descr, ARRAY_SIZE(descr), &msg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the expected json out is empty {}
pass, (descr NULL, 0, NULL, ...
subsys/net/lib/ocpp/ocpp_j.h
Outdated
#define SAMPLED_VALUE_REQ_FIELDS 2 | ||
#define SAMPLED_VALUE_TOTAL_FIELDS 3 | ||
|
||
struct authorize_payload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use generic struct json_common_payload_field_str { char * val}
for authorize_payload
, heartbeat_payload
, ocpp_status_resp_msg
subsys/net/lib/ocpp/ocpp_j.h
Outdated
char *current_time; | ||
}; | ||
|
||
struct start_txn_payload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use generic struct json_common_payload_field_int { int val}
for start_txn_payload
, remote_stop_txn_payload
, unlock_connector_payload
subsys/net/lib/ocpp/ocpp_j.h
Outdated
char *id_tag; | ||
}; | ||
|
||
struct ocpp_heartbeat_msg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never hit to use this struct
if the intention is get empty {}
json as read from the code replace snippet to
ret = json_obj_encode_buf(descr, ARRAY_SIZE(descr), &msg, tmp_buf, sizeof(tmp_buf));
to
ret = json_obj_encode_buf(NULL, 0, NULL, tmp_buf, sizeof(tmp_buf));
subsys/net/lib/ocpp/ocpp_j.h
Outdated
int transaction_id; | ||
}; | ||
|
||
struct getconfig_payload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make struct name consistent.. all of here used only for json, may json_
or j_
prefix
Replaced external JSON-C usage with native Zephyr JSON APIs across OCPP subsystem. Added buffer sizing macros and field stripping logic to handle optional fields safely during encoding and parsing. Signed-off-by: Sanjay Vallimanalan <[email protected]>
Updated prj.conf to use CONFIG_JSON_LIBRARY instead of CONFIG_JSONC. Signed-off-by: Sanjay Vallimanalan <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.