void readVec3(CborValue *it0, Vec3 *vec3)
{
    CborValue it1; CborValue* it = &it1; cbor_value_enter_container(it0, it);
    cbor_value_get_float(it, &(vec3->x)); cbor_value_advance_fixed(it);
    cbor_value_get_float(it, &(vec3->y)); cbor_value_advance_fixed(it);
    cbor_value_get_float(it, &(vec3->z)); cbor_value_advance_fixed(it);
    cbor_value_leave_container(it0, it);
}
Exemple #2
0
CborError
sol_oic_decode_cbor_repr(struct sol_coap_packet *pkt, struct sol_vector *reprs)
{
    CborParser parser;
    CborError err;
    CborValue root, array, repr;
    uint8_t *payload;
    uint16_t size;
    int payload_type;

    if (sol_coap_packet_get_payload(pkt, &payload, &size) < 0)
        return CborErrorUnknownLength;

    err = cbor_parser_init(payload, size, 0, &parser, &root);
    if (err != CborNoError)
        return err;

    if (!cbor_value_is_array(&root))
        return CborErrorIllegalType;

    err |= cbor_value_enter_container(&root, &array);

    err |= cbor_value_get_int(&array, &payload_type);
    err |= cbor_value_advance_fixed(&array);
    if (err != CborNoError)
        return err;
    if (payload_type != SOL_OIC_PAYLOAD_REPRESENTATION)
        return CborErrorIllegalType;
    if (cbor_value_map_find_value(&array, SOL_OIC_KEY_REPRESENTATION, &repr) != CborNoError)
        return CborErrorIllegalType;

    /* We're done with this CborParser, no need to close the container. */
    return sol_oic_decode_cbor_repr_map(&repr, reprs);
}
void readInputEventType(CborValue *it0, InputEventType *inputEventType)
{
    cout<<"in IET - 1\n";
    CborValue it1; CborValue *it = &it1; cbor_value_enter_container(it0, it);
    int i; cbor_value_get_int(it, &i); cbor_value_advance_fixed(it);
    inputEventType->selector = (EnumInputEventType)i;
    if (inputEventType->selector == 0) {
    };
    if (inputEventType->selector == 1) {
    };
    if (inputEventType->selector == 2) {
    };
    if (inputEventType->selector == 3) {
    };
    if (inputEventType->selector == 4) {
    };
    if (inputEventType->selector == 5) {
    };
    if (inputEventType->selector == 6) {
    };
    if (inputEventType->selector == 7) {
    };
    cbor_value_leave_container(it0, it);
    cout<<"in IET - 2\n";
}
Exemple #4
0
/**
 * Advances the CBOR value \a it until it no longer points to a tag. If \a it is
 * already not pointing to a tag, then this function returns it unchanged.
 *
 * \sa cbor_value_advance_fixed(), cbor_value_advance()
 */
CborError cbor_value_skip_tag(CborValue *it)
{
    while (cbor_value_is_tag(it)) {
        CborError err = cbor_value_advance_fixed(it);
        if (err)
            return err;
    }
    return CborNoError;
}
void readInputEventHandler(CborValue *it0, InputEventHandler *inputEventHandler)
{
    CborValue it1; CborValue *it = &it1; cbor_value_enter_container(it0, it);
    int i; cbor_value_get_int(it, &i); cbor_value_advance_fixed(it);
    inputEventHandler->selector = (EnumInputEventHandler)i;
    if (inputEventHandler->selector == 0) {
    };
    if (inputEventHandler->selector == 1) {
        /* TBD */    };
    cbor_value_leave_container(it0, it);
}
void readGeometry(CborValue *it0, Geometry *geometry)
{
    CborValue it1; CborValue *it = &it1; cbor_value_enter_container(it0, it);
    int i; cbor_value_get_int(it, &i); cbor_value_advance_fixed(it);
    geometry->selector = (EnumGeometry)i;
    if (geometry->selector == 0) {
        readShape(it, &(geometry->data.ShapeGeometry.value0));
    };
    if (geometry->selector == 1) {
        { size_t l; cbor_value_calculate_string_length(it, &l); geometry->data.ResourceGeometry.value0.resize(l+1);
        cbor_value_copy_text_string(it, (char *)(geometry->data.ResourceGeometry.value0.c_str()), &l, NULL); cbor_value_advance(it);}
    };
    cbor_value_leave_container(it0, it);
}
void readShape(CborValue *it0, Shape *shape)
{
    CborValue it1; CborValue *it = &it1; cbor_value_enter_container(it0, it);
    int i; cbor_value_get_int(it, &i); cbor_value_advance_fixed(it);
    shape->selector = (EnumShape)i;
    if (shape->selector == 0) {
    };
    if (shape->selector == 1) {
    };
    if (shape->selector == 2) {
    };
    if (shape->selector == 3) {
    };
    if (shape->selector == 4) {
    };
    if (shape->selector == 5) {
    };
    cbor_value_leave_container(it0, it);
}
Exemple #8
0
static bool
_parse_server_info_payload(struct sol_oic_server_information *info,
    uint8_t *payload, uint16_t payload_len)
{
    CborParser parser;
    CborError err;
    CborValue root, array, value, map;
    int payload_type;

    err = cbor_parser_init(payload, payload_len, 0, &parser, &root);
    if (err != CborNoError)
        return false;
    if (!cbor_value_is_array(&root))
        return false;

    err |= cbor_value_enter_container(&root, &array);

    err |= cbor_value_get_int(&array, &payload_type);
    err |= cbor_value_advance_fixed(&array);
    if (err != CborNoError)
        return false;
    if (payload_type != SOL_OIC_PAYLOAD_PLATFORM)
        return false;

    if (!cbor_value_is_map(&array))
        return false;

    /* href is intentionally ignored */

    err |= cbor_value_map_find_value(&map, SOL_OIC_KEY_REPRESENTATION, &value);
    if (!cbor_value_is_map(&value))
        return false;

    if (err != CborNoError)
        return false;

    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_PLATFORM_ID, &info->platform_id))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_MANUF_NAME, &info->manufacturer_name))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_MANUF_URL, &info->manufacturer_url))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_MODEL_NUM, &info->model_number))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_MANUF_DATE, &info->manufacture_date))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_PLATFORM_VER, &info->platform_version))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_OS_VER, &info->os_version))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_HW_VER, &info->hardware_version))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_FIRMWARE_VER, &info->firmware_version))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_SUPPORT_URL, &info->support_url))
        return false;
    if (!_cbor_map_get_str_value(&value, SOL_OIC_KEY_SYSTEM_TIME, &info->system_time))
        return false;

    return err == CborNoError;
}