Message
include/rid/message.h
Message header handling per ASTM F3411-22a.
Example usage:
uint8_t buffer[] = {
0xe3, 0xd2, 0x27, 0xcf, 0xfd, 0x7f, 0x00, 0x00,
0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00
};
const rid_message_t *message = (const rid_message_t *)buffer;
rid_protocol_version_t version = rid_message_get_protocol_version(message);
rid_message_type_t type = rid_message_get_type(message);
printf("Protocol version: %u\n", version);
printf("Message type: %u\n", type);
Structures and Types
| Type | Name |
|---|---|
| enum | rid_error_t |
| struct | rid_message_t Generic message structure for any Remote ID message. |
| enum | rid_message_type_t |
| enum | rid_protocol_version_t |
Functions
| Type | Name |
|---|---|
| const char * | rid_error_to_string (rid_error_t error) Convert error code to string representation. |
| rid_protocol_version_t | rid_message_get_protocol_version (const void *message) Get the protocol version from a generic message structure. |
| rid_message_type_t | rid_message_get_type (const void *message) Get the message type from a generic message structure. |
| int | rid_message_to_json (const void *message, char *buffer, size_t buffer_size, size_t *needed_size) Format any Remote ID message as a JSON string. |
| const char * | rid_message_type_to_string (rid_message_type_t type) Convert message type to string representation. |
| int | rid_message_validate (const void *message) Validate any Remote ID message. |
| const char * | rid_protocol_version_to_string (rid_protocol_version_t version) Convert protocol version to string representation. |
Macros
| Type | Name |
|---|---|
| define | RID_MESSAGE_SIZE 25 Size of a single message in bytes. |
Structures and Types Documentation
enum rid_error_t
enum rid_error_t {
RID_SUCCESS = 0,
RID_ERROR_NULL_POINTER = -1,
RID_ERROR_BUFFER_TOO_SMALL = -2,
RID_ERROR_BUFFER_TOO_LARGE = -3,
RID_ERROR_INVALID_CHARACTER = -4,
RID_ERROR_OUT_OF_RANGE = -5,
RID_ERROR_UNKNOWN_MESSAGE_TYPE = -6,
RID_ERROR_INVALID_LATITUDE = -7,
RID_ERROR_INVALID_LONGITUDE = -8,
RID_ERROR_INVALID_TRACK_DIRECTION = -9,
RID_ERROR_INVALID_TIMESTAMP = -10,
RID_ERROR_INVALID_PROTOCOL_VERSION = -11,
RID_ERROR_INVALID_MESSAGE_COUNT = -12,
RID_ERROR_INVALID_MESSAGE_SIZE = -13,
RID_ERROR_INVALID_LAST_PAGE_INDEX = -14,
RID_ERROR_INVALID_PAGE_NUMBER = -15,
RID_ERROR_NON_EMPTY_SIGNATURE = -16,
RID_ERROR_INVALID_UUID_VERSION = -17,
RID_ERROR_INVALID_UUID_VARIANT = -18,
RID_ERROR_INVALID_UUID_PADDING = -19,
RID_ERROR_INVALID_SERIAL_NUMBER = -20,
RID_ERROR_INVALID_CAA_REGISTRATION_ID = -21,
RID_ERROR_NOT_FOUND = -22,
RID_ERROR_INVALID_MESSAGE_TYPE = -23,
RID_ERROR_NOT_IMPLEMENTED = -24,
RID_ERROR_INVALID_COMBINATION = -25
};
struct rid_message_t
Generic message structure for any Remote ID message.
All messages are 25 bytes with a common header. Cast to specific message type after checking message_type field.
Variables:
-
uint8_t body
-
uint8_t message_type
-
uint8_t protocol_version
enum rid_message_type_t
enum rid_message_type_t {
RID_MESSAGE_TYPE_BASIC_ID = 0x00,
RID_MESSAGE_TYPE_LOCATION = 0x01,
RID_MESSAGE_TYPE_AUTH = 0x02,
RID_MESSAGE_TYPE_SELF_ID = 0x03,
RID_MESSAGE_TYPE_SYSTEM = 0x04,
RID_MESSAGE_TYPE_OPERATOR_ID = 0x05,
RID_MESSAGE_TYPE_MESSAGE_PACK = 0x0F
};
enum rid_protocol_version_t
enum rid_protocol_version_t {
RID_PROTOCOL_VERSION_0 = 0x00,
RID_PROTOCOL_VERSION_1 = 0x01,
RID_PROTOCOL_VERSION_2 = 0x02,
RID_PROTOCOL_PRIVATE_USE = 0x0F
};
Functions Documentation
function rid_error_to_string
Convert error code to string representation.
const char * rid_error_to_string (
rid_error_t error
)
Parameters:
errorThe error code to convert.
Returns:
String representation of the error code. Returns "UNKNOWN" for invalid values.
function rid_message_get_protocol_version
Get the protocol version from a generic message structure.
rid_protocol_version_t rid_message_get_protocol_version (
const void *message
)
Parameters:
messagePointer to the message structure.
Returns:
The protocol version or RID_PROTOCOL_VERSION_0 if message is NULL.
function rid_message_get_type
Get the message type from a generic message structure.
rid_message_type_t rid_message_get_type (
const void *message
)
Parameters:
messagePointer to the message structure.
Returns:
The message type or RID_MESSAGE_TYPE_BASIC_ID if message is NULL.
function rid_message_to_json
Format any Remote ID message as a JSON string.
int rid_message_to_json (
const void *message,
char *buffer,
size_t buffer_size,
size_t *needed_size
)
Determines the message type and calls the appropriate type-specific *_to_json() function.
Parameters:
messagePointer to any Remote ID message structure.bufferBuffer to store the JSON string or NULL.buffer_sizeSize of the buffer.needed_sizeIf non-NULL receives the required buffer size.
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERifmessageis NULL or if bothbufferandneeded_sizeare NULL.RID_ERROR_BUFFER_TOO_SMALLifbufferis too small.
function rid_message_type_to_string
Convert message type to string representation.
const char * rid_message_type_to_string (
rid_message_type_t type
)
Parameters:
typeThe message type to convert.
Returns:
String representation of the message type. Returns "UNKNOWN" for invalid values.
function rid_message_validate
Validate any Remote ID message.
int rid_message_validate (
const void *message
)
Dispatches to the appropriate type-specific validation function based on the message type field.
Parameters:
messagePointer to the message structure to validate.
Return value:
RID_SUCCESSif validation passes.RID_ERROR_NULL_POINTERif message is NULL.RID_ERROR_UNKNOWN_MESSAGE_TYPEif message type is not recognized.Othererror codes from type-specific validators.
function rid_protocol_version_to_string
Convert protocol version to string representation.
const char * rid_protocol_version_to_string (
rid_protocol_version_t version
)
Parameters:
versionThe protocol version to convert.
Returns:
String representation of the protocol version. Returns "UNKNOWN" for invalid values.
Macros Documentation
define RID_MESSAGE_SIZE
Size of a single message in bytes.
#define RID_MESSAGE_SIZE 25