File tree Expand file tree Collapse file tree
feeds/lorawan-gateway/rs485-module/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,29 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
1212use tokio:: time:: sleep;
1313use tokio_serial:: { DataBits , Parity , StopBits , SerialPortBuilderExt } ;
1414
15+ /// Initialize timezone from UCI system configuration
16+ fn init_timezone ( ) {
17+ match Command :: new ( "uci" )
18+ . args ( & [ "get" , "system.@system[0].timezone" ] )
19+ . output ( )
20+ {
21+ Ok ( output) if output. status . success ( ) => {
22+ if let Ok ( tz) = String :: from_utf8 ( output. stdout ) {
23+ let tz = tz. trim ( ) ;
24+ if !tz. is_empty ( ) && tz != "UTC" {
25+ std:: env:: set_var ( "TZ" , tz) ;
26+ // Notify that timezone was loaded
27+ eprintln ! ( "Timezone set from UCI: {}" , tz) ;
28+ }
29+ }
30+ }
31+ _ => {
32+ // Fallback to UTC if UCI read fails
33+ std:: env:: set_var ( "TZ" , "UTC" ) ;
34+ }
35+ }
36+ }
37+
1538// Mqtt and Serial Configuration Structures
1639#[ derive( Debug , Clone , PartialEq ) ]
1740struct Config {
@@ -437,6 +460,9 @@ async fn setup_serial(
437460
438461#[ tokio:: main]
439462async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync > > {
463+ // Initialize timezone from UCI system configuration
464+ init_timezone ( ) ;
465+
440466 // Initialize logger
441467 let logger = Arc :: new ( Logger :: new ( ) ) ;
442468 logger. init ( ) ?;
You can’t perform that action at this time.
0 commit comments