@@ -97,6 +97,24 @@ def set_manchester_min_bit_length(self, length: int) -> str:
9797 """Set MC Min Bit Length (CSmcmbl=<val>)."""
9898 return self ._send (f"CSmcmbl={ length } " , expect_response = True , timeout = 2.0 , response_pattern = None )
9999
100+ def set_message_type_enabled (self , message_type : str , enabled : bool ) -> None :
101+ """
102+ Enable/disable reception for message types (C<FLAG><TYPE>).
103+
104+ Args:
105+ message_type: One of 'MS', 'MU', 'MC' (or other 2-letter codes, e.g. 'MN').
106+ The second character is used as the type char in the command.
107+ enabled: True to enable (E), False to disable (D).
108+ """
109+ if not message_type or len (message_type ) != 2 :
110+ raise ValueError (f"Invalid message_type: { message_type } . Must be a 2-character string (e.g., 'MS')." )
111+
112+ # The command structure seems to be C<E/D><S/U/C/N>, where <S/U/C/N> is the second char of message_type
113+ cmd_char = message_type # 'S', 'U', 'C', 'N', etc.
114+ flag_char = "E" if enabled else "D"
115+ command = f"C{ flag_char } { cmd_char } "
116+ self ._send (command , expect_response = False , timeout = 0 , response_pattern = None )
117+
100118 def read_cc1101_register (self , register : int ) -> str :
101119 """Read CC1101 register (C<reg>). Register is int, sent as 2-digit hex."""
102120 reg_hex = f"{ register :02X} "
@@ -122,11 +140,30 @@ def read_eeprom_block(self, address: int) -> str:
122140 addr_hex = f"{ address :02X} "
123141 return self ._send (f"r{ addr_hex } n" , expect_response = True , timeout = 2.0 , response_pattern = None )
124142
125- def set_patable (self , value : int ) -> str :
143+ def set_patable (self , value : str | int ) -> str :
126144 """Write PA Table (x<val>)."""
127- val_hex = f"{ value :02X} "
145+ if isinstance (value , int ):
146+ val_hex = f"{ value :02X} "
147+ else :
148+ # Assume it's an already formatted hex string (e.g. 'C0')
149+ val_hex = value
128150 return self ._send (f"x{ val_hex } " , expect_response = True , timeout = 2.0 , response_pattern = None )
129151
152+ def set_bwidth (self , value : int ) -> str :
153+ """Set CC1101 Bandwidth (C10<val>)."""
154+ val_str = str (value )
155+ return self ._send (f"C10{ val_str } " , expect_response = True , timeout = 2.0 , response_pattern = None )
156+
157+ def set_rampl (self , value : int ) -> str :
158+ """Set CC1101 PA_TABLE/ramp length (W1D<val>)."""
159+ val_str = str (value )
160+ return self ._send (f"W1D{ val_str } " , expect_response = True , timeout = 2.0 , response_pattern = None )
161+
162+ def set_sens (self , value : int ) -> str :
163+ """Set CC1101 sensitivity/MCSM0 (W1F<val>)."""
164+ val_str = str (value )
165+ return self ._send (f"W1F{ val_str } " , expect_response = True , timeout = 2.0 , response_pattern = None )
166+
130167 # --- Send Commands ---
131168 # These typically don't expect a response, or the response is just an echo/OK which might be hard to sync with async rx
132169
@@ -145,3 +182,10 @@ def send_raw(self, params: str) -> None:
145182 def send_xfsk (self , params : str ) -> None :
146183 """Send xFSK (SN...). params should be the full string after SN."""
147184 self ._send (f"SN{ params } " , expect_response = False , timeout = 0 , response_pattern = None )
185+
186+ def send_message (self , message : str ) -> None :
187+ """
188+ Sends a pre-encoded message (P..., S..., e.g. from an FHEM set command).
189+ This command is sent without any additional prefix.
190+ """
191+ self ._send (message , expect_response = False , timeout = 0 , response_pattern = None )
0 commit comments