/** * @file include/di/can/net/structures.h * @brief DI-Net network maintenance data structures * @date Jul 12, 2016 * @author jjacobs * @copyright 2016 Dual Inventive Technology Centre B.V. * * descr */ #ifndef LIBDI_INCLUDE_DI_CAN_NET_STRUCTURES_H_ #define LIBDI_INCLUDE_DI_CAN_NET_STRUCTURES_H_ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /** * Node tracking structure */ struct di_can_net_node { uint32_t nodeid; /**< NodeID (msg->src_id) */ uint64_t seen; /**< Last seen (di_time_get_uptime) */ di_errno_t error; /**< Last received di_errno_t from DI_CAN_NET_DTYPE_NODE_ERROR message */ enum di_can_net_node_states state; enum di_can_net_node_types type; enum di_can_net_node_roles role; }; struct di_can_net_node_fw_version { uint8_t major; uint8_t minor; uint8_t patch; uint8_t year; /**< Year is formatted without century, year 2016 is formatted as 16 */ uint8_t month; uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; }; /** * CAN Net Subsystem */ struct di_can_net { di_bsem_t lock; bool self_was_leader; /**< Flag for application volunteer dropped leadership */ struct di_can_net_node self; /**< Self node */ struct { di_can_net_node_event_cb_t event_cb; /**< Node event callback register by application */ di_bsem_t event_cb_bsem; /**< Node event callback signal for application */ struct di_can_net_node list[DI_CAN_NET_CFG_MAX_NODES]; /**< Network node list */ } nodes; struct { enum di_can_net_discover_state state; uint64_t time; /**< Timestamp of discover request (di_time_get_uptime) */ } discover; struct { uint64_t self_error_publish_time; /**< Self node next periodic publish time when self.error != DNOK */ } periodic; }; #ifdef __cplusplus } #endif #endif /* LIBDI_INCLUDE_DI_CAN_NET_STRUCTURES_H_ */