testToTextMap queryInterface[] = {
{"invalid", TEST_INVALID},
- {"?if=oc.mi.def", TEST_GET_DEFAULT},
- {"?if=oc.mi.b", TEST_GET_BATCH},
- {"?if=oc.mi.ll", TEST_GET_LINK_LIST},
- {"?if=oc.mi.def", TEST_UNKNOWN_RESOURCE_GET_DEFAULT},
- {"?if=oc.mi.b", TEST_UNKNOWN_RESOURCE_GET_BATCH},
- {"?if=oc.mi.ll", TEST_UNKNOWN_RESOURCE_GET_LINK_LIST},
- {"?if=oc.mi.def", TEST_PUT_DEFAULT},
- {"?if=oc.mi.b", TEST_PUT_BATCH},
- {"?if=oc.mi.ll", TEST_PUT_LINK_LIST},
+ {"?if=oic.if.baseline", TEST_GET_DEFAULT},
+ {"?if=oic.if.b", TEST_GET_BATCH},
+ {"?if=oic.if.ll", TEST_GET_LINK_LIST},
+ {"?if=oic.if.baseline", TEST_UNKNOWN_RESOURCE_GET_DEFAULT},
+ {"?if=oic.if.b", TEST_UNKNOWN_RESOURCE_GET_BATCH},
+ {"?if=oic.if.ll", TEST_UNKNOWN_RESOURCE_GET_LINK_LIST},
+ {"?if=oic.if.baseline", TEST_PUT_DEFAULT},
+ {"?if=oic.if.b", TEST_PUT_BATCH},
+ {"?if=oic.if.ll", TEST_PUT_LINK_LIST},
};
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;
-static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
+//The following variable determines the interface protocol (IP, etc)
+//to be used for sending unicast messages. Default set to IP.
+static OCConnectivityType OC_CONNTYPE = CT_ADAPTER_IP;
+static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res";
// The handle for the observe registration
OCDoHandle gObserveDoHandle;
void PrintUsage()
{
OC_LOG(INFO, TAG, "Usage : occlientcoll -t <Test Case> -c <CA connectivity Type>");
- 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.");
}
OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
OCClientResponse * clientResponse)
{
- uint8_t remoteIpAddr[4];
- uint16_t remotePortNu;
-
OC_LOG(INFO, TAG,
"Entering discoveryReqCB (Application Layer CB)");
OC_LOG_V(INFO, TAG, "StackResult: %s",
OC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
}
- OCDevAddrToIPv4Addr((OCDevAddr *) clientResponse->addr, remoteIpAddr,
- remoteIpAddr + 1, remoteIpAddr + 2, remoteIpAddr + 3);
- OCDevAddrToPort((OCDevAddr *) clientResponse->addr, &remotePortNu);
-
OC_LOG_V(INFO, TAG,
"Device =============> Discovered %s @ %d.%d.%d.%d:%d",
- clientResponse->resJSONPayload, remoteIpAddr[0], remoteIpAddr[1],
- remoteIpAddr[2], remoteIpAddr[3], remotePortNu);
+ clientResponse->resJSONPayload, clientResponse->devAddr.addr, clientResponse->devAddr.port);
if(TEST == TEST_UNKNOWN_RESOURCE_GET_DEFAULT || TEST == TEST_UNKNOWN_RESOURCE_GET_BATCH ||\
TEST == TEST_UNKNOWN_RESOURCE_GET_LINK_LIST)
OCStackResult ret;
OCCallbackData cbData;
std::ostringstream getQuery;
- getQuery << "coap://" << getIPAddrTBServer(clientResponse) << ":" <<
- getPortTBServer(clientResponse) << "/SomeUnknownResource";
+ getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
+ clientResponse->devAddr.port << "/SomeUnknownResource";
cbData.cb = getReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
OCCallbackData cbData;
OCDoHandle handle;
std::ostringstream obsReg;
- obsReg << "coap://" << getIPAddrTBServer(clientResponse) << ":" <<
- getPortTBServer(clientResponse) <<
+ obsReg << "coap://" << clientResponse->devAddr.addr << ":" <<
+ clientResponse->devAddr.addr <<
getQueryStrForGetPut(clientResponse->resJSONPayload);
cbData.cb = getReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
OCCallbackData cbData;
//* Make a PUT query*/
std::ostringstream getQuery;
- getQuery << "coap://" << getIPAddrTBServer(clientResponse) << ":" <<
- getPortTBServer(clientResponse) <<
+ getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
+ clientResponse->devAddr.port <<
"/a/room" << queryInterface[TEST].text;
cbData.cb = putReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
OCStackResult ret;
OCCallbackData cbData;
- uint8_t remoteIpAddr[4];
- uint16_t remotePortNu;
-
- OCDevAddrToIPv4Addr((OCDevAddr *) clientResponse->addr, remoteIpAddr,
- remoteIpAddr + 1, remoteIpAddr + 2, remoteIpAddr + 3);
- OCDevAddrToPort((OCDevAddr *) clientResponse->addr, &remotePortNu);
-
//* Make a GET query*/
std::ostringstream getQuery;
- getQuery << "coap://" << getIPAddrTBServer(clientResponse) << ":" <<
- getPortTBServer(clientResponse) <<
+ getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
+ clientResponse->devAddr.port <<
"/a/room" << queryInterface[TEST].text;
std::cout << "Get Query: " << getQuery.str() << std::endl;
cbData.cb = discoveryReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
- ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_ALL,
+ ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri, 0, 0, CT_DEFAULT,
OC_LOW_QOS,
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
TEST = atoi(optarg);
break;
case 'c':
- OC_CONNTYPE = OCConnectivityType(atoi(optarg));
+ OC_CONNTYPE = CT_ADAPTER_IP;
break;
default:
PrintUsage();
return 0;
}
-std::string getIPAddrTBServer(OCClientResponse * clientResponse)
-{
- if (!clientResponse)
- {
- return "";
- }
- if (!clientResponse->addr)
- {
- return "";
- }
- uint8_t a, b, c, d = 0;
- if (0 != OCDevAddrToIPv4Addr(clientResponse->addr, &a, &b, &c, &d))
- {
- return "";
- }
-
- char ipaddr[16] = {'\0'};
- // ostringstream not working correctly here, hence snprintf
- snprintf(ipaddr, sizeof(ipaddr), "%d.%d.%d.%d", a,b,c,d);
- return std::string (ipaddr);
-}
-
-std::string getPortTBServer(OCClientResponse * clientResponse)
-{
- if (!clientResponse)
- {
- return "";
- }
- if (!clientResponse->addr)
- {
- return "";
- }
- uint16_t p = 0;
- if (0 != OCDevAddrToPort(clientResponse->addr, &p))
- {
- return "";
- }
- std::ostringstream ss;
- ss << p;
- return ss.str();
-}
-
std::string getQueryStrForGetPut(const char * responsePayload)
{