-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequence.puml
More file actions
110 lines (86 loc) · 5.47 KB
/
Copy pathsequence.puml
File metadata and controls
110 lines (86 loc) · 5.47 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
@startuml sequence
!theme plain
skinparam defaultFontName "DejaVu Sans"
skinparam defaultFontSize 11
skinparam backgroundColor #FAFAFA
skinparam sequenceArrowThickness 1.5
skinparam sequenceGroupBorderColor #557755
skinparam sequenceGroupBodyBackgroundColor #F0FFF0
skinparam sequenceBoxBackgroundColor #F0F0FF
skinparam noteBackgroundColor #FFFBE0
skinparam noteBorderColor #AAAAAA
title ESP32 Rover — Communication Sequence
box "Rover Server (ESP32-S3 TFT)" #E8EEFF
participant "SensorDataTask\n(Core 0)" as SDT
participant "WebServerTask\nCGrpcServer" as WS
participant "MotorController" as MC
end box
box "WiFi Network\nMOONBASE-II" #FFFBE0
participant "AP\n192.168.4.1" as AP
end box
box "Rover Client (ESP32-S3 Reverse TFT)" #FFE8F8
participant "StreamReceiveTask\n(Core 0)" as SRT
participant "CGrpcClient\nloop() — Core 1" as CL
end box
' ════════════════════════════════════════════════════════════════════════════
== Startup ==
' ════════════════════════════════════════════════════════════════════════════
WS -> AP : SetupNetwork()\n→ AP "MOONBASE-II" ready
activate WS
WS -> WS : StartServer()\n→ listen :50051, :50052
CL -> AP : WiFi.begin("MOONBASE-II")
activate CL
AP --> CL : WL_CONNECTED\nIP: 192.168.4.x
CL -> WS : TCP connect :50051 (command channel)
WS --> CL : accepted
CL -> WS : TCP connect :50052 (stream channel)
WS --> CL : accepted
CL -> SRT ** : spawn StreamReceiveTask\n(xTaskCreatePinnedToCore, Core 0)
note right SRT : Background task runs\ncontinuously reading\nIMU stream frames
' ════════════════════════════════════════════════════════════════════════════
== Steady-State: Joystick → Motor Control (20 Hz) ==
' ════════════════════════════════════════════════════════════════════════════
loop Every 50 ms (20 Hz)
CL -> CL : readJoystickData()\nanalogRead(A0–A3)\ndigitalRead(GPIO5,6)
CL -> WS : **CMD_SEND_JOYSTICK** [0x05]\n:50051 — [method(1)][len(2)][MsgPack payload]\n{left_x, left_y, right_x, right_y,\nleft_button, right_button, timestamp}
activate WS
WS -> WS : HandleJoystickData()\ndeserializeMsgPack()\nupdate m_JoystickData
WS --> CL : STATUS_OK [0x00] + {success:true, message:"OK"}
deactivate WS
WS -> MC : Update(joystick_data_t)
activate MC
MC -> MC : left_y → LEDC ch4/5 (left H-bridge)
MC -> MC : right_y → LEDC ch6/7 (right H-bridge)
MC -> MC : right_x → Servo.write(45°–135°)
deactivate MC
end
' ════════════════════════════════════════════════════════════════════════════
== Steady-State: IMU Stream Push (20 Hz) ==
' ════════════════════════════════════════════════════════════════════════════
loop Every 50 ms (20 Hz)
SDT -> SDT : lsm6dsox.getEvent()\nxSemaphoreTake(imu_mutex)\nwrite shared_imu_data\nxSemaphoreGive()
WS -> WS : xSemaphoreTake(imu_mutex)\ncopy shared_imu_data\nxSemaphoreGive()
WS -> SRT : **STREAM frame**\n:50052 — [len(2)][MsgPack payload]\n{acc_x/y/z, gyro_x/y/z,\ntemperature, timestamp}
SRT -> SRT : deserializeMsgPack()\nxSemaphoreTake(stream_mutex)\nupdate m_LatestImuData\nxSemaphoreGive()
CL -> CL : GetLatestImuData()\n[mutex-protected]\nprintImuData() → Teleplot serial
end
' ════════════════════════════════════════════════════════════════════════════
== LED Control RPC (example) ==
' ════════════════════════════════════════════════════════════════════════════
CL -> WS : **CMD_TURN_LED_ON** [0x01]\n:50051 — [0x01][0x00 0x00] (empty payload)
activate WS
WS -> WS : digitalWrite(LED_BUILTIN, HIGH)
WS --> CL : STATUS_OK + {success:true, message:"LED ON"}
deactivate WS
' ════════════════════════════════════════════════════════════════════════════
== Reconnection ==
' ════════════════════════════════════════════════════════════════════════════
...connection drops...
CL -> CL : IsConnected() → false
CL -> SRT !! : Disconnect()\n→ vTaskDelete(StreamTask)\n→ stop both sockets
CL -> WS : TCP connect :50051
WS --> CL : accepted
CL -> WS : TCP connect :50052
WS --> CL : accepted
CL -> SRT ** : spawn new StreamReceiveTask
@enduml