本文整理汇总了C++中OCRepresentation::getUri方法的典型用法代码示例。如果您正苦于以下问题:C++ OCRepresentation::getUri方法的具体用法?C++ OCRepresentation::getUri怎么用?C++ OCRepresentation::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCRepresentation
的用法示例。
在下文中一共展示了OCRepresentation::getUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onBootStrapCallback
/* Callback Function to be called by the platform
when response arrives from the BootStrap Server */
void onBootStrapCallback(const HeaderOptions &headerOptions, const OCRepresentation &rep,
const int eCode)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap entry");
if (SUCCESS_RESPONSE != eCode)
{
dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- onGET Response error: %d", eCode);
return ;
}
dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- GET request was successful");
dlog_print(DLOG_INFO, LOG_TAG, "#### onBootStrap -- Resource URI: %s", rep.getUri().c_str());
logMessage = "----------------------------<br>";
logMessage += "GET request was successful<br>";
logMessage += "URI : " + rep.getUri() + "<br>";
defaultRegion = rep.getValue< std::string >("r");
defaultSystemTime = rep.getValue< std::string >("st");
defaultCurrency = rep.getValue< std::string >("c");
defaultLocation = rep.getValue< std::string >("loc");
logMessage += "Location : " + defaultLocation + "<br>";
logMessage += "SystemTime : " + defaultSystemTime + "<br>";
logMessage += "currency : " + defaultCurrency + "<br>";
logMessage += "Region : " + defaultRegion + "<br>";
dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());
//Call updateLog in the thread safe mode
ecore_main_loop_thread_safe_call_sync(updateLog, &logMessage);
}
示例2: triggerNetworkConnectionCb
void RemoteEnrolleeResource::triggerNetworkConnectionCb(
const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep,
const int eCode)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d",
rep.getUri().c_str(),
eCode);
if (eCode != 0)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"triggerNetworkConnectionCb : Trigger action failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
m_provStatusCb(provStatus);
return;
}
else
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"triggerNetworkConnectionCb : Provisioning is success ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
m_provStatusCb(provStatus);
return;
}
}
示例3: onBootstrap
// callback handler on GET request
void onBootstrap(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
{
pthread_mutex_lock(&mutex_lock);
isWaiting = 0;
pthread_mutex_unlock(&mutex_lock);
if (eCode != SUCCESS_RESPONSE)
{
std::cout << "onGET Response error: " << eCode << std::endl;
return ;
}
std::cout << "\n\nGET request was successful" << std::endl;
std::cout << "\tResource URI: " << rep.getUri() << std::endl;
defaultDeviceName = rep.getValue< std::string >("n");
defaultLocation = rep.getValue< std::string >("loc");
defaultLocationName = rep.getValue< std::string >("locn");
defaultRegion = rep.getValue< std::string >("r");
defaultCurrency = rep.getValue< std::string >("c");
std::cout << "\tDeviceName : " << defaultDeviceName << std::endl;
std::cout << "\tLocation : " << defaultLocation << std::endl;
std::cout << "\tLocationName : " << defaultLocationName << std::endl;
std::cout << "\tCurrency : " << defaultCurrency << std::endl;
std::cout << "\tRegion : " << defaultRegion << std::endl;
}
示例4: onGet
// Callback handler on GET request
void onGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
{
(void)headerOptions;
try
{
if (eCode == OC_STACK_OK)
{
std::cout << "GET request was successful" << std::endl;
std::cout << "Resource URI: " << rep.getUri() << std::endl;
std::cout << "Payload: " << rep.getPayload() << std::endl;
rep.getValue("on-off", mylight.m_on_off);
rep.getValue("dim", mylight.m_dim);
rep.getValue("color", mylight.m_color);
std::cout << "\ton-off: " << mylight.m_on_off << std::endl;
std::cout << "\tcolor: " << mylight.m_color << std::endl;
std::cout << "\tdim: " << mylight.m_dim << std::endl;
putLightRepresentation(curResource);
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
}
}
catch (std::exception &e)
{
std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
}
}
示例5: uri
/*
* Class: org_iotivity_base_OcRepresentation
* Method: getUri
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri
(JNIEnv *env, jobject thiz)
{
LOGD("OcRepresentation_getUri");
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
if (!rep) return nullptr;
std::string uri(rep->getUri());
return env->NewStringUTF(uri.c_str());
}
示例6: onObserve
void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
{
std::cout << "onObserve" << std::endl;
// if(eCode == SUCCESS_RESPONSE)
if(eCode <= OC_STACK_RESOURCE_DELETED)
{
AttributeMap attributeMap = rep.getAttributeMap();
for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
{
if(attributeMap.find(it->first) == attributeMap.end())
{
return;
}
}
if(rep.getUri().empty())
{
cout << "uri is null\n";
return;
}
std::cout << std::endl;
std::cout << "========================================================" << std::endl;
std::cout << "Receive OBSERVE RESULT:" << std::endl;
std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
{
std::cout << "\tAttribute name: " << it->first << " value: ";
for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
{
std::cout << "\t" << *valueItr << " ";
}
std::cout << std::endl;
}
if(observe_count() > 30)
{
std::cout << "Cancelling Observe..." << std::endl;
OCStackResult result = g_curResource->cancelObserve();
std::cout << "Cancel result: " << result << std::endl;
sleep(10);
std::cout << "DONE" << std::endl;
std::exit(0);
}
}
else
{
std::cout << "onObserve Response error: " << eCode << std::endl;
std::exit(-1);
}
}
示例7: getProvStatusResponse
void RemoteEnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/,
const OCRepresentation& rep, const int eCode)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : %s, eCode = %d",
rep.getUri().c_str(),
eCode);
if (eCode != 0)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"getProvStatusResponse : Provisioning is failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
m_provStatusCb(provStatus);
return;
}
int ps = -1;
rep.getValue(OC_RSRVD_ES_PS, ps);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ps - %d",
ps);
if (ps == ES_PS_NEED_PROVISIONING) //Indicates the need for provisioning
{
OCRepresentation provisioningRepresentation;
provisioningRepresentation.setValue(OC_RSRVD_ES_TNN,
std::string(m_ProvConfig.provData.WIFI.ssid));
provisioningRepresentation.setValue(OC_RSRVD_ES_CD,
std::string(m_ProvConfig.provData.WIFI.pwd));
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ssid - %s",
m_ProvConfig.provData.WIFI.ssid);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : pwd - %s",
m_ProvConfig.provData.WIFI.pwd);
m_ocResource->post(provisioningRepresentation, QueryParamsMap(),
std::function<
void(const HeaderOptions& headerOptions,
const OCRepresentation& rep, const int eCode) >(
std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)));
}
else if (ps == ES_PS_PROVISIONING_COMPLETED) //Indicates that provisioning is completed
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"getProvStatusResponse : Provisioning is successful");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONED_ALREADY);
m_provStatusCb(provStatus);
}
}
示例8: onReboot
void onReboot(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
pthread_mutex_lock(&mutex_lock);
isWaiting = 0;
pthread_mutex_unlock(&mutex_lock);
if (eCode != SUCCESS_RESPONSE)
{
return ;
}
std::cout << "\tResource URI: " << rep.getUri() << std::endl;
std::cout << "\t\tReboot:" << rep.getValue< std::string >("value") << std::endl;
}
示例9: onGet
void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode)
{
try
{
if(eCode == OC_STACK_OK)
{
dlog_print(DLOG_INFO, LOG_TAG, "GET request was successful %s", rep.getUri().c_str());
std::cout << "Attributes : " << rep.numberOfAttributes() << std::endl;
typedef std::map<std::string, int>::iterator it_type;
for(it_type iterator = intprops.begin(); iterator != intprops.end(); iterator++) {
std::cout << "Key : " << iterator->first << " Value = "<<rep[iterator->first]<<std::endl;
iterator->second = rep[iterator->first];
}
typedef std::map<std::string, double>::iterator itd_type;
for(itd_type iterator = doubleprops.begin(); iterator != doubleprops.end(); iterator++) {
std::cout << "Key : " << iterator->first << " Value = "<<rep[iterator->first]<<std::endl;
iterator->second = rep[iterator->first];
}
rvidata r;
r.lt = rep["leftTemperature"];
r.rt = rep["rightTemperature"];
r.lhs = rep["leftSeatHeat"];
r.rhs = rep["rightSeatHeat"];
r.fs = rep["fanSpeed"];
r.fd = rep["fanDown"];
r.fr = rep["fanRight"];
r.fu = rep["fanUp"];
r.fac = rep["fanAC"];
r.fa = rep["fanAuto"];
r.fr = rep["fanRecirc"];
r.dm = rep["defrostMax"];
r.df = rep["defrostFront"];
r.dr = rep["defrostRear"];
send_message(&r);
}
else
{
dlog_print(DLOG_INFO, LOG_TAG, "GET request was UNsuccessful");
}
}
catch(std::exception& e)
{
std::cout << "Exception: " << e.what() << " in onPut" << std::endl;
}
}
示例10: checkProvInformationCb
void RemoteEnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/,
const OCRepresentation& rep, const int eCode)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d",
rep.getUri().c_str(),
eCode);
if (eCode != 0)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"checkProvInformationCb : Provisioning is failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
m_provStatusCb(provStatus);
return;
}
int ps = -1;
rep.getValue(OC_RSRVD_ES_PS, ps);
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : ps - %d", ps);
//Provisioning status check
if (ps == ES_PS_PROVISIONING_COMPLETED)
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"checkProvInformationCb : Provisioning is success. "
"Now trigger network connection ");
#ifdef REMOTE_ARDUINO_ENROLEE
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);
m_provStatusCb(provStatus);
#endif
triggerNetworkConnection();
return;
}
else
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"checkProvInformationCb : Provisioning is failed ");
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);
m_provStatusCb(provStatus);
return;
}
}
示例11: onGet
// callback handler on GET request
void onGet(const HeaderOptions &headerOption , const OCRepresentation& rep , const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
std::cout << "GET request was successful" << std::endl;
AttributeMap attributeMap = rep.getAttributeMap();
std::cout << "Resource URI: " << rep.getUri() << std::endl;
for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
{
std::cout << "\tAttribute name: " << it->first << " value: ";
for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
{
std::cout << "\t" << *valueItr << " ";
}
std::cout << std::endl;
}
std::vector< OCRepresentation > children = rep.getChildren();
for(auto oit = children.begin() ; oit != children.end() ; ++oit)
{
std::cout << "Child Resource URI: " << oit->getUri() << std::endl;
attributeMap = oit->getAttributeMap();
for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
{
std::cout << "\tAttribute name: " << it->first << " value: ";
for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
{
std::cout << "\t" << *valueItr << " ";
}
std::cout << std::endl;
}
}
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}
示例12: onGetForPresence
void GroupManager::onGetForPresence(const HeaderOptions& headerOptions,
const OCRepresentation& rep, const int eCode, CollectionPresenceCallback callback)
{
if (eCode == OC_STACK_OK)
{
std::cout << "GET request was successful" << std::endl;
std::cout << "Resource URI: " << rep.getUri() << std::endl;
checkCollectionRepresentation(rep, callback);
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
callback("", OC_STACK_ERROR);
}
}
示例13: onGet
// Callback handler on GET request
void onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
std::cout << "GET request was successful" << std::endl;
std::cout << "Resource URI: " << rep.getUri() << std::endl;
printRepresentation(rep);
putLightRepresentation(curResource);
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}
示例14: onGet
void SensorResource::onGet(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
{
try {
if(eCode == OC_STACK_OK) {
std::cout << "Resource URI: " << rep.getUri() << std::endl;
if (rep.hasAttribute("fanstate")) {
std::string state = rep.getValue<std::string>("fanstate");
m_fanState = (state == "on" ? true:false);
std::cout << "\tfanstate: " << m_fanState << std::endl;
}
}
else {
std::cout << "onGET Response error: " << eCode << std::endl;
}
}
catch(std::exception& e) {
std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
}
}
示例15: onLightGet
void onLightGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
{
if (eCode == OC_STACK_OK)
{
std::cout << "GET Light request was successful" << std::endl;
std::cout << "Resource URI: " << rep.getUri() << std::endl;
rep.getValue("state", mylight.m_state);
rep.getValue("power", mylight.m_power);
rep.getValue("name", mylight.m_name);
std::cout << "\tstate: " << mylight.m_state << std::endl;
std::cout << "\tpower: " << mylight.m_power << std::endl;
std::cout << "\tname: " << mylight.m_name << std::endl;
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}