X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fnotification%2Fsrc%2Fconsumer%2FNSConsumerNetworkEventListener.c;h=d48d89732af66b815735abd28f7598f5551be7ca;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=b43749ba3999068ffde76bfd319659320132a767;hpb=112597ac33022a4ad678f228e97cdff627eee9b6;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/notification/src/consumer/NSConsumerNetworkEventListener.c b/service/notification/src/consumer/NSConsumerNetworkEventListener.c index b43749b..d48d897 100644 --- a/service/notification/src/consumer/NSConsumerNetworkEventListener.c +++ b/service/notification/src/consumer/NSConsumerNetworkEventListener.c @@ -25,11 +25,12 @@ #include "NSConsumerCommon.h" #include "cautilinterface.h" #include "oic_malloc.h" +#include "oic_string.h" #include "NSConsumerDiscovery.h" #include "NSConsumerNetworkEventListener.h" -#define NS_PRESENCE_SUBSCRIBE_QUERY "coap://224.0.1.187:5683/oic/ad?rt=oic.r.notification" +#define NS_PRESENCE_SUBSCRIBE_QUERY "/oic/ad?rt=x.org.iotivity.notification" void NSConnectionStateListener(const CAEndpoint_t * info, bool isConnected); @@ -56,21 +57,21 @@ NSResult NSConsumerListenerInit() NS_LOG(DEBUG, "Request to subscribe presence"); OCStackResult stackResult = NSInvokeRequest(getPresenceHandle(), OC_REST_PRESENCE, NULL, NS_PRESENCE_SUBSCRIBE_QUERY, NULL, NSConsumerPresenceListener, - NULL, CT_DEFAULT); - NS_VERIFY_STACK_OK(stackResult, NS_ERROR); + NULL, NULL, CT_DEFAULT); + NS_VERIFY_STACK_SUCCESS(NSOCResultToSuccess(stackResult), NS_ERROR); NS_LOG(DEBUG, "Request to discover provider"); stackResult = NSInvokeRequest(NULL, OC_REST_DISCOVER, NULL, NS_DISCOVER_QUERY, NULL, NSProviderDiscoverListener, - NULL, CT_DEFAULT); - NS_VERIFY_STACK_OK(stackResult, NS_ERROR); + NULL, NULL, CT_DEFAULT); + NS_VERIFY_STACK_SUCCESS(NSOCResultToSuccess(stackResult), NS_ERROR); return NS_OK; } void NSConsumerListenerTermiate() { - CARegisterNetworkMonitorHandler(NULL, NULL); + CAUnregisterNetworkMonitorHandler(NSAdapterStateListener, NSConnectionStateListener); OCCancel(*getPresenceHandle(), NS_QOS, NULL, 0); } @@ -79,7 +80,7 @@ void NSConnectionStateListener(const CAEndpoint_t * info, bool connected) NS_VERIFY_NOT_NULL_V(info); NS_LOG_V(DEBUG, "adapter : %d", info->adapter); - NS_LOG_V(DEBUG, "remote_address : %s:%d", info->addr, info->port); + NS_LOG_V(INFO_PRIVATE, "remote_address : %s:%d", info->addr, info->port); NS_LOG_V(DEBUG, "isConnect : %d", connected); NSTaskType type = TASK_EVENT_CONNECTED; @@ -90,16 +91,21 @@ void NSConnectionStateListener(const CAEndpoint_t * info, bool connected) { type = TASK_EVENT_CONNECTED_TCP; NS_LOG(DEBUG, "try to discover notification provider : TCP."); - // TODO convet to OCDevAddr; - // addr = ..... } else if (info->adapter == CA_ADAPTER_IP) { - NS_LOG(DEBUG, "try to discover notification provider."); - // TODO convet to OCDevAddr; - // addr = ..... + NS_LOG(DEBUG, "try to discover notification provider : IP."); } + addr = (OCDevAddr *)OICMalloc(sizeof(OCDevAddr)); + NS_VERIFY_NOT_NULL_V(addr); + + addr->adapter = (OCTransportAdapter) info->adapter; + OICStrcpy(addr->addr, MAX_ADDR_STR_SIZE, info->addr); + addr->flags = info->flags; + addr->ifindex = info->ifindex; + addr->port = info->port; + NSTask * task = NSMakeTask(type, addr); NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(task, NSOICFree(addr));