-
Notifications
You must be signed in to change notification settings - Fork 20
/
mqtt.py
136 lines (90 loc) · 3.28 KB
/
mqtt.py
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
128
129
130
131
132
133
134
135
136
######
# MQTT Connection Function
######
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to broker")
global Connected # Use global variable
Connected = True # Signal connection
else: print("Connection failed")
def on_message(client, userdata, message): print(message.topic + " " + message.payload.decode())
######
# ENGINE TOPIC MQTT
######
def on_message_rpm(digi, obj, message):
rpm_mqtt = int((message.payload.decode()))
rpm.set_frame(rpm_mqtt)
def on_message_coolant(digi, obj, message):
coolant_mqtt = int((message.payload.decode()))
coolant.set_frame(coolant_mqtt)
def on_message_egt(digi, obj, message):
egt_mqtt = int((message.payload.decode()))
egt.set_frame(egt_mqtt)
def on_message_oilpressure(digi, obj, message):
oilpressure_mqtt = int((message.payload.decode()))
oilpressure.set_frame(oilpressure_mqtt)
def on_message_boost(digi, obj, message):
boost_mqtt = int((message.payload.decode()))
boost.set_frame(boost_mqtt)
######
# CABIN TOPIC MQTT
######
def on_message_speed_cv(digi, obj, message):
global speed_status
speed_cv_mqtt = int((message.payload.decode()))
speed_status = speed_cv_mqtt
def on_message_speed_gps(digi, obj, message):
global speed_gps_status
speed_gps_mqtt = int((message.payload.decode()))
speed_gps_status = speed_gps_mqtt
def on_message_outside_temp(digi, obj, message):
global outside_temp_status
outside_temp_mqtt = int((message.payload.decode()))
outside_temp_status = outside_temp_mqtt
def on_message_fuel(digi, obj, message):
global fuel_status
fuel_mqtt = int((message.payload.decode()))
fuel_status = fuel_mqtt
######
# INDICATOR TOPIC MQTT
######
def on_message_illumination(digi, obj, message):
global illumination_state
illumination_mqtt = int((message.payload.decode()))
illumination_state = illumination_mqtt
def on_message_foglight(digi, obj, message):
global foglight_state
foglight_mqtt = int((message.payload.decode()))
foglight_state = foglight_mqtt
def on_message_defog(digi, obj, message):
global defog_state
defog_mqtt = int((message.payload.decode()))
defog_state = defog_mqtt
def on_message_highbeam(digi, obj, message):
global highbeam_state
highbeam_mqtt = int((message.payload.decode()))
highbeam_state = highbeam_mqtt
def on_message_leftturn(digi, obj, message):
global leftturn_state
leftturn_mqtt = int((message.payload.decode()))
leftturn_state = leftturn_mqtt
def on_message_rightturn(digi, obj, message):
global rightturn_state
rightturn_mqtt = int((message.payload.decode()))
rightturn_state = rightturn_mqtt
def on_message_brakewarn(digi, obj, message):
global brakewarn_state
brakewarn_mqtt = int((message.payload.decode()))
brakewarn_state = brakewarn_mqtt
def on_message_oillight(digi, obj, message):
global oillight_state
oillight_mqtt = int((message.payload.decode()))
oillight_state = oillight_mqtt
def on_message_alt(digi, obj, message):
global alt_state
alt_mqtt = int((message.payload.decode()))
alt_state = alt_mqtt
def on_message_glow(digi, obj, message):
global glow_state
glow_mqtt = int((message.payload.decode()))
glow_state = glow_mqtt