Software Design

@startuml
skinparam BoxPadding 10
!pragma teoz true
title Indus Software (Re)Design

box Main Board
participant ESP32
participant SIM7070E
participant "Battery\nMonitor" as BM
end box
box On site
collections RTU
participant Teltonica
end box
queue "Indus NMC" as NMC

->ESP32: Boot\nCheck Boot Reason

group If Wake From Sleep
ESP32 -> ESP32 : Configure Teltonika power switch Pin
ESP32 -> Teltonica: Power Up Teltonika
{tstart} ESP32 -> ESP32 : Start inactivity timer
activate ESP32
ESP32 -> ESP32 : Configure all other I/O pins
ESP32 -> BM : Request Battery Measurement
BM -> ESP32 : Battery Voltage Report
ESP32 -> SIM7070E: Send Voltage Report SMS
SIM7070E -> NMC : Send Battery Voltage Report
group Activity Detection
RTU -> ESP32: RS323 Activity Detected\nRestart Inactivity Timer
end
ESP32 -> ESP32 : Inactivity Timer Expired
deactivate ESP32
ESP32 -> Teltonica: Power Down
ESP32 -> ESP32: Deep Sleep
end

group If First Boot
ESP32 -> ESP32 : Configure all I/O pins
ESP32 -> BM : Request Battery Measurement
BM -> ESP32 : Battery Voltage Report
ESP32 -> SIM7070E: Send Voltage Report SMS
SIM7070E -> NMC : Send Battery Voltage Report
ESP32 -> ESP32: Deep Sleep
end

@enduml