Материал из Module developer
Перейти к: навигация, поиск

Then get description of the module using ModuleID: var module = B.getModule(moduleID);
Get the linkd to the device driver and server driver. Connect them:

    var device = module.getDevice("DuoTecno Network");
    var server = IR.GetDevice("iRidium Server");
    server.Connect();
    device.Connect();

Create listeners for the possibility to connect to the server (it is required for not duplicating commands to the server and to the device, but for sending them directly either to the server if it is available or to the device):

   B.AddListener(B.EVENT_CONNECT_TO_SERVER_AVAILABLE, 0, function () {
        device.Disconnect();
    })
    B.AddListener(B.EVENT_CONNECT_TO_SERVER_NOT_AVAILABLE, 0, function () {
        device.Connect(); 
    })