summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile57
-rw-r--r--README.md12
-rw-r--r--curl_scripts/backend_message.sh30
-rw-r--r--curl_scripts/device_message.sh30
-rw-r--r--curl_scripts/register_service_backend.sh39
-rw-r--r--curl_scripts/register_service_device.sh26
-rwxr-xr-xfind_setup_gen.sh17
-rw-r--r--priv/setup_backend.config96
-rw-r--r--priv/setup_device.config94
-rw-r--r--rebar.config17
-rw-r--r--rebar.config.magnus17
-rw-r--r--src/rvi.app.src20
-rw-r--r--src/rvi_app.erl22
-rw-r--r--src/rvi_sup.erl35
14 files changed, 512 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3d74103
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,57 @@
+.PHONY: all deps compile setup clean doc setup_backend setup_device
+
+
+NAME=rvi
+export KVDB_BACKENDS=ets
+
+SETUP_GEN=$(shell ./find_setup_gen.sh)
+
+
+all: deps compile
+
+deps:
+ rebar get-deps
+
+compile:
+ rebar compile
+
+recomp:
+ rebar compile skip_deps=true
+
+setup_device:
+ ERL_LIBS=$(PWD)/deps:$(ERL_LIBS):$(PWD) \
+ $(SETUP_GEN) $(NAME) priv/setup_device.config setup_device
+
+setup_backend:
+ ERL_LIBS=$(PWD)/deps:$(ERL_LIBS):$(PWD) \
+ $(SETUP_GEN) $(NAME) priv/setup_backend.config setup_backend
+
+target_backend:
+ ERL_LIBS=$(PWD)/deps:$(ERL_LIBS) \
+ $(SETUP_GEN) $(NAME) priv/setup_backend.config setup -pz $(PWD)/ebin \
+ -target rel_backend -vsn 0.1
+
+target_device:
+ ERL_LIBS=$(PWD)/deps:$(ERL_LIBS) \
+ $(SETUP_GEN) $(NAME) priv/setup_device.config setup -pz $(PWD)/ebin \
+ -target rel_device -vsn 0.1
+
+#
+# Start the backend server
+#
+run_backend: setup_backend
+ erl -boot setup_backend/start -config setup_backend/sys
+
+
+#
+# Start the backend device.
+#
+run_device: setup_device
+ erl -boot setup_device/start -config setup_device/sys
+
+
+doc:
+ REBAR_DOC=1 rebar skip_deps=true get-deps doc
+
+clean:
+ rebar clean
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0af0c79
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# TOP LEVEL RVI PROJECT
+
+Better documentation coming soon.
+
+make
+
+Window 1: make run_backend
+Window 2: make run_device
+Window 3: cd curl; sh register_backend.sh
+Window 4: cd curl; sh device_message.sh
+
+mfeuer _at_ jaguarlandrover dot com. \ No newline at end of file
diff --git a/curl_scripts/backend_message.sh b/curl_scripts/backend_message.sh
new file mode 100644
index 0000000..b6a7ccd
--- /dev/null
+++ b/curl_scripts/backend_message.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Create new accounts, like the ga account
+# But other accounts may be create
+. $HOME/.exodmrc
+
+ #if [ $# != 2 ]
+#then
+# echo "Usage: $0 temperature"
+# exit 255
+#fi
+# the password (actually erlang node cookie) must be 100% hidden
+# so this is only for testing!!!!!
+
+URL=http://localhost:8801
+curl -u $USER_AUTH -k -X POST $URL -d @- << EOF
+{
+ "jsonrpc": "2.0",
+ "method": "message",
+ "id": "1",
+ "params":
+ {
+ "calling_service": "hvac_app",
+ "target": "rpc:jlr.com/vin/1234/hvac/set_fan_speed",
+ "timeout": 1405099531,
+ "parameters": [
+ { "speed": 5 }
+ ]
+ }
+}
+EOF
diff --git a/curl_scripts/device_message.sh b/curl_scripts/device_message.sh
new file mode 100644
index 0000000..a2dba0f
--- /dev/null
+++ b/curl_scripts/device_message.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Create new accounts, like the ga account
+# But other accounts may be create
+. $HOME/.exodmrc
+
+ #if [ $# != 2 ]
+#then
+# echo "Usage: $0 temperature"
+# exit 255
+#fi
+# the password (actually erlang node cookie) must be 100% hidden
+# so this is only for testing!!!!!
+
+URL=http://localhost:8811
+curl -u $USER_AUTH -k -X POST $URL -d @- << EOF
+{
+ "jsonrpc": "2.0",
+ "method": "message",
+ "id": "1",
+ "params":
+ {
+ "calling_service": "hvac_app",
+ "target": "rpc:jlr.com/backend/hvac/set_fan_speed",
+ "timeout": 1405099531,
+ "parameters": [
+ { "speed": 5 }
+ ]
+ }
+}
+EOF
diff --git a/curl_scripts/register_service_backend.sh b/curl_scripts/register_service_backend.sh
new file mode 100644
index 0000000..bc812e1
--- /dev/null
+++ b/curl_scripts/register_service_backend.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Create new accounts, like the ga account
+# But other accounts may be create
+. $HOME/.exodmrc
+
+ #if [ $# != 2 ]
+#then
+# echo "Usage: $0 temperature"
+# exit 255
+#fi
+# the password (actually erlang node cookie) must be 100% hidden
+# so this is only for testing!!!!!
+
+URL=http://localhost:8801
+curl -u $USER_AUTH -k -X POST $URL -d @- << EOF
+{
+ "jsonrpc": "2.0",
+ "method": "register_service",
+ "id": "1",
+ "params":
+ {
+ "service": "hvac/set_fan_speed",
+ "network_address": "http://localhost:8901"
+ }
+}
+EOF
+
+#curl -u $USER_AUTH -k -X POST $URL -d @- << EOF
+#{
+# "jsonrpc": "2.0",
+# "method": "register_service",
+# "id": "1",
+# "params":
+# {
+# "service": "hvac/set_temperature",
+# "network_address": "http://localhost:8901"
+# }
+#}
+#EOF
diff --git a/curl_scripts/register_service_device.sh b/curl_scripts/register_service_device.sh
new file mode 100644
index 0000000..05f8952
--- /dev/null
+++ b/curl_scripts/register_service_device.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Create new accounts, like the ga account
+# But other accounts may be create
+. $HOME/.exodmrc
+
+ #if [ $# != 2 ]
+#then
+# echo "Usage: $0 temperature"
+# exit 255
+#fi
+# the password (actually erlang node cookie) must be 100% hidden
+# so this is only for testing!!!!!
+
+URL=http://localhost:8811
+curl -u $USER_AUTH -k -X POST $URL -d @- << EOF
+{
+ "jsonrpc": "2.0",
+ "method": "register_service",
+ "id": "1",
+ "params":
+ {
+ "service": "hvac",
+ "network_address": "http://localhost:8901"
+ }
+}
+EOF
diff --git a/find_setup_gen.sh b/find_setup_gen.sh
new file mode 100755
index 0000000..72cc213
--- /dev/null
+++ b/find_setup_gen.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ -z $ERL_LIBS ]; then
+ L=`pwd`/deps
+else
+ L=`pwd`/deps:$ERL_LIBS
+fi
+
+dirs=`echo $L | sed 's/\:/ /g'`
+
+for d in $dirs; do
+ f=$d/setup/setup_gen
+ if [ -f $f ]; then
+ echo "$f"
+ exit 0
+ fi
+done
diff --git a/priv/setup_backend.config b/priv/setup_backend.config
new file mode 100644
index 0000000..596244d
--- /dev/null
+++ b/priv/setup_backend.config
@@ -0,0 +1,96 @@
+%% -*- erlang -*-
+[
+ %% Put include first, making it possible to override any defaults below
+ %%
+ %% Add our own app(s)
+ {apps,
+ [kernel,
+ stdlib,
+ sasl,
+ {setup, load},
+ syntax_tools,
+ lager,
+ crypto,
+ public_key,
+ exo,
+ bert,
+ compiler,
+ ssl,
+ asn1,
+
+ rvi,
+ rvi_common,
+ service_edge,
+ service_discovery,
+ authorize,
+ schedule,
+ data_link_backend,
+ {data_link_device, load}, %% Load, but do not start.
+ protocol ]},
+
+ %%
+ %% Custom environment settings
+ %%
+ {env,
+ [
+ {lager,
+ [ { handlers,
+ [{lager_console_backend, debug}]
+ }
+ ]
+ },
+
+ {rvi,
+ [
+ { node_address, "localhost:9990" }, %% Should match bert_rpc_server below
+ { node_service_prefix, "jlr.com/backend/"},
+
+ { backend_address, "localhost:9990" },
+ { backend_service_prefix, "jlr.com/backend/" },
+
+ %% Fire up a bert rpcserver for the backend data link module.
+
+ { components,
+ [
+ { service_edge,
+ [ { url, "http://localhost:8801" },
+ { exo_http_opts, [ { port, 8801 } ] }
+ ]
+ },
+ { service_discovery,
+ [ { url, "http://localhost:8802" },
+ { exo_http_opts, [ { port, 8802 } ] }
+ ]
+ },
+ { schedule,
+ [ { url, "http://localhost:8803" },
+ { exo_http_opts, [ { port, 8803 } ] }
+ ]
+ },
+ { authorize,
+ [ { url, "http://localhost:8804" },
+ { exo_http_opts, [ { port, 8804 } ] }
+ ]
+ },
+ { protocol,
+ [ { url, "http://localhost:8805" },
+ { exo_http_opts, [ { port, 8805 } ] }
+ ]
+ },
+ { data_link,
+ [
+ %% Listen to port 9990 for incoming calls. Must match
+ %% the port specified for node_address, which is used by
+ %% remote nodes to address this node.
+ { bert_rpc_server, [ { port, 9990 }]},
+ { url, "http://localhost:8806" },
+ { exo_http_opts, [ { port, 8806 } ] }
+ ]
+
+ }
+ ]
+ }
+ ]}
+]}
+
+].
diff --git a/priv/setup_device.config b/priv/setup_device.config
new file mode 100644
index 0000000..3ef6bcb
--- /dev/null
+++ b/priv/setup_device.config
@@ -0,0 +1,94 @@
+%% -*- erlang -*-
+[
+ %% Put include first, making it possible to override any defaults below
+ %%
+ %% Add our own app(s)
+ {apps,
+ [kernel,
+ stdlib,
+ sasl,
+ {setup, load},
+ syntax_tools,
+ lager,
+ crypto,
+ public_key,
+ exo,
+ bert,
+ compiler,
+ ssl,
+ asn1,
+
+
+
+ rvi,
+ rvi_common,
+ service_edge,
+ service_discovery,
+ authorize,
+ schedule,
+ { data_link_backend, load }, %% Load, but do not start
+ data_link_device,
+ protocol ]},
+
+ %%
+ %% Custom environment settings
+ %%
+ {env,
+ [
+ {lager,
+ [ { handlers,
+ [ {lager_console_backend, debug} ]
+ }
+ ]
+ },
+
+ {rvi,
+ [
+ { node_address, "localhost:9991" }, %% Should matcch bert_rpc_server below
+ { node_service_prefix, "jlr.com/vin/1234/"},
+
+ { backend_address, "localhost:9990" },
+ { backend_service_prefix, "jlr.com/backend/" },
+
+ { components,
+ [
+ { service_edge,
+ [ { url, "http://localhost:8811" },
+ { exo_http_opts, [ { port, 8811 } ] }
+ ]
+ },
+ { service_discovery,
+ [ { url, "http://localhost:8812" },
+ { exo_http_opts, [ { port, 8812 } ] }
+ ]
+ },
+ { schedule,
+ [ { url, "http://localhost:8813" },
+ { exo_http_opts, [ { port, 8813 } ] }
+ ]
+ },
+ { authorize,
+ [ { url, "http://localhost:8814" },
+ { exo_http_opts, [ { port, 8814 } ] }
+ ]
+ },
+ { protocol,
+ [ { url, "http://localhost:8815" },
+ { exo_http_opts, [ { port, 8815 } ] }
+ ]
+ },
+ { data_link,
+ [ { url, "http://localhost:8816" },
+ %% Listen to port 9991 for incoming calls. Must match
+ %% the port specified for node_address, which is used by
+ %% remote nodes to address this node.
+ { bert_rpc_server, [ { port, 9991 }]},
+
+ { exo_http_opts, [ { port, 8816 } ] }
+ ]
+ }
+ ]
+ }
+ ]}
+]}
+].
diff --git a/rebar.config b/rebar.config
new file mode 100644
index 0000000..5e2908e
--- /dev/null
+++ b/rebar.config
@@ -0,0 +1,17 @@
+%% -*- erlang -*-
+
+%%
+%% Top level app that controls other apps.
+%%
+{erl_opts, [debug_info]}.
+{deps,
+ [
+ {setup, ".*", {git, "https://github.com/uwiger/setup.git", "HEAD"}},
+ {protocol, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/protocol", "master"}},
+ {data_link_device, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/data_link_device", "master"}},
+ {data_link_backend, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/data_link_backend", "master"}},
+ {authorize, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/authorize", "master"}},
+ {schedule, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/schedule", "master"}},
+ {service_edge, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/service_edge", "master"}},
+ {service_discovery, ".*", {git, "https://gerrit.automotivelinux.org/gerrit/RVI/service_discovery", "master"}}
+ ]}.
diff --git a/rebar.config.magnus b/rebar.config.magnus
new file mode 100644
index 0000000..1d5536b
--- /dev/null
+++ b/rebar.config.magnus
@@ -0,0 +1,17 @@
+%% -*- erlang -*-
+
+%%
+%% Top level app that controls other apps.
+%%
+{erl_opts, [debug_info]}.
+{deps,
+ [
+ {setup, ".*", {git, "https://github.com/uwiger/setup.git", "HEAD"}},
+ {protocol, ".*", {git, "file:///home/magnus/work/jlr/rvi/protocol.git", "master"}},
+ {data_link_device, ".*", {git, "file:///home/magnus/work/jlr/rvi/data_link_device.git", "master"}},
+ {data_link_backend, ".*", {git, "file:///home/magnus/work/jlr/rvi/data_link_backend.git", "master"}},
+ {authorize, ".*", {git, "file:///home/magnus/work/jlr/rvi/authorize.git", "master"}},
+ {schedule, ".*", {git, "file:///home/magnus/work/jlr/rvi/schedule.git", "master"}},
+ {service_edge, ".*", {git, "file:///home/magnus/work/jlr/rvi/service_edge.git", "master"}},
+ {service_discovery, ".*", {git, "file:///home/magnus/work/jlr/rvi/service_discovery.git", "master"}}
+ ]}.
diff --git a/src/rvi.app.src b/src/rvi.app.src
new file mode 100644
index 0000000..4c15497
--- /dev/null
+++ b/src/rvi.app.src
@@ -0,0 +1,20 @@
+%% -*- erlang -*-
+{application, rvi,
+ [
+ {description, ""},
+ {vsn, "0.1"},
+ {registered, []},
+ {applications, [
+ kernel,
+ stdlib,
+ schedule,
+ rvi_common,
+ service_edge,
+ service_discovery,
+ authorize,
+ data_link_backend,
+ data_link_device,
+ protocol
+ ]},
+ {mod, { rvi_app, []}}
+ ]}.
diff --git a/src/rvi_app.erl b/src/rvi_app.erl
new file mode 100644
index 0000000..197dacd
--- /dev/null
+++ b/src/rvi_app.erl
@@ -0,0 +1,22 @@
+-module(rvi_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2,
+ start_phase/3,
+ stop/1]).
+
+%% ===================================================================
+%% Application callbacks
+%% ===================================================================
+
+start(_StartType, _StartArgs) ->
+ rvi_sup:start_link().
+
+start_phase(ping, _, _) ->
+%% exoport:ping(),
+ ok.
+
+stop(_State) ->
+ ok.
diff --git a/src/rvi_sup.erl b/src/rvi_sup.erl
new file mode 100644
index 0000000..72b6eea
--- /dev/null
+++ b/src/rvi_sup.erl
@@ -0,0 +1,35 @@
+-module(rvi_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+%% Helper macro for declaring children of supervisor
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+%% ===================================================================
+%% API functions
+%% ===================================================================
+
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% ===================================================================
+%% Supervisor callbacks
+%% ===================================================================
+
+init([]) ->
+ {ok, { {one_for_one, 5, 10},
+ [
+%% ?CHILD(rvi_alarms, worker),
+%% ?CHILD(rvi_log, worker),
+%% ?CHILD(rvi_can, worker),
+%% ?CHILD(rvi_waypoints, worker)
+ %% ?CHILD(rvi_gps, worker),
+ %% ?CHILD(exodmo_config, worker)
+ ]} }.
+