MIP_SDK  latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
mip_dispatch.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "mip_types.h"
4 #include "mip_field.h"
5 #include "mip_packet.h"
6 #include "mip_descriptors.h"
7 
8 #include <stdbool.h>
9 
10 
11 #ifdef __cplusplus
12 namespace mip {
13 namespace C {
14 extern "C" {
15 #endif
16 
17 
21 
22 
35 
36 
37 
45 typedef void (*mip_dispatch_packet_callback)(void* context, const mip_packet_view* packet, mip_timestamp timestamp);
46 
54 typedef void (*mip_dispatch_field_callback)(void* context, const mip_field_view* field, mip_timestamp timestamp);
55 
62 typedef bool (*mip_dispatch_extractor)(const mip_field_view* field, void *ptr);
63 
64 
65 enum {
71 
75 };
76 
91 
94 typedef struct mip_dispatch_handler
95 {
96  struct mip_dispatch_handler* _next;
97  union
98  {
99  mip_dispatch_packet_callback _packet_callback;
100  mip_dispatch_field_callback _field_callback;
101  mip_dispatch_extractor _extract_callback;
102  };
103  void* _user_data;
104  uint8_t _type;
105  uint8_t _descriptor_set;
106  uint8_t _field_descriptor;
107  uint8_t _enabled;
109 
110 
111 void mip_dispatch_handler_init_packet_handler(mip_dispatch_handler* handler, uint8_t descriptor_set, bool after_fields, mip_dispatch_packet_callback callback, void* context);
112 void mip_dispatch_handler_init_field_handler(mip_dispatch_handler* handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void* context);
113 void mip_dispatch_handler_init_extractor(mip_dispatch_handler* handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor extractor, void* field_ptr);
114 
115 void mip_dispatch_handler_set_enabled(mip_dispatch_handler* handler, bool enable);
117 
118 
126 
127 
130 typedef struct mip_dispatcher
131 {
132  mip_dispatch_handler* _first_handler;
134 
135 
140 
141 void mip_dispatcher_dispatch_packet(mip_dispatcher* self, const mip_packet_view* packet, mip_timestamp timestamp);
142 
147 
148 
149 #ifdef __cplusplus
150 } // extern "C"
151 } // namespace C
152 } // namespace mip
153 #endif
mip_packet.h
mip::C::MIP_DISPATCH_ANY_DATA_SET
@ MIP_DISPATCH_ANY_DATA_SET
Definition: mip_dispatch.h:70
mip::C::mip_dispatch_field_callback
void(* mip_dispatch_field_callback)(void *context, const mip_field_view *field, mip_timestamp timestamp)
Signature for field-level callbacks.
Definition: mip_dispatch.h:54
mip
A collection of C++ classes and functions covering the full mip api.
Definition: commands_3dm.c:11
mip::C::mip_dispatcher_remove_handler
void mip_dispatcher_remove_handler(mip_dispatcher *self, mip_dispatch_handler *handler)
Removes a handler from the dispatch system.
Definition: mip_dispatch.c:210
mip::C::MIP_DISPATCH_ANY_DESCRIPTOR
@ MIP_DISPATCH_ANY_DESCRIPTOR
Definition: mip_dispatch.h:74
mip_types.h
mip::C::mip_dispatch_handler_init_extractor
void mip_dispatch_handler_init_extractor(mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor extractor, void *field_ptr)
Initialize the dispatch handler with an extraction callback.
Definition: mip_dispatch.c:131
mip::C::mip_packet_view
Structure representing a MIP Packet.
Definition: mip_packet.h:50
mip::C::mip_dispatcher
Holds the state of the MIP dispatch system.
Definition: mip_dispatch.h:130
mip::C::mip_dispatch_handler
struct mip::C::mip_dispatch_handler mip_dispatch_handler
Handler information for MIP Packet or Field callbacks.
mip::C::mip_dispatcher_init
void mip_dispatcher_init(mip_dispatcher *self)
Initializes the mip_dispatcher object.
Definition: mip_dispatch.c:178
mip::C::mip_dispatch_packet_callback
void(* mip_dispatch_packet_callback)(void *context, const mip_packet_view *packet, mip_timestamp timestamp)
Signature for packet-level callbacks.
Definition: mip_dispatch.h:45
mip::C::mip_dispatcher_add_handler
void mip_dispatcher_add_handler(mip_dispatcher *self, mip_dispatch_handler *handler)
Registers a handler in the dispatch system.
Definition: mip_dispatch.c:189
mip::C::mip_dispatch_handler_is_enabled
bool mip_dispatch_handler_is_enabled(mip_dispatch_handler *handler)
Determines if the handler is currently enabled.
Definition: mip_dispatch.c:166
mip::C::mip_field_view
A structure representing a MIP field.
Definition: mip_field.h:52
mip::C::mip_dispatch_handler_init_field_handler
void mip_dispatch_handler_init_field_handler(mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void *user_data)
Initialize the dispatch handler with a field callback.
Definition: mip_dispatch.c:86
mip_field.h
mip::C::mip_dispatch_handler_init_packet_handler
void mip_dispatch_handler_init_packet_handler(mip_dispatch_handler *handler, uint8_t descriptor_set, bool post_callback, mip_dispatch_packet_callback callback, void *user_data)
Initialize the dispatch handler with a packet callback.
Definition: mip_dispatch.c:51
mip_descriptors.h
mip::C::mip_dispatcher_dispatch_packet
void mip_dispatcher_dispatch_packet(mip_dispatcher *self, const mip_packet_view *packet, mip_timestamp timestamp)
Called to dispatch the callbacks for a given packet.
Definition: mip_dispatch.c:353
mip::C::mip_dispatch_handler
Handler information for MIP Packet or Field callbacks.
Definition: mip_dispatch.h:94
mip::C::mip_timestamp
microstrain::C::microstrain_embedded_timestamp mip_timestamp
Definition: mip_types.h:15
mip::C::mip_dispatch_extractor
bool(* mip_dispatch_extractor)(const mip_field_view *field, void *ptr)
Signature for extraction callbacks.
Definition: mip_dispatch.h:62
mip::C::mip_dispatcher
struct mip::C::mip_dispatcher mip_dispatcher
Holds the state of the MIP dispatch system.
mip::C::mip_dispatcher_remove_all_handlers
void mip_dispatcher_remove_all_handlers(mip_dispatcher *self)
Removes all handlers from the dispatcher.
Definition: mip_dispatch.c:239
mip::C::mip_dispatch_handler_set_enabled
void mip_dispatch_handler_set_enabled(mip_dispatch_handler *handler, bool enable)
Enables or disables the handler.
Definition: mip_dispatch.c:156