int ScreenHandler::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: sendDataToKnx((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: sendDataToScreenObj((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 2: disconnectGateway(); break; case 3: onQuit(); break; case 4: onScreenChange((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 5: onScreenChange((*reinterpret_cast< int(*)>(_a[1]))); break; case 6: onDataFromKnx((*reinterpret_cast< QString(*)>(_a[1]))); break; case 7: onDataFromScreenObj((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break; case 8: onMsg((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; default: ; } _id -= 9; } return _id; }
int main(int argc, char const *argv[]) { int rc = -1; iotfclient client; //catch interrupt signal signal(SIGINT, sigHandler); signal(SIGTERM, sigHandler); char *configFilePath = NULL; if(isEMBDCHomeDefined()){ getSamplesPath(&configFilePath); configFilePath = realloc(configFilePath,strlen(configFilePath)+15); strcat(configFilePath,"gateway.cfg"); } else{ printf("IOT_EMBDC_HOME is not defined\n"); printf("Define IOT_EMBDC_HOME to client library path to execute samples\n"); return -1; } rc = initialize_configfile(&client, configFilePath,1); free(configFilePath); if(rc != SUCCESS){ printf("initialize failed and returned rc = %d.\n Quitting..", rc); return 0; } setKeepAliveInterval(59); rc = connectiotf(&client); if(rc != SUCCESS){ printf("Connection failed and returned rc = %d.\n Quitting..", rc); return 0; } //Registering the function "myCallback" as the command handler. setGatewayCommandHandler(&client, myCallback); // providing "+" will subscribe to all the command of all formats. subscribeToDeviceCommands(&client, "elevator", "elevator-1", "+", "+", 0); while(!interrupt) { printf("Publishing the event stat with rc "); //publishing gateway events rc= publishGatewayEvent(&client, "elevatorDevices","elevatorGateway", "{\"d\" : {\"temp\" : 34 }}", QOS0); //publishing device events on behalf of a device rc= publishDeviceEvent(&client, "elevator","elevator-1","status","json", "{\"d\" : {\"temp\" : 34 }}", QOS0); printf(" %d\n", rc); //Yield for receiving commands. yield(&client, 1000); sleep(1); } printf("Quitting!!\n"); //Be sure to disconnect the gateway at exit disconnectGateway(&client); return 0; }