summaryrefslogtreecommitdiffstats
path: root/test/afb-test/fixtures/mapi_low-can.lua
diff options
context:
space:
mode:
authorFrederic Marec <frederic.marec@iot.bzh>2019-04-09 17:52:22 +0200
committerFrédéric Marec <frederic.marec@iot.bzh>2019-11-26 13:44:25 +0000
commiteb4d2471f1609e217b2a3a919eeb7d76ca1c7417 (patch)
tree0be9335d9d15bce09d1c787abb21d8022e4485db /test/afb-test/fixtures/mapi_low-can.lua
parent46d1948f5a4b46d9e2424dd56fede1720167c580 (diff)
Fix event receive Fix event not receive Fix lockwait event Remove trailing indentation Bug-AGL: SPEC-2374 Change-Id: Ie64b23c242bc13dcf7af96ff3ed2316bf6cad5f7 Signed-off-by: Frederic Marec <frederic.marec@iot.bzh> (cherry picked from commit 5c3503e35c1b883e97ed6874f7683d0a7b5938b7)
Diffstat (limited to 'test/afb-test/fixtures/mapi_low-can.lua')
-rw-r--r--test/afb-test/fixtures/mapi_low-can.lua34
1 files changed, 26 insertions, 8 deletions
diff --git a/test/afb-test/fixtures/mapi_low-can.lua b/test/afb-test/fixtures/mapi_low-can.lua
index 9909492..b88fc2f 100644
--- a/test/afb-test/fixtures/mapi_low-can.lua
+++ b/test/afb-test/fixtures/mapi_low-can.lua
@@ -26,16 +26,34 @@ function _unsubscribe(source, args)
AFB:success(source)
end
+function _evtpush(source, context, val)
+ local event = val[0]
+ return AFB:evtpush(source, _evtHandles[event], val[1])
+end
+
function _get(source, args)
- local evtHandle1 = AFB:evtmake(source, 'messages_engine_speed')
- local evtHandle2 = AFB:evtmake(source, 'messages_vehicle_speed')
- if type(evtHandle1) == "userdata" and type(evtHandle2) == "userdata" then
- AFB:subscribe(source, evtHandle1)
- AFB:evtpush(source,evtHandle1,{value = 1234})
- AFB:subscribe(source, evtHandle2)
- AFB:evtpush(source,evtHandle2,{value = 5678})
- end
+ _evtHandles = {}
+ _messageHandles = {}
+
+ _evtHandles['messages_engine_speed'] = nil
+ _evtHandles['messages_vehicle_speed'] = nil
+
+ _messageHandles['messages_engine_speed'] = 1234
+ _messageHandles['messages_vehicle_speed'] = 5678
+
+ for k,v in pairs(_messageHandles) do
+ if type(_evtHandles[k]) ~= "userdata" then
+ _evt = AFB:evtmake(source, k)
+ _evtHandles[k] = _evt
+ end
+ if type(_evtHandles[k]) == "userdata" then
+ AFB:subscribe(source, _evtHandles[k])
+ AFB:timerset(source, {uid="evtpush_"..k, delay=1, count=1}, "_evtpush", {k, v})
+ end
+ end
+
AFB:success(source)
+
end
function _list(source, args)