help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False))
help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER']))
+help_vars.Add(BoolVariable('DISABLE_PRESENCE', 'Disable Presence Feature', False))
help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False))
if env.get('DISABLE_TCP_SERVER'):
defines.append('-DDISABLE_TCP_SERVER=1')
+if env.get('DISABLE_PRESENCE') == False:
+ env.AppendUnique(CPPDEFINES = ['WITH_PRESENCE'])
+
libs = []
if env.get('SECURED') == '1':
defines.append('-D__WITH_DTLS__=1')
goto IotivityStop;
}
+#ifdef WITH_PRESENCE
result = OCStartPresence(0);
if (result != OC_STACK_OK)
{
OIC_LOG_V(ERROR, TAG, "OCStartPresence Failed: %d", result);
goto IotivityStop;
}
-
+#endif
// PIStartPlugin
PIPlugin* plugin = NULL;
OIC_LOG(INFO, TAG, "IoTivity Initialized properly, Starting Zigbee Plugin...");
extern "C" {
#endif // __cplusplus
-/** For the feature presence.*/
-#define WITH_PRESENCE
-
#include "ocpresence.h"
// TODO : need for secure psi
/** Presence URI through which the OIC devices advertise their presence.*/
#define OC_RSRVD_PRESENCE_URI "/oic/ad"
+#endif // WITH_PRESENCE
/** Presence URI through which the OIC devices advertise their device presence.*/
#define OC_RSRVD_DEVICE_PRESENCE_URI "/oic/prs"
-#endif // WITH_PRESENCE
-
/** For multicast Discovery mechanism.*/
#define OC_MULTICAST_DISCOVERY_URI "/oic/res"
OIC_LOG(INFO, TAG, "Calling OCSendResponse with:");
OIC_LOG_V(INFO, TAG, "\tEndpoint address: %s", responseEndpoint.addr);
- OIC_LOG_V(INFO, TAG, "\tEndpoint adapter: %s", responseEndpoint.adapter);
- OIC_LOG_V(INFO, TAG, "\tResponse result : %s", responseInfo.result);
+ OIC_LOG_V(INFO, TAG, "\tEndpoint adapter: %d", responseEndpoint.adapter);
+ OIC_LOG_V(INFO, TAG, "\tResponse result : %d", responseInfo.result);
OIC_LOG_V(INFO, TAG, "\tResponse for uri: %s", responseInfo.info.resourceUri);
result = OCSendResponse(&responseEndpoint, &responseInfo);
if target_os not in ['windows', 'msys_nt']:
example_names += [
'fridgeserver', 'fridgeclient',
- 'presenceserver', 'presenceclient',
'roomserver', 'roomclient',
'garageserver',
'garageclient',
examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])
example_names += ['rdclient']
examples_env.AppendUnique(LIBS = ['resource_directory'])
+ if examples_env.get('DISABLE_PRESENCE') == False:
+ example_names += ['presenceserver', 'presenceclient']
examples = map(make_single_file_cpp_program, example_names)
return result;
}
+#ifdef WITH_PRESENCE
OCStackApplicationResult subscribePresenceCallback(void* ctx,
OCDoHandle /*handle*/,
OCClientResponse* clientResponse)
return OC_STACK_KEEP_TRANSACTION;
}
+#endif
OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
const std::string& host, const std::string& resourceType,
OCConnectivityType connectivityType, SubscribeCallback& presenceHandler)
{
+#ifdef WITH_PRESENCE
if (!presenceHandler)
{
return OC_STACK_INVALID_PARAM;
os.str().c_str(), nullptr,
nullptr, connectivityType,
OC_LOW_QOS, &cbdata, NULL, 0);
+#else
+ return OC_STACK_NOT_IMPLEMENTED;
+#endif
}
OCStackResult InProcClientWrapper::UnsubscribePresence(OCDoHandle handle)
{
+#ifdef WITH_PRESENCE
OCStackResult result;
auto cLock = m_csdkLock.lock();
}
return result;
+#else
+ return OC_STACK_NOT_IMPLEMENTED;
+#endif
}
#ifdef WITH_CLOUD
OCStackResult InProcServerWrapper::startPresence(const unsigned int seconds)
{
+#ifdef WITH_PRESENCE
auto cLock = m_csdkLock.lock();
OCStackResult result = OC_STACK_ERROR;
if(cLock)
throw OCException(OC::Exception::START_PRESENCE_FAILED, result);
}
return result;
+#else
+ return OC_STACK_NOT_IMPLEMENTED;
+#endif
}
OCStackResult InProcServerWrapper::stopPresence()
{
+#ifdef WITH_PRESENCE
auto cLock = m_csdkLock.lock();
OCStackResult result = OC_STACK_ERROR;
if(cLock)
throw OCException(OC::Exception::END_PRESENCE_FAILED, result);
}
return result;
+#else
+ return OC_STACK_NOT_IMPLEMENTED;
+#endif
}
OCStackResult InProcServerWrapper::sendResponse(
OC_STACK_SVR_DB_NOT_EXIST,
OC_STACK_AUTHENTICATION_FAILURE,
OC_STACK_NOT_ALLOWED_OXM,
+#ifdef WITH_PRESENCE
OC_STACK_PRESENCE_STOPPED,
OC_STACK_PRESENCE_TIMEOUT,
OC_STACK_PRESENCE_DO_NOT_HANDLE,
+#endif
OC_STACK_USER_DENIED_REQ,
OC_STACK_NOT_ACCEPTABLE,
OC_STACK_METHOD_NOT_ALLOWED,
OCPayloadDestroy((OCPayload *)platform1);
}
+#ifdef WITH_PRESENCE
TEST(PresencePayload, Normal)
{
static const char uri1[] = "/testuri";
OCPayloadDestroy(cparsed);
}
+#endif
// Representation Payloads
TEST(RepresentationEncoding, BaseAttributeTypes)
{
case OC_STACK_OK:
case OC_STACK_RESOURCE_CREATED:
case OC_STACK_RESOURCE_DELETED:
+#ifdef WITH_PRESENCE
case OC_STACK_PRESENCE_STOPPED:
+#endif
case OC_STACK_CONTINUE:
case OC_STACK_RESOURCE_CHANGED:
return true;
#define NS_DISCOVER_QUERY "/oic/res?rt=x.org.iotivity.notification"
#define NS_PRESENCE_SUBSCRIBE_QUERY_TCP "/oic/ad?rt=x.org.iotivity.notification"
+#ifdef WITH_PRESENCE
OCStackApplicationResult NSConsumerPresenceListener(
void * ctx, OCDoHandle handle, OCClientResponse * clientResponse)
{
return OC_STACK_KEEP_TRANSACTION;
}
+#endif
OCStackApplicationResult NSProviderDiscoverListener(
void * ctx, OCDoHandle handle, OCClientResponse * clientResponse)
else if (address->adapter == OC_ADAPTER_TCP)
{
type = CT_ADAPTER_TCP;
- NS_LOG(DEBUG, "Request discover and subscribe presence [TCP]");
+ NS_LOG(DEBUG, "Request discover [TCP]");
+#ifdef WITH_PRESENCE
NS_LOG(DEBUG, "Subscribe presence [TCP]");
NSInvokeRequest(NULL, OC_REST_PRESENCE, address, NS_PRESENCE_SUBSCRIBE_QUERY_TCP,
NULL, NSConsumerPresenceListener, NULL, NULL, type);
-
+#endif
if (rType == NS_DISCOVER_CLOUD)
{
callbackData = (void *) NS_DISCOVER_CLOUD;
void NSConsumerDiscoveryTaskProcessing(NSTask *);
+#ifdef WITH_PRESENCE
OCStackApplicationResult NSConsumerPresenceListener(void *, OCDoHandle, OCClientResponse *);
-
+#endif
// for discover result
OCStackApplicationResult NSProviderDiscoverListener(void *, OCDoHandle, OCClientResponse *);
// {
// return NS_ERROR;
// }
-
+ OCStackResult stackResult;
+#ifdef WITH_PRESENCE
NS_LOG(DEBUG, "Request to subscribe presence");
- OCStackResult stackResult = NSInvokeRequest(getPresenceHandle(), OC_REST_PRESENCE, NULL,
+ stackResult = NSInvokeRequest(getPresenceHandle(), OC_REST_PRESENCE, NULL,
NS_PRESENCE_SUBSCRIBE_QUERY, NULL, NSConsumerPresenceListener,
NULL, NULL, CT_DEFAULT);
NS_VERIFY_STACK_SUCCESS(NSOCResultToSuccess(stackResult), NS_ERROR);
-
+#endif
NS_LOG(DEBUG, "Request to discover provider");
stackResult = NSInvokeRequest(NULL, OC_REST_DISCOVER, NULL,
NS_DISCOVER_QUERY, NULL, NSProviderDiscoverListener,
\r
#include "NSProviderDiscovery.h"\r
\r
+#ifdef WITH_PRESENCE\r
NSResult NSStartPresence()\r
{\r
NS_LOG(DEBUG, "NSStartPresence()");\r
NS_LOG(DEBUG, "NSStopPresence() NS_OK");\r
return NS_OK;\r
}\r
+#endif\r
\r
void * NSDiscoverySchedule(void * ptr)\r
{\r
\r
switch (node->taskType)\r
{\r
+#ifdef WITH_PRESENCE\r
case TASK_START_PRESENCE:\r
NS_LOG(DEBUG, "CASE TASK_START_PRESENCE : ");\r
NSStartPresence();\r
NS_LOG(DEBUG, "CASE TASK_STOP_PRESENCE : ");\r
NSStopPresence();\r
break;\r
+#endif\r
case TASK_REGISTER_RESOURCE:\r
NS_LOG(DEBUG, "CASE TASK_REGISTER_RESOURCE : ");\r
NSRegisterResource();\r
#include "NSProviderScheduler.h"\r
#include "NSProviderResource.h"\r
\r
+#ifdef WITH_PRESENCE\r
NSResult NSStartPresence();\r
NSResult NSStopPresence();\r
+#endif\r
\r
#endif /* _NS_PROVIDER_DISCOVERY_H_ */\r
case OC_STACK_RESOURCE_DELETED:
case OC_STACK_TIMEOUT:
case OC_STACK_COMM_ERROR:
+#ifdef WITH_PRESENCE
case OC_STACK_PRESENCE_STOPPED:
case OC_STACK_PRESENCE_TIMEOUT:
case OC_STACK_PRESENCE_DO_NOT_HANDLE:
+#endif
{
setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
case OC_STACK_INVALID_REQUEST_HANDLE:
case OC_STACK_TIMEOUT:
case OC_STACK_COMM_ERROR:
+#ifdef WITH_PRESENCE
case OC_STACK_PRESENCE_STOPPED:
case OC_STACK_PRESENCE_TIMEOUT:
+#endif
default:
verifiedState = BROKER_STATE::LOST_SIGNAL;
break;
case OC_STACK_OK:
case OC_STACK_RESOURCE_CREATED:
case OC_STACK_RESOURCE_DELETED:
+#ifdef WITH_PRESENCE
case OC_STACK_PRESENCE_STOPPED:
+#endif
case OC_STACK_CONTINUE:
case OC_STACK_RESOURCE_CHANGED:
return true;