/** * @file di/rpc.h * @brief brief * @date Aug 27, 2015 * @author rheijden * @copyright 2015 Dual Inventive Technology Centre B.V. * * RPC */ #ifndef INCLUDE_DI_RPC_H_ #define INCLUDE_DI_RPC_H_ #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif #include #include enum di_rpc_types di_rpc_types_from_str(const char *type); const char *di_rpc_types_to_str(const enum di_rpc_types type); const char *di_rpc_data_type_to_str(const enum di_rpc_data_type type); bool di_rpc_data_is_type(const struct di_rpc_data *data, const enum di_rpc_data_type type); const char *di_rpc_msg_type_to_str(const enum di_rpc_msg_type type); /** * init rpc_data_struct * @param data pointer to rpc_data_struct */ void di_rpc_rpc_data_init(struct di_rpc_data *data); /** * Reset RPC message structure * @param msg The message to reset * @param device_uid The device:uid which must be valid (checked with di_device_uid_isvalid) */ void di_rpc_msg_reset(struct di_rpc_msg *msg, const char device_uid[DI_DEVICE_UID_LEN]); #ifndef __cplusplus #define di_rpc_to_str(type) \ _Generic((type), \ const enum di_rpc_msg_type : di_rpc_msg_type_to_str, \ enum di_rpc_msg_type : di_rpc_msg_type_to_str, \ const enum di_rpc_types : di_rpc_types_to_str, \ enum di_rpc_types : di_rpc_types_to_str, \ const enum di_rpc_data_type : di_rpc_data_type_to_str, \ enum di_rpc_data_type : di_rpc_data_type_to_str \ )(type) #endif #ifdef __cplusplus } #endif #ifdef __cplusplus static inline const char *di_rpc_to_str(const enum di_rpc_types type) { return di_rpc_types_to_str(type); } static inline const char *di_rpc_to_str(const enum di_rpc_data_type type) { return di_rpc_data_type_to_str(type); } static inline const char *di_rpc_to_str(const enum di_rpc_msg_type type) { return di_rpc_msg_type_to_str(type); } #endif #endif /* INCLUDE_DI_RPC_H_ */