First class data visualization and communication library with embedded devices. Code is maintained at github.com/Overdrivr/Telemetry
Dependents: telemetry_car_demo telemetry_demo_FRDM-TFC telemetry_example_01 telemetry_indexed_data_demo ... more
Diff: telemetry.hpp
- Revision:
- 3:37d2d127bc83
- Parent:
- 2:b7a3ac7bcec8
- Child:
- 4:8e3de1a314e1
diff -r b7a3ac7bcec8 -r 37d2d127bc83 telemetry.hpp --- a/telemetry.hpp Thu Feb 11 08:10:08 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -#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