AJ_Status AJServices_Init(AJ_Object* appObjects, AJ_Object* proxyObjects, AJ_Object* announceObjects, const char* deviceManufactureName, const char* deviceProductName) { AJ_Status status = AJ_OK; #ifdef CONFIG_SERVICE status = Config_Init(); if (status != AJ_OK) { goto Exit; } #endif #ifdef ONBOARDING_SERVICE status = Onboarding_Init(deviceManufactureName, deviceProductName); if (status != AJ_OK) { goto Exit; } #endif #ifdef NOTIFICATION_SERVICE_PRODUCER status = NotificationProducer_Init(); if (status != AJ_OK) { goto Exit; } #endif #ifdef NOTIFICATION_SERVICE_CONSUMER status = NotificationConsumer_Init(proxyObjects); if (status != AJ_OK) { goto Exit; } #endif #ifdef CONTROLPANEL_SERVICE status = Controlee_Init(); if (status != AJ_OK) { goto Exit; } #endif Exit: return status; }
int main(int argc, char *args[]) { Config config; Config_Init(&config); if( !Config_FromArgs(&config, argc, args) ) return 1; Config_Load(&config, config.configFile); Config_Check(&config); Config_Print(config); MD3Model model; model.scale = config.model_scale; model.fps = config.fps; MD3Anims anims; anims.n_anims = 0; anims.anims = NULL; if( config.redirect2File ) { if( config.stdoutFile ) freopen(config.stdoutFile, "w+", stdout); if( config.stderrFile ) freopen(config.stderrFile, "w+", stderr); } model.path = Utils_GetPath(config.modelFile); if( MD3Viewer_Init(&config) ) { if( config.modelFile != NULL && MD3Loader_Load(&model, config.modelFile) ) { if( config.debug ) { MD3Verbose_PrintModelInfo(&model); } if( !config.info ) { MD3Viewer_SetModel(&model); if( config.animFile != NULL ) { if( MD3Anim_Load(config.animFile, &anims) ) MD3Viewer_SetAnims(&anims); else fprintf(stderr, "Failed to load animation file: '%s'\n", config.animFile); } #ifdef DMALLOC debugmalloc_naplofajl("memlog.txt"); debugmalloc_dump(); #endif MD3Viewer_Start(); MD3Viewer_Quit(); } MD3Loader_FreeModel(&model); if( config.animFile != NULL ) MD3Anim_FreeAnims(&anims); } else fprintf(stderr, "Failed to load modell!\n"); } else fprintf(stderr, "Failed to init viewer!\n"); if( config.redirect2File ) { if( config.stdoutFile ) fclose(stdout); if( config.stderrFile ) fclose(stderr); } return 0; }
int AJ_Main(void) { AJ_Status status = AJ_OK; uint8_t isUnmarshalingSuccessful = FALSE; AJSVC_ServiceStatus serviceStatus; AJ_Message msg; AJ_Initialize(); AJ_AboutSetIcon(aboutIconContent, aboutIconContentSize, aboutIconMimetype, aboutIconUrl); status = PropertyStore_Init(); if (status != AJ_OK) { goto Exit; } status = Config_Init(); if (status != AJ_OK) { goto Exit; } status = Onboarding_Init(); if (status != AJ_OK) { goto Exit; } AJ_RegisterObjects(AppObjects, NULL); SetBusAuthPwdCallback(MyBusAuthPwdCB); while (TRUE) { status = AJ_OK; serviceStatus = AJSVC_SERVICE_STATUS_NOT_HANDLED; if (!isBusConnected) { isBusConnected = AJRouter_Connect(&busAttachment, ROUTER_NAME); if (!isBusConnected) { // Failed to connect to router? continue; // Retry establishing connection to router. } } status = AJApp_ConnectedHandler(&busAttachment); if (!AJOBS_IsWiFiConnected()) { status = AJ_ERR_RESTART; } if (status == AJ_OK) { status = AJ_UnmarshalMsg(&busAttachment, &msg, AJAPP_UNMARSHAL_TIMEOUT); isUnmarshalingSuccessful = (status == AJ_OK); if (status == AJ_ERR_TIMEOUT) { if (AJ_ERR_LINK_TIMEOUT == AJ_BusLinkStateProc(&busAttachment)) { status = AJ_ERR_READ; // something's not right. force disconnect } } if (isUnmarshalingSuccessful) { if (serviceStatus == AJSVC_SERVICE_STATUS_NOT_HANDLED) { serviceStatus = AJApp_MessageProcessor(&busAttachment, &msg, &status); } if (serviceStatus == AJSVC_SERVICE_STATUS_NOT_HANDLED) { //Pass to the built-in bus message handlers status = AJ_BusHandleBusMessage(&msg); } AJ_NotifyLinkActive(); } //Unmarshaled messages must be closed to free resources AJ_CloseMsg(&msg); } if (status == AJ_ERR_READ || status == AJ_ERR_RESTART || status == AJ_ERR_RESTART_APP) { if (isBusConnected) { AJApp_DisconnectHandler(&busAttachment, status != AJ_ERR_READ); isBusConnected = !AJRouter_Disconnect(&busAttachment, status != AJ_ERR_READ); if (status == AJ_ERR_RESTART_APP) { AJ_Reboot(); } } } } // while (TRUE) return 0; Exit: return (1); }