#include <stdint.h>
-#define MSG_HEADER 0x1234
-#define MSG_MAXID 2
+#define MSG_HEADER 0x1234
+
+#define MSG_VALID_DEVICE 0x0001
+#define MSG_VALID_START 0x0002
+#define MSG_VALID_PERIOD 0x0004
+#define MSG_VALID_WORLD 0x0008
#pragma pack(1)
typedef enum {
+ MSG_ID_INIT, // Device initialization
MSG_ID_SYNC, // Time synchronization
MSG_ID_EVENT, // Event occurred
+ MSG_MAX_ID, // Maximum message ID
} msgid_t;
typedef struct {
uint16_t cksum; // Body checksum
} header_t;
+typedef struct {
+ uint16_t valid; // Message valid bits
+ uint16_t device; // Device ID to use
+ ntime_t start; // Transmit start time
+ ntime_t period; // Transmit period
+ ntime_t world; // World time (since 1970)
+} init_msg_t;
+
typedef struct {
uint32_t seq; // Current sequence counter
ntime_t time; // Time of previous message