Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: telemetry_car_demo telemetry_demo_FRDM-TFC telemetry_example_01 telemetry_indexed_data_demo ... more
Diff: telemetry.hpp
- Revision:
- 0:3a30eba5d8f7
diff -r 000000000000 -r 3a30eba5d8f7 telemetry.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telemetry.hpp Wed Jan 27 17:39:36 2016 +0000
@@ -0,0 +1,72 @@
+#ifndef TELEMETRY_H_
+#define TELEMETRY_H_
+
+#include "stddef.h"
+#include "stdint.h"
+
+#define INCOMING_BUFFER_SIZE 128
+#define OUTGOING_BUFFER_SIZE 128
+#define TOPIC_BUFFER_SIZE 64
+
+// Forward declaration of user state
+typedef struct TM_state TM_state;
+
+// Enumeration of supported message payloads
+enum TM_type {
+ TM_float32 = 0,
+ TM_uint8 = 1,
+ TM_uint16 = 2,
+ TM_uint32 = 3,
+ TM_int8 = 4,
+ TM_int16 = 5,
+ TM_int32 = 6,
+ TM_string = 7
+};
+typedef enum TM_type TM_type;
+
+// Data structure for received messages
+typedef struct TM_msg TM_msg;
+struct TM_msg {
+ TM_type type;
+ char * topic;
+ void * buffer;
+ uint32_t size;
+};
+
+// Data structure for holding transport interface
+typedef struct TM_transport TM_transport;
+struct TM_transport {
+ int32_t (*read)(void * buf, uint32_t sizeToRead);
+ int32_t (*readable)();
+ int32_t (*write)(void * buf, uint32_t sizeToWrite);
+ int32_t (*writeable)();
+};
+
+void init_telemetry(TM_state * s, TM_transport * t);
+
+// Decodes TM_msg buffer and emplaces its value into dst
+// Returns 0 if decoding was successful
+uint32_t emplace(TM_msg * m, char * buf, size_t bufSize);
+uint32_t emplace_u8(TM_msg * m, uint8_t * dst);
+uint32_t emplace_u16(TM_msg * m, uint16_t * dst);
+uint32_t emplace_u32(TM_msg * m, uint32_t * dst);
+uint32_t emplace_i8(TM_msg * m, int8_t * dst);
+uint32_t emplace_i16(TM_msg * m, int16_t * dst);
+uint32_t emplace_i32(TM_msg * m, int32_t * dst);
+uint32_t emplace_f32(TM_msg * m, float * dst);
+
+void publish(const char * topic, char * msg);
+void publish_u8(const char * topic, uint8_t msg);
+void publish_u16(const char * topic, uint16_t msg);
+void publish_u32(const char * topic, uint32_t msg);
+void publish_i8(const char * topic, int8_t msg);
+void publish_i16(const char * topic, int16_t msg);
+void publish_i32(const char * topic, int32_t msg);
+void publish_f32(const char * topic, float msg);
+
+void subscribe(void (*callback)(TM_state * s, TM_msg * m));
+
+void update_telemetry(float elapsedTime);
+
+
+#endif