fix(lwm2m): decode/encode data as signed integer

This commit is contained in:
Shawn 2021-04-08 09:42:16 +08:00 committed by turtleDeng
parent 765d84ef48
commit f8fbd3e3db
1 changed files with 2 additions and 2 deletions

View File

@ -126,7 +126,7 @@ value(Value, ResourceId, ObjDefinition) ->
Value; % keep binary type since it is same as a string for jsx
"Integer" ->
Size = byte_size(Value)*8,
<<IntResult:Size>> = Value,
<<IntResult:Size/signed>> = Value,
IntResult;
"Float" ->
Size = byte_size(Value)*8,
@ -365,7 +365,7 @@ encode_int(Int) when Int >= 0 ->
binary:encode_unsigned(Int);
encode_int(Int) when Int < 0 ->
Size = byte_size_of_signed(-Int) * 8,
<<Int:Size>>.
<<Int:Size/signed>>.
byte_size_of_signed(UInt) ->
byte_size_of_signed(UInt, 0).