Exemplo n.º 1
0
JNIEXPORT jboolean JNICALL hasAttribute(JNIEnv *env, jobject jobj, jstring jstr)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
	string str = env->GetStringUTFChars(jstr,0);

    return rep->hasAttribute(str);
}
Exemplo n.º 2
0
JNIEXPORT jstring JNICALL getUri(JNIEnv *env, jobject jobj)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
    string uri = rep->getUri();
    __android_log_print(ANDROID_LOG_INFO, TAG, "getUri() URI : %s", uri.c_str());
    return env->NewStringUTF(uri.c_str());
}
Exemplo n.º 3
0
void SensorRule::onHeartRateSelectChanged(QString value)
{
    OC::OCRepresentation rep;

    rep.setValue("heartRate", value.toInt());

    m_resource->put(rep, OC::QueryParamsMap(), IoTivity::onPut);
}
Exemplo n.º 4
0
JNIEXPORT void JNICALL setValueString(JNIEnv *env, jobject jobj, jstring jstr, jstring jval)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
	string str = env->GetStringUTFChars(jstr,0);
	string val = env->GetStringUTFChars(jval,0);

    rep->setValue(str, val);
}
Exemplo n.º 5
0
JNIEXPORT jboolean JNICALL getValueBool(JNIEnv *env, jobject jobj, jstring jstr)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
	string str = env->GetStringUTFChars(jstr,0);
    bool val;
    rep->getValue(str, val);
    __android_log_print(ANDROID_LOG_INFO, TAG, "getValueBool() : %d", val);
    return((jboolean) val);
}
Exemplo n.º 6
0
JNIEXPORT jstring JNICALL getValueString(JNIEnv *env, jobject jobj, jstring jstr)
{
    OC::OCRepresentation *rep = getHandle<OC::OCRepresentation>(env, jobj);
	string str = env->GetStringUTFChars(jstr,0);
	string get_val;
    rep->getValue(str, get_val);

    __android_log_print(ANDROID_LOG_INFO, TAG, "getValueString() : %s", get_val.c_str());
    return env->NewStringUTF(get_val.c_str());
}
Exemplo n.º 7
0
void SensorRule::updateRuleView(const OC::OCRepresentation &rep)
{
    bool value;

    setEnabled(true);

    if (rep.hasAttribute(IoTivity::IOTIVITY_KITCH_RULE))
    {
        rep.getValue(IoTivity::IOTIVITY_KITCH_RULE, value);
        updateKitchMonitorState(value);
    }

    if (rep.hasAttribute(IoTivity::IOTIVITY_CRAZY_JUMPING_RULE))
    {
        rep.getValue(IoTivity::IOTIVITY_CRAZY_JUMPING_RULE, value);
        updateCrazyJumpingState(value);
    }

    if (rep.hasAttribute("density"))
    {
        int densityValue;
        rep.getValue("density", densityValue);
        updateDefineDensity(densityValue);
    }

    if (rep.hasAttribute("heartRate"))
    {
        int heartRateValue;
        rep.getValue("heartRate", heartRateValue);
        updateDefineHeartRate(heartRateValue);
    }
}
Exemplo n.º 8
0
void SensorRule::onCrazyJumpingChecked(bool checkedState)
{
    bool state;
    OC::OCRepresentation rep;

    if (m_resource == nullptr)
        return;

    state = checkedState == Qt::Unchecked ? false : true;

    rep.setValue(IoTivity::IOTIVITY_CRAZY_JUMPING_RULE, state);

    m_resource->put(rep, OC::QueryParamsMap(), IoTivity::onPut);
}
void on_iotivity_utility_get(const OC::HeaderOptions &headerOptions,
                             const OC::OCRepresentation &rep, const int eCode)
{
    (void) headerOptions;
    if (eCode == OC_STACK_OK)
    {
        if (rep.hasAttribute("name"))
        {
            std::string name = "";
            rep.getValue("name", name);
            std::cout << "\tname " << name << std::endl;
        }
    }
    g_iotivity_utility_condition_variable.notify_one();
}
Exemplo n.º 10
0
void SensorRule::sensorChanged(const OC::OCRepresentation &sensor)
{
    RuleChangedEvent *event;

    if (sensor.getUri() != objectName().toStdString())
        return;

    event = new RuleChangedEvent(static_cast< QEvent::Type >(QEvent::User + 1));
    event->setSensorRepresentation(sensor);
    QApplication::instance()->postEvent(this, event);
}
void processAttributes(const OC::OCRepresentation &rep,
                       const std::map <std::string, AttrDesc> *attrMap,
                       std::string prefix)
{
    for (auto &attr : *attrMap)
    {
        if (rep.hasAttribute(attr.first))
        {
            std::cout << prefix << attr.first << "";
        }
        else
        {
            continue;
        }

        switch (attr.second.type)
        {
            case ATTR_TYPE_BOOL:
                {
                    bool value;
                    rep.getValue(attr.first, value);
                    std::cout << " (bool):\t " << ((value) ? "TRUE" : "FALSE") << std::endl;
                    break;
                }
            case ATTR_TYPE_INT:
                {
                    int value;
                    rep.getValue(attr.first, value);
                    std::cout << " (int):\t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_INT64:
                {
                    double value;
                    rep.getValue(attr.first, value);
                    std::cout << " (int64): \t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_STRING:
                {
                    std::string value;
                    rep.getValue(attr.first, value);
                    std::cout << " (string): \t " << value << std::endl;
                    break;
                }
            case ATTR_TYPE_VECTOR:
                {
                    OC::OCRepresentation internal;
                    rep.getValue(attr.first, internal);
                    std::cout << std::endl;
                    processAttributes(internal, attr.second.composite, prefix + "\t");
                    break;
                }
            default:
                {
                    std::cout << "not handled yet" << std::endl;
                    break;
                }
        }
    }

}