stackState = OC_STACK_UNINIT_IN_PROGRESS;
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
// Ensure that the TTL associated with ANY and ALL presence notifications originating from
// here send with the code "OC_STACK_PRESENCE_STOPPED" result.
presenceResource.presenceTTL = 0;
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
// Free memory dynamically allocated for resources
deleteAllResources();
// CA_DISCOVER will become GET and isMulticast
requestInfo.method = CA_GET;
break;
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
case OC_REST_PRESENCE:
// Replacing method type with GET because "presence"
// is a stack layer only implementation.
requestInfo.method = CA_GET;
break;
- #endif
+#endif
default:
result = OC_STACK_INVALID_METHOD;
goto exit;
}
// prepare for response
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
if (method == OC_REST_PRESENCE)
{
char *presenceUri = NULL;
// look for callbacks into the application.
resourceUri = presenceUri;
}
- #endif
+#endif
ttl = GetTicks(MAX_CB_TIMEOUT_SECONDS * MILLISECONDS_PER_SECOND);
result = AddClientCB(&clientCB, cbData, token, tokenLength, &resHandle,
ret = CAResultToOCResult (caResult);
break;
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
case OC_REST_PRESENCE:
FindAndDeleteClientCB(clientCB);
break;
- #endif
+#endif
default:
ret = OC_STACK_INVALID_METHOD;
OCStackResult OCProcess()
{
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
OCProcessPresence();
- #endif
+#endif
CAHandleRequestResponse();
return OC_STACK_OK;
*handle = pointer;
result = OC_STACK_OK;
- #ifdef WITH_PRESENCE
- if(presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(pointer->rsrcType, OC_PRESENCE_TRIGGER_CREATE);
}
- #endif
+#endif
exit:
if (result != OC_STACK_OK)
{
resource->rsrcResources[i] = (OCResource *) resourceHandle;
OC_LOG(INFO, TAG, PCF("resource bound"));
- #ifdef WITH_PRESENCE
- if(presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(((OCResource *) resourceHandle)->rsrcType,
OC_PRESENCE_TRIGGER_CHANGE);
}
- #endif
+#endif
return OC_STACK_OK;
}
OC_LOG(INFO, TAG, PCF("resource unbound"));
// Send notification when resource is unbounded successfully.
- #ifdef WITH_PRESENCE
- if(presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(((OCResource *) resourceHandle)->rsrcType,
OC_PRESENCE_TRIGGER_CHANGE);
}
- #endif
+#endif
return OC_STACK_OK;
}
}
result = BindResourceTypeToResource(resource, resourceTypeName);
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
if(presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(resource->rsrcType, OC_PRESENCE_TRIGGER_CHANGE);
}
- #endif
+#endif
return result;
}
result = BindResourceInterfaceToResource(resource, resourceInterfaceName);
- #ifdef WITH_PRESENCE
- if(presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(resource->rsrcType, OC_PRESENCE_TRIGGER_CHANGE);
}
- #endif
+#endif
return result;
}
resource->entityHandler = entityHandler;
resource->entityHandlerCallbackParam = callbackParam;
- #ifdef WITH_PRESENCE
- if(presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (presenceResource.handle)
{
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(resource->rsrcType, OC_PRESENCE_TRIGGER_CHANGE);
}
- #endif
+#endif
return OC_STACK_OK;
}
uint32_t maxAge = 0;
OC_LOG(INFO, TAG, PCF("Notifying all observers"));
- #ifdef WITH_PRESENCE
- if(handle == presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (handle == presenceResource.handle)
{
return OC_STACK_OK;
}
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
VERIFY_NON_NULL(handle, ERROR, OC_STACK_ERROR);
// Verify that the resource exists
incrementSequenceNumber(resPtr);
method = OC_REST_OBSERVE;
maxAge = MAX_OBSERVE_AGE;
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
result = SendAllObserverNotification (method, resPtr, maxAge,
OC_PRESENCE_TRIGGER_DELETE, NULL, qos);
- #else
+#else
result = SendAllObserverNotification (method, resPtr, maxAge, qos);
- #endif
+#endif
return result;
}
}
headResource = NULL;
tailResource = NULL;
// Init Virtual Resources
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
presenceResource.presenceTTL = OC_DEFAULT_PRESENCE_TTL_SECONDS;
result = OCCreateResource(&presenceResource.handle,
result = OCChangeResourceProperty(
&(((OCResource *) presenceResource.handle)->resourceProperties),
OC_ACTIVE, 0);
- #endif
+#endif
if (result == OC_STACK_OK)
{
while (pointer)
{
temp = pointer->next;
- #ifdef WITH_PRESENCE
- if(pointer != (OCResource *) presenceResource.handle)
+#ifdef WITH_PRESENCE
+ if (pointer != (OCResource *) presenceResource.handle)
{
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
deleteResource(pointer);
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
}
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
pointer = temp;
}
SRMDeInitSecureResources();
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
// Ensure that the last resource to be deleted is the presence resource. This allows for all
// presence notification attributed to their deletion to be processed.
deleteResource((OCResource *) presenceResource.handle);
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
}
OCStackResult deleteResource(OCResource *resource)
{
// Invalidate all Resource Properties.
resource->resourceProperties = (OCResourceProperty) 0;
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
if(resource != (OCResource *) presenceResource.handle)
{
- #endif // WITH_PRESENCE
+#endif // WITH_PRESENCE
OCNotifyAllObservers((OCResourceHandle)resource, OC_HIGH_QOS);
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
}
if(presenceResource.handle)
((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
SendPresenceNotification(resource->rsrcType, OC_PRESENCE_TRIGGER_DELETE);
}
- #endif
+#endif
// Only resource in list.
if (temp == headResource && temp == tailResource)
{
CA_ADAPTER_RFCOMM_BTEDR,
CA_ADAPTER_GATT_BTLE
- #ifdef RA_ADAPTER
+#ifdef RA_ADAPTER
,CA_ADAPTER_REMOTE_ACCESS
- #endif
+#endif
};
int numConnTypes = sizeof(connTypes)/sizeof(connTypes[0]);