You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.3 KiB
91 lines
2.3 KiB
//
|
|
// Created by MightyPork on 2017/12/22.
|
|
//
|
|
|
|
#ifndef GEX_F072_MSG_RESPONSES_H
|
|
#define GEX_F072_MSG_RESPONSES_H
|
|
|
|
#ifndef GEX_MESSAGES_H
|
|
#error "Include messages.h instead!"
|
|
#endif
|
|
|
|
/**
|
|
* Respond to a TF message using printf-like formatting.
|
|
*
|
|
* @param type - response type byte
|
|
* @param frame_id - ID of the original msg
|
|
* @param format - printf format
|
|
* @param ... - replacements
|
|
*/
|
|
void __attribute__((format(printf,3,4)))
|
|
com_respond_snprintf(TF_ID frame_id, TF_TYPE type, const char *format, ...);
|
|
|
|
/**
|
|
* Respond to a TF message with a buffer of fixed length and custom type.
|
|
*
|
|
* @param type - response type byte
|
|
* @param frame_id - ID of the original msg
|
|
* @param buf - byte buffer
|
|
* @param len - buffer size
|
|
*/
|
|
void com_respond_buf(TF_ID frame_id, TF_TYPE type, const uint8_t *buf, uint32_t len);
|
|
|
|
/**
|
|
* Respond to a TF message with empty body and MSG_SUCCESS type.
|
|
*
|
|
* @param frame_id - ID of the original msg
|
|
*/
|
|
void com_respond_ok(TF_ID frame_id);
|
|
|
|
/**
|
|
* Respond with a error constant (converted to string)
|
|
*
|
|
* @param frame_id - ID of the original msg
|
|
* @param error - error to report
|
|
*/
|
|
void com_respond_error(TF_ID frame_id, error_t error);
|
|
|
|
/**
|
|
* Same like tf_respond_buf(), but used for sending spontaneous reports.
|
|
*
|
|
* @param type - response type byte
|
|
* @param buf - byte buffer
|
|
* @param len - buffer size
|
|
*/
|
|
void com_send_buf(TF_TYPE type, const uint8_t *buf, uint32_t len);
|
|
|
|
/**
|
|
* Same like tf_respond_buf(), but the buffer length is measured with strlen.
|
|
* Used to sending ASCII string responses.
|
|
*
|
|
* @param type - response type byte
|
|
* @param frame_id - ID of the original msg
|
|
* @param str - character buffer, zero terminated
|
|
*/
|
|
void com_respond_str(TF_TYPE type, TF_ID frame_id, const char *str);
|
|
|
|
/**
|
|
* Schedule sending a one-byte response with MSG_SUCCESS type.
|
|
*
|
|
* @param frame_id - ID of the original msg
|
|
* @param d - data
|
|
*/
|
|
void com_respond_u8(TF_ID frame_id, uint8_t d);
|
|
|
|
/**
|
|
* Schedule sending a two-byte response with MSG_SUCCESS type.
|
|
*
|
|
* @param frame_id - ID of the original msg
|
|
* @param d - data
|
|
*/
|
|
void com_respond_u16(TF_ID frame_id, uint16_t d);
|
|
|
|
/**
|
|
* Schedule sending a 4-byte response with MSG_SUCCESS type.
|
|
*
|
|
* @param frame_id - ID of the original msg
|
|
* @param d - data
|
|
*/
|
|
void com_respond_u32(TF_ID frame_id, uint32_t d);
|
|
|
|
#endif //GEX_F072_MSG_RESPONSES_H
|
|
|