From d147b9150542047ee42d7f622524ec0bf3b34128 Mon Sep 17 00:00:00 2001 From: Doug Hudson Date: Thu, 14 May 2015 13:44:55 -0400 Subject: [PATCH] Remove WiFi and Ethernet connectivity type options in RI. - Replace with IPv4 and IPv6 options. - Note that IPv6 is not currently supported - Update C/C++ sample apps - Update C/C++ unit tests - Update several services files to support mod. Change-Id: I086580d76665355d14cfa240347252cef969fa64 Signed-off-by: Doug Hudson Reviewed-on: https://gerrit.iotivity.org/gerrit/995 Tested-by: jenkins-iotivity Reviewed-by: Sakthivel Samidurai Reviewed-by: Joseph Morrow Reviewed-by: Mandeep Shetty Reviewed-by: Erich Keane --- examples/OICMiddle/Client.cpp | 2 +- resource/csdk/stack/include/octypes.h | 4 +- .../linux/SimpleClientServer/occlient.cpp | 21 +++++---- .../SimpleClientServer/occlientbasicops.cpp | 26 +++++++---- .../linux/SimpleClientServer/occlientcoll.cpp | 30 ++++++------ .../linux/SimpleClientServer/occlientslow.cpp | 12 +++-- .../samples/linux/secure/occlientbasicops.cpp | 4 +- resource/csdk/stack/src/ocstack.c | 13 ++++-- resource/csdk/stack/src/oicgroup.c | 10 ++-- resource/csdk/stack/test/stacktests.cpp | 4 +- resource/examples/devicediscoveryclient.cpp | 21 +++++---- resource/examples/fridgeclient.cpp | 23 ++++++---- resource/examples/garageclient.cpp | 43 ----------------- resource/examples/groupclient.cpp | 43 ----------------- resource/examples/groupserver.cpp | 43 ----------------- resource/examples/presenceclient.cpp | 23 ++++++---- resource/examples/roomclient.cpp | 41 ----------------- resource/examples/simpleclient.cpp | 35 +------------- resource/examples/simpleclientHQ.cpp | 43 ++++------------- resource/examples/simpleclientserver.cpp | 21 +++++---- resource/examples/threadingsample.cpp | 43 ----------------- resource/unittests/OCPlatformTest.cpp | 46 +++++++++---------- resource/unittests/OCResourceTest.cpp | 4 +- .../NotificationManager/include/hosting.h | 11 +---- .../linux/sampleConsumer/SampleConsumer.cpp | 2 +- .../sample-app/linux/mqtt/mqttclient.cpp | 2 +- .../tizen/PPMSampleApp/src/ppmsampleapp.cpp | 2 +- .../src/SensorProcessor/ResourceFinder.cpp | 34 ++------------ .../linux/groupaction/groupserver.cpp | 4 +- .../sampleapp/linux/groupsyncaction/group.cpp | 11 ++--- .../things-manager/sdk/src/GroupManager.cpp | 26 ++--------- .../sdk/src/GroupSynchronization.cpp | 37 +++++++-------- .../sdk/src/ThingsConfiguration.cpp | 10 +--- 33 files changed, 190 insertions(+), 504 deletions(-) diff --git a/examples/OICMiddle/Client.cpp b/examples/OICMiddle/Client.cpp index c8576d6767..b753b94e22 100644 --- a/examples/OICMiddle/Client.cpp +++ b/examples/OICMiddle/Client.cpp @@ -39,7 +39,7 @@ void MiddleClient::findResources() { m_resourceMap.clear(); - OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, OC_WIFI, m_findCB); + OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, OC_ALL, m_findCB); } void MiddleClient::foundOCResource(shared_ptr resource) diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index 7868428ebf..5210210df9 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -201,8 +201,8 @@ typedef enum */ typedef enum { - OC_ETHERNET = 0, - OC_WIFI, + OC_IPV4 = 0, + OC_IPV6, OC_EDR, OC_LE, OC_ALL // Multicast message: send over all the interfaces. diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp index c6f175fbb3..46fac55bc9 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp @@ -35,9 +35,9 @@ static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oc/core"; static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s:6298/oc/core/d"; static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oc/core/d"; static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core"; -//The following variable determines the interface (wifi, ethernet etc.) -//to be used for sending unicast messages. Default set to WIFI. -static OCConnectivityType OC_CONNTYPE = OC_WIFI; +//The following variable determines the interface protocol (IPv4, IPv6, etc) +//to be used for sending unicast messages. Default set to IPv4. +static OCConnectivityType OC_CONNTYPE = OC_IPV4; static std::string putPayload = "{\"oc\":[{\"rep\":{\"power\":15,\"state\":true}}]}"; static std::string coapServerIP = "255.255.255.255"; static std::string coapServerPort = "5683"; @@ -74,7 +74,7 @@ static void PrintUsage() { OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1..17> -c <0|1>"); OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources"); - OC_LOG(INFO, TAG, "-c <0|1> : Send unicast messages over Ethernet or WIFI"); + OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)"); OC_LOG(INFO, TAG, "-t 1 : Discover Resources"); OC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request"); OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Nonconfirmable Get Request" @@ -741,7 +741,10 @@ int main(int argc, char* argv[]) TEST_CASE = atoi(optarg); break; case 'c': - OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + // 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, "IPv6 not currently supported, using IPv4."); break; default: PrintUsage(); @@ -856,11 +859,11 @@ std::string getConnectivityType (OCConnectivityType connType) { switch (connType) { - case OC_ETHERNET: - return "Ethernet"; + case OC_IPV4: + return "IPv4"; - case OC_WIFI: - return "WiFi"; + case OC_IPV6: + return "IPv6"; case OC_LE: return "BLE"; diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp index f844666236..30f79d9447 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientbasicops.cpp @@ -41,9 +41,9 @@ static int TEST_CASE = 0; static const char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oc/core"; static std::string putPayload = "{\"state\":\"off\",\"power\":10}"; -//The following variable determines the interface (wifi, ethernet etc.) -//to be used for sending unicast messages. Default set to WIFI. -static OCConnectivityType OC_CONNTYPE = OC_WIFI; +//The following variable determines the interface protocol (IPv4, IPv6, etc) +//to be used for sending unicast messages. Default set to IPv4. +static OCConnectivityType OC_CONNTYPE = OC_IPV4; static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core"; int gQuitFlag = 0; @@ -69,8 +69,8 @@ static void PrintUsage() " Initiate Nonconfirmable Get/Put/Post Requests"); OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate " "Confirmable Get/Put/Post Requests"); - OC_LOG(INFO, TAG, "-c <0|1> : Send unicast messages over Ethernet or WIFI."); - OC_LOG(INFO, TAG, "Default connectivityType WIFI"); + OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)"); + OC_LOG(INFO, TAG, "Default connectivityType IPv4"); } /* @@ -645,11 +645,14 @@ void printResourceList() printf("port = %s\n", iter->port); switch (iter->connType) { - case OC_ETHERNET: - printf("connType = %s\n","Ethernet"); + case OC_IPV4: + printf("connType = %s\n","IPv4"); break; - case OC_WIFI: - printf("connType = %s\n","WiFi"); + case OC_IPV6: + // TODO: Allow IPv6 when support is added + printf("IPv6 not currently supported, default to IPv4\n"); + //printf("connType = %s\n","IPv6"); + printf("connType = %s\n","IPv4"); break; case OC_LE: printf("connType = %s\n","BLE"); @@ -698,7 +701,10 @@ int main(int argc, char* argv[]) TEST_CASE = atoi(optarg); break; case 'c': - OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + // 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(); diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp index dddf8277b7..f609aea383 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp @@ -76,9 +76,9 @@ testToTextMap queryInterface[] = { static std::string putPayload = "{\"state\":\"off\",\"power\":\"0\"}"; -//The following variable determines the interface (wifi, ethernet etc.) -//to be used for sending unicast messages. Default set to WIFI. -static OCConnectivityType OC_CONNTYPE = OC_WIFI; +//The following variable determines the interface protocol (IPv4, IPv6, etc) +//to be used for sending unicast messages. Default set to IPv4. +static OCConnectivityType OC_CONNTYPE = OC_IPV4; static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core"; // The handle for the observe registration @@ -107,24 +107,24 @@ int InitDiscovery(); void PrintUsage() { OC_LOG(INFO, TAG, "Usage : occlientcoll -t -c "); - OC_LOG(INFO, TAG, "-c <0|1> : Send messages over Ethernet or WIFI"); - OC_LOG(INFO, TAG, "Test Case 1 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)"); + OC_LOG(INFO, TAG, "Test Case 1 : Discover Resources && Initiate GET Request on an "\ "available resource using default interface."); - OC_LOG(INFO, TAG, "Test Case 2 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "Test Case 2 : Discover Resources && Initiate GET Request on an "\ "available resource using batch interface."); - OC_LOG(INFO, TAG, "Test Case 3 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "Test Case 3 : Discover Resources && Initiate GET Request on an "\ "available resource using link list interface."); - OC_LOG(INFO, TAG, "Test Case 4 : Discover Resources && Initiate GET & PUT Request on an"\ + OC_LOG(INFO, TAG, "Test Case 4 : Discover Resources && Initiate GET & PUT Request on an "\ "available resource using default interface."); - OC_LOG(INFO, TAG, "Test Case 5 : Discover Resources && Initiate GET & PUT Request on an"\ + OC_LOG(INFO, TAG, "Test Case 5 : Discover Resources && Initiate GET & PUT Request on an "\ "available resource using batch interface."); - OC_LOG(INFO, TAG, "Test Case 6 : Discover Resources && Initiate GET & PUT Request on an"\ + OC_LOG(INFO, TAG, "Test Case 6 : Discover Resources && Initiate GET & PUT Request on an "\ "available resource using link list interface."); - OC_LOG(INFO, TAG, "Test Case 7 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "Test Case 7 : Discover Resources && Initiate GET Request on an "\ "unavailable resource using default interface."); - OC_LOG(INFO, TAG, "Test Case 8 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "Test Case 8 : Discover Resources && Initiate GET Request on an "\ "unavailable resource using batch interface."); - OC_LOG(INFO, TAG, "Test Case 9 : Discover Resources && Initiate GET Request on an"\ + OC_LOG(INFO, TAG, "Test Case 9 : Discover Resources && Initiate GET Request on an "\ "unavailable resource using link list interface."); } @@ -358,7 +358,9 @@ int main(int argc, char* argv[]) TEST = atoi(optarg); break; case 'c': - OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported + // OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + OC_CONNTYPE = OC_IPV4; break; default: PrintUsage(); diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp index 6a9a66eb49..5fc29c6610 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlientslow.cpp @@ -37,9 +37,9 @@ static std::string coapServerIP = "255.255.255.255"; static std::string coapServerPort = "5683"; static std::string coapServerResource = "/a/led"; -//The following variable determines the interface (wifi, ethernet etc.) -//to be used for sending unicast messages. Default set to WIFI. -static OCConnectivityType OC_CONNTYPE = OC_WIFI; +//The following variable determines the interface protocol (IPv4, IPv6, etc) +//to be used for sending unicast messages. Default set to IPv4. +static OCConnectivityType OC_CONNTYPE = OC_IPV4; static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core"; static int IPV4_ADDR_SIZE = 16; void StripNewLineChar(char* str); @@ -58,7 +58,7 @@ void handleSigInt(int signum) static void PrintUsage() { OC_LOG(INFO, TAG, "Usage : occlient -c <0|1> -u <0|1> -t <1|2|3>"); - OC_LOG(INFO, TAG, "-c <0|1> : Send unicast messages over Ethernet or WIFI"); + OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)"); OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources"); OC_LOG(INFO, TAG, "-t 1 : Discover Resources"); OC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request"); @@ -241,7 +241,9 @@ int main(int argc, char* argv[]) TEST_CASE = atoi(optarg); break; case 'c': - OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported + // OC_CONNTYPE = OCConnectivityType(atoi(optarg)); + OC_CONNTYPE = OC_IPV4; break; default: PrintUsage(); diff --git a/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp b/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp index 186a5f8857..5f8d7b6e7d 100644 --- a/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp +++ b/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp @@ -258,9 +258,7 @@ int InitDiscovery() OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!"); return OC_STACK_INVALID_PARAM; } - printf("Select Connectivity type on which discovery request needs to be send : "); - printf("0:ETH, 1:WIFI\n"); - discoveryReqConnType = ((getchar() - '0') == 0) ? OC_ETHERNET : OC_WIFI; + discoveryReqConnType = OC_IPV4; } else { diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 44ed5ac726..8c6d0045d0 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -654,11 +654,11 @@ OCStackResult OCToCATransportType(OCConnectivityType ocConType, CATransportType_ switch(ocConType) { - case OC_ETHERNET: + case OC_IPV4: *caConType = CA_IPV4; break; - case OC_WIFI: - *caConType = CA_IPV4; + case OC_IPV6: + *caConType = CA_IPV6; break; case OC_EDR: *caConType = CA_EDR; @@ -667,7 +667,7 @@ OCStackResult OCToCATransportType(OCConnectivityType ocConType, CATransportType_ *caConType = CA_LE; break; case OC_ALL: - // Currently OC_ALL represents WIFI and ETHERNET + // Currently OC_ALL represents IPv4 // Add other connectivity types as they are enabled in future *caConType = (CATransportType_t) (CA_IPV4); break; @@ -685,7 +685,10 @@ OCStackResult CAToOCConnectivityType(CATransportType_t caConType, OCConnectivity switch(caConType) { case CA_IPV4: - *ocConType = OC_ETHERNET; + *ocConType = OC_IPV4; + break; + case CA_IPV6: + *ocConType = OC_IPV6; break; case CA_EDR: *ocConType = OC_EDR; diff --git a/resource/csdk/stack/src/oicgroup.c b/resource/csdk/stack/src/oicgroup.c index 66fce6c63f..47d34be774 100755 --- a/resource/csdk/stack/src/oicgroup.c +++ b/resource/csdk/stack/src/oicgroup.c @@ -905,16 +905,12 @@ OCStackResult SendAction(OCDoHandle *handle, const char *targetUri, cbdata.cd = NULL; cbdata.context = (void*)DEFAULT_CONTEXT_VALUE; -// TODO: Selecting OC_WIFI for android, tizen and OC_ETHERNET for linux platform. +// TODO: Selecting OC_IPV4. // It is temporary change as OC_ALL is not working currently. Remove this code and use OC_ALL // once it is functioning. -#if defined(__ANDROID__) || defined(__TIZEN__) - return OCDoResource(handle, OC_REST_PUT, targetUri, - NULL, (char *) action, OC_WIFI, OC_NA_QOS, &cbdata, NULL, 0); -#else + return OCDoResource(handle, OC_REST_PUT, targetUri, - NULL, (char *) action, OC_ETHERNET, OC_NA_QOS, &cbdata, NULL, 0); -#endif + NULL, (char *) action, OC_IPV4, OC_NA_QOS, &cbdata, NULL, 0); } OCStackResult DoAction(OCResource* resource, OCActionSet* actionset, diff --git a/resource/csdk/stack/test/stacktests.cpp b/resource/csdk/stack/test/stacktests.cpp index ce85f70b3f..bf3722a7ac 100644 --- a/resource/csdk/stack/test/stacktests.cpp +++ b/resource/csdk/stack/test/stacktests.cpp @@ -200,7 +200,7 @@ TEST(StackDiscovery, DISABLED_DoResourceDeviceDiscovery) szQueryUri, 0, 0, - OC_WIFI, + OC_IPV4, OC_LOW_QOS, &cbData, NULL, @@ -236,7 +236,7 @@ TEST(StackResource, DISABLED_UpdateResourceNullURI) szQueryUri, 0, 0, - OC_WIFI, + OC_IPV4, OC_LOW_QOS, &cbData, NULL, diff --git a/resource/examples/devicediscoveryclient.cpp b/resource/examples/devicediscoveryclient.cpp index e3dba581dd..5c7511c142 100644 --- a/resource/examples/devicediscoveryclient.cpp +++ b/resource/examples/devicediscoveryclient.cpp @@ -116,7 +116,7 @@ int main(int argc, char* argv[]) { std::ostringstream requestURI; std::string deviceDiscoveryURI = "/oc/core/d"; - OCConnectivityType connectivityType = OC_WIFI; + OCConnectivityType connectivityType = OC_IPV4; if(argc == 2) { @@ -129,34 +129,37 @@ int main(int argc, char* argv[]) { { if(optionSelected == 0) { - connectivityType = OC_ETHERNET; + connectivityType = OC_IPV4; } else if(optionSelected == 1) { - connectivityType = OC_WIFI; + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported + //connectivityType = OC_IPV6; + connectivityType = OC_IPV4; + std::cout << "IPv6 not currently supported. Using default IPv4" << std::endl; } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } catch(std::exception&) { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; + std::cout << "Invalid input argument. Using IPv4 as connectivity type" << std::endl; } } else { std::cout << "Usage devicediscoveryclient " << std::endl; - std::cout<<"connectivityType: Default WIFI" << std::endl; - std::cout << "connectivityType 0: ETHERNET" << std::endl; - std::cout << "connectivityType 1: WIFI" << std::endl; + std::cout << "connectivityType: Default IPv4" << std::endl; + std::cout << "connectivityType 0: IPv4" << std::endl; + std::cout << "connectivityType 1: IPv6 (not currently supported)" << std::endl; } // Create PlatformConfig object PlatformConfig cfg { diff --git a/resource/examples/fridgeclient.cpp b/resource/examples/fridgeclient.cpp index 259aec42ad..501ad754c0 100644 --- a/resource/examples/fridgeclient.cpp +++ b/resource/examples/fridgeclient.cpp @@ -267,7 +267,7 @@ class ClientFridge int main(int argc, char* argv[]) { - OCConnectivityType connectivityType = OC_WIFI; + OCConnectivityType connectivityType = OC_IPV4; if(argc == 2) { try @@ -279,34 +279,37 @@ int main(int argc, char* argv[]) { if(optionSelected == 0) { - connectivityType = OC_ETHERNET; + connectivityType = OC_IPV4; } else if(optionSelected == 1) { - connectivityType = OC_WIFI; + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported + //connectivityType = OC_IPV6; + connectivityType = OC_IPV4; + std::cout << "IPv6 not currently supported. Using default IPv4" << std::endl; } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } catch(std::exception&) { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; + std::cout << "Invalid input argument. Using IPv4 as connectivity type" << std::endl; } } else { - std::cout<<"Usage: fridgeclient \n"; - std::cout<<"ConnectivityType: Default WIFI\n"; - std::cout<<"ConnectivityType 0: ETHERNET\n"; - std::cout<<"ConnectivityType 1: WIFI\n"; + std::cout << "Usage: fridgeclient \n"; + std::cout << "connectivityType: Default IPv4" << std::endl; + std::cout << "connectivityType 0: IPv4" << std::endl; + std::cout << "connectivityType 1: IPv6 (not currently supported)" << std::endl; } PlatformConfig cfg diff --git a/resource/examples/garageclient.cpp b/resource/examples/garageclient.cpp index 8dcc6b25fb..c64528d037 100644 --- a/resource/examples/garageclient.cpp +++ b/resource/examples/garageclient.cpp @@ -288,49 +288,6 @@ int main(int argc, char* argv[]) { std::ostringstream requestURI; - OCConnectivityType connectivityType = OC_WIFI; - - if(argc == 2) - { - try - { - std::size_t inputValLen; - int optionSelected = std::stoi(argv[1], &inputValLen); - - if(inputValLen == strlen(argv[1])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; - } - } - catch(std::exception&) - { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; - } - } - else - { - std::cout<<"Usage: garageclient \n"; - std::cout<<"ConnectivityType: Default WIFI\n"; - std::cout<<"ConnectivityType 0: ETHERNET\n"; - std::cout<<"ConnectivityType 1: WIFI\n"; - } - // Create PlatformConfig object PlatformConfig cfg { OC::ServiceType::InProc, diff --git a/resource/examples/groupclient.cpp b/resource/examples/groupclient.cpp index cd8d6f6ce3..89c5a617c2 100644 --- a/resource/examples/groupclient.cpp +++ b/resource/examples/groupclient.cpp @@ -173,49 +173,6 @@ int main(int argc, char* argv[]) ostringstream requestURI; requestURI << OC_MULTICAST_DISCOVERY_URI << "?rt=a.collection"; - OCConnectivityType connectivityType = OC_WIFI; - - if(argc == 2) - { - try - { - std::size_t inputValLen; - int optionSelected = stoi(argv[1], &inputValLen); - - if(inputValLen == strlen(argv[1])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; - } - } - catch(exception&) - { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; - } - } - else - { - std::cout<<"Usage: groupclient \n"; - std::cout<<"ConnectivityType: Default WIFI\n"; - std::cout<<"ConnectivityType 0: ETHERNET\n"; - std::cout<<"ConnectivityType 1: WIFI\n"; - } - PlatformConfig config { OC::ServiceType::InProc, ModeType::Client, "0.0.0.0", 0, OC::QualityOfService::LowQos }; diff --git a/resource/examples/groupserver.cpp b/resource/examples/groupserver.cpp index fc4aaef0e9..c4b069d90c 100644 --- a/resource/examples/groupserver.cpp +++ b/resource/examples/groupserver.cpp @@ -80,49 +80,6 @@ int main(int argc, char* argv[]) { ostringstream requestURI; - OCConnectivityType connectivityType = OC_WIFI; - - if(argc == 2) - { - try - { - std::size_t inputValLen; - int optionSelected = stoi(argv[1], &inputValLen); - - if(inputValLen == strlen(argv[1])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; - } - } - catch(exception&) - { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; - } - } - else - { - std::cout<<"Usage: groupclient \n"; - std::cout<<"ConnectivityType: Default WIFI\n"; - std::cout<<"ConnectivityType 0: ETHERNET\n"; - std::cout<<"ConnectivityType 1: WIFI\n"; - } - PlatformConfig config { OC::ServiceType::InProc, ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos }; diff --git a/resource/examples/presenceclient.cpp b/resource/examples/presenceclient.cpp index 5a3c686180..305bfe599c 100644 --- a/resource/examples/presenceclient.cpp +++ b/resource/examples/presenceclient.cpp @@ -35,7 +35,7 @@ std::shared_ptr curResource; std::mutex resourceLock; static int TEST_CASE = 0; -static OCConnectivityType connectivityType = OC_WIFI; +static OCConnectivityType connectivityType = OC_IPV4; /** * List of methods that can be inititated from the client @@ -63,9 +63,9 @@ void printUsage() << std::endl; std::cout << "-t 6 : Discover Resources and Initiate Multicast Presence with two Filters" << std::endl; - std::cout<<"ConnectivityType: Default WIFI" << std::endl; - std::cout << "-c 0 : Send message over ETHERNET interface" << std::endl; - std::cout << "-c 1 : Send message over WIFI interface" << std::endl; + std::cout<<"ConnectivityType: Default IPv4" << std::endl; + std::cout << "-c 0 : Send message with IPv4" << std::endl; + std::cout << "-c 1 : Send message with IPv6" << std::endl; } // Callback to presence @@ -221,21 +221,26 @@ int main(int argc, char* argv[]) { { if(optionSelected == 0) { - connectivityType = OC_ETHERNET; + connectivityType = OC_IPV4; } else if(optionSelected == 1) { - connectivityType = OC_WIFI; + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 + // is supported + //connectivityType = OC_IPV6; + connectivityType = OC_IPV4; + std::cout << "IPv6 not currently supported. Using default IPv4" + << std::endl; } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } break; @@ -247,7 +252,7 @@ int main(int argc, char* argv[]) { } catch(std::exception& ) { - std::cout << "Invalid input argument. Using WIFI as connectivity type" + std::cout << "Invalid input argument. Using IPv4 as connectivity type" << std::endl; } diff --git a/resource/examples/roomclient.cpp b/resource/examples/roomclient.cpp index 6d5c759653..fdba60dd9b 100644 --- a/resource/examples/roomclient.cpp +++ b/resource/examples/roomclient.cpp @@ -224,47 +224,6 @@ int main(int argc, char* argv[]) { std::ostringstream requestURI; - OCConnectivityType connectivityType = OC_WIFI; - if(argc == 2) - { - try - { - std::size_t inputValLen; - int optionSelected = std::stoi(argv[1], &inputValLen); - - if(inputValLen == strlen(argv[1])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; - } - } - catch(std::exception& ) - { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; - } - } - else - { - std::cout << "Usage roomclient " << std::endl; - std::cout<<"connectivityType: Default WIFI" << std::endl; - std::cout << "connectivityType 0: ETHERNET" << std::endl; - std::cout << "connectivityType 1: WIFI" << std::endl; - } // Create PlatformConfig object PlatformConfig cfg { diff --git a/resource/examples/simpleclient.cpp b/resource/examples/simpleclient.cpp index e3b2f39ba8..e06d7318de 100644 --- a/resource/examples/simpleclient.cpp +++ b/resource/examples/simpleclient.cpp @@ -36,7 +36,6 @@ typedef std::map> DiscoveredRe DiscoveredResourceMap discoveredResources; std::shared_ptr curResource; static ObserveType OBSERVE_TYPE_TO_USE = ObserveType::Observe; -static OCConnectivityType connectivityType = OC_WIFI; std::mutex curResourceLock; class Light @@ -388,12 +387,9 @@ void printUsage() { std::cout << std::endl; std::cout << "---------------------------------------------------------------------\n"; - std::cout << "Usage : simpleclient " << std::endl; + std::cout << "Usage : simpleclient " << std::endl; std::cout << " ObserveType : 1 - Observe" << std::endl; std::cout << " ObserveType : 2 - ObserveAll" << std::endl; - std::cout << " connectivityType: Default WIFI" << std::endl; - std::cout << " ConnectivityType : 0 - ETHERNET"<< std::endl; - std::cout << " ConnectivityType : 1 - WIFI"<< std::endl; std::cout << "---------------------------------------------------------------------\n\n"; } @@ -416,25 +412,6 @@ void checkObserverValue(int value) } } -void checkConnectivityValue(int value) -{ - if(value == 0) - { - connectivityType = OC_ETHERNET; - std::cout << "<===Setting connectivityType to Ethernet===>\n\n"; - } - else if(value == 1) - { - connectivityType = OC_WIFI; - std::cout << "<===Setting connectivityType to WIFI===>\n\n"; - } - else - { - std::cout << "<===Invalid ConnectivitType selected." - <<"Setting ConnectivityType to WIFI===>\n\n"; - } -} - int main(int argc, char* argv[]) { std::ostringstream requestURI; @@ -444,19 +421,11 @@ int main(int argc, char* argv[]) { printUsage(); if (argc == 1) { - std::cout << "<===Setting ObserveType to Observe and ConnectivityType to WIFI===>\n\n"; + std::cout << "<===Setting ObserveType to Observe and ConnectivityType to IPv4===>\n\n"; } else if (argc == 2) - { - - checkObserverValue(std::stoi(argv[1])); - std::cout << "<===No ConnectivtyType selected. " - << "Setting ConnectivityType to WIFI===>\n\n"; - } - else if(argc == 3) { checkObserverValue(std::stoi(argv[1])); - checkConnectivityValue(std::stoi(argv[2])); } else { diff --git a/resource/examples/simpleclientHQ.cpp b/resource/examples/simpleclientHQ.cpp index 98bc93d2ff..af0bea4af7 100644 --- a/resource/examples/simpleclientHQ.cpp +++ b/resource/examples/simpleclientHQ.cpp @@ -370,61 +370,35 @@ void foundResource(std::shared_ptr resource) void PrintUsage() { std::cout << std::endl; - std::cout << "Usage : simpleclientHQ " << std::endl; + std::cout << "Usage : simpleclientHQ " << std::endl; std::cout << " ObserveType : 1 - Observe" << std::endl; std::cout << " ObserveType : 2 - ObserveAll" << std::endl; - std::cout<<" ConnectivityType: Default WIFI" << std::endl; - std::cout << " ConnectivityType : 0 - ETHERNET"<< std::endl; - std::cout << " ConnectivityType : 1 - WIFI"<< std::endl; } int main(int argc, char* argv[]) { std::ostringstream requestURI; - OCConnectivityType connectivityType = OC_WIFI; try { if (argc == 1) { OBSERVE_TYPE_TO_USE = ObserveType::Observe; } - else if (argc ==2 || argc==3) + else if (argc == 2) { int value = std::stoi(argv[1]); if (value == 1) + { OBSERVE_TYPE_TO_USE = ObserveType::Observe; + } else if (value == 2) + { OBSERVE_TYPE_TO_USE = ObserveType::ObserveAll; + } else - OBSERVE_TYPE_TO_USE = ObserveType::Observe; - - if(argc == 3) { - std::size_t inputValLen; - int optionSelected = std::stoi(argv[2], &inputValLen); - - if(inputValLen == strlen(argv[2])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } + OBSERVE_TYPE_TO_USE = ObserveType::Observe; } } else @@ -435,10 +409,9 @@ int main(int argc, char* argv[]) { } catch(std::exception&) { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; + std::cout << "Invalid input argument. Using Observe as observe type" << std::endl; } - // Create PlatformConfig object PlatformConfig cfg { OC::ServiceType::InProc, diff --git a/resource/examples/simpleclientserver.cpp b/resource/examples/simpleclientserver.cpp index 25019a4291..43f4899754 100644 --- a/resource/examples/simpleclientserver.cpp +++ b/resource/examples/simpleclientserver.cpp @@ -300,7 +300,7 @@ struct FooResource int main(int argc, char* argv[]) { - OCConnectivityType connectivityType = OC_WIFI; + OCConnectivityType connectivityType = OC_IPV4; if(argc == 2) { @@ -313,34 +313,37 @@ int main(int argc, char* argv[]) { if(optionSelected == 0) { - connectivityType = OC_ETHERNET; + connectivityType = OC_IPV4; } else if(optionSelected == 1) { - connectivityType = OC_WIFI; + // TODO: re-enable IPv4/IPv6 command line selection when IPv6 is supported + // connectivityType = OC_IPV6; + connectivityType = OC_IPV4; + std::cout << "IPv6 not currently supported. Using default IPv4" << std::endl; } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } else { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; + std::cout << "Invalid connectivity type selected. Using default IPv4" << std::endl; } } catch(std::exception& ) { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; + std::cout << "Invalid input argument. Using IPv4 as connectivity type" << std::endl; } } else { std::cout<< "Usage simpleclientserver " << std::endl; - std::cout<<" ConnectivityType: Default WIFI" << std::endl; - std::cout << " ConnectivityType : 0 - ETHERNET" << std::endl; - std::cout << " ConnectivityType : 1 - WIFI" << std::endl; + std::cout<< " ConnectivityType: Default IPv4" << std::endl; + std::cout << " ConnectivityType : 0 - IPv4" << std::endl; + std::cout << " ConnectivityType : 1 - IPv6 (not currently supported)" << std::endl; } PlatformConfig cfg { diff --git a/resource/examples/threadingsample.cpp b/resource/examples/threadingsample.cpp index 95e04897e8..9d4b5e99e8 100644 --- a/resource/examples/threadingsample.cpp +++ b/resource/examples/threadingsample.cpp @@ -35,8 +35,6 @@ #include "OCApi.h" using namespace OC; -static OCConnectivityType connectivityType = OC_WIFI; - static std::ostringstream requestURI; struct FooResource @@ -336,47 +334,6 @@ void server() int main(int argc, char* argv[]) { - if(argc == 2) - { - try - { - std::size_t inputValLen; - int optionSelected = std::stoi(argv[1], &inputValLen); - - if(inputValLen == strlen(argv[1])) - { - if(optionSelected == 0) - { - connectivityType = OC_ETHERNET; - } - else if(optionSelected == 1) - { - connectivityType = OC_WIFI; - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" - << std::endl; - } - } - else - { - std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl; - } - } - catch(std::exception& ) - { - std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl; - } - } - else - { - std::cout<< "Usage threadingsample " << std::endl; - std::cout<<"ConnectivityType: Default WIFI" << std::endl; - std::cout << " ConnectivityType : 0 - ETHERNET" << std::endl; - std::cout << " ConnectivityType : 1 - WIFI" << std::endl; - } - requestURI << OC_MULTICAST_DISCOVERY_URI << "?rt=core.foo"; PlatformConfig cfg { diff --git a/resource/unittests/OCPlatformTest.cpp b/resource/unittests/OCPlatformTest.cpp index 4154d61263..2264e37cf8 100644 --- a/resource/unittests/OCPlatformTest.cpp +++ b/resource/unittests/OCPlatformTest.cpp @@ -478,13 +478,13 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_EQ(OC_STACK_OK, OCPlatform::findResource("", requestURI.str(), - OC_WIFI, &foundResource)); + OC_IPV4, &foundResource)); } TEST(FindResourceTest, FindResourceNullResourceURI) { EXPECT_ANY_THROW(OCPlatform::findResource("", nullptr, - OC_WIFI, &foundResource)); + OC_IPV4, &foundResource)); } TEST(FindResourceTest, FindResourceNullResourceURI1) @@ -492,7 +492,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(), - OC_WIFI, &foundResource)); + OC_IPV4, &foundResource)); } TEST(FindResourceTest, FindResourceNullHost) @@ -500,7 +500,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(), - OC_WIFI, &foundResource)); + OC_IPV4, &foundResource)); } TEST(FindResourceTest, FindResourceNullresourceHandler) @@ -508,7 +508,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_THROW(OCPlatform::findResource("", requestURI.str(), - OC_WIFI, NULL), OC::OCException); + OC_IPV4, NULL), OC::OCException); } TEST(FindResourceTest, DISABLED_FindResourceWithLowQoS) @@ -516,7 +516,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_EQ(OC_STACK_OK, - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResource, + OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource, OC::QualityOfService::LowQos)); } @@ -525,7 +525,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_EQ(OC_STACK_OK, - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResource, + OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource, OC::QualityOfService::MidQos)); } @@ -534,7 +534,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_EQ(OC_STACK_OK, - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResource, + OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource, OC::QualityOfService::HighQos)); } @@ -543,7 +543,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light"; EXPECT_EQ(OC_STACK_OK, - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResource, + OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource, OC::QualityOfService::NaQos)); } @@ -556,7 +556,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_EQ(OC_STACK_OK, - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, &receivedDeviceInfo)); + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo)); } TEST(GetDeviceInfoTest, GetDeviceInfoNullDeviceURI) @@ -564,7 +564,7 @@ namespace OCPlatformTest PlatformConfig cfg; OCPlatform::Configure(cfg); EXPECT_ANY_THROW( - OCPlatform::getDeviceInfo("", nullptr, OC_WIFI, &receivedDeviceInfo)); + OCPlatform::getDeviceInfo("", nullptr, OC_IPV4, &receivedDeviceInfo)); } TEST(GetDeviceInfoTest, GetDeviceInfoWithNullDeviceInfoHandler) @@ -575,7 +575,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_THROW( - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, NULL), + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, NULL), OC::OCException); } @@ -587,7 +587,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_EQ(OC_STACK_OK, - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, &receivedDeviceInfo, + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo, OC::QualityOfService::LowQos)); } @@ -599,7 +599,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_EQ(OC_STACK_OK, - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, &receivedDeviceInfo, + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo, OC::QualityOfService::MidQos)); } @@ -611,7 +611,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_EQ(OC_STACK_OK, - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, &receivedDeviceInfo, + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo, OC::QualityOfService::HighQos)); } @@ -623,7 +623,7 @@ namespace OCPlatformTest std::ostringstream requestURI; requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI; EXPECT_EQ(OC_STACK_OK, - OCPlatform::getDeviceInfo("", requestURI.str(), OC_WIFI, &receivedDeviceInfo, + OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo, OC::QualityOfService::NaQos)); } @@ -662,7 +662,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, hostAddress, - OC_WIFI, &presenceHandler)); + OC_IPV4, &presenceHandler)); } TEST(SubscribePresenceTest, SubscribePresenceWithNullHost) @@ -670,7 +670,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr, - OC_WIFI, &presenceHandler)); + OC_IPV4, &presenceHandler)); } TEST(SubscribePresenceTest, SubscribePresenceWithNullPresenceHandler) @@ -678,7 +678,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr, - OC_WIFI, NULL)); + OC_IPV4, NULL)); } TEST(SubscribePresenceTest, DISABLED_SubscribePresenceWithResourceType) @@ -686,7 +686,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, - OC_MULTICAST_IP, "core.light", OC_WIFI, &presenceHandler)); + OC_MULTICAST_IP, "core.light", OC_IPV4, &presenceHandler)); } TEST(SubscribePresenceTest, SubscribePresenceWithNullResourceType) @@ -694,7 +694,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, - OC_MULTICAST_IP, nullptr, OC_WIFI, &presenceHandler)); + OC_MULTICAST_IP, nullptr, OC_IPV4, &presenceHandler)); } TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandleAndRT) @@ -702,7 +702,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, - OC_MULTICAST_IP, "core.light", OC_WIFI, &presenceHandler)); + OC_MULTICAST_IP, "core.light", OC_IPV4, &presenceHandler)); EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle)); } @@ -717,7 +717,7 @@ namespace OCPlatformTest OCPlatform::OCPresenceHandle presenceHandle = nullptr; EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, - OC_MULTICAST_IP, OC_WIFI, &presenceHandler)); + OC_MULTICAST_IP, OC_IPV4, &presenceHandler)); EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle)); } diff --git a/resource/unittests/OCResourceTest.cpp b/resource/unittests/OCResourceTest.cpp index daf4517db7..d647c1f95b 100644 --- a/resource/unittests/OCResourceTest.cpp +++ b/resource/unittests/OCResourceTest.cpp @@ -49,7 +49,7 @@ namespace OCResourceTest //Helper method OCResource::Ptr ConstructResourceObject(std::string host, std::string uri) { - OCConnectivityType connectivityType = OC_WIFI; + OCConnectivityType connectivityType = OC_IPV4; std::vector types = {"intel.rpost"}; std::vector ifaces = {DEFAULT_INTERFACE}; @@ -450,7 +450,7 @@ namespace OCResourceTest { OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource"); EXPECT_TRUE(resource != NULL); - EXPECT_TRUE(resource->connectivityType() == OC_WIFI); + EXPECT_TRUE(resource->connectivityType() == OC_IPV4); } //IsObservable Test diff --git a/service/notification-manager/NotificationManager/include/hosting.h b/service/notification-manager/NotificationManager/include/hosting.h index 7d224d195c..c85eea8581 100755 --- a/service/notification-manager/NotificationManager/include/hosting.h +++ b/service/notification-manager/NotificationManager/include/hosting.h @@ -30,14 +30,7 @@ #include "ocstack.h" #include "logger.h" -// TODO: Selecting OC_WIFI for android, tizen and OC_ETHERNET for linux platform -// is temporary change as OC_ALL is not working currently. Remove this code and use OC_ALL -// once it is functioning. -#if defined(__ANDROID__) || defined(__TIZEN__) -#define OC_TRANSPORT OC_WIFI -#else -#define OC_TRANSPORT OC_ETHERNET -#endif +#define OC_TRANSPORT OC_ALL #ifdef __cplusplus extern "C" { @@ -65,4 +58,4 @@ OCStackResult OICStopCoordinate(); } #endif // __cplusplus -#endif //_HOSTING_H_ \ No newline at end of file +#endif //_HOSTING_H_ diff --git a/service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp b/service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp index 7c2c8efffb..054465d51c 100755 --- a/service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp +++ b/service/notification-manager/SampleApp/linux/sampleConsumer/SampleConsumer.cpp @@ -224,7 +224,7 @@ void foundResource(std::shared_ptr< OCResource > resource) OCStackResult nmfindResource(const std::string &host , const std::string &resourceName) { - return OCPlatform::findResource(host , resourceName , OC_ETHERNET, &foundResource); + return OCPlatform::findResource(host , resourceName , OC_ALL, &foundResource); } void getRepresentation(std::shared_ptr< OCResource > resource) diff --git a/service/protocol-plugin/sample-app/linux/mqtt/mqttclient.cpp b/service/protocol-plugin/sample-app/linux/mqtt/mqttclient.cpp index 679667fade..ec6d2ede3c 100644 --- a/service/protocol-plugin/sample-app/linux/mqtt/mqttclient.cpp +++ b/service/protocol-plugin/sample-app/linux/mqtt/mqttclient.cpp @@ -394,7 +394,7 @@ int main(int argc, char *argv[]) std::cout.setf(std::ios::boolalpha); // Find all resources requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.fan"; - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResourceFan); + OCPlatform::findResource("", requestURI.str(), OC_ALL, &foundResourceFan); std::cout << "Finding Resource... " << std::endl; while (true) { diff --git a/service/protocol-plugin/sample-app/tizen/PPMSampleApp/src/ppmsampleapp.cpp b/service/protocol-plugin/sample-app/tizen/PPMSampleApp/src/ppmsampleapp.cpp index 1d3c21ca55..05c128711c 100644 --- a/service/protocol-plugin/sample-app/tizen/PPMSampleApp/src/ppmsampleapp.cpp +++ b/service/protocol-plugin/sample-app/tizen/PPMSampleApp/src/ppmsampleapp.cpp @@ -543,7 +543,7 @@ send_msg_clicked_cb(void *data , Evas_Object *obj , void *event_info) // Find fan resources std::ostringstream requestURI; requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.fan"; - OCPlatform::findResource("", requestURI.str(), OC_WIFI, &foundResourceFan); + OCPlatform::findResource("", requestURI.str(), OC_ALL, &foundResourceFan); std::cout << "Finding Resource... " << std::endl; } catch (OCException &e) diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp index c44d242d53..ba7342cd0d 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp @@ -78,13 +78,7 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n case OC_STACK_OK: requestURI << "coap://" << hostAddress << "/oc/core?rt=SSManager.Sensor"; - ret = OC::OCPlatform::findResource("", requestURI.str(), OC_WIFI, - std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); - - if (ret != OC_STACK_OK) - SSM_CLEANUP_ASSERT(SSM_E_FAIL); - - ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET, + ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ALL, std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); if (ret != OC_STACK_OK) @@ -133,27 +127,14 @@ SSMRESULT CResourceFinder::startResourceFinder() std::ostringstream multicastPresenceURI; multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX; - ret = OC::OCPlatform::findResource("", requestURI.str(), OC_WIFI, + ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ALL, std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); if (ret != OC_STACK_OK) SSM_CLEANUP_ASSERT(SSM_E_FAIL); - ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET, - std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1)); - - if (ret != OC_STACK_OK) - SSM_CLEANUP_ASSERT(SSM_E_FAIL); - - ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(), - "SSManager.Sensor", OC_WIFI, std::bind(&CResourceFinder::presenceHandler, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - if (ret != OC_STACK_OK) - SSM_CLEANUP_ASSERT(SSM_E_FAIL); - ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(), - "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this, + "SSManager.Sensor", OC_ALL, std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); if (ret != OC_STACK_OK) @@ -235,14 +216,7 @@ void CResourceFinder::onExecute(void *pArg) m_mapResourcePresenceHandles.end()) { ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip, - "SSManager.Sensor", OC_WIFI, std::bind(&CResourceFinder::presenceHandler, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - if (ret != OC_STACK_OK) - SSM_CLEANUP_ASSERT(SSM_E_FAIL); - - ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip, - "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this, + "SSManager.Sensor", OC_ALL, std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); if (ret != OC_STACK_OK) diff --git a/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp b/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp index 8d0c5ab0c0..b49b2159c8 100755 --- a/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp +++ b/service/things-manager/sampleapp/linux/groupaction/groupserver.cpp @@ -484,7 +484,7 @@ int main() OCPlatform::findResource("", query, - OC_ETHERNET, + OC_ALL, &foundResource); // OCPlatform::findResource("", @@ -500,7 +500,7 @@ int main() OCPlatform::findResource("", query, - OC_ETHERNET, + OC_ALL, &foundResource); // OCPlatform::findResource("", // query, diff --git a/service/things-manager/sampleapp/linux/groupsyncaction/group.cpp b/service/things-manager/sampleapp/linux/groupsyncaction/group.cpp index 45c1cedab7..0a55c0e59c 100644 --- a/service/things-manager/sampleapp/linux/groupsyncaction/group.cpp +++ b/service/things-manager/sampleapp/linux/groupsyncaction/group.cpp @@ -118,12 +118,12 @@ int main(int argc, char* argv[]) cout << query.str() << endl; result = OCPlatform::findResource("", query.str(), - OC_ETHERNET, + OC_ALL, onFindResource); result = OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=core.musicplayer", - OC_WIFI, + OC_ALL, onFindResource); if (OC_STACK_OK == result) @@ -141,12 +141,7 @@ int main(int argc, char* argv[]) query << OC_WELL_KNOWN_QUERY << "?rt=core.speaker"; result = OCPlatform::findResource("", query.str(), - OC_ETHERNET, - onFindResource); - - result = OCPlatform::findResource("", - "coap://224.0.1.187/oc/core?rt=core.speaker", - OC_WIFI, + OC_ALL, onFindResource); if (OC_STACK_OK == result) diff --git a/service/things-manager/sdk/src/GroupManager.cpp b/service/things-manager/sdk/src/GroupManager.cpp index 581b3bb7c6..90d7e12451 100755 --- a/service/things-manager/sdk/src/GroupManager.cpp +++ b/service/things-manager/sdk/src/GroupManager.cpp @@ -229,14 +229,7 @@ OCStackResult GroupManager::findCandidateResources( OCPlatform::findResource("", query, - OC_ETHERNET, - std::function < void(std::shared_ptr < OCResource > resource) - > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1, - waitsec))); - - OCPlatform::findResource("", - query, - OC_WIFI, + OC_ALL, std::function < void(std::shared_ptr < OCResource > resource) > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1, waitsec))); @@ -369,18 +362,7 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep, result = OCPlatform::subscribePresence(presenceHandle, hostAddress, // resourceType, resourceTypes.front(), - OC_ETHERNET, - std::function< - void(OCStackResult result, const unsigned int nonce, - const std::string& hostAddress) >( - std::bind(&GroupManager::collectionPresenceHandler, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, hostAddress, oit->getUri()))); - - result = OCPlatform::subscribePresence(presenceHandle, hostAddress, - // resourceType, - resourceTypes.front(), - OC_WIFI, + OC_ALL, std::function< void(OCStackResult result, const unsigned int nonce, const std::string& hostAddress) >( @@ -428,7 +410,7 @@ OCStackResult GroupManager::subscribeCollectionPresence( { return OC_STACK_ERROR; } - + OCStackResult result = OC_STACK_OK; //callback("core.room",OC_STACK_OK); @@ -645,7 +627,7 @@ OCStackResult GroupManager::addActionSet(std::shared_ptr< OCResource > resource, { if(newActionSet->mDelay < 0) { - return OC_STACK_INVALID_PARAM; + return OC_STACK_INVALID_PARAM; } std::string message = getStringFromActionSet(newActionSet); diff --git a/service/things-manager/sdk/src/GroupSynchronization.cpp b/service/things-manager/sdk/src/GroupSynchronization.cpp index e9b8abe363..00aed30e11 100644 --- a/service/things-manager/sdk/src/GroupSynchronization.cpp +++ b/service/things-manager/sdk/src/GroupSynchronization.cpp @@ -78,9 +78,8 @@ namespace OIC query.append(collectionResourceTypes.at(i)); OCPlatform::findResource("", query, - // we will change to OC_ALL when OC_ALL flag is stable. - OC_ETHERNET, - std::bind(&GroupSynchronization::onFindGroup, this, + OC_ALL, + std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1)); } @@ -286,10 +285,10 @@ namespace OIC std::vector< std::string > resourceInterface; resourceInterface.push_back(DEFAULT_INTERFACE); - OCResource::Ptr groupSyncResource = + OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri, - // we will change to OC_ALL when OC_ALL flag is stable. - OC_ETHERNET, false, + + OC_ALL, false, resourceTypes, resourceInterface); // OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri, @@ -467,8 +466,7 @@ OCStackResult GroupSynchronization::leaveGroup( OCResource::Ptr groupSyncResource; groupSyncResource = OCPlatform::constructResourceObject(host, uri, - // we will change to OC_ALL when OC_ALL flag is stable. - OC_ETHERNET, false, + OC_ALL, false, resourceTypes, resourceInterface); // groupSyncResource = OCPlatform::constructResourceObject(host, uri, // OC_WIFI, false, resourceTypes, resourceInterface); @@ -511,7 +509,7 @@ OCStackResult GroupSynchronization::leaveGroup( { if (0 == collectionResourceType.length()) { - OC_LOG(DEBUG, TAG, + OC_LOG(DEBUG, TAG, "GroupSynchronization::deleteGroup : Error! Input params are wrong."); return; } @@ -630,13 +628,13 @@ OCStackResult GroupSynchronization::leaveGroup( result = OCPlatform::unregisterResource(resourceHandle); if (OC_STACK_OK == result) { - OC_LOG_V(DEBUG, TAG, + OC_LOG_V(DEBUG, TAG, "GroupSynchronization::deleteGroup : UnregisterResource(%d)" \ " was successful.", i + 1); } else { - OC_LOG_V(DEBUG, TAG, + OC_LOG_V(DEBUG, TAG, "GroupSynchronization::deleteGroup : UnregisterResource(%d)" \ " was unsuccessful. result - ", i + 1, result); } @@ -713,8 +711,7 @@ OCStackResult GroupSynchronization::leaveGroup( resourceRequest = request; OCPlatform::findResource("", resourceName, - // we will change to OC_ALL when OC_ALL flag is stable. - OC_ETHERNET, + OC_ALL, std::bind(&GroupSynchronization::onFindResource, this, std::placeholders::_1)); @@ -739,7 +736,7 @@ OCStackResult GroupSynchronization::leaveGroup( if (0 == resourceType.compare(type)) { - OC_LOG_V(DEBUG, TAG, + OC_LOG_V(DEBUG, TAG, "GroupSynchronization::groupEntityHandler : " \ "Found! The resource to leave is found. - %s", type); @@ -749,13 +746,13 @@ OCStackResult GroupSynchronization::leaveGroup( collectionResourceHandle, resourceHandle); if (OC_STACK_OK == result) { - OC_LOG(DEBUG, TAG, + OC_LOG(DEBUG, TAG, "GroupSynchronization::groupEntityHandler : " \ "To unbind resource was successful."); } else { - OC_LOG_V(DEBUG, TAG, + OC_LOG_V(DEBUG, TAG, "GroupSynchronization::groupEntityHandler : " \ "To unbind resource was unsuccessful. result - %d", result); @@ -764,13 +761,13 @@ OCStackResult GroupSynchronization::leaveGroup( result = OCPlatform::unregisterResource(resourceHandle); if (OC_STACK_OK == result) { - OC_LOG(DEBUG, TAG, + OC_LOG(DEBUG, TAG, "GroupSynchronization::groupEntityHandler : " \ "To unregister resource was successful."); } else { - OC_LOG_V(DEBUG, TAG, + OC_LOG_V(DEBUG, TAG, "GroupSynchronization::groupEntityHandler : " "To unregister resource was unsuccessful. result - %d", result); @@ -937,7 +934,7 @@ OCStackResult GroupSynchronization::leaveGroup( { if( 0 == foundHostUri.compare(savedHostAddress) ) { - OC_LOG(DEBUG, TAG, + OC_LOG(DEBUG, TAG, "GroupSynchronization::IsSameGroup : Found! The same group is found."); return true; } @@ -1083,7 +1080,7 @@ OCStackResult GroupSynchronization::leaveGroup( OCRepresentation child; OC_LOG(DEBUG, TAG, "GroupSynchronization::onGetJoinedRemoteChild"); -#ifndef NDEBUG +#ifndef NDEBUG // debugging // Get the resource URI resourceURI = rep.getUri(); diff --git a/service/things-manager/sdk/src/ThingsConfiguration.cpp b/service/things-manager/sdk/src/ThingsConfiguration.cpp index 82b8d5e376..43c6895933 100755 --- a/service/things-manager/sdk/src/ThingsConfiguration.cpp +++ b/service/things-manager/sdk/src/ThingsConfiguration.cpp @@ -326,16 +326,8 @@ namespace OIC std::string host = getHostFromURI(oit->getUri()); -// TODO: Selecting OC_WIFI for android, tizen and OC_ETHERNET for linux platform. -// It is temporary change as OC_ALL is not working currently. Remove this code and use OC_ALL -// once it is functioning. -#if defined(__ANDROID__) || defined(__TIZEN__) - tempResource = OCPlatform::constructResourceObject(host, uri, OC_WIFI, true, + tempResource = OCPlatform::constructResourceObject(host, uri, OC_ALL, true, oit->getResourceTypes(), m_if); -#else - tempResource = OCPlatform::constructResourceObject(host, uri, OC_ETHERNET, true, - oit->getResourceTypes(), m_if); -#endif p_resources.push_back(tempResource); } -- GitLab