summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pbx_acse.erl1
-rw-r--r--src/pbx_button.erl7
-rw-r--r--src/pbx_conn.erl7
-rw-r--r--src/pbx_invoke.erl4
-rw-r--r--src/pbx_pdu.erl20
-rw-r--r--src/pbx_rose.erl3
-rw-r--r--src/pbx_status.erl5
7 files changed, 28 insertions, 19 deletions
diff --git a/src/pbx_acse.erl b/src/pbx_acse.erl
index f225eda..cee622c 100644
--- a/src/pbx_acse.erl
+++ b/src/pbx_acse.erl
@@ -6,7 +6,6 @@
-export([init/1, handle_event/2, handle_call/2, handle_info/2,
terminate/2, code_change/3]).
--export([encode/1]).
init(_Args) ->
pbx_conn:send(encode(associate)),
diff --git a/src/pbx_button.erl b/src/pbx_button.erl
index a585dda..29d17ed 100644
--- a/src/pbx_button.erl
+++ b/src/pbx_button.erl
@@ -6,10 +6,11 @@
-include("CSTA-device-identifiers.hrl").
decode(Data) ->
- 'CSTA-get-button-information':decode('GetButtonInformationResult', Data).
+ 'CSTA-get-button-information':decode('GetButtonInformationResult',
+ Data).
encode(Device) ->
'CSTA-get-button-information':encode('GetButtonInformationArgument',
#'GetButtonInformationArgument'{
- device = #'DeviceID'{
- deviceIdentifier = Device }}).
+ device = #'DeviceID'{
+ deviceIdentifier = Device }}).
diff --git a/src/pbx_conn.erl b/src/pbx_conn.erl
index f819fdd..dde5de2 100644
--- a/src/pbx_conn.erl
+++ b/src/pbx_conn.erl
@@ -12,6 +12,8 @@
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [?HOST, ?PORT], []).
+%%%
+
init([Host, Port]) ->
pbx_pdu:start_link(),
pbx_pdu:add_handler(pbx_acse, []),
@@ -39,10 +41,13 @@ handle_info({tcp_closed, _}, Socket) ->
terminate(_Reason, Socket) ->
pbx_pdu:delete_handler(pbx_acse, []),
- gen_tcp:close(Socket).
+ gen_tcp:close(Socket),
+ ok.
code_change(_OldVsn, Socket, _Extra) ->
{ok, Socket}.
+%%%
+
send(Reply) ->
gen_server:cast(?SERVER, Reply).
diff --git a/src/pbx_invoke.erl b/src/pbx_invoke.erl
index 034fc1e..28ab3a1 100644
--- a/src/pbx_invoke.erl
+++ b/src/pbx_invoke.erl
@@ -13,6 +13,8 @@
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+%%%
+
init(_Args) ->
{ok, 0}.
@@ -37,7 +39,7 @@ terminate(_Reason, _State) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%
set({present, N}) ->
gen_server:call(?SERVER, {set, N}).
diff --git a/src/pbx_pdu.erl b/src/pbx_pdu.erl
index 21350f9..8906f4a 100644
--- a/src/pbx_pdu.erl
+++ b/src/pbx_pdu.erl
@@ -6,15 +6,6 @@
-include("Remote-Operations-Generic-ROS-PDUs.hrl").
-include("ACSE-1.hrl").
-decode({asn1_ExtAlt, <<Data/binary>>}) ->
- {ok, Pdu} = 'Remote-Operations-Generic-ROS-PDUs':decode('ROS', Data),
- Pdu;
-decode(<<Data/binary>>) ->
- {ok, Pdu} = 'ACSE-1':decode('ACSE-apdu', Data),
- decode(Pdu);
-decode(Pdu) ->
- Pdu.
-
start_link() ->
gen_event:start_link({local, ?MODULE}).
@@ -24,5 +15,16 @@ add_handler(Handler, Args) ->
delete_handler(Handler, Args) ->
gen_event:delete_handler(?MODULE, Handler, Args).
+%%%
+
+decode({asn1_ExtAlt, <<Data/binary>>}) ->
+ {ok, Pdu} = 'Remote-Operations-Generic-ROS-PDUs':decode('ROS', Data),
+ Pdu;
+decode(<<Data/binary>>) ->
+ {ok, Pdu} = 'ACSE-1':decode('ACSE-apdu', Data),
+ decode(Pdu);
+decode(Pdu) ->
+ Pdu.
+
call(Handler, Args) ->
gen_event:call(?MODULE, Handler, Args).
diff --git a/src/pbx_rose.erl b/src/pbx_rose.erl
index 6328226..0c0f09d 100644
--- a/src/pbx_rose.erl
+++ b/src/pbx_rose.erl
@@ -75,8 +75,7 @@ init(_Args) ->
{ok, {present, 0}}.
handle_event({invoke, Invoke = #'Invoke'{opcode = ?STATUS}}, _State) ->
- Status = pbx_status:decode(Invoke#'Invoke'.argument),
- case pbx_status:value(Status) of
+ case pbx_status:decode(Invoke#'Invoke'.argument) of
normal ->
reply(Invoke, pbx_status:encode());
_ ->
diff --git a/src/pbx_status.erl b/src/pbx_status.erl
index 74a60af..67e4766 100644
--- a/src/pbx_status.erl
+++ b/src/pbx_status.erl
@@ -1,11 +1,12 @@
-module(pbx_status).
--export([decode/1, encode/0, value/1]).
+-export([decode/1, encode/0]).
-include("CSTA-system-status.hrl").
decode(Data) ->
- 'CSTA-system-status':decode('SystemStatusArg', Data).
+ Status = 'CSTA-system-status':decode('SystemStatusArg', Data),
+ value(Status).
encode() ->
'CSTA-system-status':encode('SystemStatusRes', {noData, []}).