This change is part of Multiadaptor/IPv6. Sample Apps needs to be updated to allow available
and currently suppoted connectivity types.
Change-Id: I701027d599e53183673abe2afd7b0f1a5fade885
Signed-off-by: Moumita Ray <moumita.ray@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1406
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
#include "logger.h"
#include "occlient.h"
+// Tracking user input
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
+static int CONNECTIVITY = 0;
static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s:6298/oic/d";
static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oic/d";
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1..17> -c <0|1>");
+ OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1..17> -c <0|1|2>");
OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)");
+ OC_LOG(INFO, TAG, "-c 0 : Default IPv4 and IPv6 auto-selection");
+ OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+ OC_LOG(INFO, TAG, "-c 2 : IPv6 Connectivity Type (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"
OC_LOG(INFO, TAG, "-t 8 : Discover Resources and Initiate Nonconfirmable Get Request "\
"for a resource which is unavailable");
OC_LOG(INFO, TAG, "-t 9 : Discover Resources and Initiate Confirmable Get Request");
- OC_LOG(INFO, TAG, "-t 10 : Discover Resources and Initiate Confirmable Post Request");
+ OC_LOG(INFO, TAG, "-t 10 : Discover Resources and Initiate Confirmable Post Request");
OC_LOG(INFO, TAG, "-t 11 : Discover Resources and Initiate Confirmable Delete Requests");
OC_LOG(INFO, TAG, "-t 12 : Discover Resources and Initiate Confirmable Observe Requests"\
" and cancel with Low QoS");
}
else
{
- ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
- (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
+
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
+ (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
}
if (ret != OC_STACK_OK)
}
else
{
- ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
- (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
+ (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
}
if (ret != OC_STACK_OK)
}
else
{
- ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
- (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
+ (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
}
if (ret != OC_STACK_OK)
{
TEST_CASE = atoi(optarg);
break;
case 'c':
- OC_CONNTYPE = CT_ADAPTER_IP;
+ CONNECTIVITY = atoi(optarg);
break;
default:
PrintUsage();
}
if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
- (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) )
+ (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
+ (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
{
PrintUsage();
return -1;
}
if (UNICAST_DISCOVERY)
{
- printf("Enter IPv4 address of the Server hosting resource (Ex: 192.168.0.15)\n");
+ OC_LOG(INFO, TAG, "Enter IPv4 address of the Server hosting resource (Ex: 192.168.0.15)\n");
+ OC_LOG(INFO, TAG, "Ipv6 is currently not supported...");
+
if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
{
//Strip newline char from ipv4addr
OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
return OC_STACK_INVALID_PARAM;
}
- }
+ }
+ if(CONNECTIVITY == CT_ADAPTER_DEFAULT)
+ {
+ OC_CONNTYPE = CT_DEFAULT;
+ }
+ else if(CONNECTIVITY == CT_IPV4)
+ {
+ OC_CONNTYPE = CT_IP_USE_V4;
+ }
+ else if(CONNECTIVITY == CT_IPV6)
+ {
+ OC_CONNTYPE = CT_IP_USE_V6;
+
+ //TODO: Remove when IPv6 is available.
+ OC_LOG(ERROR, TAG, "IPv6 is currently not supported !!!!");
+ PrintUsage();
+ return -1;
+ }
+ else
+ {
+ OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ PrintUsage();
+ }
if(UNICAST_DISCOVERY == 0 && TEST_CASE == TEST_DISCOVER_DEV_REQ)
{
case CT_ADAPTER_IP:
return "IP";
+ case CT_IP_USE_V4:
+ return "IPv4";
+
+ case CT_IP_USE_V6:
+ return "IPv6";
+
case CT_ADAPTER_GATT_BTLE:
return "GATT";
//-----------------------------------------------------------------------------
/**
- * List of methods that can be inititated from the client
+ * List of methods that can be initiated from the client
*/
typedef enum {
TEST_DISCOVER_REQ = 1,
MAX_TESTS
} CLIENT_TEST;
+/**
+ * List of connectivity types that can be initiated from the client
+ * Required for user input validation
+ */
+typedef enum {
+ CT_ADAPTER_DEFAULT = 0,
+ CT_IPV4,
+ CT_IPV6,
+ MAX_CT
+} CLIENT_CONNECTIVITY_TYPE;
+
#ifdef WITH_PRESENCE
int InitPresence();
#endif
static int IPV4_ADDR_SIZE = 16;
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
+static int CONNECTIVITY = 0;
static const char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oic/res";
static std::string putPayload = "{\"oic\":[{\"rep\":{\"power\":15,\"state\":true}}]}";
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
+ OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1|2>");
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/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> : IPv4/IPv6 (IPv6 not currently supported)");
- OC_LOG(INFO, TAG, "Default connectivityType IPv4");
+ OC_LOG(INFO, TAG, "-c 0 : Default IPv4 and IPv6 auto-selection");
+ OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+ OC_LOG(INFO, TAG, "-c 2 : IPv6 Connectivity Type (IPv6 not currently supported)");
}
/*
if (UNICAST_DISCOVERY)
{
char ipv4addr[IPV4_ADDR_SIZE];
- printf("Enter IPv4 address of the Server hosting "
- "resource (Ex: 192.168.0.15)\n");
+ OC_LOG(INFO, TAG, "Enter IPv4 address of the Server hosting resource (Ex: 192.168.0.15) ");
+
if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
{
//Strip newline char from ipv4addr
}
const OCDevAddr *devAddr = &clientResponse->devAddr;
- char *ipaddr = (char *) OICCalloc(1, strlen(devAddr->addr));
+ char *ipaddr = (char *) OICCalloc(1, strlen(devAddr->addr) +1);
if (ipaddr)
{
snprintf(ipaddr, MAX_IP_ADDR_ST_SZ, "%s", devAddr->addr);
switch (iter->connType & CT_MASK_ADAPTER)
{
case CT_ADAPTER_IP:
+ printf("connType = %s\n","Default (IPv4) ");
+ break;
+ case CT_IP_USE_V4:
printf("connType = %s\n","IPv4");
break;
+ case CT_IP_USE_V6:
+ printf("connType = %s\n","IPv6");
+ break;
case OC_ADAPTER_GATT_BTLE:
printf("connType = %s\n","BLE");
break;
TEST_CASE = atoi(optarg);
break;
case 'c':
- OC_CONNTYPE = CT_ADAPTER_IP;
+ CONNECTIVITY = atoi(optarg);
break;
default:
PrintUsage();
}
if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
- (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) )
+ (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
+ (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
{
PrintUsage();
return -1;
return 0;
}
+ if(CONNECTIVITY == CT_ADAPTER_DEFAULT)
+ {
+ OC_CONNTYPE = CT_ADAPTER_IP;//CT_DEFAULT;
+ }
+ else if(CONNECTIVITY == CT_IPV4)
+ {
+ OC_CONNTYPE = CT_IP_USE_V4;
+ }
+ else if(CONNECTIVITY == CT_IPV6)
+ {
+ OC_CONNTYPE = CT_IP_USE_V6;
+
+ //TODO: Remove when IPv6 is available.
+ printf("\n\nIPv6 is currently not supported !!!!\n");
+ PrintUsage();
+ return -1;
+ }
+ else
+ {
+ printf("Default Connectivity type selected \n\n");
+ OC_CONNTYPE = CT_ADAPTER_IP;
+ }
+
InitDiscovery();
// Break from loop with Ctrl+C
MAX_TESTS
} CLIENT_TEST;
+/**
+ * List of connectivity types that can be initiated from the client
+ * Required for user input validation
+ */
+typedef enum {
+ CT_ADAPTER_DEFAULT = 0,
+ CT_IPV4,
+ CT_IPV6,
+ MAX_CT
+} CLIENT_CONNECTIVITY_TYPE;
+
//-----------------------------------------------------------------------------
//ResourceNode
//-----------------------------------------------------------------------------
MAX_TESTS
} CLIENT_TEST;
+/**
+ * List of connectivity types that can be initiated from the client
+ * Required for user input validation
+ */
+typedef enum {
+ CT_ADAPTER_DEFAULT = 0,
+ CT_IPV4,
+ CT_IPV6,
+ MAX_CT
+} CLIENT_CONNECTIVITY_TYPE;
+
unsigned static int TEST = TEST_INVALID;
+unsigned static int CONNECTIVITY = 0;
typedef struct
{
void PrintUsage()
{
OC_LOG(INFO, TAG, "Usage : occlientcoll -t <Test Case> -c <CA connectivity Type>");
- OC_LOG(INFO, TAG, "-c <0|1> : IPv4/IPv6 (IPv6 not currently supported)");
+ OC_LOG(INFO, TAG, "-c 0 : Default IPv4 and IPv6 auto-selection");
+ OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+ OC_LOG(INFO, TAG, "-c 2 : IPv6 Connectivity Type (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 "\
cbData.cb = discoveryReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
- ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, OC_CONNTYPE,
OC_LOW_QOS,
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
TEST = atoi(optarg);
break;
case 'c':
- OC_CONNTYPE = CT_ADAPTER_IP;
+ CONNECTIVITY = atoi(optarg);
break;
default:
PrintUsage();
return -1;
}
}
- if (TEST <= TEST_INVALID || TEST >= MAX_TESTS)
+ if ((TEST <= TEST_INVALID || TEST >= MAX_TESTS) ||
+ (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
{
PrintUsage();
return -1;
return 0;
}
+ if(CONNECTIVITY == CT_ADAPTER_DEFAULT)
+ {
+ OC_CONNTYPE = CT_DEFAULT;
+ }
+ else if(CONNECTIVITY == CT_IPV4)
+ {
+ OC_CONNTYPE = CT_IP_USE_V4;
+ }
+ else if(CONNECTIVITY == CT_IPV6)
+ {
+ OC_CONNTYPE = CT_IP_USE_V6;
+
+ //TODO: Remove when IPv6 is available.
+ OC_LOG(INFO, TAG, "Ipv6 is currently not supported...");
+ PrintUsage();
+ return -1;
+ }
+ else
+ {
+ OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ OC_CONNTYPE = CT_ADAPTER_IP;
+ }
InitDiscovery();
// Break from loop with Ctrl+C
#include "logger.h"
#include "occlientslow.h"
+// Tracking user input
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
+static int CONNECTIVITY = 0;
+
static const char * UNICAST_DISCOVERY_QUERY = "coap://%s:6298/oic/res";
static std::string putPayload = "{\"state\":\"off\",\"power\":10}";
static std::string coapServerIP = "255.255.255.255";
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> : IPv4/IPv6 (IPv6 not currently supported)");
+ OC_LOG(INFO, TAG, "Usage : occlient -c <0|1|2> -u <0|1> -t <1|2|3>");
+ OC_LOG(INFO, TAG, "-c 0 : Default IPv4 and IPv6 auto-selection");
+ OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+ OC_LOG(INFO, TAG, "-c 2 : IPv6 Connectivity Type (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");
if (UNICAST_DISCOVERY)
{
char ipv4addr[IPV4_ADDR_SIZE];
- printf("Enter IPv4 address of the Server hosting resource (Ex: 192.168.0.15)\n");
+ OC_LOG(INFO, TAG, "Enter IPv4 address of the Server hosting resource (Ex: 192.168.0.15)");
if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
{
//Strip newline char from ipv4addr
TEST_CASE = atoi(optarg);
break;
case 'c':
- OC_CONNTYPE = CT_ADAPTER_IP;
+ CONNECTIVITY = atoi(optarg);
break;
default:
PrintUsage();
}
if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
- (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) )
+ (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) ||
+ (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT))
{
PrintUsage();
return -1;
return 0;
}
+ if(CONNECTIVITY == CT_ADAPTER_DEFAULT)
+ {
+ OC_CONNTYPE = CT_ADAPTER_IP;
+ }
+ else if(CONNECTIVITY == CT_IPV4)
+ {
+ OC_CONNTYPE = CT_IP_USE_V4;
+ }
+ else if(CONNECTIVITY == CT_IPV6)
+ {
+ OC_CONNTYPE = CT_IP_USE_V6;
+
+ //TODO: Remove when IPv6 is available.
+ OC_LOG(INFO, TAG, "Ipv6 is currently not supported...");
+ PrintUsage();
+ return -1;
+ }
+ else
+ {
+ OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ OC_CONNTYPE = CT_ADAPTER_IP;
+ }
+
InitDiscovery();
// Break from loop with Ctrl+C
MAX_TESTS
} CLIENT_TEST;
+/**
+ * List of connectivity types that can be initiated from the client
+ * Required for user input validation
+ */
+typedef enum {
+ CT_ADAPTER_DEFAULT = 0,
+ CT_IPV4,
+ CT_IPV6,
+ MAX_CT
+} CLIENT_CONNECTIVITY_TYPE;
+
//-----------------------------------------------------------------------------
// Function prototype
//-----------------------------------------------------------------------------
#define TAG "occlientbasicops"
static int UNICAST_DISCOVERY = 0;
static int TEST_CASE = 0;
+static int CONN_TYPE = 0;
static int IPV4_ADDR_SIZE = 16;
static char UNICAST_DISCOVERY_QUERY[] = "coap://%s:6298/oic/res";
static char MULTICAST_DISCOVERY_QUERY[] = "/oic/res";
+OCConnectivityType discoveryReqConnType = CT_ADAPTER_IP;
static std::string putPayload = "{\"oic\":[{\"rep\":{\"state\":\"off\",\"power\":10}}]}";
static std::string coapServerIP;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3>");
+ OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1|2>");
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/Put/Post Requests");
OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
+ OC_LOG(INFO, TAG, "-c 0 : Default IPv4 and IPv6 auto-selection");
+ OC_LOG(INFO, TAG, "-c 1 : IPv4 Connectivity Type");
+ OC_LOG(INFO, TAG, "-c 2 : IPv6 Connectivity Type (IPv6 not currently supported)");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
OCMethod method;
OCCallbackData cbData;
char szQueryUri[MAX_URI_LENGTH] = { 0 };
- OCConnectivityType discoveryReqConnType;
if (UNICAST_DISCOVERY)
{
OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
return OC_STACK_INVALID_PARAM;
}
- discoveryReqConnType = CT_ADAPTER_IP;
method = OC_REST_GET;
}
else
int opt;
struct timespec timeout;
- while ((opt = getopt(argc, argv, "u:t:")) != -1)
+ while ((opt = getopt(argc, argv, "u:t:c:")) != -1)
{
switch(opt)
{
case 't':
TEST_CASE = atoi(optarg);
break;
+ case 'c':
+ CONN_TYPE = atoi(optarg);
+ break;
default:
PrintUsage();
return -1;
}
if ((UNICAST_DISCOVERY != 0 && UNICAST_DISCOVERY != 1) ||
- (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS) )
+ (TEST_CASE < TEST_DISCOVER_REQ || TEST_CASE >= MAX_TESTS)||
+ (CONN_TYPE < CT_ADAPTER_DEFAULT || CONN_TYPE >= MAX_CT))
{
PrintUsage();
return -1;
}
+
+ if(CONN_TYPE == CT_ADAPTER_DEFAULT)
+ {
+ discoveryReqConnType = CT_DEFAULT;
+ }
+ else if(CONN_TYPE == CT_IPV4)
+ {
+ discoveryReqConnType = CT_IP_USE_V4;
+ }
+ else if(CONN_TYPE == CT_IPV6)
+ {
+ //TODO: Remove when IPv6 is available.
+ //discoveryReqConnType = CT_IP_USE_V6;
+ OC_LOG(ERROR, TAG, "IPv6 is currently not supported !!!!");
+ PrintUsage();
+ return -1;
+ }
+ else
+ {
+ printf("Using Default Connectivity type\n\n");
+ PrintUsage();
+ }
+
+
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = {};
ps.open = client_fopen;
MAX_TESTS
} CLIENT_TEST;
+/**
+ * List of connectivity types that can be initiated from the client
+ * Required for user input validation
+ */
+typedef enum {
+ CT_ADAPTER_DEFAULT = 0,
+ CT_IPV4,
+ CT_IPV6,
+ MAX_CT
+} CLIENT_CONNECTIVITY_TYPE;
+
//-----------------------------------------------------------------------------
// Function prototype
//-----------------------------------------------------------------------------
using namespace OC;
+static void printUsage()
+{
+ std::cout << "Usage devicediscoveryclient <0|1>" << std::endl;
+ std::cout << "connectivityType: Default IP" << std::endl;
+ std::cout << "connectivityType 0: IPv4" << std::endl;
+ std::cout << "connectivityType 1: IPv6 (Currently not supported !)" << std::endl;
+}
//Callback after device information is received
void receivedPlatformInfo(const OCRepresentation& rep)
{
std::string platformDiscoveryURI = "/oic/p";
std::string deviceDiscoveryURI = "/oic/d";
+ //Default Connectivity type
OCConnectivityType connectivityType = CT_ADAPTER_IP;
if(argc == 2)
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_ADAPTER_IP;
}
else
{
- std::cout << "Invalid connectivity type selected. Using default IP"
- << std::endl;
+ std::cout << "Invalid connectivity type selected." << std::endl;
+ printUsage();
+ return -1;
}
}
else
}
else
{
- std::cout << "Usage devicediscoveryclient 0" << std::endl;
- std::cout << "connectivityType: Default IP" << std::endl;
- std::cout << "connectivityType 0: IP" << std::endl;
+ printUsage();
}
// Create PlatformConfig object
PlatformConfig cfg {
const uint16_t API_VERSION = 2048;
const uint16_t TOKEN = 3000;
+static void printUsage()
+{
+ std::cout << "Usage: fridgeclient <0|1>" <<std::endl;
+ std::cout << "connectivityType: Default IP" << std::endl;
+ std::cout << "connectivityType 0: IPv4" << std::endl;
+ std::cout << "connectivityType 1: IPv6 (Currently Not Supported)" << std::endl;
+}
class ClientFridge
{
public:
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
- std::cout << "Invalid connectivity type selected. Using default IP"
- << std::endl;
+ std::cout << "Invalid connectivity type selected. Using default IP" << std::endl;
+ printUsage();
}
}
else
}
else
{
- std::cout << "Usage: fridgeclient 0\n";
- std::cout << "connectivityType: Default IP" << std::endl;
- std::cout << "connectivityType 0: IP" << std::endl;
+ printUsage();
+ std::cout << "Default input argument. Using IP as connectivity type" << std::endl;
}
PlatformConfig cfg
std::shared_ptr<OCResource> curResource;
std::mutex curResourceLock;
+static void printUsage()
+{
+ std::cout<<"Usage: garageclient <0|1> \n";
+ std::cout<<"ConnectivityType: Default IP\n";
+ std::cout<<"ConnectivityType 0: IPv4 \n";
+ std::cout<<"ConnectivityType 1: IPv6 \n";
+}
+
class Garage
{
public:
std::ostringstream requestURI;
- OCConnectivityType connectivityType = CT_DEFAULT;
+ OCConnectivityType connectivityType = CT_ADAPTER_IP;
if(argc == 2)
{
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
}
else
{
- std::cout<<"Usage: garageclient 0\n";
- std::cout<<"ConnectivityType: Default IP\n";
- std::cout<<"ConnectivityType 0: IP\n";
+ printUsage();
+ std::cout << "Invalid input argument. Using IP as connectivity type" << std::endl;
}
// Create PlatformConfig object
OCResourceHandle resourceHandle;
std::vector< OCResourceHandle > resourceHandleVector;
+static void printUsage()
+{
+ std::cout<<"Usage: groupclient <0|1>\n";
+ std::cout<<"ConnectivityType: Default \n";
+ std::cout<<"ConnectivityType 0: IPv4\n";
+ std::cout<<"ConnectivityType 1: IPv6\n";
+}
void foundResource(std::shared_ptr< OCResource > resource)
{
{
ostringstream requestURI;
- OCConnectivityType connectivityType = CT_DEFAULT;
+ OCConnectivityType connectivityType = CT_ADAPTER_IP;
if(argc == 2)
{
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
}
else
{
- std::cout<<"Usage: groupclient 0\n";
- std::cout<<"ConnectivityType: Default \n";
- std::cout<<"ConnectivityType 0: IP\n";
+ printUsage();
+
}
PlatformConfig config
<< 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;
+ std::cout << "-c 1 : Send message with IPv6 (Currently Not Supported)" << std::endl;
}
// Callback to presence
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
return ++oc;
}
+static void printUsage()
+{
+ std::cout << "Usage roomclient <0|1>" << std::endl;
+ std::cout<<"connectivityType: Default" << std::endl;
+ std::cout << "connectivityType 0: IPv4" << std::endl;
+ std::cout << "connectivityType 0: IPv46 (Currently Not Supported)" << std::endl;
+}
// Forward declaration
void putRoomRepresentation(std::shared_ptr<OCResource> resource);
void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
std::ostringstream requestURI;
- OCConnectivityType connectivityType = CT_DEFAULT;
+ OCConnectivityType connectivityType = CT_ADAPTER_IP;
if(argc == 2)
{
try
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
- std::cout << "Invalid connectivity type selected. Using default IP" << std::endl;
+ std::cout << "Invalid connectivity type selected. Using default IP"<< std::endl;
}
}
else
}
else
{
- std::cout << "Usage roomclient 0" << std::endl;
- std::cout<<"connectivityType: Default" << std::endl;
- std::cout << "connectivityType 0: IP" << std::endl;
+ std::cout << "Default input argument. Using IP as Default connectivity type" << std::endl;
+ printUsage();
}
// Create PlatformConfig object
std::cout << " ObserveType : 1 - Observe" << std::endl;
std::cout << " ObserveType : 2 - ObserveAll" << std::endl;
std::cout << " ConnectivityType: Default IP" << std::endl;
- std::cout << " ConnectivityType : 0 - IP"<< std::endl;
+ std::cout << " ConnectivityType : 0 - IPv4"<< std::endl;
+ std::cout << " ConnectivityType : 0 - IPv6 (Current Not Supported )"<< std::endl;
}
int main(int argc, char* argv[]) {
std::ostringstream requestURI;
- OCConnectivityType connectivityType = CT_DEFAULT;
+ OCConnectivityType connectivityType = CT_ADAPTER_IP;
try
{
if (argc == 1)
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ PrintUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
catch(std::exception& e)
{
std::cout << "Invalid input argument." << std::endl;
+ PrintUsage();
+ return -1;
}
#include "OCApi.h"
using namespace OC;
+static void printUsage()
+{
+ std::cout<< " Usage simpleclientserver <0|1>" << std::endl;
+ std::cout<< " ConnectivityType: Default IP" << std::endl;
+ std::cout << " ConnectivityType : 0 - IPv4" << std::endl;
+ std::cout << " ConnectivityType : 1 - IPv6 (Currently Not Supported)" << std::endl;
+}
class ClientWorker
{
{
if(optionSelected == 0)
{
- connectivityType = CT_ADAPTER_IP;
+ std::cout << "Using IPv4."<< std::endl;
+ connectivityType = CT_IP_USE_V4;
+ }
+ else if(optionSelected == 1)
+ {
+ std::cout << "IPv6 is currently not supported."<< std::endl;
+ printUsage();
+ return -1;
+ //TODO: printUsage to be removed when IPv6 is available.
+ //connectivityType = CT_IP_USE_V6;
}
else
{
}
else
{
- std::cout<< "Usage simpleclientserver 0>" << std::endl;
- std::cout<< " ConnectivityType: Default IP" << std::endl;
- std::cout << " ConnectivityType : 0 - IP" << std::endl;
+ printUsage();
}
PlatformConfig cfg {