summaryrefslogtreecommitdiff
path: root/components/proto_bert/src/proto_bert_rpc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'components/proto_bert/src/proto_bert_rpc.erl')
-rw-r--r--components/proto_bert/src/proto_bert_rpc.erl60
1 files changed, 29 insertions, 31 deletions
diff --git a/components/proto_bert/src/proto_bert_rpc.erl b/components/proto_bert/src/proto_bert_rpc.erl
index cad1708..f1658a3 100644
--- a/components/proto_bert/src/proto_bert_rpc.erl
+++ b/components/proto_bert/src/proto_bert_rpc.erl
@@ -2,7 +2,7 @@
%% Copyright (C) 2014, Jaguar Land Rover
%%
%% This program is licensed under the terms and conditions of the
-%% Mozilla Public License, version 2.0. The full text of the
+%% Mozilla Public License, version 2.0. The full text of the
%% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
%%
@@ -20,12 +20,12 @@
-include_lib("lager/include/log.hrl").
-include_lib("rvi_common/include/rvi_common.hrl").
--define(SERVER, ?MODULE).
+-define(SERVER, ?MODULE).
-export([start_json_server/0]).
-export([send_message/8,
receive_message/3]).
--record(st, {
+-record(st, {
%% Component specification
cs = #component_spec{}
}).
@@ -42,26 +42,26 @@ start_json_server() ->
-send_message(CompSpec,
- ServiceName,
- Timeout,
+send_message(CompSpec,
+ TID,
+ ServiceName,
+ Timeout,
ProtoOpts,
DataLinkMod,
DataLinkOpts,
- Parameters,
- Signature) ->
+ Parameters) ->
rvi_common:request(protocol, ?MODULE, send_message,
- [ { service, ServiceName },
+ [ { transaction_id, TID },
+ { service, ServiceName },
{ timeout, Timeout },
{ protocol_opts, ProtoOpts },
{ data_link_mod, DataLinkMod },
{ data_link_opts, DataLinkOpts },
- { parameters, Parameters },
- { signature, Signature }],
+ { parameters, Parameters } ],
[ status ], CompSpec).
receive_message(CompSpec, {IP,Port}, Data) ->
- rvi_common:notification(protocol, ?MODULE, receive_message,
+ rvi_common:notification(protocol, ?MODULE, receive_message,
[ {data, Data},
{remote_ip, IP},
{remote_port, Port} ],
@@ -71,23 +71,25 @@ receive_message(CompSpec, {IP,Port}, Data) ->
%% CAlled by local exo http server
handle_rpc("send_message", Args) ->
+ LogId = rvi_common:get_json_log_id(Args),
+ {ok, TID} = rvi_common:get_json_element(["transaction_id"], Args),
{ok, ServiceName} = rvi_common:get_json_element(["service_name"], Args),
{ok, Timeout} = rvi_common:get_json_element(["timeout"], Args),
{ok, ProtoOpts} = rvi_common:get_json_element(["protocol_opts"], Args),
{ok, DataLinkMod} = rvi_common:get_json_element(["data_link_mod"], Args),
{ok, DataLinkOpts} = rvi_common:get_json_element(["data_link_opts"], Args),
{ok, Parameters} = rvi_common:get_json_element(["parameters"], Args),
- {ok, Signature} = rvi_common:get_json_element(["signature"], Args),
- [ ok ] = gen_server:call(?SERVER, { rvi, send_message,
- [ServiceName,
+ [ ok ] = gen_server:call(?SERVER, { rvi, send_message,
+ [TID,
+ ServiceName,
Timeout,
ProtoOpts,
DataLinkMod,
DataLinkOpts,
Parameters,
- Signature]}),
+ LogId]}),
{ok, [ {status, rvi_common:json_rpc_status(ok)} ]};
-
+
handle_rpc(Other, _Args) ->
@@ -107,23 +109,22 @@ handle_notification(Other, _Args) ->
ok.
-handle_call({rvi, send_message,
- [ServiceName,
+handle_call({rvi, send_message,
+ [_TID,
+ ServiceName,
Timeout,
ProtoOpts,
DataLinkMod,
DataLinkOpts,
- Parameters,
- Signature]}, _From, St) ->
+ Parameters | _LogId]}, _From, St) ->
?debug(" protocol:send(): service name: ~p~n", [ServiceName]),
?debug(" protocol:send(): timeout: ~p~n", [Timeout]),
?debug(" protocol:send(): opts: ~p~n", [ProtoOpts]),
?debug(" protocol:send(): data_link_mod: ~p~n", [DataLinkMod]),
?debug(" protocol:send(): data_link_opts: ~p~n", [DataLinkOpts]),
%% ?debug(" protocol:send(): parameters: ~p~n", [Parameters]),
- ?debug(" protocol:send(): signature: ~p~n", [Signature]),
-
- Data = term_to_binary({ ServiceName, Timeout, Parameters, Signature }),
+
+ Data = term_to_binary({ ServiceName, Timeout, Parameters }),
Res = DataLinkMod:send_data(St#st.cs, ?MODULE, ServiceName, DataLinkOpts, Data),
@@ -149,21 +150,18 @@ handle_cast_({rvi, receive_message, [Data,IP,Port]}, St) when is_list(Data)->
handle_cast({ rvi, receive_message, [list_to_binary(Data),IP,Port] }, St);
handle_cast_({rvi, receive_message, [Data, IP, Port]}, St) ->
- {ServiceName,
- Timeout,
- Parameters,
- Signature} = binary_to_term(Data),
+ {ServiceName,
+ Timeout,
+ Parameters} = binary_to_term(Data),
?debug(" protocol:rcv(): service name: ~p~n", [ServiceName]),
?debug(" protocol:rcv(): timeout: ~p~n", [Timeout]),
%% ?debug(" protocol:rcv(): parameters: ~p~n", [Parameters]),
- ?debug(" protocol:rcv(): signature: ~p~n", [Signature]),
?debug(" protocol:rcv(): remote IP/port: ~p~n", [{IP, Port}]),
service_edge_rpc:handle_remote_message(St#st.cs,
{IP, Port},
ServiceName,
Timeout,
- Parameters,
- Signature),
+ Parameters),
{noreply, St};
handle_cast_(Other, St) ->