-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiot-server-design.txt
More file actions
48 lines (35 loc) · 997 Bytes
/
iot-server-design.txt
File metadata and controls
48 lines (35 loc) · 997 Bytes
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
LightBulb Object:
init():
- status [0 Off, 1 On]
- mode [0 Static, 1 Gradient]
- colors [List of 4-Tuples]
- failure [Bool=False]
repr for Device Info Request
Update Color
Update Status (On/Off)
Update Mode (Static/Gradient)
main():
parse_cmdline_args()
init_server()
while True:
recv_message()
if lightbulb.failure:
print("lightbulb machine broke")
if status != lightbulb.status:
lightbulb.update_status(status)
if mode != lightbulb.mode:
lightbulb.update_mode(mode)
if mode = static:
send 1 color to LightBulb
if mode = gradient:
send 2 colors to LightBulb
ack back to the client
send(
msg_type,
msg_id,
num_colors,
status,
mode,
color 1,
color 2
) # client will print response