X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Fsamples%2Flinux%2FSimpleClientServer%2Focclient.cpp;h=5faaccdf0688596cd4e6eb9f04cfac2cc2a3e735;hb=b2e13cb430aeee5eca38253a454a0665eb6a68b6;hp=6a59ee05420781e36b88dffe37a2a19d895f9b10;hpb=5afbbb1a9974d2fc1251fcab00c4100fb5ac4f3d;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp index 6a59ee0..5faaccd 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp @@ -29,29 +29,24 @@ #include "logger.h" #include "occlient.h" #include "ocpayload.h" +#include "payload_logging.h" // Tracking user input -static int UNICAST_DISCOVERY = 0; -static int TEST_CASE = 0; -static int CONNECTIVITY = 0; +static int UnicastDiscovery = 0; +static int TestCase = 0; +static int Connectivity = 0; -static const char * UNICAST_DEVICE_DISCOVERY_QUERY = "coap://%s/oic/d"; -static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oic/d"; -static const char * UNICAST_PLATFORM_DISCOVERY_QUERY = "coap://%s/oic/p"; -static const char * MULTICAST_PLATFORM_DISCOVERY_QUERY = "/oic/p"; +static const char *DEVICE_DISCOVERY_QUERY = "%s/oic/d"; +static const char *PLATFORM_DISCOVERY_QUERY = "%s/oic/p"; +static const char *RESOURCE_DISCOVERY_QUERY = "%s/oic/res"; -static const char * UNICAST_RESOURCE_DISCOVERY_QUERY = "coap://%s/oic/res"; -static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oic/res"; //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 = CT_ADAPTER_IP; -static std::string coapServerIP = "255.255.255.255"; -static std::string coapServerPort = "5683"; +//to be used for sending unicast messages. Default set to IP dual stack. +static OCConnectivityType ConnType = CT_ADAPTER_IP; +static OCDevAddr serverAddr; +static char discoveryAddr[100]; static std::string coapServerResource = "/a/light"; -// Size to hold IPV4_ADDRESS:PORT -static const int IPV4_ADDR_SIZE = 24; -//Use ipv4addr for both InitDiscovery and InitPlatformOrDeviceDiscovery -char ipv4addr[IPV4_ADDR_SIZE]; + void StripNewLineChar(char* str); // The handle for the observe registration @@ -81,7 +76,7 @@ OCPayload* putPayload() { OCRepPayload* payload = OCRepPayloadCreate(); - if(!payload) + if (!payload) { std::cout << "Failed to create put payload object"<result)); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -189,14 +186,15 @@ OCStackApplicationResult putReqCB(void* ctx, OCDoHandle handle, OCClientResponse return OC_STACK_DELETE_TRANSACTION; } -OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientResponse *clientResponse) +OCStackApplicationResult postReqCB(void *ctx, OCDoHandle /*handle*/, + OCClientResponse *clientResponse) { - if(ctx == (void*)DEFAULT_CONTEXT_VALUE) + if (ctx == (void*)DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully"); } - if(clientResponse) + if (clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -210,14 +208,15 @@ OCStackApplicationResult postReqCB(void *ctx, OCDoHandle handle, OCClientRespons } OCStackApplicationResult deleteReqCB(void *ctx, - OCDoHandle handle, OCClientResponse *clientResponse) + OCDoHandle /*handle*/, + OCClientResponse *clientResponse) { - if(ctx == (void*)DEFAULT_CONTEXT_VALUE) + if (ctx == (void*)DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for DELETE recvd successfully"); } - if(clientResponse) + if (clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -230,15 +229,16 @@ OCStackApplicationResult deleteReqCB(void *ctx, return OC_STACK_DELETE_TRANSACTION; } -OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) +OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { - if(clientResponse == NULL) + if (clientResponse == NULL) { OC_LOG(INFO, TAG, "getReqCB received NULL clientResponse"); return OC_STACK_DELETE_TRANSACTION; } - if(ctx == (void*)DEFAULT_CONTEXT_VALUE) + if (ctx == (void*)DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully"); } @@ -248,14 +248,14 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); OC_LOG(INFO, TAG, PCF("=============> Get Response")); - if(clientResponse->numRcvdVendorSpecificHeaderOptions > 0) + if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0) { OC_LOG (INFO, TAG, "Received vendor specific options"); uint8_t i = 0; OCHeaderOption * rcvdOptions = clientResponse->rcvdVendorSpecificHeaderOptions; for( i = 0; i < clientResponse->numRcvdVendorSpecificHeaderOptions; i++) { - if(((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID) + if (((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID) { OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with", ((OCHeaderOption)rcvdOptions[i]).optionID ); @@ -268,14 +268,15 @@ OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse return OC_STACK_DELETE_TRANSACTION; } -OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) +OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { - if(ctx == (void*)DEFAULT_CONTEXT_VALUE) + if (ctx == (void*)DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for OBS query recvd successfully"); } - if(clientResponse) + if (clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber); @@ -286,7 +287,7 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse gNumObserveNotifies++; if (gNumObserveNotifies == 15) //large number to test observing in DELETE case. { - if(TEST_CASE == TEST_OBS_REQ_NON || TEST_CASE == TEST_OBS_REQ_CON) + if (TestCase == TEST_OBS_REQ_NON || TestCase == TEST_OBS_REQ_CON) { if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK) { @@ -294,7 +295,7 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse } return OC_STACK_DELETE_TRANSACTION; } - else if(TEST_CASE == TEST_OBS_REQ_NON_CANCEL_IMM) + else if (TestCase == TEST_OBS_REQ_NON_CANCEL_IMM) { if (OCCancel (gObserveDoHandle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK) { @@ -302,16 +303,16 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse } } } - if(clientResponse->sequenceNumber == OC_OBSERVE_REGISTER) + if (clientResponse->sequenceNumber == OC_OBSERVE_REGISTER) { OC_LOG(INFO, TAG, "This also serves as a registration confirmation"); } - else if(clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER) + else if (clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER) { OC_LOG(INFO, TAG, "This also serves as a deregistration confirmation"); return OC_STACK_DELETE_TRANSACTION; } - else if(clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION) + else if (clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION) { OC_LOG(INFO, TAG, "This also tells you that registration/deregistration failed"); return OC_STACK_DELETE_TRANSACTION; @@ -324,7 +325,8 @@ OCStackApplicationResult obsReqCB(void* ctx, OCDoHandle handle, OCClientResponse return OC_STACK_KEEP_TRANSACTION; } #ifdef WITH_PRESENCE -OCStackApplicationResult presenceCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse) +OCStackApplicationResult presenceCB(void* ctx, OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { if (ctx == (void*) DEFAULT_CONTEXT_VALUE) { @@ -334,7 +336,6 @@ OCStackApplicationResult presenceCB(void* ctx, OCDoHandle handle, OCClientRespon if (clientResponse) { OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result)); - OC_LOG_V(INFO, TAG, "NONCE NUMBER: %u", clientResponse->sequenceNumber); OC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d", gNumPresenceNotifies); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -358,8 +359,8 @@ OCStackApplicationResult presenceCB(void* ctx, OCDoHandle handle, OCClientRespon #endif // This is a function called back when a device is discovered -OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle, - OCClientResponse * clientResponse) +OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { if (ctx == (void*) DEFAULT_CONTEXT_VALUE) { @@ -378,10 +379,11 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle, clientResponse->devAddr.port); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); - OC_CONNTYPE = clientResponse->connType; + ConnType = clientResponse->connType; + serverAddr = clientResponse->devAddr; parseClientResponse(clientResponse); - switch(TEST_CASE) + switch(TestCase) { case TEST_GET_REQ_NON: InitGetRequest(OC_LOW_QOS, 0, 0); @@ -446,15 +448,16 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle, return OC_STACK_KEEP_TRANSACTION; } -OCStackApplicationResult PlatformDiscoveryReqCB (void* ctx, OCDoHandle handle, - OCClientResponse * clientResponse) +OCStackApplicationResult PlatformDiscoveryReqCB(void* ctx, + OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { if (ctx == (void*) DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully"); } - if(clientResponse) + if (clientResponse) { OC_LOG(INFO, TAG, PCF("Discovery Response:")); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -464,18 +467,18 @@ OCStackApplicationResult PlatformDiscoveryReqCB (void* ctx, OCDoHandle handle, OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse"); } - return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION; + return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION; } -OCStackApplicationResult DeviceDiscoveryReqCB (void* ctx, OCDoHandle handle, - OCClientResponse * clientResponse) +OCStackApplicationResult DeviceDiscoveryReqCB(void* ctx, OCDoHandle /*handle*/, + OCClientResponse * clientResponse) { if (ctx == (void*) DEFAULT_CONTEXT_VALUE) { OC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully"); } - if(clientResponse) + if (clientResponse) { OC_LOG(INFO, TAG, PCF("Discovery Response:")); OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload); @@ -485,7 +488,7 @@ OCStackApplicationResult DeviceDiscoveryReqCB (void* ctx, OCDoHandle handle, OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse"); } - return (UNICAST_DISCOVERY) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION; + return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION; } #ifdef WITH_PRESENCE @@ -495,37 +498,37 @@ int InitPresence() OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; std::ostringstream querySuffix; - query << "coap://" << coapServerIP << ":" << coapServerPort << OC_RSRVD_PRESENCE_URI; - if(TEST_CASE == TEST_OBS_PRESENCE) + query << OC_RSRVD_PRESENCE_URI; + if (TestCase == TEST_OBS_PRESENCE) { - result = InvokeOCDoResource(query, OC_REST_PRESENCE, OC_LOW_QOS, - presenceCB, NULL, 0); + result = InvokeOCDoResource(query, &serverAddr, OC_REST_PRESENCE, + OC_LOW_QOS, presenceCB, NULL, 0); } - if(TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTER || TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTERS) + if (TestCase == TEST_OBS_PRESENCE_WITH_FILTER || TestCase == TEST_OBS_PRESENCE_WITH_FILTERS) { querySuffix.str(""); querySuffix << query.str() << "?rt=core.led"; - result = InvokeOCDoResource(querySuffix, OC_REST_PRESENCE, OC_LOW_QOS, - presenceCB, NULL, 0); + result = InvokeOCDoResource(querySuffix, &serverAddr, OC_REST_PRESENCE, + OC_LOW_QOS, presenceCB, NULL, 0); } - if(TEST_CASE == TEST_OBS_PRESENCE_WITH_FILTERS) + if (TestCase == TEST_OBS_PRESENCE_WITH_FILTERS) { - if(result == OC_STACK_OK) + if (result == OC_STACK_OK) { querySuffix.str(""); querySuffix << query.str() << "?rt=core.fan"; - result = InvokeOCDoResource(querySuffix, OC_REST_PRESENCE, OC_LOW_QOS, + result = InvokeOCDoResource(querySuffix, &serverAddr, OC_REST_PRESENCE, OC_LOW_QOS, presenceCB, NULL, 0); } } - if(TEST_CASE == TEST_OBS_MULTICAST_PRESENCE) + if (TestCase == TEST_OBS_MULTICAST_PRESENCE) { - if(result == OC_STACK_OK) + if (result == OC_STACK_OK) { std::ostringstream multicastPresenceQuery; multicastPresenceQuery.str(""); multicastPresenceQuery << "coap://" << OC_MULTICAST_PREFIX << OC_RSRVD_PRESENCE_URI; - result = InvokeOCDoResource(multicastPresenceQuery, OC_REST_PRESENCE, OC_LOW_QOS, + result = InvokeOCDoResource(multicastPresenceQuery, &serverAddr, OC_REST_PRESENCE, OC_LOW_QOS, presenceCB, NULL, 0); } } @@ -537,8 +540,8 @@ int InitGetRequestToUnavailableResource(OCQualityOfService qos) { OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << "/SomeUnknownResource"; - return (InvokeOCDoResource(query, OC_REST_GET, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, + query << "/SomeUnknownResource"; + return (InvokeOCDoResource(query, &serverAddr, OC_REST_GET, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0)); } @@ -546,17 +549,17 @@ int InitObserveRequest(OCQualityOfService qos) { OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; - return (InvokeOCDoResource(query, - OC_REST_OBSERVE, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, obsReqCB, NULL, 0)); + query << coapServerResource; + return (InvokeOCDoResource(query, &serverAddr, OC_REST_OBSERVE, + (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, obsReqCB, NULL, 0)); } int InitPutRequest(OCQualityOfService qos) { OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; - return (InvokeOCDoResource(query, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, + query << coapServerResource; + return (InvokeOCDoResource(query, &serverAddr, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, putReqCB, NULL, 0)); } @@ -565,10 +568,10 @@ int InitPostRequest(OCQualityOfService qos) OCStackResult result; OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; + query << coapServerResource; // First POST operation (to create an Light instance) - result = InvokeOCDoResource(query, OC_REST_POST, + result = InvokeOCDoResource(query, &serverAddr, OC_REST_POST, ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS), postReqCB, NULL, 0); if (OC_STACK_OK != result) @@ -578,7 +581,7 @@ int InitPostRequest(OCQualityOfService qos) } // Second POST operation (to create an Light instance) - result = InvokeOCDoResource(query, OC_REST_POST, + result = InvokeOCDoResource(query, &serverAddr, OC_REST_POST, ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS), postReqCB, NULL, 0); if (OC_STACK_OK != result) @@ -587,7 +590,7 @@ int InitPostRequest(OCQualityOfService qos) } // This POST operation will update the original resourced /a/light - return (InvokeOCDoResource(query, OC_REST_POST, + return (InvokeOCDoResource(query, &serverAddr, OC_REST_POST, ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS), postReqCB, NULL, 0)); } @@ -596,7 +599,7 @@ void* RequestDeleteDeathResourceTask(void* myqos) { sleep (30);//long enough to give the server time to finish deleting the resource. std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; + query << coapServerResource; OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); @@ -611,7 +614,7 @@ void* RequestDeleteDeathResourceTask(void* myqos) qos = OC_HIGH_QOS; } - OCStackResult result = InvokeOCDoResource(query, OC_REST_DELETE, + OCStackResult result = InvokeOCDoResource(query, &serverAddr, OC_REST_DELETE, qos, deleteReqCB, NULL, 0); @@ -627,12 +630,12 @@ int InitDeleteRequest(OCQualityOfService qos) { OCStackResult result; std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; + query << coapServerResource; OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); // First DELETE operation - result = InvokeOCDoResource(query, OC_REST_DELETE, + result = InvokeOCDoResource(query, &serverAddr, OC_REST_DELETE, qos, deleteReqCB, NULL, 0); if (OC_STACK_OK != result) @@ -658,13 +661,13 @@ int InitGetRequest(OCQualityOfService qos, uint8_t withVendorSpecificHeaderOptio OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__); std::ostringstream query; - query << "coap://" << coapServerIP << ":" << coapServerPort << coapServerResource; + query << coapServerResource; // ocserver is written to only process "power= MAX_TESTS) || - (CONNECTIVITY < CT_ADAPTER_DEFAULT || CONNECTIVITY >= MAX_CT)) + if ((UnicastDiscovery != 0 && UnicastDiscovery != 1) || + (TestCase < TEST_DISCOVER_REQ || TestCase >= MAX_TESTS) || + (Connectivity < CT_ADAPTER_DEFAULT || Connectivity >= MAX_CT)) { PrintUsage(); return -1; } - /* Initialize OCStack*/ - if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK) + if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "OCStack init error"); return 0; } - if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IP) + if (Connectivity == CT_ADAPTER_DEFAULT || Connectivity == CT_IP) { - OC_CONNTYPE = CT_ADAPTER_IP; + ConnType = CT_ADAPTER_IP; } else { @@ -860,28 +815,31 @@ int main(int argc, char* argv[]) PrintUsage(); } - if (UNICAST_DISCOVERY) + discoveryAddr[0] = '\0'; + + if (UnicastDiscovery) { - OC_LOG(INFO, TAG, "Enter IP address with port number of the Server hosting resource"); - OC_LOG(INFO, TAG, "as follows - eg: 192.168.0.15:45454 (IP:Port) \n"); + OC_LOG(INFO, TAG, "Enter IP address of server with optional port number"); + OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n"); + OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n"); - if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin)) + if (fgets(discoveryAddr, sizeof (discoveryAddr), stdin)) { //Strip newline char from ipv4addr - StripNewLineChar(ipv4addr); + StripNewLineChar(discoveryAddr); } else { - OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!"); + OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!"); return OC_STACK_INVALID_PARAM; } } - if(UNICAST_DISCOVERY == 0 && TEST_CASE == TEST_DISCOVER_DEV_REQ) + if (UnicastDiscovery == 0 && TestCase == TEST_DISCOVER_DEV_REQ) { InitDeviceDiscovery(OC_LOW_QOS); } - else if(UNICAST_DISCOVERY == 0 && TEST_CASE == TEST_DISCOVER_PLATFORM_REQ) + else if (UnicastDiscovery == 0 && TestCase == TEST_DISCOVER_PLATFORM_REQ) { InitPlatformDiscovery(OC_LOW_QOS); } @@ -914,35 +872,6 @@ int main(int argc, char* argv[]) return 0; } -std::string getIPAddrTBServer(OCClientResponse * clientResponse) -{ - if (!clientResponse) - { - return ""; - } - if (!clientResponse->addr) - { - return ""; - } - - return std::string(clientResponse->devAddr.addr); -} - -std::string getPortTBServer(OCClientResponse * clientResponse) -{ - if (!clientResponse) - { - return ""; - } - if (!clientResponse->addr) - { - return ""; - } - std::ostringstream ss; - ss << clientResponse->devAddr.port; - return ss.str(); -} - std::string getConnectivityType (OCConnectivityType connType) { switch (connType & CT_MASK_ADAPTER) @@ -967,16 +896,12 @@ std::string getConnectivityType (OCConnectivityType connType) } } -std::string getQueryStrForGetPut(OCClientResponse * clientResponse) +std::string getQueryStrForGetPut(OCClientResponse * /*clientResponse*/) { - return "/a/light"; } void parseClientResponse(OCClientResponse * clientResponse) { - coapServerIP = getIPAddrTBServer(clientResponse); - coapServerPort = getPortTBServer(clientResponse); coapServerResource = getQueryStrForGetPut(clientResponse); } -