int main(int argc, char** argv) { uint8_t addr[20] = {0}; uint8_t* paddr = NULL; uint16_t port = OC_WELL_KNOWN_PORT; uint8_t ifname[] = "wlan0"; pthread_t threadId; pthread_t threadId_presence; int opt; printf ("OCServer is starting...\n"); if (OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr, sizeof(addr)) == ERR_SUCCESS) { printf ("Starting ocserver on address %s:%d\n",addr,port); paddr = addr; } /* * Init IoTivity as a SERVER. */ if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK) { printf ("OCStack init error\n"); return 0; } OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandlerCb); OCStackResult deviceResult = SetDeviceInfo(contentType, dateOfManufacture, deviceName, deviceUUID, firmwareVersion, hostName, manufacturerName, manufacturerUrl, modelNumber, platformVersion, supportUrl, version); deviceResult = OCSetDeviceInfo(deviceInfo); if (deviceResult != OC_STACK_OK) { printf ("Device Registration failed!\n"); exit (EXIT_FAILURE); } DeleteDeviceInfo(); /* * Create ONE light resource. */ createLightResource(gResourceUri, &Light); printf ("Entering ocserver main loop...\n"); signal(SIGINT, handleSigInt); while (!gQuitFlag) { /* * Main IoTivity function for processing. */ if (OCProcess() != OC_STACK_OK) { printf ("OCStack process error\n"); return 0; } sleep(2); } if (OCStop() != OC_STACK_OK) { printf ("OCStack process error\n"); } return 0; }
int main() { OIC_LOG(INFO, TAG, "Initializing IoTivity..."); OCStackResult result = OCInit(NULL, 0, OC_SERVER); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCInit Failed %d", result); return -1; } result = SetPlatformInfo(); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed %d", result); goto IotivityStop; } result = SetDeviceInfo(); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed: %d", result); goto IotivityStop; } result = OCStartPresence(0); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCStartPresence Failed: %d", result); goto IotivityStop; } // PIStartPlugin PIPlugin* plugin = NULL; OIC_LOG(INFO, TAG, "IoTivity Initialized properly, Starting Zigbee Plugin..."); result = PIStartPlugin(defaultComPort, PLUGIN_ZIGBEE, &plugin); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "Zigbee Plugin Start Failed: %d", result); goto IotivityStop; } if (signal(SIGINT, processCancel) == SIG_ERR) { OIC_LOG(ERROR, TAG, "Unable to catch SIGINT, terminating..."); } else { OIC_LOG(INFO, TAG, "Zigbee Plugin started correctly, press Ctrl-C to terminate application"); // Loop until sigint while (!processSignal(false) && result == OC_STACK_OK) { result = OCProcess(); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCProcess Failed: %d", result); break; } result = PIProcess(plugin); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "PIProcess Failed: %d", result); } } } OIC_LOG(INFO, TAG, "Stopping Zigbee Plugin..."); result = PIStopPlugin(plugin); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "Zigbee Plugin Stop Failed: %d", result); } OIC_LOG(INFO, TAG, "Zigbee Plugin Stopped"); // OCStop IotivityStop: OIC_LOG(INFO, TAG, "Stopping IoTivity..."); result = OCStop(); if (result != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCStop Failed: %d", result); return 0; } OIC_LOG(INFO, TAG, "Application Completed Successfully"); return 0; }
int main(int argc, char* argv[]) { uint8_t addr[20] = {0}; uint8_t* paddr = NULL; uint16_t port = OC_WELL_KNOWN_PORT; uint8_t ifname[] = "eth0"; pthread_t threadId; pthread_t threadId_presence; int opt; while ((opt = getopt(argc, argv, "o:")) != -1) { switch(opt) { case 'o': gObserveNotifyType = atoi(optarg); break; default: PrintUsage(); return -1; } } if ((gObserveNotifyType != 0) && (gObserveNotifyType != 1)) { PrintUsage(); return -1; } OC_LOG(DEBUG, TAG, "OCServer is starting..."); /*Get Ip address on defined interface and initialize coap on it with random port number * this port number will be used as a source port in all coap communications*/ if ( OCGetInterfaceAddress(ifname, sizeof(ifname), AF_INET, addr, sizeof(addr)) == ERR_SUCCESS) { OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port); paddr = addr; } if (OCInit((char *) paddr, port, OC_SERVER) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack init error"); return 0; } #ifdef WITH_PRESENCE if (OCStartPresence(0) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack presence/discovery error"); return 0; } #endif OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandlerCb); OCStackResult deviceResult = SetDeviceInfo(contentType, dateOfManufacture, deviceName, deviceUUID, firmwareVersion, hostName, manufacturerName, manufacturerUrl, modelNumber, platformVersion, supportUrl, version); if (deviceResult != OC_STACK_OK) { OC_LOG(INFO, TAG, "Device Registration failed!"); exit (EXIT_FAILURE); } deviceResult = OCSetDeviceInfo(deviceInfo); if (deviceResult != OC_STACK_OK) { OC_LOG(INFO, TAG, "Device Registration failed!"); exit (EXIT_FAILURE); } /* * Declare and create the example resource: Light */ createLightResource(gResourceUri, &Light); // Initialize observations data structure for the resource for (uint8_t i = 0; i < SAMPLE_MAX_NUM_OBSERVATIONS; i++) { interestedObservers[i].valid = false; } /* * Create a thread for changing the representation of the Light */ pthread_create (&threadId, NULL, ChangeLightRepresentation, (void *)NULL); /* * Create a thread for generating changes that cause presence notifications * to be sent to clients */ pthread_create(&threadId_presence, NULL, presenceNotificationGenerator, (void *)NULL); // Break from loop with Ctrl-C OC_LOG(INFO, TAG, "Entering ocserver main loop..."); DeleteDeviceInfo(); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack process error"); return 0; } sleep(2); } /* * Cancel the Light thread and wait for it to terminate */ pthread_cancel(threadId); pthread_join(threadId, NULL); pthread_cancel(threadId_presence); pthread_join(threadId_presence, NULL); OC_LOG(INFO, TAG, "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack process error"); } return 0; }
bool DirectGraphicsClass::Init(HWND hwnd, DWORD dwBreite, DWORD dwHoehe, DWORD dwZ_Bits, bool VSync) { Protokoll.WriteText("\n--> Direct3D init <--\n", false); Protokoll.WriteText( "---------------------\n\n", false); if(VSync == true) Protokoll.WriteText( "using VSync...\n", false); else Protokoll.WriteText( "NOT using VSync...\n", false); //D3DDISPLAYMODE DisplayMode; //HRESULT Res; lpD3DDevice = NULL; ZeroMemory(&d3dpp,sizeof(d3dpp)); lpD3D = Direct3DCreate9(D3D_SDK_VERSION); //Res = lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode); d3dpp.Windowed = CommandLineParams.RunWindowMode; // Fenster Modus ? d3dpp.BackBufferCount = 1; // 1 Backbuffer setzen d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.hDeviceWindow = hwnd; // Fenster Handle d3dpp.BackBufferWidth = SCREENWIDTH; // ScreenBreite d3dpp.BackBufferHeight = SCREENHEIGHT; // Screenhöhe d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC; // VSync an //if(VSync == true) d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC; // VSync an // else d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // VSync aus if(CommandLineParams.RunWindowMode == false) { d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; // Refresh Rate if(VSync == true) // VSYNC anlassen d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; else // VSYNC auslassen d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; // Backbuffer // ok, now try some video modes // 32 Bit / Hardware X8R8G8B8 d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; if (SUCCEEDED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &lpD3DDevice))) goto _ModeFound; // 16 Bit / Hardware R5B6G5 d3dpp.BackBufferFormat = D3DFMT_R5G6B5; if (SUCCEEDED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &lpD3DDevice))) goto _ModeFound; // 32 Bit / Software X8R8G8B8 d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; if (SUCCEEDED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &lpD3DDevice))) goto _ModeFound; // 16 Bit / Software R5G6B5 d3dpp.BackBufferFormat = D3DFMT_R5G6B5; if (SUCCEEDED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &lpD3DDevice))) goto _ModeFound; // nothing so far? OK... go for 32 bit reference rasterizer = ultraslow! // note: this does not work on my machine, so i have no idea if that helps d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; if (SUCCEEDED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, g_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &lpD3DDevice))) goto _ModeFound; // no mode found! Protokoll.WriteText("No compatible Graphics Mode found!\n", true); return false; _ModeFound: Protokoll.WriteText("DX8 Device initialised!\n", false); /* Jetzt haben wir die Informationen zusammen und machen weiter */ // Rausfinden, wie ich die Texturen laden muss (nur rechteckig, 2er Potenz) // Device kann nur quadratische Texturen D3DCAPS9 d3dCaps; lpD3DDevice->GetDeviceCaps(&d3dCaps); Protokoll.WriteText("Texture restrictions:\n", false); if (d3dCaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) { Protokoll.WriteText("Square Only: TRUE\n", false); SquareOnly = true; } else { Protokoll.WriteText("Square Only: FALSE\n", false); SquareOnly = false; } // Device kann nur Texturen mit 2er-Potenz-Grösse if (d3dCaps.TextureCaps & D3DPTEXTURECAPS_POW2) { Protokoll.WriteText("Power of Two: TRUE\n", false); PowerOfTwo = true; } else { Protokoll.WriteText("Power of Two: FALSE\n", false); PowerOfTwo = false; } SetDeviceInfo(); Protokoll.WriteText("\n-> Direct3D init successfull!\n\n", false); // DegreetoRad-Tabelle füllen for(int i=0; i<360; i++) DegreetoRad[i] = float(PI * i / 180); SetColorKeyMode(); return true; }
int main(int argc, char* argv[]) { #ifdef RA_ADAPTER char host[] = "localhost"; char user[] = "test1"; char pass[] = "intel123"; char empstr[] = ""; OCRAInfo_t rainfo = {}; rainfo.hostname = host; rainfo.port = 5222; rainfo.xmpp_domain = host; rainfo.username = user; rainfo.password = pass; rainfo.resource = empstr; rainfo.user_jid = empstr; rainfo.jidbound = jidbound; #endif int opt = 0; while ((opt = getopt(argc, argv, "o:s:p:d:u:w:r:j:")) != -1) { switch(opt) { case 'o': gObserveNotifyType = atoi(optarg); break; #ifdef RA_ADAPTER case 's': rainfo.hostname = optarg; break; case 'p': rainfo.port = atoi(optarg); break; case 'd': rainfo.xmpp_domain = optarg; break; case 'u': rainfo.username = optarg; break; case 'w': rainfo.password = optarg; break; case 'j': rainfo.user_jid = optarg; break; case 'r': rainfo.resource = optarg; break; #endif default: PrintUsage(); return -1; } } if ((gObserveNotifyType != 0) && (gObserveNotifyType != 1)) { PrintUsage(); return -1; } #ifdef RA_ADAPTER OCSetRAInfo(&rainfo); #endif OIC_LOG(DEBUG, TAG, "OCServer is starting..."); if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "OCStack init error"); return 0; } #ifdef WITH_PRESENCE if (OCStartPresence(0) != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "OCStack presence/discovery error"); return 0; } #endif OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandlerCb, NULL); OCStackResult registrationResult = SetPlatformInfo(platformID, manufacturerName, manufacturerUrl, modelNumber, dateOfManufacture, platformVersion, operatingSystemVersion, hardwareVersion, firmwareVersion, supportUrl, systemTime); if (registrationResult != OC_STACK_OK) { OIC_LOG(INFO, TAG, "Platform info setting failed locally!"); exit (EXIT_FAILURE); } registrationResult = OCSetPlatformInfo(platformInfo); if (registrationResult != OC_STACK_OK) { OIC_LOG(INFO, TAG, "Platform Registration failed!"); exit (EXIT_FAILURE); } registrationResult = SetDeviceInfo(deviceName, specVersion, dataModelVersions); if (registrationResult != OC_STACK_OK) { OIC_LOG(INFO, TAG, "Device info setting failed locally!"); exit (EXIT_FAILURE); } OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv"); registrationResult = OCSetDeviceInfo(deviceInfo); if (registrationResult != OC_STACK_OK) { OIC_LOG(INFO, TAG, "Device Registration failed!"); exit (EXIT_FAILURE); } /* * Declare and create the example resource: Light */ createLightResource(gResourceUri, &Light); // Initialize observations data structure for the resource for (uint8_t i = 0; i < SAMPLE_MAX_NUM_OBSERVATIONS; i++) { interestedObservers[i].valid = false; } /* * Create a thread for generating changes that cause presence notifications * to be sent to clients */ #ifdef WITH_PRESENCE pthread_create(&threadId_presence, NULL, presenceNotificationGenerator, (void *)NULL); #endif // Break from loop with Ctrl-C OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); DeletePlatformInfo(); DeleteDeviceInfo(); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "OCStack process error"); return 0; } } if (observeThreadStarted) { pthread_cancel(threadId_observe); pthread_join(threadId_observe, NULL); } pthread_cancel(threadId_presence); pthread_join(threadId_presence, NULL); OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "OCStack process error"); } return 0; }