-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmqtt_queue.c
More file actions
127 lines (111 loc) · 3.11 KB
/
mqtt_queue.c
File metadata and controls
127 lines (111 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* pixy_queue.c
*
* Created on: 2019Äê9ÔÂ29ÈÕ
* Author: jiez
*/
#include "mqtt_queue.h"
#include "sensors_queue.h"
void createMqttQ()
{
mqtt_queue = xQueueCreate(Q1_QUEUE_SZ, Q1_MSG_SZ);
if(mqtt_queue == NULL){
dbgTerminalError();
}
}
void createRoverQ()
{
rover_queue = xQueueCreate(Q2_QUEUE_SZ, Q2_MSG_SZ);
if(rover_queue == NULL){
dbgTerminalError();
}
}
void createStatQ()
{
stat_queue = xQueueCreate(Q2_QUEUE_SZ, Q2_MSG_SZ);
if (stat_queue == NULL)
{
dbgTerminalError();
}
}
int sendMqttFinishToSensorQ()
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
msgQueue_sensor msg;
msg.dataType = MQTT_CREATED_COMPLETE;
BaseType_t err = xQueueSendToBackFromISR(sensor_queue, &msg, &xHigherPriorityTaskWoken);
if (err != pdPASS) {
//dbgTerminalError();
while(1);
}
//dbgOutputLoc(SEND_TIME_POST_LOC);
return 1;
}
int32_t sendMsgToMqtt( msgQueue_t2 *queueElement)
{
// dbgOutputLoc(SEND_TO_QUEUE1_PRE_LOC);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
BaseType_t err = xQueueSendToBackFromISR(mqtt_queue, queueElement, &xHigherPriorityTaskWoken);
if (err != pdPASS) {
//dbgTerminalError();
dbgTerminalError();
}
// dbgOutputLoc(SEND_TO_QUEUE1_POST_LOC);
//dbgOutputLoc(SEND_TIME_POST_LOC);
return 1;
}
int32_t sendMsgToRoverQueue(msgQueue_t * queueElement)
{
// dbgOutputLoc(SEND_TO_QUEUE2_PRE_LOC);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
BaseType_t err = xQueueSendToBackFromISR(rover_queue, queueElement, &xHigherPriorityTaskWoken);
if (err != pdPASS) {
//dbgTerminalError();
dbgTerminalError();
}
// dbgOutputLoc(SEND_TO_QUEUE2_POST_LOC);
//dbgOutputLoc(SEND_TIME_POST_LOC);
return 1;
}
int32_t sendMsgToStatQueue(msgQueue_t * queueElement)
{
//dbgOutputLoc(SEND_TO_QUEUE2_PRE_LOC);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
BaseType_t err = xQueueSendToBackFromISR(stat_queue, queueElement, &xHigherPriorityTaskWoken);
if (err != pdPASS) {
//dbgTerminalError();
dbgTerminalError();
}
//dbgOutputLoc(SEND_TO_QUEUE2_POST_LOC);
//dbgOutputLoc(SEND_TIME_POST_LOC);
return 1;
}
void recieveMsgFromMqtt( msgQueue_t2 *result)
{
// dbgOutputLoc(RECIEVE_PRE_LOC);
// dbgOutputLoc(RECV_FROM_QUEUE1_PRE_LOC);
BaseType_t err = xQueueReceive(mqtt_queue, result, portMAX_DELAY);
if (err == pdFALSE) {
dbgTerminalError();
}
// dbgOutputLoc(RECV_FROM_QUEUE1_POST_LOC);
}
void recieveMsgFromRoverQ(msgQueue_t* queueElement)
{
// dbgOutputLoc(RECV_FROM_QUEUE2_PRE_LOC);
BaseType_t err = xQueueReceive(rover_queue, queueElement, portMAX_DELAY);
if (err == pdFALSE) {
dbgTerminalError();
}
// dbgOutputLoc(RECV_FROM_QUEUE2_POST_LOC);
}
void recieveMsgFromStatQueue( msgQueue_t *result)
{
// dbgOutputLoc(RECIEVE_PRE_LOC);
// dbgOutputLoc(RECV_FROM_QUEUE1_PRE_LOC);
BaseType_t err = xQueueReceive(stat_queue, result, portMAX_DELAY);
if (err == pdFALSE) {
dbgTerminalError();
}
// dbgOutputLoc(RECV_FROM_QUEUE1_POST_LOC);
}