fix
This commit is contained in:
parent
4306b94bf0
commit
1977fa5278
@ -15,7 +15,7 @@
|
||||
|
||||
%% API
|
||||
-export([start_link/0]).
|
||||
-export([mock/0, mock/1]).
|
||||
-export([mock/4]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
|
||||
@ -43,19 +43,15 @@
|
||||
%%% API
|
||||
%%%===================================================================
|
||||
|
||||
mock() ->
|
||||
LocationCode = <<"0001000290040150004002560">>,
|
||||
mock(LocationCode).
|
||||
|
||||
mock(LocationCode) when is_binary(LocationCode) ->
|
||||
mock(LocationCode, SType, CType, Value) when is_binary(LocationCode), is_integer(SType), is_integer(CType) ->
|
||||
Req = #{
|
||||
<<"version">> => <<"1.0">>,
|
||||
<<"ts">> => iot_util:current_time(),
|
||||
<<"properties">> => #{
|
||||
<<"type">> => <<"ctrl">>,
|
||||
<<"stype">> => 0,
|
||||
<<"ctype">> => 1,
|
||||
<<"value">> => 1234,
|
||||
<<"stype">> => SType,
|
||||
<<"ctype">> => CType,
|
||||
<<"value">> => Value,
|
||||
<<"timestamp">> => iot_util:current_time()
|
||||
},
|
||||
<<"location_code">> => LocationCode
|
||||
@ -98,9 +94,9 @@ init([]) ->
|
||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||
{stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
|
||||
{stop, Reason :: term(), NewState :: #state{}}).
|
||||
handle_call({mock, Request}, _From, State = #state{conn_pid = ConnPid}) when is_pid(ConnPid) ->
|
||||
handle_call({mock, Request}, _From, State = #state{conn_pid = ConnPid, flight_num = FlightNum}) when is_pid(ConnPid) ->
|
||||
publish_directive(Request, jiffy:encode(Request, [force_utf8])),
|
||||
{reply, ok, State}.
|
||||
{reply, ok, State#state{flight_num = FlightNum + 1}}.
|
||||
|
||||
%% @private
|
||||
%% @doc Handling cast messages
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user