more parts of adc fixed

This commit is contained in:
2018-02-07 20:57:02 +01:00
parent 835423099b
commit ddfbbeeb95
5 changed files with 118 additions and 29 deletions
+18 -6
View File
@@ -12,21 +12,26 @@ bool EventReport_Start(EventReport *report)
{
assert_param(report->timestamp != 0);
TF_Msg msg;
TF_ClearMsg(&msg);
msg.len = (TF_LEN) (report->length + 1 /*callsign*/ + 1 /*type*/ + 8 /*checksum*/);
msg.type = MSG_UNIT_REPORT;
const uint8_t len_overhead = 1 /*callsign*/ + 1 /*type*/ + 8 /*timestamp u64*/;
TF_Msg msg = {
.len = (TF_LEN) (report->length + len_overhead),
.type = MSG_UNIT_REPORT,
};
if (!TF_Send_Multipart(comm, &msg)) {
dbg("!! Err sending event");
return false;
}
PayloadBuilder pb = pb_start(evt_buf, 10, NULL);
report->sent_msg_id = msg.frame_id;
PayloadBuilder pb = pb_start(evt_buf, len_overhead, NULL);
pb_u8(&pb, report->unit->callsign);
pb_u8(&pb, report->type);
pb_u64(&pb, report->timestamp);
assert_param(pb.ok);
TF_Multipart_Payload(comm, evt_buf, 10);
TF_Multipart_Payload(comm, evt_buf, len_overhead);
return true;
}
@@ -36,6 +41,13 @@ void EventReport_Data(const uint8_t *buff, uint16_t len)
TF_Multipart_Payload(comm, buff, len);
}
void EventReport_PB(PayloadBuilder *pb)
{
uint32_t len;
uint8_t *buf = pb_close(pb, &len);
TF_Multipart_Payload(comm, buf, len);
}
void EventReport_End(void)
{
TF_Multipart_Close(comm);
+2
View File
@@ -21,12 +21,14 @@ typedef struct event_report_ {
uint64_t timestamp; //!< Microsecond timestamp of the event, captured as close as possible to the IRQ
uint16_t length; //!< Payload length
uint8_t *data; //!< Data if using the EventReport_Send() function, otherwise NULL and data is sent using EventReport_Data()
TF_ID sent_msg_id;
} EventReport;
bool EventReport_Send(EventReport *report);
bool EventReport_Start(EventReport *report);
void EventReport_Data(const uint8_t *buff, uint16_t len);
void EventReport_PB(PayloadBuilder *pb);
void EventReport_End(void);
#endif //GEX_F072_EVENT_REPORTS_H
+1 -2
View File
@@ -57,10 +57,9 @@ void com_send_pb(TF_TYPE type, PayloadBuilder *pb)
void com_send_buf(TF_TYPE type, const uint8_t *buf, uint32_t len)
{
TF_Msg msg = {
.type = MSG_UNIT_REPORT,
.type = type,
.data = buf,
.len = (TF_LEN) len,
.type = type,
};
TF_Send(comm, &msg); // no listener