SmartSnippets DA1459x SDK
dgtl_msg.h
Go to the documentation of this file.
1 
44 #ifndef DGTL_MSG_H_
45 #define DGTL_MSG_H_
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
58 typedef __PACKED_UNION {
59  const uint8_t pkt_type;
60  uint8_t data[0];
61 } dgtl_msg_t;
62 
98 dgtl_msg_t *dgtl_msg_alloc(uint8_t pkt_type, size_t length);
99 
108 void dgtl_msg_free(dgtl_msg_t *msg);
109 
127 void *dgtl_msg_get_param_ptr(dgtl_msg_t *msg, size_t *length);
128 
129 /*
130  * \brief Prepare DGTL message as HCI command packet
131  *
132  * This function can be used to fill HCI command packet header for a previously allocated DGTL
133  * message. The message has to have packet type set to HCI command.
134  *
135  * When called with \p msg set to \p NULL, this function will allocated new message of proper size.
136  *
137  * \param [in] msg existing DGTL message
138  * \param [in] opcode HCI command opcode
139  * \param [in] param_len length of parameters buffer
140  * \param [in] param command parameters
141  *
142  * \return DGTL message
143  *
144  */
145 dgtl_msg_t *dgtl_msg_prepare_hci_cmd(dgtl_msg_t *msg, uint16_t opcode, uint8_t param_len, void *param);
146 
147 /*
148  * \brief Prepare DGTL message as HCI event packet
149  *
150  * This function can be used to fill HCI event packet header for a previously allocated DGTL
151  * message. The message has to have packet type set to HCI event.
152  *
153  * When called with \p msg set to \p NULL, this function will allocated new message of proper size.
154  *
155  * \param [in] msg existing DGTL message
156  * \param [in] code HCI event code
157  * \param [in] param_len length of parameters buffer
158  * \param [in] param command parameters
159  *
160  * \return DGTL message
161  *
162  */
163 dgtl_msg_t *dgtl_msg_prepare_hci_evt(dgtl_msg_t *msg, uint8_t code, uint8_t param_len, void *param);
164 
176 void *dgtl_msg_to_raw_ptr(dgtl_msg_t *msg);
177 
190 dgtl_msg_t *dgtl_msg_from_raw_ptr(void *ptr, uint8_t pkt_type);
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* DGTL_MSG_H_ */
197 
dgtl_msg_get_param_ptr
void * dgtl_msg_get_param_ptr(dgtl_msg_t *msg, size_t *length)
Get pointer to message contents parameters.
dgtl_msg_alloc
dgtl_msg_t * dgtl_msg_alloc(uint8_t pkt_type, size_t length)
Allocate a DGTL message.
dgtl_msg_from_raw_ptr
dgtl_msg_t * dgtl_msg_from_raw_ptr(void *ptr, uint8_t pkt_type)
Get DGTL message pointer from raw buffer.
dgtl_msg_free
void dgtl_msg_free(dgtl_msg_t *msg)
Free DGTL message.
__PACKED_UNION
typedef __PACKED_UNION
DGTL message.
Definition: dgtl_msg.h:58
dgtl_msg_to_raw_ptr
void * dgtl_msg_to_raw_ptr(dgtl_msg_t *msg)
Get pointer for raw buffer of DGTL message.
msg
Structure for messages with id, type, data.
Definition: msg_queues.h:144