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


C++ OCDoResource函数代码示例

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


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

示例1: InitDiscovery

int InitDiscovery(OCQualityOfService qos)
{
    OCStackResult ret;
    OCCallbackData cbData;
    /* Start a discovery query*/
    char szQueryUri[64] = { 0 };

    if (UNICAST_DISCOVERY)
    {
        snprintf(szQueryUri, sizeof(szQueryUri), UNICAST_DISCOVERY_QUERY, ipv4addr);
    }
    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,
                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
    }
    else
    {
        ret = OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, (OC_ALL),
                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS, &cbData, NULL, 0);
    }
    if (ret != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }
    return ret;
}
开发者ID:EmuxEvans,项目名称:iotivity,代码行数:35,代码来源:occlient.cpp

示例2: OCDoResource

OCStackResult InProcClientWrapper::SubscribePresence(OCDoHandle* handle,
        const std::string& host, const std::string& resourceType,
        SubscribeCallback& presenceHandler)
{
    OCCallbackData cbdata = {0};

    ClientCallbackContext::SubscribePresenceContext* ctx =
        new ClientCallbackContext::SubscribePresenceContext();
    ctx->callback = presenceHandler;
    cbdata.cb = &subscribePresenceCallback;
    cbdata.context = static_cast<void*>(ctx);
    cbdata.cd = [](void* c)
    {
        delete static_cast<ClientCallbackContext::SubscribePresenceContext*>(c);
    };
    auto cLock = m_csdkLock.lock();

    std::ostringstream os;
    os << host << "/oc/presence";

    if(!resourceType.empty())
    {
        os << "?rt=" << resourceType;
    }

    if(!cLock)
    {
        delete ctx;
        return OC_STACK_ERROR;
    }

    return OCDoResource(handle, OC_REST_PRESENCE, os.str().c_str(), nullptr, nullptr,
                        OC_LOW_QOS, &cbdata, NULL, 0);
}
开发者ID:TizenTeam,项目名称:iotivity,代码行数:34,代码来源:InProcClientWrapper.cpp

示例3: InvokeOCDoResource

OCStackResult InvokeOCDoResource(char *query,
                                 OCMethod method, OCQualityOfService qos,
                                 OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions, struct cmd *command)
{
    OCStackResult ret;
    OCCallbackData cbData;
    OCDoHandle handle;

    cbData.cb = cb;
//    cbData.context = (void*)CTX_VAL;
    cbData.context = (void *)(command->cbctx);
    cbData.cd = NULL;
	
        printf("query=%s\n", query);

	ret = OCDoResource(&handle, method, query, 0,
                (method == OC_REST_PUT) ? command->putpayload : NULL,
                qos, &cbData, options, numOptions);

	if (ret != OC_STACK_OK)
	{
		OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
	}
	else if (method == OC_REST_OBSERVE || method == OC_REST_OBSERVE_ALL)
	{
		gObserveDoHandle = handle;
	}

    return ret;
}
开发者ID:WorksSystems,项目名称:wks_oic_raclient,代码行数:30,代码来源:main.c

示例4: SendGetRequest

OCStackResult SendGetRequest(OCDPDev_t* peer)
{
    OIC_LOG(INFO, TAG, "Send Get REQ to Led server");

    char szQueryUri[] = "/a/led";
    OCDoHandle handle;
    OCCallbackData cbData;
    OCDevAddr endpoint;
    OCStackResult ret;

    memcpy(&endpoint, &peer->endpoint, sizeof(OCDevAddr));
    endpoint.port = peer->securePort;
    endpoint.flags = (OCTransportFlags)(endpoint.flags | OC_SECURE);

    cbData.cb = getReqCB;
    cbData.context = NULL;
    cbData.cd = NULL;

    OIC_LOG(INFO, TAG, "Request to /a/light ");
    ret = OCDoResource(&handle, OC_REST_GET, szQueryUri,
               &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0);
    if (ret != OC_STACK_OK)
    {
        OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, OC_REST_GET);
    }

    return ret;
}
开发者ID:aaronkim,项目名称:iotivity,代码行数:28,代码来源:occlientdirectpairing.cpp

示例5: SendPingMessage

OCStackResult SendPingMessage(KeepAliveEntry_t *entry)
{
    VERIFY_NON_NULL(entry, FATAL, OC_STACK_INVALID_PARAM);

    // Send ping message.
    OCCallbackData pingData = { .context = NULL, .cb = PingRequestCallback };
    OCDevAddr devAddr = { .adapter = OC_ADAPTER_TCP };
    CopyEndpointToDevAddr(&(entry->remoteAddr), &devAddr);

    OCRepPayload *payload = OCRepPayloadCreate();
    if (!payload)
    {
        OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
        return OC_STACK_ERROR;
    }
    payload->base.type = PAYLOAD_TYPE_REPRESENTATION;
    OCRepPayloadSetPropInt(payload, INTERVAL, entry->interval);

    OCDoResource(NULL, OC_REST_PUT, KEEPALIVE_RESOURCE_URI, &devAddr,
                 (OCPayload *) payload, CT_ADAPTER_TCP, OC_LOW_QOS, &pingData, NULL, 0);

    // Update timeStamp with time sent ping message for next ping message.
    entry->timeStamp = OICGetCurrentTime(TIME_IN_US);
    entry->sentPingMsg = true;

    OIC_LOG_V(DEBUG, TAG, "Client sent ping message, interval [%d]", entry->interval);

    return OC_STACK_OK;
}
开发者ID:Subh1994,项目名称:iotivity,代码行数:29,代码来源:oickeepalive.c

示例6: InvokeOCDoResource

OCStackResult InvokeOCDoResource(std::ostringstream &query,
                                 OCMethod method,
                                 const OCDevAddr *dest,
                                 OCQualityOfService qos,
                                 OCClientResponseHandler cb,
                                 OCHeaderOption * options, uint8_t numOptions)
{
    OCStackResult ret;
    OCCallbackData cbData;

    cbData.cb = cb;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;

    ret = OCDoResource(NULL, method, query.str().c_str(), dest,
        (method == OC_REST_PUT || method == OC_REST_POST) ? putPayload() : NULL,
         CT_DEFAULT, qos, &cbData, options, numOptions);

    if (ret != OC_STACK_OK)
    {
        OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d",
                 ret, method);
    }

    return ret;
}
开发者ID:TianyouLi,项目名称:iotivity,代码行数:26,代码来源:occlientbasicops.cpp

示例7: InvokeOCDoResource

OCStackResult InvokeOCDoResource(std::ostringstream &query,
                                 OCDevAddr *remoteAddr,
                                 OCMethod method,
                                 OCQualityOfService qos,
                                 OCClientResponseHandler cb,
                                 OCHeaderOption * options,
                                 uint8_t numOptions)
{
    OCStackResult ret;
    OCCallbackData cbData;
    OCDoHandle handle;

    cbData.cb = cb;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;

    ret = OCDoResource(&handle, method, query.str().c_str(), remoteAddr,
                       (method == OC_REST_PUT) ? putPayload() : NULL,
                       (ConnType), qos, &cbData, options, numOptions);

    if (ret != OC_STACK_OK)
    {
        OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
    }
#ifdef WITH_PRESENCE
    else if (method == OC_REST_PRESENCE)
    {
        gPresenceHandle = handle;
    }
#endif

    return ret;
}
开发者ID:InfiniteDevelopment,项目名称:iotivity,代码行数:33,代码来源:occlient.cpp

示例8: InitDiscovery

int InitDiscovery(OCQualityOfService qos)
{
    OCCallbackData cbData;
    cbData.cb       = discoveryReqCB;
    cbData.context  = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd       = NULL;

    OCDevAddr dest;
    dest.adapter    = OC_ADAPTER_REMOTE_ACCESS;
    dest.flags      = OC_DEFAULT_FLAGS;
    strncpy (dest.addr, remoteServerJabberID, MAX_ADDR_STR_SIZE - 1);

    OCStackResult ret = OCDoResource(NULL,
                OC_REST_GET,
                MULTICAST_RESOURCE_DISCOVERY_QUERY,
                &dest,
                NULL,
                CT_ADAPTER_REMOTE_ACCESS,
                (qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
                &cbData,
                NULL,
                0
            );

    if (ret != OC_STACK_OK)
    {
        OC_LOG_V(ERROR, TAG, "Error %u in OCDoResource with discovery", ret);
    }
    return ret;
}
开发者ID:chetan336,项目名称:iotivity,代码行数:30,代码来源:ocremoteaccessclient.cpp

示例9: InitDiscovery

int InitDiscovery()
{
    OCStackResult ret;
    OCCallbackData cbData;
    OCDoHandle handle;
    /* Start a discovery query*/
    char szQueryUri[64] = { 0 };
    if (UNICAST_DISCOVERY)
    {
        strcpy(szQueryUri, TEST_APP_UNICAST_DISCOVERY_QUERY);
    }
    else
    {
        strcpy(szQueryUri, OC_WELL_KNOWN_QUERY);
    }
    cbData.cb = discoveryReqCB;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;
    ret = OCDoResource(&handle, OC_REST_GET, szQueryUri, 0, 0, OC_LOW_QOS, &cbData, NULL, 0);
    if (ret != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }
    return ret;
}
开发者ID:prajoshpremdas,项目名称:iotivity,代码行数:25,代码来源:occlientbasicops.cpp

示例10: InitGetRequest

int InitGetRequest(OCClientResponse * clientResponse)
{
    OCStackResult ret;
    OCCallbackData cbData;

    //* Make a GET query*/
    std::ostringstream getQuery;
    getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
            clientResponse->devAddr.port <<
            "/a/room" << queryInterface[TEST].text;

    std::cout << "Get Query: " << getQuery.str() << std::endl;

    cbData.cb = getReqCB;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;
    ret = OCDoResource(NULL, OC_REST_GET,
            getQuery.str().c_str(), 0, 0, OC_CONNTYPE, OC_LOW_QOS,
            &cbData, NULL, 0);
    if (ret != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }
    return ret;
}
开发者ID:darcyg,项目名称:iotivity-1,代码行数:25,代码来源:occlientcoll.cpp

示例11: OCCloudSignup

OCStackResult OCCloudSignup(const char *host, const char *deviceId,
        const char *authprovider,
        const char *authcode, OCClientResponseHandler response)
{
        char    targetUri[MAX_URI_LENGTH * 2] = { 0, };
        snprintf(targetUri, MAX_URI_LENGTH * 2, "%s%s", host, DEFAULT_AUTH_SIGNUP);

        OCCallbackData cbData;
        memset(&cbData, 0, sizeof(OCCallbackData));
        cbData.cb = response;
        cbData.cd = NULL;
        cbData.context = (void *)DEFAULT_CONTEXT_VALUE;

        printf("Host: %s\n", targetUri);
        printf("Dev id: %s\n", deviceId);
        printf("Auth Provider: %s\n", authprovider);
        printf("Auth Code: %s\n", authcode);

        OCRepPayload *registerPayload = OCRepPayloadCreate();

        OCRepPayloadSetPropString(registerPayload, "di", deviceId);
        OCRepPayloadSetPropString(registerPayload, "authprovider", authprovider);
        OCRepPayloadSetPropString(registerPayload, "authcode", authcode);

        return OCDoResource(NULL, OC_REST_POST, targetUri, NULL, (OCPayload *)registerPayload,
                CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:27,代码来源:cloud_connector.c

示例12: OCCloudSession

OCStackResult OCCloudSession(const char *host, const char *query, const char *uId,
        const char *deviceId,
        const char *accesstoken,
        bool isLogin, OCClientResponseHandler response)
{
        char    targetUri[MAX_URI_LENGTH * 2] = { 0, };
        snprintf(targetUri, MAX_URI_LENGTH * 2, "%s%s", host, query);

        OCCallbackData cbData;
        memset(&cbData, 0, sizeof(OCCallbackData));
        cbData.cb = response;
        cbData.cd = NULL;
        cbData.context = (void *)DEFAULT_CONTEXT_VALUE;

        OCRepPayload *loginoutPayload = OCRepPayloadCreate();

        if (uId != NULL)
        {
                OCRepPayloadSetPropString(loginoutPayload, "uid", uId);
        }

        if (deviceId != NULL)
        {
                OCRepPayloadSetPropString(loginoutPayload, "di", deviceId);
        }

        if (accesstoken != NULL)
        {
                OCRepPayloadSetPropString(loginoutPayload, "accesstoken", accesstoken);
        }
        OCRepPayloadSetPropBool(loginoutPayload, "login", isLogin);

        return OCDoResource(NULL, OC_REST_POST, targetUri, NULL, (OCPayload *)loginoutPayload,
                CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:35,代码来源:cloud_connector.c

示例13: ErrorCallback

void *FindProvisioningResource(void *data) {

    // If user stopped the process before thread get scheduled then check and return from this function;
    if (IsSetupStopped()) {
        ErrorCallback(DEVICE_NOT_PROVISIONED);
        ClearMemory();
        return NULL;
    }

    OCStackResult ret = OC_STACK_ERROR;

    OIC_LOG_V(DEBUG, TAG, "szFindResourceQueryUri = %s", szFindResourceQueryUri);

    OCCallbackData ocCBData;

    ocCBData.cb = FindProvisioningResourceResponse;
    ocCBData.context = (void *) EASY_SETUP_DEFAULT_CONTEXT_VALUE;
    ocCBData.cd = NULL;


    ret = OCDoResource(NULL, OC_REST_DISCOVER, szFindResourceQueryUri, NULL, NULL,
                       netProvInfo->connType, OC_LOW_QOS,
                       &ocCBData, NULL, 0);

    if (ret != OC_STACK_OK) {
        ErrorCallback(DEVICE_NOT_PROVISIONED);
        ClearMemory();
    }

    return NULL;
}
开发者ID:tienfuc,项目名称:iotivity-democlient-snap,代码行数:31,代码来源:provisioning.cpp

示例14: cbdata

    OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
        const OCDevAddr& devAddr,
        const std::string& uri,
        const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
        ObserveCallback& callback, QualityOfService QoS)
    {
        if(!callback)
        {
            return OC_STACK_INVALID_PARAM;
        }
        OCStackResult result;

        ClientCallbackContext::ObserveContext* ctx =
            new ClientCallbackContext::ObserveContext(callback);
        OCCallbackData cbdata(
                static_cast<void*>(ctx),
                observeResourceCallback,
                [](void* c){delete static_cast<ClientCallbackContext::ObserveContext*>(c);}
                );

        OCMethod method;
        if (observeType == ObserveType::Observe)
        {
            method = OC_REST_OBSERVE;
        }
        else if (observeType == ObserveType::ObserveAll)
        {
            method = OC_REST_OBSERVE_ALL;
        }
        else
        {
            method = OC_REST_OBSERVE_ALL;
        }

        std::string url = assembleSetResourceUri(uri, queryParams).c_str();

        auto cLock = m_csdkLock.lock();

        if(cLock)
        {
            std::lock_guard<std::recursive_mutex> lock(*cLock);
            OCHeaderOption options[MAX_HEADER_OPTIONS];

            result = OCDoResource(handle, method,
                                  url.c_str(), &devAddr,
                                  nullptr,
                                  CT_DEFAULT,
                                  static_cast<OCQualityOfService>(QoS),
                                  &cbdata,
                                  assembleHeaderOptions(options, headerOptions),
                                  headerOptions.size());
        }
        else
        {
            delete ctx;
            return OC_STACK_ERROR;
        }

        return result;
    }
开发者ID:yanghyunjin,项目名称:IoTAR,代码行数:60,代码来源:InProcClientWrapper.cpp

示例15: 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;
    OIC_LOG_V(INFO, TAG, "OBSERVE payload from client =");
    OCPayload* payload = putPayload();
    OIC_LOG_PAYLOAD(INFO, 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)
    {
        OIC_LOG(ERROR, TAG, "OCStack resource error");
    }
    else
    {
        gObserveDoHandle = handle;
    }
    return ret;
}
开发者ID:alexgg,项目名称:iotivity,代码行数:28,代码来源:occlientcoll.cpp


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