config: work properly if the AMB plugin were not loaded or failed to initialize
authorJanos Kovacs <jankovac503@gmail.com>
Sun, 29 Dec 2013 16:02:56 +0000 (18:02 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Thu, 8 Jan 2015 16:37:12 +0000 (18:37 +0200)
Change-Id: I42cb789b669e7ed6bfb08685782d66a181d35ab9

packaging.in/murphy.lua

index 17a70ff..d2892de 100644 (file)
@@ -1,4 +1,5 @@
 with_system_controller = true
+with_amb = false
 verbose = 0
 
 m = murphy.get()
@@ -45,7 +46,13 @@ end
 
 -- load the AMB plugin
 if m:plugin_exists('amb') then
-    m:load_plugin('amb')
+    m:try_load_plugin('amb')
+
+    if builtin.method.amb_initiate and
+       builtin.method.amb_update
+    then
+        with_amb = true
+    end
 else
     m:info("No amb plugin found...")
 end
@@ -321,14 +328,16 @@ mdb.select {
     condition = "id = 0"
 }
 
-sink.lua {
-    name = "night_mode",
-    inputs = { owner = mdb.select.select_night_mode },
-    property = "NightMode",
-    type = "b",
-    initiate = builtin.method.amb_initiate,
-    update = builtin.method.amb_update
-}
+if with_amb then
+    sink.lua {
+        name = "night_mode",
+        inputs = { owner = mdb.select.select_night_mode },
+        property = "NightMode",
+        type = "b",
+        initiate = builtin.method.amb_initiate,
+        update = builtin.method.amb_update
+    }
+end
 
 
 -- Driving mode processing chain
@@ -378,14 +387,16 @@ mdb.select {
     condition = "id = 0"
 }
 
-sink.lua {
-    name = "driving_mode",
-    inputs = { owner = mdb.select.select_driving_mode },
-    property = "DrivingMode",
-    type = "u",
-    initiate = builtin.method.amb_initiate,
-    update = builtin.method.amb_update
-}
+if with_amb then
+    sink.lua {
+        name = "driving_mode",
+        inputs = { owner = mdb.select.select_driving_mode },
+        property = "DrivingMode",
+        type = "u",
+        initiate = builtin.method.amb_initiate,
+        update = builtin.method.amb_update
+    }
+end
 
 -- turn signals (left, right)