[api] define a generic 32hex checking function
This commit is contained in:
parent
d64d41be3a
commit
80073a5de5
|
@ -39,8 +39,11 @@ check_version(_, _) ->
|
||||||
{false, false}.
|
{false, false}.
|
||||||
|
|
||||||
check_sensor(Sensor) ->
|
check_sensor(Sensor) ->
|
||||||
case re:run(Sensor, "[0-9a-f]+", []) of
|
check_32hex(Sensor).
|
||||||
{match, [{0,32}]} -> {Sensor, true};
|
|
||||||
|
check_32hex(String) ->
|
||||||
|
case re:run(String, "[0-9a-f]+", []) of
|
||||||
|
{match, [{0,32}]} -> {String, true};
|
||||||
_ -> {false, false}
|
_ -> {false, false}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -91,9 +94,9 @@ check_unit(Unit) ->
|
||||||
check_token(undefined, undefined) ->
|
check_token(undefined, undefined) ->
|
||||||
{false, false};
|
{false, false};
|
||||||
check_token(Token, undefined) ->
|
check_token(Token, undefined) ->
|
||||||
check_sensor(Token);
|
check_32hex(Token);
|
||||||
check_token(undefined, Token) ->
|
check_token(undefined, Token) ->
|
||||||
check_sensor(Token);
|
check_32hex(Token);
|
||||||
check_token(_, _) ->
|
check_token(_, _) ->
|
||||||
{false, false}.
|
{false, false}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue