mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
fix: login failed
This commit is contained in:
parent
fd8088afc1
commit
177dc0ee8d
@ -41,9 +41,9 @@ init([#{<<"channel">> := ChannelId, <<"client">> := ClientId, <<"ip">> := Host,
|
||||
Dclient = #dclient{channel = ChannelId, client = ClientId, status = ?DCLIENT_INTIALIZED, clock = Clock, userdata = UserData, child = ChildState},
|
||||
dgiot_client:add(ChannelId, ClientId),
|
||||
case Mod:init(Dclient) of
|
||||
{ok, NewDclient} ->
|
||||
do_connect(NewDclient),
|
||||
{ok, NewDclient, hibernate};
|
||||
{ok, NewChildState} ->
|
||||
do_connect(Dclient#dclient{child = NewChildState}),
|
||||
{ok, Dclient#dclient{child = NewChildState}, hibernate};
|
||||
{stop, Reason} ->
|
||||
{stop, Reason}
|
||||
end.
|
||||
|
@ -25,6 +25,14 @@
|
||||
-export([init/1, handle_info/2, terminate/2]).
|
||||
|
||||
%% tcp client callback
|
||||
init(#dclient{channel = ChannelId, child = #child_state{} = ChildState}) ->
|
||||
case dgiot_product:get_channel(ChannelId) of
|
||||
not_find ->
|
||||
{stop, <<"not find product">>};
|
||||
ProductId ->
|
||||
io:format("~s ~p ~p ~p ~n", [?FILE, ?LINE, ChannelId, ProductId]),
|
||||
{ok, ChildState#child_state{product = ProductId}}
|
||||
end;
|
||||
init(#dclient{channel = ChannelId}) ->
|
||||
case dgiot_product:get_channel(ChannelId) of
|
||||
not_find ->
|
||||
@ -46,7 +54,7 @@ handle_info(connection_ready, #dclient{child = #child_state{product = ProductId}
|
||||
{noreply, ChildState#child_state{device = Device}}
|
||||
end;
|
||||
|
||||
handle_info(#{<<"cmd">> := Cmd, <<"data">> := Data, <<"productId">> := ProductId}, #dclient{child = ChildState} = Dclient) ->
|
||||
handle_info(#{<<"cmd">> := Cmd, <<"data">> := Data, <<"productId">> := ProductId}, #dclient{child = #child_state{} = ChildState} = Dclient) ->
|
||||
case do_cmd(ProductId, Cmd, Data, Dclient) of
|
||||
default ->
|
||||
{noreply, ChildState};
|
||||
|
Loading…
Reference in New Issue
Block a user