cleanup and added sync + async commands

This commit is contained in:
2018-01-15 14:06:48 +01:00
parent 5d12b23ceb
commit b3d1f95e7d
5 changed files with 137 additions and 31 deletions
+7
View File
@@ -5,6 +5,7 @@
#include "platform.h"
#include "messages.h"
#include "msg_responses.h"
#include "payload_builder.h"
void com_respond_snprintf(TF_ID frame_id, TF_TYPE type, const char *format, ...)
{
@@ -37,6 +38,12 @@ void com_respond_ok(TF_ID frame_id)
com_respond_buf(frame_id, MSG_SUCCESS, NULL, 0);
}
void com_send_pb(TF_TYPE type, PayloadBuilder *pb)
{
uint32_t len;
uint8_t *buf = pb_close(pb, &len);
com_send_buf(type, buf, len);
}
void com_send_buf(TF_TYPE type, const uint8_t *buf, uint32_t len)
{
+10
View File
@@ -9,6 +9,8 @@
#error "Include messages.h instead!"
#endif
#include "payload_builder.h"
/**
* Respond to a TF message using printf-like formatting.
*
@@ -54,6 +56,14 @@ void com_respond_error(TF_ID frame_id, error_t error);
*/
void com_send_buf(TF_TYPE type, const uint8_t *buf, uint32_t len);
/**
* Send a payload builder's content
*
* @param type - response type byte
* @param pb - builder
*/
void com_send_pb(TF_TYPE type, PayloadBuilder *pb);
/**
* Same like tf_respond_buf(), but the buffer length is measured with strlen.
* Used to sending ASCII string responses.