chore(gw-lwm2m): store lifetime in clientinfo

This commit is contained in:
JianBo He 2021-10-09 11:50:33 +08:00
parent cfc905aa1a
commit 92a5c333af
2 changed files with 6 additions and 5 deletions

View File

@ -57,7 +57,7 @@
%% TODO:
-define(DEFAULT_OVERRIDE,
#{ clientid => <<"">> %% Generate clientid by default
, username => <<"${Packet.querystring.epn}">>
, username => <<"${Packet.uri_query.ep}">>
, password => <<"">>
}).
@ -300,13 +300,14 @@ enrich_clientinfo(#coap_message{options = Options} = Msg,
Channel = #channel{clientinfo = ClientInfo0}) ->
Query = maps:get(uri_query, Options, #{}),
case Query of
#{<<"ep">> := Epn} ->
%% TODO: put endpoint-name, lifetime into clientinfo ???
#{<<"ep">> := Epn, <<"lt">> := Lifetime} ->
Username = maps:get(<<"imei">>, Query, Epn),
Password = maps:get(<<"password">>, Query, undefined),
ClientId = maps:get(<<"device_id">>, Query, Epn),
ClientInfo =
ClientInfo0#{username => Username,
ClientInfo0#{endpoint_name => Epn,
lifetime => binary_to_integer(Lifetime),
username => Username,
password => Password,
clientid => ClientId},
{ok, NClientInfo} = fix_mountpoint(Msg, ClientInfo),

View File

@ -345,7 +345,7 @@ update(#coap_message{options = Opts, payload = Payload} = Msg,
WithContext,
CmdType,
#session{reg_info = OldRegInfo} = Session) ->
Query = maps:get(uri_query, Opts),
Query = maps:get(uri_query, Opts, #{}),
RegInfo = append_object_list(Query, Payload),
UpdateRegInfo = maps:merge(OldRegInfo, RegInfo),
LifeTime = get_lifetime(UpdateRegInfo, OldRegInfo),