Skip to content

Commit

Permalink
Remove hpr_time_ms just improve time
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie committed Feb 15, 2024
1 parent 73f33bf commit 476777a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/protocols/gwmp/hpr_gwmp_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ packet_up_to_push_data(Up, Timestamp, GatewayLocation) ->
BaseMeta = #{
gateway_id => B58,
gateway_name => Name,
regi => hpr_packet_up:region(Up),
hpr_time_ms => Timestamp
regi => hpr_packet_up:region(Up)
},
%% NOTE: everything in meta needs to be string -> string.
Meta =
Expand All @@ -257,13 +256,16 @@ packet_up_to_push_data(Up, Timestamp, GatewayLocation) ->
}
end,

%% calendar strips milliseconds, add them back for formatting.
{Date, {Hour, Min, Sec0}} = calendar:system_time_to_universal_time(Timestamp, millisecond),
Sec = Sec0 + (Timestamp rem 1000 / 1000),
ISOTime = iso8601:format({Date, {Hour, Min, Sec}}),

Data = semtech_udp:push_data(
Token,
MAC,
#{
time => iso8601:format(
calendar:system_time_to_universal_time(Timestamp, millisecond)
),
time => ISOTime,
tmst => hpr_packet_up:timestamp(Up) band 16#FFFF_FFFF,
freq => hpr_packet_up:frequency_mhz(Up),
rfch => 0,
Expand Down
6 changes: 2 additions & 4 deletions test/hpr_protocol_gwmp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,7 @@ verify_push_data(PacketUp, PushDataBinary) ->
),
<<"regi">> => erlang:atom_to_binary(
hpr_packet_up:region(PacketUp)
),
<<"hpr_time_ms">> => fun erlang:is_integer/1
)
}
}
]
Expand Down Expand Up @@ -838,8 +837,7 @@ verify_push_data_with_location(PacketUp, PushDataBinary, IndexString) ->
),
<<"gateway_h3index">> => erlang:list_to_binary(IndexString),
<<"gateway_lat">> => hpr_utils:format_coord(ExpectedLat),
<<"gateway_long">> => hpr_utils:format_coord(ExpectedLong),
<<"hpr_time_ms">> => fun erlang:is_integer/1
<<"gateway_long">> => hpr_utils:format_coord(ExpectedLong)
}
}
]
Expand Down

0 comments on commit 476777a

Please sign in to comment.