• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OCDoResource函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: InitPutRequest

int InitPutRequest(OCClientResponse * clientResponse)
{
    OCStackResult ret;
    OCCallbackData cbData;
    //* Make a PUT query*/
    std::ostringstream getQuery;
    getQuery << "coap://" << clientResponse->devAddr.addr << ":" <<
            clientResponse->devAddr.port <<
            "/a/room" << queryInterface[TestType].text;
    cbData.cb = putReqCB;
    cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
    cbData.cd = NULL;
    OIC_LOG_V(INFO, TAG, "PUT payload from client = ");
    OCPayload* payload = putPayload();
    OIC_LOG_PAYLOAD(INFO, payload);
    OCPayloadDestroy(payload);

    ret = OCDoResource(NULL, OC_REST_PUT, getQuery.str().c_str(),
                       &clientResponse->devAddr, putPayload(), ConnType,
                       OC_LOW_QOS, &cbData, NULL, 0);
    if (ret != OC_STACK_OK)
    {
        OIC_LOG(ERROR, TAG, "OCStack resource error");
    }
    return ret;
}
开发者ID:alexgg,项目名称:iotivity,代码行数:26,代码来源:occlientcoll.cpp


示例17: 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


示例18: ProvisionDefaultACLCB

/**
 * Callback handler of default ACL provisioning.
 *
 * @param[in] ctx             ctx value passed to callback from calling function.
 * @param[in] UNUSED          handle to an invocation
 * @param[in] clientResponse  Response from queries to remote servers.
 * @return  OC_STACK_DELETE_TRANSACTION to delete the transaction
 *          and OC_STACK_KEEP_TRANSACTION to keep it.
 */
static OCStackApplicationResult ProvisionDefaultACLCB(void *ctx, OCDoHandle UNUSED,
                                                       OCClientResponse *clientResponse)
{
    OC_LOG_V(INFO, TAG, "IN ProvisionDefaultACLCB.");

    VERIFY_NON_NULL(TAG, clientResponse, ERROR);
    VERIFY_NON_NULL(TAG, ctx, ERROR);

    OTMContext_t* otmCtx = (OTMContext_t*) ctx;
    (void)UNUSED;

    if (OC_STACK_RESOURCE_CREATED == clientResponse->result)
    {
        OC_LOG_V(INFO, TAG, "Staring commit hash task.");
        // TODO hash currently have fixed value 0.
        uint16_t aclHash = 0;
        otmCtx->selectedDeviceInfo->pstat->commitHash = aclHash;
        otmCtx->selectedDeviceInfo->pstat->tm = NORMAL;
        OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
        if(!secPayload)
        {
            OC_LOG(ERROR, TAG, "Failed to memory allocation");
            return OC_STACK_NO_MEMORY;
        }
        secPayload->base.type = PAYLOAD_TYPE_SECURITY;
        secPayload->securityData = BinToPstatJSON(otmCtx->selectedDeviceInfo->pstat);
        if (NULL == secPayload->securityData)
        {
            OICFree(secPayload);
            SetResult(otmCtx, OC_STACK_INVALID_JSON);
            return OC_STACK_DELETE_TRANSACTION;
        }
        OC_LOG_V(INFO, TAG, "Created payload for commit hash: %s",secPayload->securityData);

        char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};
        if(!PMGenerateQuery(true,
                            otmCtx->selectedDeviceInfo->endpoint.addr,
                            otmCtx->selectedDeviceInfo->securePort,
                            otmCtx->selectedDeviceInfo->connType,
                            query, sizeof(query), OIC_RSRC_PSTAT_URI))
        {
            OC_LOG(ERROR, TAG, "ProvisionDefaultACLCB : Failed to generate query");
            return OC_STACK_ERROR;
        }
        OC_LOG_V(DEBUG, TAG, "Query=%s", query);

        OCCallbackData cbData = {.context=NULL, .cb=NULL, .cd=NULL};
        cbData.cb = &FinalizeProvisioningCB;
        cbData.context = (void*)otmCtx;
        cbData.cd = NULL;
        OCStackResult ret = OCDoResource(NULL, OC_REST_PUT, query, 0, (OCPayload*)secPayload,
                otmCtx->selectedDeviceInfo->connType, OC_HIGH_QOS, &cbData, NULL, 0);
        OC_LOG_V(INFO, TAG, "OCDoResource returned: %d",ret);
        if (ret != OC_STACK_OK)
        {
            OC_LOG(ERROR, TAG, "OCStack resource error");
            SetResult(otmCtx, ret);
        }
    }
开发者ID:tienfuc,项目名称:iotivity-democlient-snap,代码行数:68,代码来源:ownershiptransfermanager.c


示例19: PutOwnerTransferModeToResource

static OCStackResult PutOwnerTransferModeToResource(OTMContext_t* otmCtx)
{
    OC_LOG(DEBUG, TAG, "IN PutOwnerTransferModeToResource");

    if(!otmCtx || !otmCtx->selectedDeviceInfo)
    {
        OC_LOG(ERROR, TAG, "Invalid parameters");
        return OC_STACK_INVALID_PARAM;
    }

    OCProvisionDev_t* deviceInfo = otmCtx->selectedDeviceInfo;
    OicSecOxm_t selectedOxm = deviceInfo->doxm->oxmSel;
    char query[MAX_URI_LENGTH + MAX_QUERY_LENGTH] = {0};

    if(!PMGenerateQuery(false,
                        deviceInfo->endpoint.addr, deviceInfo->endpoint.port,
                        deviceInfo->connType,
                        query, sizeof(query), OIC_RSRC_DOXM_URI))
    {
        OC_LOG(ERROR, TAG, "PutOwnerTransferModeToResource : Failed to generate query");
        return OC_STACK_ERROR;
    }
    OC_LOG_V(DEBUG, TAG, "Query=%s", query);
    OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
    if(!secPayload)
    {
        OC_LOG(ERROR, TAG, "Failed to memory allocation");
        return OC_STACK_NO_MEMORY;
    }
    secPayload->base.type = PAYLOAD_TYPE_SECURITY;
    secPayload->securityData = g_OTMDatas[selectedOxm].createSelectOxmPayloadCB(otmCtx);
    if (NULL == secPayload->securityData)
    {
        OICFree(secPayload);
        OC_LOG(ERROR, TAG, "Error while converting bin to json");
        return OC_STACK_ERROR;
    }
    OC_LOG_V(DEBUG, TAG, "Payload : %s", secPayload->securityData);

    OCCallbackData cbData;
    cbData.cb = &OwnerTransferModeHandler;
    cbData.context = (void *)otmCtx;
    cbData.cd = NULL;
    OCStackResult res = OCDoResource(NULL, OC_REST_PUT, query,
                                     &deviceInfo->endpoint, (OCPayload*)secPayload,
                                     deviceInfo->connType, OC_LOW_QOS, &cbData, NULL, 0);
    if (res != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "OCStack resource error");
    }

    OC_LOG(DEBUG, TAG, "OUT PutOwnerTransferModeToResource");

    return res;
}
开发者ID:tienfuc,项目名称:iotivity-democlient-snap,代码行数:55,代码来源:ownershiptransfermanager.c


示例20: if

OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle,
        const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
        const HeaderOptions& headerOptions, ObserveCallback& callback, QualityOfService QoS)
{
    OCStackResult result;
    OCCallbackData cbdata = {0};

    ClientCallbackContext::ObserveContext* ctx = new ClientCallbackContext::ObserveContext();
    ctx->callback = callback;
    cbdata.context = static_cast<void*>(ctx);
    cbdata.cb = &observeResourceCallback;
    cbdata.cd = [](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;
    }

    auto cLock = m_csdkLock.lock();

    if(cLock)
    {
        std::ostringstream os;
        os << host << assembleSetResourceUri(uri, queryParams).c_str();

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

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

    return result;
}
开发者ID:TizenTeam,项目名称:iotivity,代码行数:55,代码来源:InProcClientWrapper.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OCFS2_I函数代码示例发布时间:2022-05-30
下一篇:
C++ OB_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap