-#else
-OCStackResult OCProcessPresence()
-{
- OCStackResult result = OC_STACK_OK;
- uint8_t ipAddr[4] = { 0 };
- uint16_t port = 0;
-
- ClientCB* cbNode = NULL;
- OCDevAddr dst;
- OCClientResponse clientResponse;
- OCResponse * response = NULL;
-
- LL_FOREACH(cbList, cbNode) {
- if(OC_REST_PRESENCE == cbNode->method)
- {
- if(cbNode->presence)
- {
- uint32_t now = GetTime(0);
- OC_LOG_V(DEBUG, TAG, "----------------this TTL level %d", cbNode->presence->TTLlevel);
- OC_LOG_V(DEBUG, TAG, "----------------current ticks %d", now);
-
-
- if(cbNode->presence->TTLlevel >= (PresenceTimeOutSize + 1))
- {
- goto exit;
- }
-
- if(cbNode->presence->TTLlevel < PresenceTimeOutSize){
- OC_LOG_V(DEBUG, TAG, "----------------timeout ticks %d",
- cbNode->presence->timeOut[cbNode->presence->TTLlevel]);
- }
-
- if(cbNode->presence->TTLlevel >= PresenceTimeOutSize)
- {
- OC_LOG(DEBUG, TAG, PCF("----------------No more timeout ticks"));
- if (ParseIPv4Address( cbNode->requestUri, ipAddr, &port))
- {
- OCBuildIPv4Address(ipAddr[0], ipAddr[1], ipAddr[2], ipAddr[3], port,
- &dst);
- result = FormOCClientResponse(&clientResponse, OC_STACK_PRESENCE_TIMEOUT,
- (OCDevAddr *) &dst, 0, NULL);
- if(result != OC_STACK_OK)
- {
- goto exit;
- }
- result = FormOCResponse(&response, cbNode, 0, NULL, NULL,
- &cbNode->token, &clientResponse, NULL);
- if(result != OC_STACK_OK)
- {
- goto exit;
- }
-
- // Increment the TTLLevel (going to a next state), so we don't keep
- // sending presence notification to client.
- cbNode->presence->TTLlevel++;
- OC_LOG_V(DEBUG, TAG, "----------------moving to TTL level %d",
- cbNode->presence->TTLlevel);
- }
- else
- {
- result = OC_STACK_INVALID_IP;
- goto exit;
- }
- HandleStackResponses(response);
- }
- if(now >= cbNode->presence->timeOut[cbNode->presence->TTLlevel])
- {
- OC_LOG(DEBUG, TAG, PCF("time to test server presence =========="));
-
-#ifdef CA_INT
- CAToken_t token = NULL;
- CAResult_t caResult = CAGenerateToken(&token);
- if (caResult != CA_STATUS_OK)
- {
- CADestroyToken(token);
- goto exit;
- }
-#else
- OCCoAPToken token;
- OCGenerateCoAPToken(&token);
-
- result = OCDoCoAPResource(OC_REST_GET, OC_LOW_QOS,
- &token, (const char *)cbNode->requestUri, NULL, NULL, 0);
-
- if(result != OC_STACK_OK)
- {
- goto exit;
- }
-#endif // CA_INT
- cbNode->presence->TTLlevel++;
- OC_LOG_V(DEBUG, TAG, "----------------moving to TTL level %d", cbNode->presence->TTLlevel);
- }
- }
- }
- }
-exit:
- if (result != OC_STACK_OK)
- {
- OC_LOG(ERROR, TAG, PCF("OCProcessPresence error"));
- }
- return result;
-}
-#endif // CA_INT