int main(int argc, char* argv[]) { int opt; resourceList = NULL; while ((opt = getopt(argc, argv, "u:t:c:")) != -1) { switch(opt) { case 'u': UnicastDiscovery = atoi(optarg); break; case 't': TestCase = atoi(optarg); break; case 'c': Connectivity = atoi(optarg); break; default: PrintUsage(); return -1; } } if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) || (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS) || (Connectivity < CT_ADAPTER_DEFAULT || Connectivity >= MAX_CT)) { PrintUsage(); return -1; } /* Initialize OCStack*/ if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack init error"); return 0; } if(Connectivity == CT_ADAPTER_DEFAULT || Connectivity == CT_IP) { ConnType = CT_ADAPTER_IP;//CT_DEFAULT; } else { OC_LOG(INFO, TAG, "Default Connectivity type selected"); PrintUsage(); } InitDiscovery(); // Break from loop with Ctrl+C signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack process error"); return 0; } sleep(2); } freeResourceList(); OC_LOG(INFO, TAG, "Exiting occlient main loop..."); if (OCStop() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack stop error"); } return 0; }
int main(int argc, char* argv[]) { int opt; resourceList = NULL; while ((opt = getopt(argc, argv, "u:t:c:")) != -1) { switch(opt) { case 'u': UNICAST_DISCOVERY = atoi(optarg); break; case 't': TEST_CASE = atoi(optarg); break; case 'c': // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported // OC_CONNTYPE = OCConnectivityType(atoi(optarg)); OC_CONNTYPE = OC_IPV4; OC_LOG(INFO, TAG, "Using default IPv4, IPv6 not currently supported."); break; default: PrintUsage(); return -1; } } if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) || (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ) { PrintUsage(); return -1; } /* Initialize OCStack*/ if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack init error"); return 0; } InitDiscovery(); // Break from loop with Ctrl+C signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack process error"); return 0; } sleep(2); } freeResourceList(); OC_LOG(INFO, TAG, "Exiting occlient main loop..."); if (OCStop() != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack stop error"); } return 0; }