Skip to content

Commit 3714d2a

Browse files
committed
Automatically update status in idle state
1 parent 9c63de1 commit 3714d2a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ocpp_station.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ idle(cast, {rpccall, 'NotifyReport', MessageId, Message},
332332
ocpp_message:get(<<"seqNo">>, Message)]),
333333
keep_state_and_data
334334
end;
335+
idle(cast, {rpccall, 'StatusNotification', MessageId, Message}, Data) ->
336+
case update_status(Message, Data) of
337+
{ok, NewData} ->
338+
Response =
339+
ocpp_message:new_response('StatusNotification', #{}, MessageId),
340+
send_response(Response, Data),
341+
UpdatedData = NewData;
342+
{error, _} ->
343+
Response = ocpp_error:new('GenericError', MessageId),
344+
send_error(Response, Data),
345+
UpdatedData = Data
346+
end,
347+
{keep_state, UpdatedData};
335348
idle(cast, {rpccall, _, _, Message}, Data) ->
336349
NewData = handle_rpccall(Message, Data),
337350
{next_state, idle, NewData};

0 commit comments

Comments
 (0)