-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow.puml
62 lines (51 loc) · 1.3 KB
/
workflow.puml
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
@startuml
title Postbox monitor workflow
start
:Determine wake reason;
if (ESP_SLEEP_WAKEUP_EXT1) then (Sensor event)
if (Which sensor?) then (Door)
if (What state?) then (Open)
:**Send message**:\n"RETRIEVED";
:Set trigger event:\n"Door Closed";
else (Closed)
:Set trigger event:\n"Flap Open";
endif
else (Flap)
:**Send message**:\n"DELIVERED";
:Set trigger event:\n"Door Open";
endif
elseif (ESP_SLEEP_WAKEUP_TIMER) then (Ping or event retry timer)
:Increment the\nretry counter;
:**Send message**:\n(Last unsent message type);
:Set trigger event:\n(Active trigger event);
else (Hard boot)
:**Send message**:\n"BOOT";
:Set trigger event:\n"Flap Open";
endif
if (Any unsent messages?) then (Yes)
:Schedule a send retry;
else (No)
:Schedule the next\nPING event;
endif
:Flush all Serial data;
:Force WiFi disconnect;
:Enter deep sleep;
stop
partition "Send message" {
if (Connect to WiFi) then (success)
:Read sensors;
:Build JSON payload;
:POST to remote endpoint;
if (HTTP response code) then (200 OK)
:Clear the retry flag;
end
else (Not 200 OK)
:Schedule a send retry;
endif
else (failure)
:Schedule a send retry;
endif
:Enter deep sleep;
end
}
@enduml