4#ifndef PSTOP_PSTOP_MSG_H
5#define PSTOP_PSTOP_MSG_H
9#include "pstop/config.h"
10#include "pstop/device_id.h"
11#include "pstop/error.h"
13typedef uint8_t message_type_t;
15#define PSTOP_MESSAGE_OK 0x55U
16#define PSTOP_MESSAGE_STOP 0x92U
17#define PSTOP_MESSAGE_BOND 0xADU
18#define PSTOP_MESSAGE_UNBOND 0x6AU
19#define PSTOP_MESSAGE_UNKNOWN 0x0FU
97uint8_t pstop_message_get_message(
const pstop_msg_t *msg);
98uint64_t pstop_message_get_stamp(
const pstop_msg_t *msg);
99uint32_t pstop_message_get_counter(
const pstop_msg_t *msg);
103 uint64_t timestamp, uint64_t received_timestamp,
105 uint32_t counter, uint32_t received_counter);
113 uint64_t timestamp, uint64_t received_timestamp,
115 uint32_t counter, uint32_t received_counter);
118 uint64_t timestamp, uint64_t received_timestamp,
120 uint32_t counter, uint32_t received_counter);
123 uint64_t timestamp, uint64_t received_timestamp,
125 uint32_t counter, uint32_t received_counter);
127pstop_error_t pstop_is_message_valid(
const pstop_msg_t *msg);
139void pstop_message_decode(
pstop_msg_t *msg,
const uint8_t *data);
151void pstop_message_encode(
const pstop_msg_t *msg, uint8_t *data);
Identifier of a pstop device.
Definition device_id.h:12
A PSTOP message object.
Definition pstop_msg.h:25
message_type_t message
Type of message.
Definition pstop_msg.h:34
uint16_t checksum
a CRC-16 checksum of the above values.
Definition pstop_msg.h:85
device_id_t id
The UUID of this device.
Definition pstop_msg.h:50
uint64_t stamp
The timestamp (in milliseconds) of this message.
Definition pstop_msg.h:39
uint32_t counter
An incrementing counter.
Definition pstop_msg.h:66
uint64_t received_stamp
The last timestamp that we received from the client.
Definition pstop_msg.h:45
uint16_t calculated_checksum
The checksum that is calculated when a PSTOP message is decoded from an array of bytes.
Definition pstop_msg.h:91
uint32_t received_counter
The last counter we received from the client.
Definition pstop_msg.h:72
uint32_t padding1
extra padding bytes
Definition pstop_msg.h:77
uint8_t version
Version of this message.
Definition pstop_msg.h:29
uint32_t heartbeat_timeout
A timeout in milliseconds that we expect to receive heartbeats from this machine.
Definition pstop_msg.h:61
uint32_t padding2
Reserved.
Definition pstop_msg.h:80
device_id_t receiver_id
Unique ID of the device we are sending this message to.
Definition pstop_msg.h:55