Functions for iterating over fields in a MIP packet.
More...
Use these functions to iterate over the fields in a MIP packet.
Example:
{
switch( mip_field_field_desriptor(&field) )
{
case MIP_DATA_DESC_SENSOR_SCALED_ACCEL:
break;
}
}
◆ mip_field_init_empty()
Intended to be used with mip_field_next_in_packet. The field will not be valid (mip_field_is_valid will return false).
- Parameters
-
◆ mip_field_from_header_ptr()
| mip_field_view mip::C::mip_field_from_header_ptr |
( |
const uint8_t * |
header, |
|
|
uint8_t |
total_length, |
|
|
uint8_t |
descriptor_set |
|
) |
| |
Generally you should use mip_field_from_packet() or mip_field_create() instead.
- Parameters
-
| header | A pointer to the header and payload. Usually inside of a MIP packet. |
| total_length | The total length of either the field or packet payload, starting from header_ptr and including the header bytes. If total_length is longer than the field (i.e. if it's the packet payload length) then mip_field_next() may be used to iterate fields. |
| descriptor_set | The descriptor set for the packet containing this field. May be 0x00 if not used by any function handling the field. |
- Returns
- a mip_field struct with the field data.
◆ mip_field_first_from_packet()
Typically this would be used as the first step when iterating through all fields in a received packet. To access each field after the first, call mip_field_next(). You should call mip_field_is_at_end() or mip_field_is_valid() after obtaining each field (including the first) to determine if the field is actually valid.
- Parameters
-
| packet | The mip packet containing 0 or more fields. Assumed to be valid, and the payload pointer and size must be correct. |
- Returns
- A mip_field struct with the first field from the packet.
◆ mip_field_next_after()
- Parameters
-
| field | An existing MIP field in a packet. Can be invalid, in which case the result will also be invalid. |
- Returns
- A mip_field struct referencing the next field after the input field._ Check mip_field_is_valid() to see if the field exists.
◆ mip_field_next()
- Parameters
-
| field | This mip_field struct will be updated to the next field._ Can be an invalid field, in which case the result will be invalid as well. |
- Returns
- true if the field exists and is valid.
◆ mip_field_next_in_packet()
- Parameters
-
| field | An initialized mip_field struct. This will be updated to the next field in the packet, if one exists. Otherwise it will be invalid. |
| packet | A valid MIP packet. |
- Returns
- true if another field exists.
-
false if there are no more fields.
Example usage:
struct mip_field field;
{
}
bool mip_field_next_in_packet(mip_field_view *field, const mip_packet_view *packet)
Iterates over all fields in a packet.
Definition: mip_field.c:240
void mip_field_init_empty(mip_field_view *field)
Initialize a mip_field struct to an invalid/empty state.
Definition: mip_field.c:106
bool mip_field_next(mip_field_view *field)
Updates the mip_field to refer to the next field in a packet.
Definition: mip_field.c:211
bool mip_field_is_valid(const mip_field_view *field)
Returns true if the field has a valid field descriptor.
Definition: mip_field.c:91