fix debug info

This commit is contained in:
anlicheng 2024-11-10 12:38:00 +08:00
parent 922894bf04
commit 0b90c99f06
2 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ ai_event(Id) when is_integer(Id) ->
case hackney:request(post, Url, Headers, Body, [{pool, false}]) of
{ok, 200, _, ClientRef} ->
{ok, RespBody} = hackney:body(ClientRef),
lager:debug("[iot_api] send body: ~p, get error is: ~p", [Body, RespBody]),
lager:debug("[iot_api] send body: ~p, get response is: ~p", [Body, RespBody]),
hackney:close(ClientRef);
{ok, HttpCode, _, ClientRef} ->
{ok, RespBody} = hackney:body(ClientRef),

View File

@ -485,12 +485,12 @@ handle_event(cast, {handle, {event, Event0}}, ?STATE_ACTIVATED, State = #state{u
handle_event(cast, {handle, {ai_event, Event0}}, ?STATE_ACTIVATED, State = #state{uuid = UUID, aes = AES, has_session = true}) ->
EventText = iot_cipher_aes:decrypt(AES, Event0),
lager:debug("[iot_host] uuid: ~p, get ai_event: ~p", [UUID, EventText]),
lager:debug("[iot_host] ai_event uuid: ~p, text: ~p", [UUID, EventText]),
case catch jiffy:decode(EventText, [return_maps]) of
#{<<"event_type">> := EventType, <<"params">> := Params0 = #{<<"device_uuid">> := DeviceUUID, <<"props">> := Props}} ->
case iot_device:is_alive(DeviceUUID) of
error ->
lager:notice("[iot_host] uuid: ~p, device_uuid: ~p is not alive, get ai_event: ~p", [UUID, DeviceUUID, EventText]),
lager:notice("[iot_host] ai_event uuid: ~p, device_uuid: ~p is not alive, text: ~p", [UUID, DeviceUUID, EventText]),
ok;
{ok, DevicePid} ->
Params = maps:remove(<<"props">>, Params0),
@ -509,9 +509,9 @@ handle_event(cast, {handle, {ai_event, Event0}}, ?STATE_ACTIVATED, State = #stat
iot_device:ai_event(DevicePid, EventType, Params)
end;
Event when is_map(Event) ->
lager:warning("[iot_host] host: ~p, event: ~p, not supported", [UUID, Event]);
lager:warning("[iot_host] ai_event host: ~p, text: ~p, not supported", [UUID, Event]);
Other ->
lager:warning("[iot_host] host: ~p, event error: ~p", [UUID, Other])
lager:warning("[iot_host] ai_event host: ~p, error: ~p", [UUID, Other])
end,
{keep_state, State};