-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_main.c
52 lines (48 loc) · 1.04 KB
/
process_main.c
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
/*
* process_main.c
*
* Created on: 2019Äê11ÔÂ3ÈÕ
* Author: jiez
*/
#include "process_main.h"
#include "client_cbs.h"
void *processObject(void * arg0)
{
// createSensorQ();
sensor_state_fsm myFsm;
ADC_Params params;
ADC_Params_init(¶ms);
ADC_Handle adc = ADC_open(Board_ADC0, ¶ms);
myFsm.adc = adc;
myFsm.reportUltra = false;
myFsm.state = OBJECT_FINDING;
myFsm.distWarn = false;
msgQueue_sensor msgRecv;
bool isMqttReady = false;
while (1)
{
int res = recieveMsgFromSensorQ(&msgRecv);
if (res < 0)
{
dbgTerminalError();
}
if (res == 4)
{
isMqttReady = true;
}
if (isMqttReady)
{
if (res == 0|| res == 3)
{
//pixy data
sensor_fsm(&myFsm, &msgRecv);
}
else if (res == 1)
{
//ultrasonic data
sensor_fsm(&myFsm, &msgRecv);
}
}
}
return (NULL);
}