From bce32598d3670169d3987e1b2ae315625e52dcd3 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 25 Dec 2023 15:41:35 +0800 Subject: [PATCH] fix zd_consumer --- apps/iot/src/consumer/iot_zd_consumer.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/iot/src/consumer/iot_zd_consumer.erl b/apps/iot/src/consumer/iot_zd_consumer.erl index 7577712..3e9a2fb 100644 --- a/apps/iot/src/consumer/iot_zd_consumer.erl +++ b/apps/iot/src/consumer/iot_zd_consumer.erl @@ -158,8 +158,21 @@ handle_info({directive_reply, Reply}, State = #state{logger_pid = LoggerPid, fli FlightInfo = <<"flight_num: ", (integer_to_binary(FlightNum - 1))/binary>>, case Reply of {ok, RawReq, DirectiveResult} -> + case DirectiveResult of + ok -> + iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, <<"OK">>, FlightInfo]); + {ok, Response} when is_binary(Response) -> + iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, Response, FlightInfo]); + {error, Reason0} -> + Reason = if + is_atom(Reason0) -> atom_to_binary(Reason0); + is_binary(Reason0) -> Reason0; + true -> <<"Unknow error">> + end, + iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Reason, FlightInfo]) + end, iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, DirectiveResult, FlightInfo]); - {error, RawReq, Error} -> + {error, RawReq, Error} when is_binary(Error) -> iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Error, FlightInfo]) end, {noreply, State#state{flight_num = FlightNum - 1}};