1- use crate :: {
2- config:: { DataEndpoint , DataType , DEVICE_IDENTIFIER , MAX_HANDLER_RETRIES } , get_needed_message_size, impl_letype_num,
3- lock:: RouterMutex ,
4- message_meta, serialize,
5- telemetry_packet:: TelemetryPacket ,
6- MessageElementCount , TelemetryError ,
7- TelemetryResult ,
8- } ;
1+ use crate :: { config:: { DataEndpoint , DataType , DEVICE_IDENTIFIER , MAX_HANDLER_RETRIES } , get_needed_message_size, impl_letype_num, lock:: RouterMutex , message_meta, serialize, telemetry_packet:: TelemetryPacket , EndpointsBroadcastMode , MessageElementCount , TelemetryError , TelemetryResult } ;
92use alloc:: { boxed:: Box , collections:: VecDeque , format, sync:: Arc , vec, vec:: Vec } ;
103
114#[ cfg( all( not( feature = "std" ) , target_os = "none" ) ) ]
@@ -357,7 +350,7 @@ impl Router {
357350 payload,
358351 ) ?;
359352
360- self . transmit_message ( & error_pkt)
353+ self . tx ( & error_pkt)
361354 }
362355
363356 // ---------- PUBLIC API: now all &self (thread-safe via internal locking) ----------
@@ -374,7 +367,7 @@ impl Router {
374367 st. transmit_queue . pop_front ( )
375368 } ;
376369 let Some ( pkt) = pkt_opt else { break } ;
377- self . transmit_message ( & pkt) ?; // No lock held while calling user code
370+ self . tx ( & pkt) ?; // No lock held while calling user code
378371 }
379372 Ok ( ( ) )
380373 }
@@ -430,7 +423,7 @@ impl Router {
430423 st. transmit_queue . pop_front ( )
431424 } ;
432425 let Some ( pkt) = pkt_opt else { break } ;
433- self . transmit_message ( & pkt) ?;
426+ self . tx ( & pkt) ?;
434427 if self . clock . now_ms ( ) . wrapping_sub ( start) >= timeout_ms as u64 {
435428 break ;
436429 }
@@ -444,7 +437,7 @@ impl Router {
444437 /// # Returns
445438 /// A TelemetryResult indicating success or failure.
446439 fn process_rx_queue_item ( & self , item : RxItem ) -> TelemetryResult < ( ) > {
447- self . receive_item ( & item)
440+ self . rx_item ( & item)
448441 }
449442
450443 /// Process packets in the receive queue for up to `timeout_ms` milliseconds.
@@ -491,7 +484,7 @@ impl Router {
491484 let mut st = self . state . lock ( ) ;
492485 st. transmit_queue . pop_front ( )
493486 } {
494- self . transmit_message ( & pkt) ?;
487+ self . tx ( & pkt) ?;
495488 did_any = true ;
496489 }
497490 if !drain_fully && self . clock . now_ms ( ) . wrapping_sub ( start) >= timeout_ms as u64 {
@@ -525,7 +518,7 @@ impl Router {
525518 /// * `pkt` - The TelemetryPacket to enqueue.
526519 /// # Returns
527520 /// A TelemetryResult indicating success or failure.
528- pub fn transmit_message_queue ( & self , pkt : TelemetryPacket ) -> TelemetryResult < ( ) > {
521+ pub fn tx_queue ( & self , pkt : TelemetryPacket ) -> TelemetryResult < ( ) > {
529522 pkt. validate ( ) ?;
530523 let mut st = self . state . lock ( ) ;
531524 st. transmit_queue . push_back ( pkt) ;
@@ -736,7 +729,7 @@ impl Router {
736729 env. timestamp_ms ,
737730 payload,
738731 ) ?;
739- self . transmit_message ( & error_pkt)
732+ self . tx ( & error_pkt)
740733 }
741734
742735 /// Core receive function handling both Packet and Serialized RxItems.
@@ -745,7 +738,7 @@ impl Router {
745738 /// * `item` - The RxItem to process (either Packet or Serialized).
746739 /// # Returns
747740 /// A TelemetryResult indicating success or failure.
748- pub fn receive_item ( & self , item : & RxItem ) -> TelemetryResult < ( ) > {
741+ pub fn rx_item ( & self , item : & RxItem ) -> TelemetryResult < ( ) > {
749742 match item {
750743 RxItem :: Packet ( pkt) => {
751744 pkt. validate ( ) ?;
@@ -832,7 +825,7 @@ impl Router {
832825 /// * `pkt` - The TelemetryPacket to transmit.
833826 /// # Returns
834827 /// A TelemetryResult indicating success or failure.
835- pub fn transmit_message ( & self , pkt : & TelemetryPacket ) -> TelemetryResult < ( ) > {
828+ pub fn tx ( & self , pkt : & TelemetryPacket ) -> TelemetryResult < ( ) > {
836829 pkt. validate ( ) ?;
837830
838831 let has_serialized_local = pkt
@@ -843,7 +836,7 @@ impl Router {
843836 let send_remote = pkt
844837 . endpoints ( )
845838 . iter ( )
846- . any ( |e| !self . cfg . is_local_endpoint ( * e) ) ;
839+ . any ( |e| ( !self . cfg . is_local_endpoint ( * e) && e . get_broadast_mode ( ) != EndpointsBroadcastMode :: Never ) || e . get_broadast_mode ( ) == EndpointsBroadcastMode :: Always ) ;
847840
848841 // Only serialize if needed.
849842 let bytes_opt = if has_serialized_local || send_remote {
@@ -892,9 +885,9 @@ impl Router {
892885 /// * `bytes` - The serialized telemetry packet as a byte slice.
893886 /// # Returns
894887 /// A TelemetryResult indicating success or failure.
895- pub fn receive_serialized ( & self , bytes : & [ u8 ] ) -> TelemetryResult < ( ) > {
888+ pub fn rx_serialized ( & self , bytes : & [ u8 ] ) -> TelemetryResult < ( ) > {
896889 let item = RxItem :: Serialized ( Arc :: from ( bytes) ) ;
897- self . receive_item ( & item)
890+ self . rx_item ( & item)
898891 }
899892
900893 /// Enqueue and process a telemetry packet.
@@ -903,9 +896,9 @@ impl Router {
903896 /// * `pkt` - The TelemetryPacket to process.
904897 /// # Returns
905898 /// A TelemetryResult indicating success or failure.
906- pub fn receive ( & self , pkt : & TelemetryPacket ) -> TelemetryResult < ( ) > {
899+ pub fn rx ( & self , pkt : & TelemetryPacket ) -> TelemetryResult < ( ) > {
907900 let item = RxItem :: Packet ( pkt. clone ( ) ) ;
908- self . receive_item ( & item)
901+ self . rx_item ( & item)
909902 }
910903
911904 /// Build a packet then send immediately.
@@ -916,7 +909,7 @@ impl Router {
916909 /// A TelemetryResult indicating success or failure.
917910 pub fn log < T : LeBytes > ( & self , ty : DataType , data : & [ T ] ) -> TelemetryResult < ( ) > {
918911 log_raw ( self . sender , ty, data, self . clock . now_ms ( ) , |pkt| {
919- self . transmit_message ( & pkt)
912+ self . tx ( & pkt)
920913 } )
921914 }
922915
@@ -928,7 +921,7 @@ impl Router {
928921 /// A TelemetryResult indicating success or failure.
929922 pub fn log_queue < T : LeBytes > ( & self , ty : DataType , data : & [ T ] ) -> TelemetryResult < ( ) > {
930923 log_raw ( self . sender , ty, data, self . clock . now_ms ( ) , |pkt| {
931- self . transmit_message_queue ( pkt)
924+ self . tx_queue ( pkt)
932925 } )
933926 }
934927
@@ -946,7 +939,7 @@ impl Router {
946939 data : & [ T ] ,
947940 ) -> TelemetryResult < ( ) > {
948941 log_raw ( self . sender , ty, data, timestamp, |pkt| {
949- self . transmit_message ( & pkt)
942+ self . tx ( & pkt)
950943 } )
951944 }
952945
@@ -964,7 +957,7 @@ impl Router {
964957 data : & [ T ] ,
965958 ) -> TelemetryResult < ( ) > {
966959 log_raw ( self . sender , ty, data, timestamp, |pkt| {
967- self . transmit_message_queue ( pkt)
960+ self . tx_queue ( pkt)
968961 } )
969962 }
970963}
0 commit comments