"filter");
OC_LOG(INFO, TAG, "-t 14 : Discover Resources and Initiate Nonconfirmable presence with "\
"2 filters");
+ OC_LOG(INFO, TAG, "-t 15 : Discover Resources and Initiate Nonconfirmable multicast presence.");
#endif
- OC_LOG(INFO, TAG, "-t 15 : Discover Resources and Initiate Nonconfirmable Observe Requests "\
+ OC_LOG(INFO, TAG, "-t 16 : Discover Resources and Initiate Nonconfirmable Observe Requests "\
"then cancel immediately with High QOS");
- OC_LOG(INFO, TAG, "-t 16 : Discover Resources and Initiate Nonconfirmable Get Request and "\
+ OC_LOG(INFO, TAG, "-t 17 : Discover Resources and Initiate Nonconfirmable Get Request and "\
"add vendor specific header options");
- OC_LOG(INFO, TAG, "-t 17 : Discover Devices");
+ OC_LOG(INFO, TAG, "-t 18 : Discover Devices");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
case TEST_OBS_PRESENCE:
case TEST_OBS_PRESENCE_WITH_FILTER:
case TEST_OBS_PRESENCE_WITH_FILTERS:
+ case TEST_OBS_MULTICAST_PRESENCE:
InitPresence();
break;
#endif
presenceCB, NULL, 0);
}
}
+ if(TEST_CASE == TEST_OBS_MULTICAST_PRESENCE)
+ {
+ if(result == OC_STACK_OK)
+ {
+ std::ostringstream multicastPresenceQuery;
+ multicastPresenceQuery.str("");
+ multicastPresenceQuery << "coap://" << OC_MULTICAST_PREFIX << OC_PRESENCE_URI;
+ result = InvokeOCDoResource(multicastPresenceQuery, OC_REST_PRESENCE, OC_LOW_QOS,
+ presenceCB, NULL, 0);
+ }
+ }
return result;
}
#endif
TEST_OBS_PRESENCE,
TEST_OBS_PRESENCE_WITH_FILTER,
TEST_OBS_PRESENCE_WITH_FILTERS,
+ TEST_OBS_MULTICAST_PRESENCE,
#endif
TEST_OBS_REQ_NON_CANCEL_IMM,
TEST_GET_REQ_NON_WITH_VENDOR_HEADER_OPTIONS,
}
else
{
- snprintf(fullUri, MAX_URI_LENGTH, "%s%s", OC_MULTICAST_IP, endPoint->resourceUri);
+ snprintf(fullUri, MAX_URI_LENGTH, "coap://%s:%u%s", OC_MULTICAST_IP, OC_MULTICAST_PORT,
+ endPoint->resourceUri);
cbNode = GetClientCB(NULL, 0, NULL, fullUri);
if(cbNode)
{
<< std::endl;
std::cout << "-t 6 : Discover Resources and Initiate Multicast Presence with two Filters"
<< std::endl;
- std::cout << "-t 4 : Discover Resources and Initiate Multicast Presence" << std::endl;
- std::cout << "-t 5 : Discover Resources and Initiate Multicast Presence with Filter"
- << std::endl;
- std::cout << "-t 6 : Discover Resources and Initiate Multicast Presence with two Filters"
- << std::endl;
std::cout<<"ConnectivityType: Default WIFI" << std::endl;
std::cout << "-c 0 : Send message over ETHERNET interface" << std::endl;
std::cout << "-c 1 : Send message over WIFI interface" << std::endl;
OCPlatform::OCPresenceHandle presenceHandle = nullptr;
OCStackResult result = OC_STACK_OK;
+ std::ostringstream multicastPresenceURI;
+ multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
+
if(TEST_CASE == TEST_MULTICAST_PRESENCE_NORMAL)
{
result = OCPlatform::subscribePresence(presenceHandle,
- OC_MULTICAST_IP, connectivityType, presenceHandler);
+ multicastPresenceURI.str(), connectivityType, presenceHandler);
if(result == OC_STACK_OK)
{
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTER)
{
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
+ result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.light",
connectivityType, &presenceHandler);
if(result == OC_STACK_OK)
{
}
else if(TEST_CASE == TEST_MULTICAST_PRESENCE_WITH_FILTERS)
{
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.light",
+ result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.light",
connectivityType, &presenceHandler);
if(result == OC_STACK_OK)
{
}
std::cout << "\"core.light\"." << std::endl;
- result = OCPlatform::subscribePresence(presenceHandle, OC_MULTICAST_IP, "core.fan",
+ result = OCPlatform::subscribePresence(presenceHandle, multicastPresenceURI.str(), "core.fan",
connectivityType, &presenceHandler);
if(result == OC_STACK_OK)
{
* request. It can be used to unsubscribe from these events in the future.
* It will be set upon successful return of this method.
* @param host - The IP address/addressable name of the server to subscribe to.
+ * This should be in the format coap://address:port
* @param connectivityType - @ref OCConnectivityType type of connectivity indicating the
* interface. Example: OC_WIFI, OC_ETHERNET, OC_ALL
* @param resourceType - a resource type specified as a filter for subscription callbacks.
s_mirrorResourceList = createMirrorResourceList();
s_requestHandleList = createRequestHandleList();
- result = requestPresence(OC_DEFAULT_ADDRESS);
+ result = requestPresence(OC_MULTICAST_PREFIX);
if(result != OC_STACK_OK)
{
return OC_STACK_ERROR;
cbData.cd = NULL;
char queryUri[OIC_STRING_MAX_VALUE] = { '\0' };
- sprintf(queryUri, "%s%s", sourceResourceAddress , OC_PRESENCE_URI);
+ sprintf(queryUri, "coap://%s%s", sourceResourceAddress , OC_PRESENCE_URI);
OC_LOG_V(DEBUG, HOSTING_TAG, "initializePresenceForCoordinating Query : %s", queryUri);
result = OCDoResource(&handle, OC_REST_PRESENCE, queryUri, 0, 0, OC_ETHERNET, OC_LOW_QOS, &cbData, NULL, 0);
std::ostringstream requestURI;
requestURI << OC_WELL_KNOWN_QUERY << "?rt=SSManager.Sensor";
+ std::ostringstream multicastPresenceURI;
+ multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
+
ret = OC::OCPlatform::findResource("", requestURI.str(), OC_WIFI,
std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
- ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, OC_MULTICAST_IP,
+ ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(),
"SSManager.Sensor", OC_WIFI, std::bind(&CResourceFinder::presenceHandler, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
- ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, OC_MULTICAST_IP,
+ ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(),
"SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));