RockBLOCK 9704 C Library
Doxygen documentation for the RockBLOCK 9704 C Library.
Loading...
Searching...
No Matches
imt_queue.h
Go to the documentation of this file.
1#ifndef IMT_QUEUE_H
2#define IMT_QUEUE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stdlib.h>
10#include <string.h>
11#include <stdbool.h>
12
17#ifndef IMT_QUEUE_SIZE
18 #define IMT_QUEUE_SIZE 1U
19#endif
20
25#define IMT_CRC_SIZE 2U
26
31#ifdef ARDUINO
32 #ifndef IMT_PAYLOAD_SIZE
33 #define IMT_PAYLOAD_SIZE 5000U + IMT_CRC_SIZE
34 #endif
35#else
36 #ifndef IMT_PAYLOAD_SIZE
37 #define IMT_PAYLOAD_SIZE 100000U + IMT_CRC_SIZE
38 #endif
39#endif
40
45typedef struct
46{
47 uint16_t id;
48 uint8_t * buffer;
49 size_t length;
50 uint16_t topic;
52 bool ready;
53} imt_t;
54
59typedef struct
60{
62 uint16_t count;
63 uint16_t head;
64 uint16_t tail;
65 uint16_t maxLength;
67
76bool imtQueueMoAdd(const uint16_t topic, const char * data, const size_t length);
77
86bool imtQueueMtAdd(const uint16_t topic, const uint16_t id, const size_t length);
87
93bool imtQueueMoRemove(void);
94
100bool imtQueueMtRemove(void);
101
108
115
122
130void imtQueueMtLock(bool lock);
131
136void imtQueueInit (void);
137
144inline size_t imtQueueSize(imt_queue_t * queue)
145{
146 return queue->count;
147}
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif
bool imtQueueMtRemove(void)
Remove an outgoing mobile-terminated (MT) message from the queue.
Definition imt_queue.c:125
#define IMT_QUEUE_SIZE
Number of messages allowed in the internal message queue.
Definition imt_queue.h:18
bool imtQueueMoAdd(const uint16_t topic, const char *data, const size_t length)
Add an outgoing mobile-originated (MO) message to the queue.
Definition imt_queue.c:11
bool imtQueueMoRemove(void)
Remove an outgoing mobile-originated (MO) message from the queue.
Definition imt_queue.c:104
imt_t * imtQueueMoGetFirst(void)
Get the address of the head of the MO queue.
Definition imt_queue.c:68
imt_t * imtQueueMtGetLast(void)
Get the address of the latest message in the MT queue.
Definition imt_queue.c:92
void imtQueueInit(void)
Used to initialise both outgoing and incoming queues.
Definition imt_queue.c:146
bool imtQueueMtAdd(const uint16_t topic, const uint16_t id, const size_t length)
Add an incoming mobile-terminated (MT) message to the queue.
Definition imt_queue.c:31
void imtQueueMtLock(bool lock)
Lock or unlock the MT queue to prevent messages from getting discarded if full.
Definition imt_queue.c:56
imt_t * imtQueueMtGetFirst(void)
Get the address of the head of the MT queue.
Definition imt_queue.c:80
size_t imtQueueSize(imt_queue_t *queue)
Inline function used to get the current size of the selected queue.
Definition imt_queue.h:144
Circular buffer structure to hold queued messages.
Definition imt_queue.h:60
uint16_t tail
Definition imt_queue.h:64
uint16_t count
Definition imt_queue.h:62
uint16_t head
Definition imt_queue.h:63
uint16_t maxLength
Definition imt_queue.h:65
Represents a single message in the queue.
Definition imt_queue.h:46
bool readyToProcess
Definition imt_queue.h:51
uint16_t topic
Definition imt_queue.h:50
bool ready
Definition imt_queue.h:52
size_t length
Definition imt_queue.h:49
uint8_t * buffer
Definition imt_queue.h:48
uint16_t id
Definition imt_queue.h:47