/* * Class: org_iotivity_base_OcRepresentation * Method: size * Signature: ()I */ JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size (JNIEnv *env, jobject thiz) { LOGD("OcRepresentation_size"); OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz); if (!rep) return -1; return static_cast<jint>(rep->numberOfAttributes()); }
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; } }