当前位置: 首页>>代码示例>>C++>>正文


C++ OC_LOG函数代码示例

本文整理汇总了C++中OC_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ OC_LOG函数的具体用法?C++ OC_LOG怎么用?C++ OC_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OC_LOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DetermineObserverQoS

// send notifications based on the qos of the request
// The qos passed as a parameter overrides what the client requested
// If we want the client preference taking high priority make:
// qos = resourceObserver->qos;
OCQualityOfService DetermineObserverQoS(OCMethod method, ResourceObserver * resourceObserver,
        OCQualityOfService appQoS)
{
    OCQualityOfService decidedQoS = appQoS;
    if(appQoS == OC_NA_QOS)
    {
        decidedQoS = resourceObserver->qos;
    }

    if(appQoS != OC_HIGH_QOS)
    {
        OC_LOG_V(INFO, TAG, "Current NON count for this observer is %d",
                resourceObserver->lowQosCount);
        #ifdef WITH_PRESENCE
        if((resourceObserver->forceHighQos \
                || resourceObserver->lowQosCount >= MAX_OBSERVER_NON_COUNT) \
                && method != OC_REST_PRESENCE)
        #else
        if(resourceObserver->forceHighQos \
                || resourceObserver->lowQosCount >= MAX_OBSERVER_NON_COUNT)
        #endif
            {
            resourceObserver->lowQosCount = 0;
            // at some point we have to to send CON to check on the
            // availability of observer
            OC_LOG(INFO, TAG, PCF("This time we are sending the  notification as High qos"));
            decidedQoS = OC_HIGH_QOS;
            }
        else
        {
            (resourceObserver->lowQosCount)++;
        }
    }
    return decidedQoS;
}
开发者ID:prajoshpremdas,项目名称:iotivity,代码行数:39,代码来源:ocobserve.c

示例2: loop

// The loop function is called in an endless loop
void loop()
{
    // This artificial delay is kept here to avoid endless spinning
    // of Arduino microcontroller. Modify it as per specfic application needs.

    if (OCProcess() != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, PCF("OCStack process error"));
        return;
    }

    char *user_cmd = NULL;

//  ble.pollingDisconnect();

    user_cmd = ble.Debug2BLE(true);
    ble.BLE2Debug( true );

    if ( user_cmd )
    {
        free( user_cmd );
        user_cmd = NULL;
    }

}
开发者ID:MCherifiOSS,项目名称:iotivity,代码行数:26,代码来源:trackee.cpp

示例3: SCOPE_LOG_F

        void RCSRemoteResourceObject::startCaching(CacheUpdatedCallback cb)
        {
            SCOPE_LOG_F(DEBUG, TAG);

            if (isCaching())
            {
                OC_LOG(DEBUG, TAG, "startCaching : already Started");
                throw RCSBadRequestException{ "Caching already started." };
            }

            if (cb)
            {
                m_cacheId = ResourceCacheManager::getInstance()->requestResourceCache(
                        m_primitiveResource,
                        std::bind(cachingCallback, std::placeholders::_1, std::placeholders::_2,
                                std::move(cb)), REPORT_FREQUENCY::UPTODATE, 0);
            }
            else
            {
                m_cacheId = ResourceCacheManager::getInstance()->requestResourceCache(
                        m_primitiveResource, { }, REPORT_FREQUENCY::NONE, 0);
            }

            OC_LOG_V(DEBUG, TAG, "startCaching CACHE ID %d", m_cacheId);
        }
开发者ID:Lyoncore,项目名称:iotivity-demo-uc15,代码行数:25,代码来源:RCSRemoteResourceObject.cpp

示例4: discoveryReqCB

// This is a function called back when a device is discovered
OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
                                        OCClientResponse * clientResponse)
{
    OC_LOG(INFO, TAG,
            "Entering discoveryReqCB (Application Layer CB)");
    OC_LOG_V(INFO, TAG, "StackResult: %s",
            getResult(clientResponse->result));

    if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
    {
        OC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
    }

    OC_LOG_V(INFO, TAG,
            "Device =============> Discovered @ %s:%d",
            clientResponse->devAddr.addr,
            clientResponse->devAddr.port);
    OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);

    ConnType = clientResponse->connType;

    if(TestType == TEST_UNKNOWN_RESOURCE_GET_DEFAULT || TestType == TEST_UNKNOWN_RESOURCE_GET_BATCH ||\
            TestType == TEST_UNKNOWN_RESOURCE_GET_LINK_LIST)
    {
        InitGetRequestToUnavailableResource(clientResponse);
    }
    else
    {
        InitGetRequest(clientResponse);
    }
    return OC_STACK_KEEP_TRANSACTION;
}
开发者ID:HoTaeWang,项目名称:iotivity,代码行数:33,代码来源:occlientcoll.cpp

示例5: PstatEntityHandler

/**
 * This internal method is the entity handler for pstat resources.
 */
OCEntityHandlerResult PstatEntityHandler(OCEntityHandlerFlag flag,
        OCEntityHandlerRequest * ehRequest,
        void *callbackParam)
{
    OCEntityHandlerResult ehRet = OC_EH_ERROR;
    // This method will handle REST request (GET/POST) for /oic/sec/pstat
    if (flag & OC_REQUEST_FLAG)
    {
        OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
        switch (ehRequest->method)
        {
            case OC_REST_GET:
                ehRet = HandlePstatGetRequest(ehRequest);
                break;
            case OC_REST_PUT:
                ehRet = HandlePstatPutRequest(ehRequest);
                break;
            default:
                ehRet = OC_EH_ERROR;
                SendSRMResponse(ehRequest, ehRet, NULL);
                break;
        }
    }
    return ehRet;
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:28,代码来源:pstatresource.c

示例6: InitObserveRequest

int InitObserveRequest(OCClientResponse * clientResponse)
{
    OCStackResult ret;
    OCCallbackData cbData;
    OCDoHandle handle;
    std::ostringstream obsReg;
    obsReg << getQueryStrForGetPut();
    cbData.cb = getReqCB;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;
    OC_LOG_V(INFO, TAG, "OBSERVE payload from client =");
    OCPayload* payload = putPayload();
    OC_LOG_PAYLOAD(INFO, TAG, payload);
    OCPayloadDestroy(payload);

    ret = OCDoResource(&handle, OC_REST_OBSERVE, obsReg.str().c_str(),
                       &clientResponse->devAddr, 0, ConnType,
                       OC_LOW_QOS, &cbData, NULL, 0);
    if (ret != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }
    else
    {
        gObserveDoHandle = handle;
    }
    return ret;
}
开发者ID:HoTaeWang,项目名称:iotivity,代码行数:28,代码来源:occlientcoll.cpp

示例7: InitDoxmResource

/**
 * Initialize DOXM resource by loading data from persistent storage.
 *
 * @retval  OC_STACK_OK for Success, otherwise some error value
 */
OCStackResult InitDoxmResource()
{
    OCStackResult ret = OC_STACK_ERROR;

    //Read DOXM resource from PS
    char* jsonSVRDatabase = GetSVRDatabase();
    if(jsonSVRDatabase)
    {
        //Convert JSON DOXM into binary format
        gDoxm = JSONToDoxmBin(jsonSVRDatabase, true);
    }
    /*
     * If SVR database in persistent storage got corrupted or
     * is not available for some reason, a default doxm is created
     * which allows user to initiate doxm provisioning again.
     */
    if(!jsonSVRDatabase || !gDoxm)
    {
        gDoxm = GetDoxmDefault();
    }
    ret = CheckDeviceID();
    if (ret == OC_STACK_OK)
    {
        //Instantiate 'oic.sec.doxm'
        ret = CreateDoxmResource();
    }
    else
    {
        OC_LOG (ERROR, TAG, "CheckDeviceID failed");
    }
    OICFree(jsonSVRDatabase);
    return ret;
}
开发者ID:chetan336,项目名称:iotivity,代码行数:38,代码来源:doxmresource.c

示例8: DoxmEntityHandler

/*
 * This internal method is the entity handler for DOXM resources.
 */
OCEntityHandlerResult DoxmEntityHandler (OCEntityHandlerFlag flag,
                                        OCEntityHandlerRequest * ehRequest,
                                        void* callbackParam)
{
    (void)callbackParam;
    OCEntityHandlerResult ehRet = OC_EH_ERROR;

    if(NULL == ehRequest)
    {
        return ehRet;
    }


    if (flag & OC_REQUEST_FLAG)
    {
        OC_LOG (DEBUG, TAG, "Flag includes OC_REQUEST_FLAG");
        switch (ehRequest->method)
        {
            case OC_REST_GET:
                ehRet = HandleDoxmGetRequest(ehRequest);
                break;

            case OC_REST_PUT:
                ehRet = HandleDoxmPutRequest(ehRequest);
                break;

            default:
                ehRet = OC_EH_ERROR;
                SendSRMResponse(ehRequest, ehRet, NULL);
                break;
        }
    }

    return ehRet;
}
开发者ID:chetan336,项目名称:iotivity,代码行数:38,代码来源:doxmresource.c

示例9: constructResponse

OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest)
{
    OCRepPayload* payload = OCRepPayloadCreate();
    if (!payload)
    {
        OC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
        return NULL;
    }

    if (ehRequest->resource == g_prov.handle)
    {
        OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PS, g_prov.ps);
        OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_TNT, g_prov.tnt);
        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_TNN, g_prov.tnn);
        OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CD, g_prov.cd);
    }
    else if (ehRequest->requestHandle == g_net.handle)
    {

        OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_NET);
        OCRepPayloadSetPropInt(payload, "ant", g_net.ant[0]);
    }
    return payload;
}
开发者ID:tienfuc,项目名称:iotivity-democlient-snap,代码行数:25,代码来源:resourceHandler.cpp

示例10: getReqCB

OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
                                  OCClientResponse * clientResponse)
{
    OC_LOG_V(INFO, TAG, "StackResult: %s",
            getResult(clientResponse->result));
    if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
    {
        OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
        if(clientResponse->sequenceNumber == 0)
        {
            OC_LOG_V(INFO, TAG, "Callback Context for GET query recvd successfully");
            OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
        }
        else
        {
            OC_LOG_V(INFO, TAG, "Callback Context for Get recvd successfully %d",
                    gNumObserveNotifies);
            OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);;
            gNumObserveNotifies++;
            if (gNumObserveNotifies == 3)
            {
                if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
                {
                    OC_LOG(ERROR, TAG, "Observe cancel error");
                }
            }
        }
    }
    if(TestType == TEST_PUT_DEFAULT || TestType == TEST_PUT_BATCH || TestType == TEST_PUT_LINK_LIST)
    {
        InitPutRequest(clientResponse);
    }
    return OC_STACK_KEEP_TRANSACTION;
}
开发者ID:HoTaeWang,项目名称:iotivity,代码行数:34,代码来源:occlientcoll.cpp

示例11: OCEntityHandlerCb

// This is the entity handler for the registered resource.
// This is invoked by OCStack whenever it recevies a request for this resource.
OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
                                        OCEntityHandlerRequest *entityHandlerRequest )
{
    OCEntityHandlerResult ehRet = OC_EH_OK;

    if (entityHandlerRequest )
    {
        if (flag & OC_REQUEST_FLAG)
        {
            OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
            if (OC_REST_GET == entityHandlerRequest->method)
            {
                if ( JsonGenerator( (char *)entityHandlerRequest->resJSONPayload,
                                    entityHandlerRequest->resJSONPayloadLen ) == false )
                {
                    ehRet  = OC_EH_ERROR;
                }
            }
            if (OC_REST_PUT == entityHandlerRequest->method)
            {
                if (JsonGenerator( (char *)entityHandlerRequest->resJSONPayload,
                                   entityHandlerRequest->resJSONPayloadLen ) == false )
                {
                    ehRet  = OC_EH_ERROR;
                }
            }

        }
        else if (flag & OC_OBSERVE_FLAG)
        {
            OC_LOG (INFO, TAG, PCF("Flag includes OC_OBSERVE_FLAG"));
            if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo->action)
            {
                OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
                g_PROXIUnderObservation = 1;
            }
            else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo->action)
            {
                OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
            }
        }

        Serial.println((char *)entityHandlerRequest->resJSONPayload);
    }

    return ehRet;
}
开发者ID:HoTaeWang,项目名称:iotivity,代码行数:49,代码来源:trackee.cpp

示例12: OCEntityHandlerCb

// This is the entity handler for the registered resource.
// This is invoked by OCStack whenever it recevies a request for this resource.
OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
                                        OCEntityHandlerRequest *entityHandlerRequest )
{
    OCEntityHandlerResult ehRet = OC_EH_OK;

    if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
    {
        OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
        if (OC_REST_GET == entityHandlerRequest->method)
        {
            if (JsonGenerator((char *)entityHandlerRequest->resJSONPayload, \
                              entityHandlerRequest->resJSONPayloadLen))
            {
            }
            else
            {
                ehRet = OC_EH_ERROR;
            }
        }
        if (OC_REST_PUT == entityHandlerRequest->method)
        {
            //Do something with the 'put' payload
            if (JsonGenerator((char *)entityHandlerRequest->resJSONPayload, \
                              entityHandlerRequest->resJSONPayloadLen))
            {
            }
            else
            {
                ehRet = OC_EH_ERROR;
            }
        }
    }
    if (entityHandlerRequest && (flag & OC_OBSERVE_FLAG))
    {
        if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo->action)
        {
            OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
            g_PROXIUnderObservation = 1;
        }
        else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo->action)
        {
            OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
        }
    }

    return ehRet;
}
开发者ID:EmuxEvans,项目名称:iotivity,代码行数:49,代码来源:trackee.cpp

示例13: SetResult

/**
 * Function to save the result of provisioning.
 *
 * @param[in,out] otmCtx   Context value of ownership transfer.
 * @param[in] res   result of provisioning
 */
static void SetResult(OTMContext_t* otmCtx, const OCStackResult res)
{
    OC_LOG_V(DEBUG, TAG, "IN SetResult : %d ", res);

    if(!otmCtx)
    {
        OC_LOG(WARNING, TAG, "OTMContext is NULL");
        return;
    }

    if(otmCtx->selectedDeviceInfo)
    {
        for(size_t i = 0; i < otmCtx->ctxResultArraySize; i++)
        {
            if(memcmp(otmCtx->selectedDeviceInfo->doxm->deviceID.id,
                      otmCtx->ctxResultArray[i].deviceId.id, UUID_LENGTH) == 0)
            {
                otmCtx->ctxResultArray[i].res = res;
                if(OC_STACK_OK != res)
                {
                    otmCtx->ctxHasError = true;
                }
            }
        }

        g_otmCtx = NULL;

        //If all request is completed, invoke the user callback.
        if(IsComplete(otmCtx))
        {
            otmCtx->ctxResultCallback(otmCtx->userCtx, otmCtx->ctxResultArraySize,
                                       otmCtx->ctxResultArray, otmCtx->ctxHasError);
            OICFree(otmCtx->ctxResultArray);
            OICFree(otmCtx);
        }
        else
        {
            if(OC_STACK_OK != StartOwnershipTransfer(otmCtx,
                                                     otmCtx->selectedDeviceInfo->next))
            {
                OC_LOG(ERROR, TAG, "Failed to StartOwnershipTransfer");
            }
        }
    }

    OC_LOG(DEBUG, TAG, "OUT SetResult");
}
开发者ID:keyfour,项目名称:iotivity,代码行数:53,代码来源:ownershiptransfermanager.c

示例14: InitDiscovery

int InitDiscovery()
{
    OCStackResult ret;
    OCCallbackData cbData;
    /* Start a discovery query*/
    char szQueryUri[64] = {};
    if (UNICAST_DISCOVERY)
    {
        char ipv4addr[IPV4_ADDR_SIZE];
        printf("Enter IPv4 address of the Server hosting "
               "resource (Ex: 192.168.0.15)\n");
        if (fgets(ipv4addr, IPV4_ADDR_SIZE, stdin))
        {
            //Strip newline char from ipv4addr
            StripNewLineChar(ipv4addr);
            snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DISCOVERY_QUERY, ipv4addr);
        }
        else
        {
            OC_LOG(ERROR, TAG, "!! Bad input for IPV4 address. !!");
            return OC_STACK_INVALID_PARAM;
        }
    }
    else
    {
        strcpy(szQueryUri, MULTICAST_RESOURCE_DISCOVERY_QUERY);
    }
    cbData.cb = discoveryReqCB;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;
    if (UNICAST_DISCOVERY)
    {
        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_CONNTYPE,
                OC_LOW_QOS, &cbData, NULL, 0);
    }
    else
    {
        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, (OC_ALL),
                OC_LOW_QOS, &cbData, NULL, 0);
    }

    if (ret != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }
    return ret;
}
开发者ID:sonicbison,项目名称:iotivity,代码行数:47,代码来源:occlientbasicops.cpp

示例15: AmsMgrDiscoveryCallback

static OCStackApplicationResult AmsMgrDiscoveryCallback(void *ctx, OCDoHandle handle,
                         OCClientResponse * clientResponse)
{
    OC_LOG_V(INFO, TAG, "%s Begin", __func__ );

    if (!ctx ||
        !clientResponse ||
        !clientResponse->payload||
        (PAYLOAD_TYPE_SECURITY != clientResponse->payload->type)||
        (OC_STACK_OK != clientResponse->result))
    {
        OC_LOG_V(ERROR, TAG, "%s Invalid Response ", __func__);
        return OC_STACK_KEEP_TRANSACTION;
    }

    (void)handle;
    PEContext_t *context = (PEContext_t *) ctx;
    if (context->state != AWAITING_AMS_RESPONSE)
    {
        OC_LOG_V(ERROR, TAG, "%s Invalid PE State ", __func__);
        return OC_STACK_DELETE_TRANSACTION;
    }

    OicSecDoxm_t *doxm = NULL;
    OC_LOG_V(INFO, TAG, "Doxm DeviceId Discovery response = %s\n",
          ((OCSecurityPayload*)clientResponse->payload)->securityData);
    doxm = JSONToDoxmBin(((OCSecurityPayload*)clientResponse->payload)->securityData);

    //As doxm is NULL amsmgr can't test if response from trusted AMS service
    //so keep the transaction.
    if(NULL == doxm)
    {
        OC_LOG_V(ERROR, TAG, "%s : Unable to convert JSON to Binary",__func__);
        return OC_STACK_KEEP_TRANSACTION;
    }

    OicUuid_t deviceId = {.id={}};
    memcpy(&deviceId, &doxm->deviceID, sizeof(deviceId));
    OICFree(doxm);

    /* TODO : By assuming that the first response received is the actual
     * AMS service, a 'bad device' can cause DoS attack.
     */
    if (memcmp(&context->amsMgrContext->amsDeviceId, &deviceId,
            sizeof(context->amsMgrContext->amsDeviceId)) == 0)
    {
        OC_LOG(INFO, TAG, "AMS Manager Sending unicast discovery to get secured port info");
        //Sending Unicast discovery to get secure port information
        if(OC_STACK_OK == SendUnicastSecurePortDiscovery(context, &clientResponse->devAddr,
                clientResponse->connType))
        {
            context->retVal = ACCESS_WAITING_FOR_AMS;
            return OC_STACK_DELETE_TRANSACTION;
        }
    }
    context->retVal = ACCESS_DENIED_AMS_SERVICE_ERROR;
    SRMSendResponse(context->retVal);
    return OC_STACK_DELETE_TRANSACTION;
}
开发者ID:keyfour,项目名称:iotivity,代码行数:59,代码来源:amsmgr.c


注:本文中的OC_LOG函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。