summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Feuer <mfeuer@jaguarlandrover.com>2014-12-02 15:56:40 -0800
committerMagnus Feuer <mfeuer@jaguarlandrover.com>2014-12-02 15:56:40 -0800
commitdb9e7b88351463fba8245f9b0749cd61c7ae2bf9 (patch)
treecbf934356d42dccbd6b55440e7ae605bfbac248d
parente919847f300c30ae614019d1d206b6e1cddf21cd (diff)
downloadrvi_core-db9e7b88351463fba8245f9b0749cd61c7ae2bf9.tar.gz
Now reports service availability and unavailability
-rwxr-xr-xhvac_demo/hvac_emulator.py19
-rwxr-xr-xhvac_demo/mobile_emulator.py20
2 files changed, 38 insertions, 1 deletions
diff --git a/hvac_demo/hvac_emulator.py b/hvac_demo/hvac_emulator.py
index a66b9d2..e108dc2 100755
--- a/hvac_demo/hvac_emulator.py
+++ b/hvac_demo/hvac_emulator.py
@@ -79,6 +79,22 @@ def publish(key, value):
sys.stdout.flush()
return ['ok']
+def services_available(services):
+ print
+ print "Services available: ", services
+
+ sys.stdout.write("Enter <key> <val> or q to quit: ")
+ sys.stdout.flush()
+ return ['ok']
+
+def services_unavailable(services):
+ print
+ print "Services not available: ", services
+
+ sys.stdout.write("Enter <key> <val> or q to quit: ")
+ sys.stdout.flush()
+ return ['ok']
+
#
# Subscribe command is invoked by the mobile emulator when it sends
# messages to the jlr.com/vin/1234/hvac/subscribe service.
@@ -164,6 +180,8 @@ emulator_service = RVIJSONRPCServer(addr=((emulator_service_host, emulator_servi
#
emulator_service.register_function(publish, emulator_publish_service_name)
emulator_service.register_function(subscribe, emulator_subscribe_service_name)
+emulator_service.register_function(services_available, 'services_available')
+emulator_service.register_function(services_unavailable, 'services_unavailable')
# Create a thread to handle incoming stuff so that we can do input
@@ -182,7 +200,6 @@ time.sleep(0.5)
# We register both services using our own URL as a callback.
#
res = rvi_server.register_service(service = emulator_publish_service_name,
-
network_address = emulator_service_url)
#
diff --git a/hvac_demo/mobile_emulator.py b/hvac_demo/mobile_emulator.py
index e1c8499..6eebe03 100755
--- a/hvac_demo/mobile_emulator.py
+++ b/hvac_demo/mobile_emulator.py
@@ -110,6 +110,23 @@ def publish(vin, key, value):
+def services_available(services):
+ print
+ print "Services available: ", services
+
+ sys.stdout.write("Enter <key> <val> or q to quit: ")
+ sys.stdout.flush()
+ return ['ok']
+
+def services_unavailable(services):
+ print
+ print "Services not available: ", services
+
+ sys.stdout.write("Enter <key> <val> or q to quit: ")
+ sys.stdout.flush()
+ return ['ok']
+
+
#
# Check that we have the correct arguments
#
@@ -179,12 +196,15 @@ print "Emulator service URL", emulator_service_url
res = rvi_server.register_service(service = emulator_service_name,
network_address = emulator_service_url)
+
# Service Edge will return the full, global service name that the
# registration was recorded as:
#
# jlr.com/backend/mobile/[phone_number]/hvac/publish
#
full_emulator_service_name = res['service']
+emulator_service.register_function(services_available, 'services_available')
+emulator_service.register_function(services_unavailable, 'services_unavailable')
#
# Send of a subscribe to the hvac emulator running on the