fix(lwm2m): decode/encode data as signed integer
This commit is contained in:
parent
765d84ef48
commit
f8fbd3e3db
|
@ -126,7 +126,7 @@ value(Value, ResourceId, ObjDefinition) ->
|
||||||
Value; % keep binary type since it is same as a string for jsx
|
Value; % keep binary type since it is same as a string for jsx
|
||||||
"Integer" ->
|
"Integer" ->
|
||||||
Size = byte_size(Value)*8,
|
Size = byte_size(Value)*8,
|
||||||
<<IntResult:Size>> = Value,
|
<<IntResult:Size/signed>> = Value,
|
||||||
IntResult;
|
IntResult;
|
||||||
"Float" ->
|
"Float" ->
|
||||||
Size = byte_size(Value)*8,
|
Size = byte_size(Value)*8,
|
||||||
|
@ -365,7 +365,7 @@ encode_int(Int) when Int >= 0 ->
|
||||||
binary:encode_unsigned(Int);
|
binary:encode_unsigned(Int);
|
||||||
encode_int(Int) when Int < 0 ->
|
encode_int(Int) when Int < 0 ->
|
||||||
Size = byte_size_of_signed(-Int) * 8,
|
Size = byte_size_of_signed(-Int) * 8,
|
||||||
<<Int:Size>>.
|
<<Int:Size/signed>>.
|
||||||
|
|
||||||
byte_size_of_signed(UInt) ->
|
byte_size_of_signed(UInt) ->
|
||||||
byte_size_of_signed(UInt, 0).
|
byte_size_of_signed(UInt, 0).
|
||||||
|
|
Loading…
Reference in New Issue