Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
void parseClientResponse(OCClientResponse * clientResponse)
{
    coapServerIP = getIPAddrTBServer(clientResponse);
    coapServerPort = getPortTBServer(clientResponse);
    coapServerResource = getQueryStrForGetPut(clientResponse);
}