From 95d4bb3445d6b64d871e07d4bda46911e28727c0 Mon Sep 17 00:00:00 2001 From: "koushik.girijala" Date: Fri, 3 Jul 2015 12:48:02 +0530 Subject: [PATCH] [CA] RI sample occlient fix for not able to send get unicast data fixed OCconectivity type and port number adding to uri Change-Id: Ie99e66dd6c7840008d9f0cfc41089d183907c585 Signed-off-by: koushik.girijala Reviewed-on: https://gerrit.iotivity.org/gerrit/1503 Tested-by: jenkins-iotivity Reviewed-by: Abhishek Pandey Reviewed-by: Erich Keane --- .../samples/linux/SimpleClientServer/occlient.cpp | 51 ++++++++++------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp index d0c13a6..841835a 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp @@ -34,12 +34,12 @@ 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 * 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:6298/oic/p"; +static const char * UNICAST_PLATFORM_DISCOVERY_QUERY = "coap://%s/oic/p"; static const char * MULTICAST_PLATFORM_DISCOVERY_QUERY = "/oic/p"; -static const char * UNICAST_RESOURCE_DISCOVERY_QUERY = "coap://%s:6298/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. @@ -48,7 +48,8 @@ static std::string putPayload = "{\"oic\":[{\"rep\":{\"power\":15,\"state\":true static std::string coapServerIP = "255.255.255.255"; static std::string coapServerPort = "5683"; static std::string coapServerResource = "/a/light"; -static const int IPV4_ADDR_SIZE = 16; +// 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); @@ -831,34 +832,13 @@ int main(int argc, char* argv[]) OC_LOG(ERROR, TAG, "OCStack init error"); return 0; } - if (UNICAST_DISCOVERY) - { - 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 - StripNewLineChar(ipv4addr); - } - else - { - 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) + if(CONNECTIVITY == CT_ADAPTER_DEFAULT || CONNECTIVITY == CT_IPV4) { - OC_CONNTYPE = CT_IP_USE_V4; + OC_CONNTYPE = CT_ADAPTER_IP; } 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(); @@ -870,6 +850,23 @@ int main(int argc, char* argv[]) PrintUsage(); } + if (UNICAST_DISCOVERY) + { + 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"); + + if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin)) + { + //Strip newline char from ipv4addr + StripNewLineChar(ipv4addr); + } + else + { + OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!"); + return OC_STACK_INVALID_PARAM; + } + } + if(UNICAST_DISCOVERY == 0 && TEST_CASE == TEST_DISCOVER_DEV_REQ) { InitDeviceDiscovery(OC_LOW_QOS); -- 2.7.4