Esempio n. 1
0
static void run_writer(pid_t peer)
{
    // writer is a type_nest_i writer
    qeo_factory_t *factory;
    qeocore_type_t *type_nest_i;
    qeocore_writer_t *writer;
    qeocore_data_t *outer=NULL;
    qeocore_data_t *inner=NULL;

    int status;

    /* initialize */
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type_nest_i = type_nest_i_register(factory)));
    assert(NULL != (writer = qeocore_writer_open(factory, type_nest_i, NULL,
                                                 QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    log_pid("=================================== writer initialized");
    assert(NULL != (outer = qeocore_writer_data_new(writer)));
    /* fill outer struct */
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int32_id, &_outer_int32_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int8_id, &_outer_int8_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_string_id, &_outer_string_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int16_id, &_outer_int16_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _outer_int64_id, &_outer_int64_value));

    /* fill inner struct */
    assert(QEO_OK == qeocore_data_get_member(outer, _inner_id, &inner));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int32_id, &_inner_int32_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int8_id, &_inner_int8_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_string_id, &_inner_string_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int16_id, &_inner_int16_value));
    assert(QEO_OK == qeocore_data_set_member(inner, _inner_int64_id, &_inner_int64_value));
    assert(QEO_OK == qeocore_data_set_member(outer, _inner_id, &inner));
    log_verbose(" =================== _outer_int32_value = %u \n", _outer_int32_value );
    log_verbose(" =================== _outer_int8_value = %u \n", _outer_int8_value );
    log_verbose(" =================== _outer_int16_value = %u \n", _outer_int16_value );
    log_verbose(" =================== _outer_int64_value = %"PRIu64" \n", _outer_int64_value );
    log_verbose(" =================== _inner_int32_value = %u \n", _inner_int32_value );
    log_verbose(" =================== _inner_int8_value = %u \n", _inner_int8_value );
    log_verbose(" =================== _inner_int16_value = %u \n", _inner_int16_value );
    log_verbose(" =================== _inner_int64_value = %"PRIu64" \n", _inner_int64_value );
    /* write */
    assert(QEO_OK == qeocore_writer_write(writer, outer));
    log_pid("===================================== writer wrote outer data");
    assert(peer == waitpid(peer, &status, 0));
    assert(0 == status);
    log_pid("===================================== writer done");
    /* clean up */
    qeocore_data_free(inner);
    qeocore_data_free(outer);
    qeocore_writer_close(writer);
    qeocore_type_free(type_nest_i);
    qeocore_factory_close(factory);
}
Esempio n. 2
0
static void my_on_data_available(const qeocore_reader_t *reader,
                                 const qeocore_data_t *data,
                                 uintptr_t userdata)
{
    switch (qeocore_data_get_status(data)) {
        case QEOCORE_DATA: {
            qeocore_data_t *seqdata = NULL;
            byte_array_t array;
            int i, size;

            log_pid("reader received data");
            assert(QEO_OK == qeocore_data_get_member(data, _size_id, &size));
            assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata));
            assert(QEO_OK == qeocore_data_sequence_get(seqdata, (qeo_sequence_t *)&array, 0, QEOCORE_SIZE_UNLIMITED));
            assert(size == DDS_SEQ_LENGTH(array));
            assert(_test_size == DDS_SEQ_LENGTH(array));
            for (i = 0; i < size; i++) {
                assert(DDS_SEQ_ITEM(array, i) == (i & 0xff));
            }
            qeocore_data_sequence_free(seqdata, (qeo_sequence_t *)&array);
            qeocore_data_free(seqdata);
            sem_post(&_sync); /* release main thread */
            break;
        }
        case QEOCORE_NO_MORE_DATA:
        case QEOCORE_REMOVE:
            /* ignore */
            break;
        default:
            abort();
            break;
    }
}
Esempio n. 3
0
static void run_writer(pid_t peer)
{
    qeo_factory_t *factory;
    qeocore_type_t *type;
    qeocore_writer_t *writer;
    qeocore_data_t *data, *seqdata;
    byte_array_t array;
    int status, i;

    /* initialize */
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type = type_register(factory)));
    assert(NULL != (writer = qeocore_writer_open(factory, type, NULL,
                                                 QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    log_pid("writer initialized");
    assert(NULL != (data = qeocore_writer_data_new(writer)));
    assert(QEO_OK == qeocore_data_set_member(data, _size_id, &_test_size));
    /* init sequence */
    DDS_SEQ_INIT(array);
    assert(NULL != (DDS_SEQ_DATA(array) = malloc(_test_size * sizeof(char))));
    DDS_SEQ_LENGTH(array) = DDS_SEQ_MAXIMUM(array) = _test_size;
    for (i = 0; i < _test_size; i++) {
        DDS_SEQ_ITEM(array, i) = i & 0xff;
    }
    assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata));
    assert(QEO_OK == qeocore_data_sequence_set(seqdata, (const qeo_sequence_t *)&array, 0));
    assert(QEO_OK == qeocore_data_set_member(data, _buf_id, &seqdata));
    /* write */
    assert(QEO_OK == qeocore_writer_write(writer, data));
    log_pid("writer wrote data");
    assert(peer == waitpid(peer, &status, 0));
    assert(0 == status);
    log_pid("writer done");
    /* clean up */
    free(DDS_SEQ_DATA(array));
    qeocore_data_free(seqdata);
    qeocore_data_free(data);
    qeocore_writer_close(writer);
    qeocore_type_free(type);
    qeocore_factory_close(factory);
}
Esempio n. 4
0
int main(int argc, const char **argv)
{
    qeo_factory_t *factory;
    qeocore_reader_t *reader;
    qeocore_writer_t *writer;
    qeocore_type_t *type;
    qeocore_data_t *rdata, *wdata;
    int i;

    for (i = 0; i < 2; i++) {
        /* initialize */
        assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
        init_factory(factory);
        assert(NULL != (type = nested_type_get(1, 0, 0)));
        assert(QEO_OK == qeocore_type_register(factory, type, "nested"));
        assert(NULL != (reader = qeocore_reader_open(factory,  type, NULL,
                                                     QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL)));
        assert(NULL != (writer = qeocore_writer_open(factory, type, NULL,
                                                     QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL)));
        /* write */
        assert(NULL != (wdata = qeocore_writer_data_new(writer)));
        fill_data(wdata);
        assert(QEO_OK == qeocore_writer_write(writer, wdata));
        /* check data */
        assert(NULL != (rdata = qeocore_reader_data_new(reader)));
        assert(QEO_OK == qeocore_reader_read(reader, NULL, rdata));
        expected_status = QEOCORE_DATA;
        validate_data(rdata);
        /* remove */
        assert(QEO_OK == qeocore_writer_remove(writer, wdata));
        /* clean up */
        qeocore_data_free(wdata);
        qeocore_data_free(rdata);
        qeocore_writer_close(writer);
        qeocore_reader_close(reader);
        qeocore_type_free(type);
        qeocore_factory_close(factory);
    }
}
Esempio n. 5
0
static void fill_data(qeocore_data_t *data)
{
    qeocore_data_t *inner = NULL;
    int32_t i;

    /* fill outer struct */
    i = 123;
    assert(QEO_OK == qeocore_data_set_member(data, _id_id, &i));
    /* fill inner struct */
    assert(QEO_OK == qeocore_data_get_member(data, _inner_id, &inner));
    i = 456;
    assert(QEO_OK == qeocore_data_set_member(inner, _num_id, &i));
    assert(QEO_OK == qeocore_data_set_member(data, _inner_id, &inner));
    qeocore_data_free(inner);
}
Esempio n. 6
0
static void validate_data(const qeocore_data_t *data)
{
    qeocore_data_t *inner = NULL;
    int32_t i = 0;

    assert(expected_status == qeocore_data_get_status(data));
    /* check outer struct */
    assert(QEO_OK == qeocore_data_get_member(data, _id_id, &i));
    assert(123 == i);
    if (expected_status == QEOCORE_DATA) {
        /* check inner struct */
        assert(QEO_OK == qeocore_data_get_member(data, _inner_id, &inner));
        assert(QEO_OK == qeocore_data_get_member(inner, _num_id, &i));
        assert(456 == i);
        qeocore_data_free(inner);
    }
}
Esempio n. 7
0
qeo_retcode_t qeo_json_state_reader_foreach(const qeo_json_state_reader_t *reader,
                                            qeo_json_iterate_callback     cb,
                                            uintptr_t                     userdata)
{
    qeojson_reader_t  *jsonreader = (qeojson_reader_t *) reader;
    qeo_retcode_t     rc          = QEO_OK;
    char              *datastr    = NULL;

    if ((NULL == reader) || (NULL == cb)) {
        rc = QEO_EINVAL;
    }
    else {
        qeocore_filter_t      filter  = { 0 };
        qeo_iterate_action_t  action  = QEO_ITERATE_CONTINUE;
        qeocore_data_t        *data;

        data = qeocore_reader_data_new(jsonreader->reader);
        if (NULL == data) {
            rc = QEO_ENOMEM;
        }
        else {
            json_reader_dispatcher_cookie_t *dc = (json_reader_dispatcher_cookie_t *)qeocore_reader_get_userdata(jsonreader->reader);
            filter.instance_handle = DDS_HANDLE_NIL;
            while (1) {
                rc = qeocore_reader_read(jsonreader->reader, &filter, data);
                if (QEO_OK == rc) {
                    filter.instance_handle = qeocore_data_get_instance_handle(data);
                    datastr = json_from_data(dc->typedesc, data);
                    action  = cb(datastr, userdata);
                    free(datastr);
                    if (QEO_ITERATE_CONTINUE == action) {
                        qeocore_data_reset(data);
                        continue;
                    }
                }
                else if (QEO_ENODATA == rc) {
                    rc = QEO_OK;
                }
                /* QEO_ENODATA or ITERATE_ABORT or error */
                break;
            }
            qeocore_data_free(data);
        }
    }
    return rc;
}
Esempio n. 8
0
qeo_retcode_t qeo_json_event_writer_write(const qeo_json_event_writer_t *writer, const char *json_data)
{
    qeo_retcode_t     result      = QEO_EINVAL;
    qeojson_writer_t  *jsonwriter = (qeojson_writer_t *) writer;
    json_t            *jsonData   = json_loads(json_data, 0, NULL);

    if ((NULL != jsonData) && (NULL != writer)) {
        json_writer_dispatcher_cookie_t *dc   = (json_writer_dispatcher_cookie_t *)qeocore_writer_get_userdata(jsonwriter->writer);
        qeocore_data_t                  *data = qeocore_writer_data_new(jsonwriter->writer);
        if (QEO_OK == data_from_json(dc->typedesc, jsonData, data)) {
            result = qeocore_writer_write(jsonwriter->writer, data);
        }
        qeocore_data_free(data);
        json_decref(jsonData);
    }
    return result;
}
Esempio n. 9
0
static int fwd_server_count_instances(const qeocore_reader_t *reader)
{
    qeo_retcode_t rc = QEO_OK;
    qeocore_filter_t filter = { 0 };
    qeocore_data_t *data;
    int cnt = 0;

    data = qeocore_reader_data_new(reader);
    if (NULL != data) {
        filter.instance_handle = DDS_HANDLE_NIL;
        while (1) {
            rc = qeocore_reader_read(reader, &filter, data);
            if (QEO_OK == rc) {
                filter.instance_handle = qeocore_data_get_instance_handle(data);
                cnt++;
#ifdef DEBUG
                {
                    const org_qeo_system_Forwarder_t *fwd = qeocore_data_get_data(data);

                    qeo_log_d("forwarder %d : id=%" PRIx64 " -> %s", cnt, fwd->deviceId,
                              (fwd->deviceId == reader->entity.factory->qeo_id.device_id ? "self" : "other"));
                }
#endif
                qeocore_data_reset(data);
                continue;
            }
            else if (QEO_ENODATA == rc) {
                rc = QEO_OK;
            }
            /* QEO_ENODATA or error */
            break;
        }
        qeocore_data_free(data);
    }
    if (QEO_OK == rc) {
        qeo_log_i("found %d local forwarders", cnt);
    }
    else {
        qeo_log_e("failed to read all local forwarders");
    }
    return cnt;
}
Esempio n. 10
0
qeo_retcode_t qeo_state_reader_foreach(const qeo_state_reader_t *reader,
                                       qeo_iterate_callback cb,
                                       uintptr_t userdata)
{
    qeocore_reader_t *r = (qeocore_reader_t *)reader;
    qeo_retcode_t rc = QEO_OK;

    if ((NULL == r) || (NULL == cb)) {
        rc = QEO_EINVAL;
    }
    else {
        qeocore_filter_t filter = { 0 };
        qeo_iterate_action_t action = QEO_ITERATE_CONTINUE;
        qeocore_data_t *data;

        data = qeocore_reader_data_new(r);
        if (NULL == data) {
            rc = QEO_ENOMEM;
        }
        else {
            filter.instance_handle = DDS_HANDLE_NIL;
            while (1) {
                rc = qeocore_reader_read(r, &filter, data);
                if (QEO_OK == rc) {
                    filter.instance_handle = qeocore_data_get_instance_handle(data);
                    if (QEO_ITERATE_CONTINUE == action) {
                        action = cb(qeocore_data_get_data(data), userdata);
                    }
                    qeocore_data_reset(data);
                }
                else if (QEO_ENODATA == rc) {
                    rc = QEO_OK;
                    break;
                }
            }
            qeocore_data_free(data);
        }
    }
    return rc;
}
static void my_on_data_available(const qeocore_reader_t *reader,
                                 const qeocore_data_t *data,
                                 uintptr_t userdata)
{
    // the reader is a type_nest-a reader
    switch (qeocore_data_get_status(data)) {
    case QEOCORE_DATA: {

        int outer_int32_value_rx=0, outer_int8_value_rx=0, outer_int16_value_rx=0;
        int inner_int32_value_rx=0, inner_int8_value_rx=0, inner_int16_value_rx=0;
        int64_t outer_int64_value_rx=0;
        int64_t inner_int64_value_rx=0;
        char* outer_string_value_rx="";
        char* inner_string_value_rx="";
        qeocore_data_t *inner_value_rx=NULL;
        log_pid("===================================== reader received data");
        assert(QEO_OK == qeocore_data_get_member(data, _outer_int32_id, &outer_int32_value_rx));
        assert(QEO_OK == qeocore_data_get_member(data, _outer_int8_id, &outer_int8_value_rx));
        assert(QEO_OK == qeocore_data_get_member(data, _outer_string_id, &outer_string_value_rx));
        assert(QEO_OK == qeocore_data_get_member(data, _outer_int16_id, &outer_int16_value_rx));
        assert(QEO_OK == qeocore_data_get_member(data, _outer_int64_id, &outer_int64_value_rx));
        assert(QEO_OK == qeocore_data_get_member(data, _inner_id, &inner_value_rx));
        assert(QEO_OK == qeocore_data_get_member(inner_value_rx, _inner_int32_id, &inner_int32_value_rx));
        assert(QEO_OK == qeocore_data_get_member(inner_value_rx, _inner_int8_id, &inner_int8_value_rx));
        assert(QEO_OK == qeocore_data_get_member(inner_value_rx, _inner_string_id, &inner_string_value_rx));
        assert(QEO_OK == qeocore_data_get_member(inner_value_rx, _inner_int16_id, &inner_int16_value_rx));
        assert(QEO_OK == qeocore_data_get_member(inner_value_rx, _inner_int64_id, &inner_int64_value_rx));
        log_verbose(" =================== outer_int32_value_rx = %u \n", outer_int32_value_rx );
        log_verbose(" =================== outer_int8_value_rx = %u \n", outer_int8_value_rx );
        log_verbose(" =================== outer_string_value_rx = \"%s\" \n", outer_string_value_rx );
        log_verbose(" =================== outer_int16_value_rx = %u \n", outer_int16_value_rx );
        log_verbose(" =================== outer_int64_value_rx = %"PRIu64" \n", outer_int64_value_rx );
        log_verbose(" =================== inner_int32_value_rx = %u \n", inner_int32_value_rx );
        log_verbose(" =================== inner_int8_value_rx = %u \n", inner_int8_value_rx );
        log_verbose(" =================== inner_string_value_rx = \"%s\" \n", inner_string_value_rx );
        log_verbose(" =================== inner_int16_value_rx = %u \n", inner_int16_value_rx );
        log_verbose(" =================== inner_int64_value_rx = %"PRIu64" \n", inner_int64_value_rx );
        assert(outer_int32_value_rx==_outer_int32_value);
        assert(outer_int8_value_rx==_outer_int8_value);
        assert(0 == strcmp(_outer_string_value, outer_string_value_rx));
        assert(outer_int16_value_rx==_outer_int16_value);
        assert(outer_int64_value_rx==_outer_int64_value);
        assert(inner_int32_value_rx==0);
        assert(inner_int8_value_rx==0);
        assert(0 == strcmp("", inner_string_value_rx));
        assert(inner_int16_value_rx==0);
        assert(inner_int64_value_rx==0);
        qeocore_data_free(inner_value_rx);
        free(outer_string_value_rx);
        free(inner_string_value_rx);
        sem_post(&_sync); /* release main thread */
        break;
    }
    case QEOCORE_NO_MORE_DATA:
    case QEOCORE_REMOVE:
        /* ignore */
        break;
    default:
        abort();
        break;
    }
}
Esempio n. 12
0
static json_t *member_data_to_json(const json_t *member, const qeocore_data_t *data)
{
    json_t  *json_data  = NULL;
    json_t  *id         = json_object_get(member, KEY_ID);            // Mandatory
    json_t  *type       = json_object_get(member, KEY_QEO_TYPE_CODE); // Mandatory

    if ((NULL == id) || (!json_is_integer(id)) ||
        (NULL == type) || (!json_is_integer(type))) {
        return json_data;
    }

    qeocore_member_id_t qeo_member_id = (qeocore_member_id_t) json_integer_value(id);
    qeocore_typecode_t  qeoTypeCode   = (qeocore_typecode_t) json_integer_value(type);

    switch (qeoTypeCode) {
        case QEOCORE_TYPECODE_BOOLEAN:
        {
            qeo_boolean_t bool_value = 0;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &bool_value)) {
                json_data = bool_value ? (json_true()) : (json_false());
            }
        }
        break;

        case QEOCORE_TYPECODE_INT8:
        {
            int8_t int_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &int_value)) {
                json_data = json_integer(int_value);
            }
        }
        break;

        case QEOCORE_TYPECODE_INT16:
        {
            int16_t int_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &int_value)) {
                json_data = json_integer(int_value);
            }
        }
        break;

        case QEOCORE_TYPECODE_INT32:
        {
            int32_t int_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &int_value)) {
                json_data = json_integer(int_value);
            }
        }
        break;

        case QEOCORE_TYPECODE_INT64:
        {
            int64_t int_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &int_value)) {
                char *char_value = NULL;
                if (-1 != asprintf(&char_value, "%" PRId64 "", int_value)) {
                    json_data = json_string(char_value);
                    free(char_value);
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_FLOAT32:
        {
            float float_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &float_value)) {
                json_data = json_real(float_value);
            }
        }
        break;

        case QEOCORE_TYPECODE_STRING:
        {
            char *char_value;
            if (QEO_OK == qeocore_data_get_member(data, qeo_member_id, &char_value)) {
                json_data = json_string(char_value);
                free(char_value);
            }
        }
        break;

        case QEOCORE_TYPECODE_STRUCT:
        {
            qeocore_data_t *qeo_data = NULL;
            do {
                json_t *item = json_object_get(member, KEY_ITEM);
                if (NULL == item) {
                    qeo_log_e("NULL == item");
                    break;
                }

                if (!json_is_object(item)) {
                    qeo_log_e("not an object");
                    break;
                }

                if (QEO_OK != qeocore_data_get_member(data, qeo_member_id, &qeo_data)) {
                    qeo_log_e("qeocore_data_get_member failed");
                    break;
                }

                if (NULL == qeo_data) {
                    qeo_log_e("NULL == qeo_data");
                    break;
                }

                json_data = object_data_to_json(item, qeo_data);
            } while (0);

            if (NULL != qeo_data) {
                qeocore_data_free(qeo_data);
            }
        }
        break;

        case QEOCORE_TYPECODE_SEQUENCE:
        {
            json_t *items = json_object_get(member, KEY_ITEMS);
            if ((NULL != items) && json_is_object(items)) {
                qeocore_data_t *seqdata = NULL;
                if ((QEO_OK == qeocore_data_get_member(data, qeo_member_id, &seqdata)) && (NULL != seqdata)) {
                    json_data = array_data_to_json(items, seqdata);
                    qeocore_data_free(seqdata);
                }
            }
        }
        break;
        case QEOCORE_TYPECODE_ENUM:
        {
            qeo_enum_value_t enum_value;
            if (QEO_OK != qeocore_data_get_member(data, qeo_member_id, &enum_value)) {
                qeo_log_e("Could not get member");
                break;
            } 
            if (is_valid_enum_value(member, enum_value) == false){
                qeo_log_e("Not a valid enum value");
                break;
            }
            json_data = json_integer(enum_value);

        }
        break;
    }
    return json_data;
}
Esempio n. 13
0
static qeo_retcode_t member_to_data(json_t *member, json_t *json_data, qeocore_data_t *data)
{
    qeo_retcode_t result = QEO_EINVAL;

    json_t  *id   = json_object_get(member, KEY_ID);            // Mandatory
    json_t  *type = json_object_get(member, KEY_QEO_TYPE_CODE); // Mandatory

    if ((NULL == id) || (!json_is_integer(id)) ||
        (NULL == type) || (!json_is_integer(type))) {
        return result;
    }
    result = QEO_EFAIL;

    qeocore_member_id_t qeo_member_id = (qeocore_member_id_t) json_integer_value(id);
    qeocore_typecode_t  qeoTypeCode   = (qeocore_typecode_t) json_integer_value(type);
/*
    bool isKey = false;
    json_t *key_value = json_object_get(member, KEY_KEY);
    if ((NULL != key_value) && (json_is_true(key_value))) {
        isKey = true;
    }
 */
    switch (qeoTypeCode) {
        case QEOCORE_TYPECODE_BOOLEAN:
        {
            if (json_is_boolean(json_data)) {
                qeo_boolean_t qeo_value = (qeo_boolean_t) json_is_true(json_data);
                result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                if (QEO_OK != result) {
                    qeo_log_e("qeocore_data_set_member failed");
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_INT8:
        {
            if (json_is_integer(json_data)) {
                json_int_t json_value = json_integer_value(json_data);
                if ((-128LL <= json_value) && (json_value <= 127LL)) {
                    int8_t qeo_value = (int8_t)json_value;
                    result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                    if (QEO_OK != result) {
                        qeo_log_e("qeocore_data_set_member failed");
                    }
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_INT16:
        {
            if (json_is_integer(json_data)) {
                json_int_t json_value = json_integer_value(json_data);
                if ((-32768LL <= json_value) && (json_value <= 32767LL)) {
                    int16_t qeo_value = (int16_t)json_value;
                    result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                    if (QEO_OK != result) {
                        qeo_log_e("qeocore_data_set_member failed");
                    }
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_INT32:
        {
            if (json_is_integer(json_data)) {
                json_int_t json_value = json_integer_value(json_data);
                if ((-2147483648LL <= json_value) && (json_value <= 2147483647LL)) {
                    int32_t qeo_value = (int32_t)json_value;
                    result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_INT64:
        {
            if (json_is_integer(json_data)) {
                int64_t qeo_value = (int64_t) json_integer_value(json_data);
                result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                if (QEO_OK != result) {
                    qeo_log_e("qeocore_data_set_member failed");
                }
            }

            if (json_is_string(json_data)) {
                const char *qeo_value = json_string_value(json_data);

                intmax_t num = strtoimax(qeo_value, NULL, 10);
                result = qeocore_data_set_member(data, qeo_member_id, (int64_t *) &num);
                if (QEO_OK != result) {
                    qeo_log_e("qeocore_data_set_member failed");
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_FLOAT32:
        {
            /*
               *Also allow integer values, when float:0.0 is written in a webview then JSON.stringify can result into float:0
               *meaning that the float 0.0 is transformed in an integer like 0, that's why we also need to allow integers, to be
               *able to handle these rounding issues.
             */
            if (json_is_real(json_data) || json_is_integer(json_data)) {
                float qeo_value = (float) json_real_value(json_data);
                result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                if (QEO_OK != result) {
                    qeo_log_e("qeocore_data_set_member failed");
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_STRING:
        {
            if (json_is_string(json_data)) {
                const char *qeo_value = json_string_value(json_data);
                result = qeocore_data_set_member(data, qeo_member_id, &qeo_value);
                if (QEO_OK != result) {
                    qeo_log_e("qeocore_data_set_member failed");
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_STRUCT:
        {
            if (json_is_object(json_data)) {
                qeocore_data_t *qeo_data = NULL;
                do {
                    if (QEO_OK != qeocore_data_get_member(data, qeo_member_id, &qeo_data)) {
                        qeo_log_e("qeocore_data_get_member failed");
                        break;
                    }

                    if (NULL == qeo_data) {
                        qeo_log_e("NULL == qeo_data");
                        break;
                    }

                    json_t *item = json_object_get(member, KEY_ITEM);
                    if (NULL == item) {
                        qeo_log_e("NULL == item");
                        break;
                    }
                    if (!json_is_object(item)) {
                        qeo_log_e("item is not an object");
                        break;
                    }

                    result = object_to_data(item, json_data, qeo_data);
                    if (QEO_OK != result) {
                        qeo_log_e("object_to_data failed");
                        break;
                    }

                    result = qeocore_data_set_member(data, qeo_member_id, &qeo_data);
                    if (QEO_OK != result) {
                        qeo_log_e("qeocore_data_set_member failed: member_id:%u", qeo_member_id);
                        break;
                    }
                } while (0);

                if (NULL != qeo_data) {
                    qeocore_data_free(qeo_data);
                }
            }
        }
        break;

        case QEOCORE_TYPECODE_SEQUENCE:
        {
            if (json_is_array(json_data)) {
                qeocore_data_t *qeo_data = NULL;
                if ((QEO_OK == qeocore_data_get_member(data, qeo_member_id, &qeo_data)) && (NULL != qeo_data)) {
                    json_t *items = json_object_get(member, KEY_ITEMS);
                    if ((NULL != items) && json_is_object(items)) {
                        if (QEO_OK == array_to_data(items, json_data, qeo_data)) {
                            result = qeocore_data_set_member(data, qeo_member_id, &qeo_data);
                        }
                    }
                }
                qeocore_data_free(qeo_data);
            }
        }
        break;
        case QEOCORE_TYPECODE_ENUM:
        {
            if (!json_is_integer(json_data)){
                qeo_log_e("Enum should be integer");
                break;
            }
            qeo_enum_value_t enum_val = (qeo_enum_value_t) json_integer_value(json_data);
            if (is_valid_enum_value(member, enum_val) == false){
                qeo_log_e("Could not convert json to enum");
                break;
            }
            result = qeocore_data_set_member(data, qeo_member_id, &enum_val);
        }
        break;
    }
    return result;
}