packaging: merged config from system-controller test branch.
[profile/ivi/murphy.git] / packaging.in / murphy.lua
1 with_system_controller = false
2
3 m = murphy.get()
4
5 -- try loading the various logging plugins
6 m:try_load_plugin('systemd')
7 m:try_load_plugin('dlog')
8
9 -- load the console plugin
10 m:try_load_plugin('console')
11
12 m:try_load_plugin('console.disabled', 'webconsole', {
13                   address = 'wsck:127.0.0.1:3000/murphy',
14                   httpdir = '/usr/share/murphy/webconsole' });
15
16 -- load the dbus plugin
17 if m:plugin_exists('dbus') then
18     m:load_plugin('dbus')
19 end
20
21 -- load the native resource plugin
22 if m:plugin_exists('resource-native') then
23     m:load_plugin('resource-native')
24     m:info("native resource plugin loaded")
25 else
26     m:info("No native resource plugin found...")
27 end
28
29 -- load the dbus resource plugin
30 m:try_load_plugin('resource-dbus', {
31     dbus_bus = "system",
32     dbus_service = "org.Murphy",
33     dbus_track = true,
34     default_zone = "driver",
35     default_class = "implicit"
36 })
37
38 -- load the domain control plugin
39 if m:plugin_exists('domain-control') then
40     m:load_plugin('domain-control')
41 else
42     m:info("No domain-control plugin found...")
43 end
44
45 -- load the AMB plugin
46 if m:plugin_exists('amb') then
47     m:load_plugin('amb')
48 else
49     m:info("No amb plugin found...")
50 end
51
52 -- load the ASM resource plugin
53 if m:plugin_exists('resource-asm') then
54     m:load_plugin('resource-asm', {
55         zone = "driver",
56         share_mmplayer = "player:AVP,mandatory,exclusive,strict",
57         ignored_argv0 = "WebProcess"
58     })
59 else
60     m:info("No audio session manager plugin found...")
61 end
62
63 if m:plugin_exists('ivi-resource-manager') and not with_system_controller then
64     m:load_plugin('ivi-resource-manager')
65 end
66
67 -- define application classes
68 application_class {
69     name     = "interrupt",
70     priority = 99,
71     modal    = true ,
72     share    = false,
73     order    = "fifo"
74 }
75
76 application_class {
77     name     = "emergency",
78     priority = 80,
79     modal    = false,
80     share    = false,
81     order    = "fifo"
82 }
83 application_class {
84     name     = "alert",
85     priority = 51,
86     modal    = false,
87     share    = false,
88     order    = "fifo"
89 }
90
91 application_class {
92     name     = "navigator",
93     priority = 50,
94     modal    = false,
95     share    = true,
96     order    = "fifo"
97 }
98
99 application_class {
100     name     = "phone",
101     priority = 6 ,
102     modal    = false,
103     share    = true ,
104     order    = "lifo"
105 }
106 application_class {
107     name     = "camera",
108     priority = 5,
109     modal    = false,
110     share    = false,
111     order    = "lifo"
112 }
113
114 application_class { name="event"    , priority=4 , modal=false, share=true , order="fifo" }
115 application_class { name="game"     , priority=3 , modal=false, share=false, order="lifo" }
116 --# doesn't need to be created here, ivi-resource-manager creates it if loaded
117 --#application_class { name="basic"    , priority=2 , modal=false, share=false, order="lifo" }
118 application_class { name="player"   , priority=1 , modal=false, share=true , order="lifo" }
119 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
120
121 -- define zone attributes
122 zone.attributes {
123     type = {mdb.string, "common", "rw"},
124     location = {mdb.string, "anywhere", "rw"}
125 }
126
127 -- define zones
128 zone {
129      name = "driver",
130      attributes = {
131          type = "common",
132          location = "front-left"
133      }
134 }
135
136 zone {
137      name = "passanger1",
138      attributes = {
139          type = "private",
140          location = "front-right"
141      }
142 }
143
144 zone {
145      name = "passanger2",
146      attributes = {
147          type = "private",
148          location = "back-left"
149      }
150 }
151
152 zone {
153      name = "passanger3",
154      attributes = {
155          type = "private",
156          location = "back-right"
157      }
158 }
159
160 zone {
161      name = "passanger4",
162      attributes = {
163          type = "private",
164          location = "back-left"
165      }
166 }
167
168
169 -- define resource classes
170 if not m:plugin_exists('ivi-resource-manager') and
171    not with_system_controller
172 then
173    resource.class {
174         name = "audio_playback",
175         shareable = true,
176         attributes = {
177             role = { mdb.string, "music", "rw" },
178             pid = { mdb.string, "<unknown>", "rw" },
179             policy = { mdb.string, "relaxed", "rw" }
180         }
181    }
182 end
183
184 resource.class {
185      name = "audio_recording",
186      shareable = true,
187      attributes = {
188          role   = { mdb.string, "music"    , "rw" },
189          pid    = { mdb.string, "<unknown>", "rw" },
190          policy = { mdb.string, "relaxed"  , "rw" }
191      }
192 }
193
194 resource.class {
195      name = "video_playback",
196      shareable = false,
197 }
198
199 resource.class {
200      name = "video_recording",
201      shareable = false
202 }
203
204 if not m:plugin_exists('ivi-resource-manager') then
205 resource.method.veto = {
206     function(zone, rset, grant, owners)
207         rset_priority = application_class[rset.application_class].priority
208
209         owner_id = owners.audio_playback.resource_set
210         rset_id = rset.id
211
212         if (rset_priority >= 50 and owner_id ~= rset_id) then
213             print("*** resource-set "..rset_id.." - veto")
214             return false
215         end
216
217         return true
218     end
219 }
220 end
221
222 -- test for creating selections
223 mdb.select {
224            name = "audio_owner",
225            table = "audio_playback_owner",
226            columns = {"application_class"},
227            condition = "zone_name = 'driver'"
228 }
229
230 mdb.select {
231            name = "vehicle_speed",
232            table = "amb_vehicle_speed",
233            columns = {"value"},
234            condition = "key = 'VehicleSpeed'"
235 }
236
237 element.lua {
238    name    = "speed2volume",
239    inputs  = { speed = mdb.select.vehicle_speed, param = 9 },
240    outputs = {  mdb.table { name = "speedvol",
241                             index = {"zone", "device"},
242                             columns = {{"zone", mdb.string, 16},
243                                        {"device", mdb.string, 16},
244                                        {"value", mdb.floating}},
245                             create = true
246                            }
247              },
248    oldvolume = 0.0,
249    update  = function(self)
250                 speed = self.inputs.speed.single_value
251                 if (speed) then
252                     volume = (speed - 144.0) / 7.0
253                 else
254                     volume = 0.0
255                 end
256                 diff = volume - self.oldvolume
257                 if (diff*diff > self.inputs.param) then
258                     print("*** element "..self.name.." update "..volume)
259                     self.oldvolume = volume
260                     mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
261                 end
262              end
263 }
264
265 -- Night mode processing chain
266
267 mdb.select {
268     name = "exterior_brightness",
269     table = "amb_exterior_brightness",
270     columns = { "value" },
271     condition = "key = 'ExteriorBrightness'"
272 }
273
274 element.lua {
275     name    = "nightmode",
276     inputs  = { brightness = mdb.select.exterior_brightness },
277     oldmode = -1;
278     outputs = {
279         mdb.table {
280             name = "amb_nightmode",
281             index = { "id" },
282             create = true,
283             columns = {
284                 { "id", mdb.unsigned },
285                 { "night_mode", mdb.unsigned }
286             }
287         }
288     },
289     update = function(self)
290         -- This is a trivial function to calculate night mode. Later, we will
291         -- need a better threshold value and hysteresis to prevent oscillation.
292
293         brightness = self.inputs.brightness.single_value
294
295         if not brightness then
296             return
297         end
298
299         print("*** element "..self.name.." update brightness: "..brightness)
300
301         if brightness > 300 then
302             mode = 0
303         else
304             mode = 1
305         end
306
307         print("*** resulting mode: ".. mode)
308
309         if not (mode == self.oldmode) then
310             mdb.table.amb_nightmode:replace({ id = 0, night_mode = mode })
311         end
312
313         self.oldmode = mode
314     end
315 }
316
317 mdb.select {
318     name = "select_night_mode",
319     table = "amb_nightmode",
320     columns = { "night_mode" },
321     condition = "id = 0"
322 }
323
324 sink.lua {
325     name = "night_mode",
326     inputs = { owner = mdb.select.select_night_mode },
327     property = "NightMode",
328     type = "b",
329     initiate = builtin.method.amb_initiate,
330     update = builtin.method.amb_update
331 }
332
333
334 -- Driving mode processing chain
335
336
337 element.lua {
338     name    = "drivingmode",
339     inputs  = { speed = mdb.select.vehicle_speed },
340     oldmode = -1;
341     outputs = {
342         mdb.table {
343             name = "amb_drivingmode",
344             index = { "id" },
345             create = true,
346             columns = {
347                 { "id", mdb.unsigned },
348                 { "driving_mode", mdb.unsigned }
349             }
350         }
351     },
352     update = function(self)
353
354         speed = self.inputs.speed.single_value
355
356         if not speed then
357             return
358         end
359
360         if speed == 0 then
361             mode = 0
362         else
363             mode = 1
364         end
365
366         if not (mode == self.oldmode) then
367             mdb.table.amb_drivingmode:replace({ id = 0, driving_mode = mode })
368         end
369
370         self.oldmode = mode
371     end
372 }
373
374 mdb.select {
375     name = "select_driving_mode",
376     table = "amb_drivingmode",
377     columns = { "driving_mode" },
378     condition = "id = 0"
379 }
380
381 sink.lua {
382     name = "driving_mode",
383     inputs = { owner = mdb.select.select_driving_mode },
384     property = "DrivingMode",
385     type = "u",
386     initiate = builtin.method.amb_initiate,
387     update = builtin.method.amb_update
388 }
389
390 -- turn signals (left, right)
391
392 mdb.select {
393     name = "winker",
394     table = "amb_turn_signal",
395     columns = { "value" },
396     condition = "key = 'TurnSignal'"
397 }
398
399 -- regulation (on), use "select_driving_mode"
400
401 -- shift position (parking, reverse, other)
402
403 mdb.select {
404     name = "gear_position",
405     table = "amb_gear_position",
406     columns = { "value" },
407     condition = "key = 'GearPosition'"
408 }
409
410 -- cameras (back, front, left, right)
411
412 element.lua {
413     name    = "camera_state",
414     inputs  = { winker = mdb.select.winker, gear = mdb.select.gear_position },
415     oldmode = -1;
416     outputs = {
417         mdb.table {
418             name = "target_camera_state",
419             index = { "id" },
420             create = true,
421             columns = {
422                 { "id", mdb.unsigned },
423                 { "front_camera", mdb.unsigned },
424                 { "back_camera", mdb.unsigned },
425                 { "right_camera", mdb.unsigned },
426                 { "left_camera", mdb.unsigned }
427             }
428         }
429     },
430     update = function(self)
431
432         front_camera = 0
433         back_camera = 0
434         right_camera = 0
435         left_camera = 0
436
437         if self.inputs.gear == 128 then
438             back_camera = 1
439         elseif self.inputs.winker == 1 then
440             right_camera = 1
441         elseif self.inputs.winker == 2 then
442             left_camera = 1
443         end
444
445         mdb.table.target_camera_state:replace({ id = 0, front_camera = front_camera, back_camera = back_camera, right_camera = right_camera, left_camera = left_camera })
446
447     end
448 }
449
450 -- load the telephony plugin
451 m:try_load_plugin('telephony')
452
453
454 -- system controller test setup
455
456 if not with_system_controller then
457    return
458 end
459
460 window_operation_names = {
461     [1] = "create",
462     [2] = "destroy",
463     [3] = "name_change",
464     [4] = "visible",
465     [5] = "configure",
466     [6] = "active"
467 }
468
469 function window_operation_name(oper)
470     local name = window_operation_names[oper]
471     if name then return name end
472     return "<unknown " .. tostring(oper) .. ">"
473 end
474
475 command_names = {
476     [0x00001] = "send_appid",
477     [0x10001] = "create",
478     [0x10002] = "destroy",
479     [0x10003] = "show",
480     [0x10004] = "hide",
481     [0x10005] = "move",
482     [0x10006] = "change_active",
483     [0x10007] = "change_layer",
484     [0x10008] = "change_attr",
485     [0x10009] = "name",
486     [0x10011] = "map_thumb",
487     [0x10012] = "unmap_thumb",
488     [0x10020] = "show layer",
489     [0x10021] = "hide_layer",
490     [0x10022] = "change_layer_attr",
491     [0x20001] = "add_input",
492     [0x20002] = "del_input",
493     [0x20003] = "send_input"
494 }
495
496 function command_name(command)
497     local name = command_names[command]
498     if name then return name end
499     return "<unknown " .. tostring(command) .. ">"
500 end
501
502 wmgr = window_manager({
503   geometry = function(self, w,h, v)
504                   if type(v) == "function" then
505                       return v(w,h)
506                   end
507                   return v
508              end,
509
510   outputs = { { name  = "Center",
511                 id    = 0,
512                 areas = { Status = {
513                               id     = 100,
514                               pos_x  = 0,
515                               pos_y  = 0,
516                               width  = function(w,h) return w end,
517                               height = 64
518                           },
519                           Full = {
520                               id     = 1,
521                               pos_x  = 0,
522                               pos_y  = 64,
523                               width  = function(w,h) return w end,
524                               height = function(w,h) return h-64-128 end
525                           },
526                           Upper = {
527                               id     = 2,
528                               pos_x  = 0,
529                               pos_y  = 64,
530                               width  = function(w,h) return w end,
531                               height = function(w,h) return (h-64-128)/2 end
532                           },
533                           Lower = {
534                               id     = 3,
535                               pos_x  = 0,
536                               pos_y  = function(w,h) return (h-64-128)/2+64 end,
537                               width  = function(w,h) return w end,
538                               height = function(w,h) return (h-64-128)/2 end
539                           },
540                           UpperLeft = {
541                               id     = 4,
542                               pos_x  = 0,
543                               pos_y  = 64,
544                               width  = function(w,h) return w/2 end,
545                               height = function(w,h) return (h-64-128)/2 end
546                           },
547                           UpperRight = {
548                               id     = 5,
549                               pos_x  = function(w,h) return w/2 end,
550                               pos_y  = 64,
551                               width  = function(w,h) return w/2 end,
552                               height = function(w,h) return (h-64-128)/2 end
553                           },
554                           LowerLeft = {
555                               id     = 6,
556                               pos_x  = 0,
557                               pos_y  = function(w,h) return (h-64-128/2)+64 end,
558                               width  = function(w,h) return w/2 end,
559                               height = function(w,h) return (h-64-128)/2 end
560                           },
561                           LowerRight = {
562                               id     = 7,
563                               pos_x  = function(w,h) return w/2 end,
564                               pos_y  = function(w,h) return (h-64-128/2)+64 end,
565                               width  = function(w,h) return w/2 end,
566                               height = function(w,h) return (h-64-128)/2 end
567                           },
568                           SysApp = {
569                               id     = 8,
570                               pos_x  = 0,
571                               pos_y  = 64,
572                               width  = function(w,h) return w end,
573                               height = function(w,h) return h-64-128 end
574                           },
575                           ["SysApp.Left"] = {
576                               id     = 9,
577                               pos_x  = 0,
578                               pos_y  = 64,
579                               width  = function(w,h) return w/2-181 end,
580                               height = function(w,h) return h-64-128 end
581                           },
582                           ["SysApp.Right"] = {
583                               id     = 10,
584                               pos_x  = function(w,h) return w/2+181 end,
585                               pos_y  = 64,
586                               width  = function(w,h) return w/2-181 end,
587                               height = function(w,h) return h-64-128 end
588                           },
589                         }
590                },
591                { name  = "Mid",
592                  id    = 1
593                }
594
595   },
596   layers = { {      0, "Background"   , 1 },
597              {      1, "Application"  , 2 },
598              {      2, "Softkeyboard" , 4 },
599              {      3, "HomeScreen"   , 2 },
600              {      4, "ControlBar"   , 2 },
601              {      5, "InterruptApp" , 2 },
602              {      6, "OnScreen"     , 2 },
603              {    101, "Input"        , 3 },
604              {    102, "Touch"        , 4 },
605              {    103, "Cursor"       , 5 },
606              { 0x1000, "Background"   , 1 },
607              { 0x2000, "Normal"       , 2 },
608              { 0x3000, "Fullscreen"   , 2 },
609              { 0x4000, "InputPanel"   , 3 },
610              { 0xA000, "Touch"        , 4 },
611              { 0xB000, "Cursor"       , 5 },
612              { 0xC000, "Startup"      , 6 }
613   },
614
615
616   window_update = function(self, oper, win, mask)
617                       if (verbose) then
618                           print("*** WINDOW UPDATE oper:"..window_operation_name(oper).." mask: "..tostring(mask))
619                           print(win)
620                       end
621
622                       local arg = m:JSON({ surface = win.surface,
623                                            winname = win.name,
624                       })
625                       local command = 0
626
627                       if oper == 1 then -- create
628                            if win.layertype and win.layertype == 3 then
629                                print("ignoring input panel window creation")
630                                return
631                            end
632                            command     = 0x10001
633                       elseif oper == 2 then -- destroy
634                            command     = 0x10002
635                       elseif oper == 3 then  -- namechange
636                            command     = 0x10009
637                       elseif oper == 4 or oper == 5 then --visible or configure
638                            command     = 0x10008
639                            arg.zone    = win.area
640                            arg.node    = win.node
641                            arg.layer   = win.layer
642                            arg.pos_x   = win.pos_x
643                            arg.pos_y   = win.pos_y
644                            arg.width   = win.width
645                            arg.height  = win.height
646                            arg.raise   = win.raise
647                            arg.visible = win.visible
648                            arg.active  = win.active
649                       elseif oper == 6 then -- active
650                            if false and win.active ~= 0 then
651                                print("### already active")
652                                return
653                            end
654                            command = 0x10006
655                       else
656                            print("### nothing to do")
657                            return
658                       end
659
660                       local msg = m:JSON({ command = command,
661                                            appid   = win.appid,
662                                            pid     = win.pid,
663                                            arg     = arg
664                       })
665                       print("### sending window message: " .. command_name(msg.command))
666                       print(msg)
667                       sc:send_message(msg.appid, msg)
668
669                       if (oper == 1) then -- create
670                           local a = animation({})
671                           local r = m:JSON({surface = win.surface,
672                                             visible = 1,
673                                             raise   = 1})
674                           self:window_request(r,a,0)
675                       end
676                   end,
677
678   layer_update = function(self, oper, j, mask)
679                       if verbose then
680                           print("*** LAYER UPDATE oper:"..oper.." mask: "..tostring(mask))
681                           print(j)
682                       end
683                  end,
684   output_update = function(self, oper, out, mask)
685                       local idx = out.index
686                       if verbose then
687                           print("*** OUTPUT UPDATE oper:"..oper.." mask: "..tostring(mask))
688                       end
689                       print(out)
690                       if (oper == 1) then -- create
691                           local outdef = self.outputs[idx+1]
692                           if outdef then
693                               self:output_request(m:JSON({index = idx,
694                                                           id    = outdef.id,
695                                                           name  = outdef.name
696                                                           }))
697                           end
698                       elseif (oper == 5) then -- done
699                           local ads = self.outputs[idx+1].areas
700                           if ads then
701                               for name,area in pairs(ads) do
702                                   local a = m:JSON({name=name,output=out.index})
703                                   for fld,val in pairs(area) do
704                                       a[fld] = self:geometry(out.width,out.height,val)
705                                    end
706                                    self:area_create(a)
707                               end
708                           end
709                       end
710                   end
711 })
712
713
714 sc = m:get_system_controller()
715
716 connected = false
717
718 -- these shoud be before wmgr:connect() is called
719 print("====== creating applications")
720 application {
721     appid      = "default",
722     area       = "Center.Full",
723     privileges = { screen = "none", audio = "none" }
724 }
725
726 application {
727     appid      = "org.tizen.ico.homescreen",
728     area       = "Center.Full",
729     privileges = { screen = "system", audio = "system" }
730 }
731
732 application {
733     appid      = "org.tizen.ico.statusbar",
734     area       = "Center.Status",
735     privileges = { screen = "system", audio = "none" }
736 }
737
738
739 if sc then
740     sc.client_handler = function (self, cid, msg)
741         print('*** client handler: ' .. tostring(msg))
742         if not connected then
743             print('Trying to connect to wayland...')
744             connected = wmgr:connect()
745         else
746             print('Window manager already connected...')
747         end
748     end
749
750     sc.generic_handler = function (self, cid, msg)
751         print('*** generic handler: ' .. tostring(msg))
752     end
753
754     sc.window_handler = function (self, cid, msg)
755         print('*** window handler: ' .. command_name(msg.command) .. ' ' .. tostring(msg))
756
757         local a = animation({})
758         if msg.command == 0x10003 then       -- ico SHOW command
759             local raise_mask = 0x01000000
760             local lower_mask = 0x02000000
761             msg.arg.visible = 1
762             if msg.arg and msg.arg.anim_name then
763                 local time = msg.arg.time
764                 time = m:AND(time, m:NEG(m:OR(raise_mask, lower_mask)))
765                 time = 200
766                 if m:AND(msg.arg.anim_time, raise_mask) then
767                     msg.arg.raise = 1
768                 elseif m:AND(msg.arg.anim_time, lower_mask) then
769                     msg.arg.raise = 0
770                 end
771                 a.show = { msg.arg.anim_name, time }
772                 print('time: ' .. tostring(a.show[2]))
773             end
774             print('##### SHOW')
775             print(tostring(msg.arg))
776             wmgr:window_request(msg.arg, a, 0)
777         elseif msg.command == 0x10004 then   -- ico HIDE command
778             local raise_mask = 0x01000000
779             local lower_mask = 0x02000000
780             msg.arg.visible = 0
781             if msg.arg and msg.arg.anim_name then
782                 local time = msg.arg.time
783                 time = m:AND(time, m:NEG(m:OR(raise_mask, lower_mask)))
784                 time = 200
785                 if m:AND(msg.arg.anim_time, raise_mask) then
786                     msg.arg.raise = 1
787                 end
788                 if m:AND(msg.arg.anim_time, lower_mask) then
789                     msg.arg.raise = 0
790                 end
791                 a.hide = { msg.arg.anim_name, time }
792                 print('hide animation time: ' .. tostring(a.hide[2]))
793             end
794             print('##### HIDE')
795             print(tostring(msg.arg))
796             wmgr:window_request(msg.arg, a, 0)
797         elseif msg.command == 0x10005 then   -- ico MOVE
798             print('##### MOVE')
799             print(tostring(msg.arg))
800             wmgr:window_request(msg.arg, a, 0)
801         elseif msg.command == 0x10006 then   -- ico ACTIVE
802             print('##### ACTIVE')
803             if not msg.arg.active then
804                 msg.arg.active = 0
805             end
806             print(tostring(msg.arg))
807             wmgr:window_request(msg.arg, a, 0)
808         elseif msg.command == 0x10007 then   -- ico CHANGE_LAYER
809             print('##### CHANGE_LAYER')
810             print(tostring(msg.arg))
811             --[[
812             if msg.arg.layer ~= 4 or msg.arg.layer ~= 5 then
813                 print("do not change layer for other than cursor or touch")
814                 return
815             end
816             --]]
817             wmgr:window_request(msg.arg, a, 0)
818         elseif msg.command == 0x10011 then   -- ico MAP_THUMB
819             local framerate = msg.arg.framerate
820             print('##### MAP_THUMB')
821             msg.arg.map = 1
822             if not framerate or framerate < 0 then
823                 framerate = 0
824             end
825             wmgr:window_request(msg.arg, a, framerate)
826         elseif msg.command == 0x10012 then   -- ico UNMAP_THUMB
827             print('##### UNMAP_THUMB')
828             msg.arg.map = 0
829             wmgr:window_request(msg.arg, a, 0)
830         elseif msg.command == 0x10020 then   -- ico SHOW_LAYER command
831             msg.arg.visible = 1
832             print('##### SHOW_LAYER')
833             wmgr:layer_request(msg.arg)
834         end
835     end
836     sc.input_handler = function (self, cid, msg)
837         print('*** input handler: ' .. tostring(msg))
838     end
839     sc.user_handler = function (self, cid, msg)
840         print('*** user handler: ' .. tostring(msg))
841     end
842     sc.resource_handler = function (self, cid, msg)
843         print('*** resource handler: ' .. tostring(msg))
844
845         reply = m.JSON({ command = 'reply to client #' .. tostring(cid) })
846
847         if sc:send_message(self, cid, reply) then
848             print('*** reply OK')
849         else
850             print('*** reply FAILED')
851         end
852     end
853     sc.inputdev_handler = function (self, cid, msg)
854         print('*** inputdev handler: ' .. tostring(msg))
855     end
856 end