@@ -26,28 +26,34 @@ def __init__(self, send_command_func: Callable[[str, bool, float, Optional[Patte
2626
2727 def get_version (self , timeout : float = 2.0 ) -> str :
2828 """Query firmware version (V)."""
29- pattern = re .compile (r"V\s.*SIGNAL(?:duino|ESP|STM).*" , re .IGNORECASE )
29+ pattern = re .compile (r"V\s.*SIGNAL(?:duino|ESP|STM).*(?:\s\d\d:\d\d:\d\d) " , re .IGNORECASE )
3030 return self ._send ("V" , expect_response = True , timeout = timeout , response_pattern = pattern )
3131
3232 def get_help (self ) -> str :
3333 """Show help (?)."""
34+ # This is for internal use/legacy. The MQTT 'cmds' command uses a specific pattern.
3435 return self ._send ("?" , expect_response = True , timeout = 2.0 , response_pattern = None )
3536
37+ def get_cmds (self ) -> str :
38+ """Show help/commands (?). Used for MQTT 'cmds' command."""
39+ pattern = re .compile (r".*" )
40+ return self ._send ("?" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
41+
3642 def get_free_ram (self ) -> str :
3743 """Query free RAM (R)."""
3844 # Response is typically a number (bytes)
39- pattern = re .compile (r"^\d+$ " )
45+ pattern = re .compile (r"^[0-9]+ " )
4046 return self ._send ("R" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
4147
4248 def get_uptime (self ) -> str :
4349 """Query uptime in seconds (t)."""
4450 # Response is a number (seconds)
45- pattern = re .compile (r"^\d+$ " )
51+ pattern = re .compile (r"^[0-9]+ " )
4652 return self ._send ("t" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
4753
4854 def ping (self ) -> str :
4955 """Ping device (P)."""
50- return self ._send ("P" , expect_response = True , timeout = 2.0 , response_pattern = re .compile (r"OK " ))
56+ return self ._send ("P" , expect_response = True , timeout = 2.0 , response_pattern = re .compile (r"^OK$ " ))
5157
5258 def get_cc1101_status (self ) -> str :
5359 """Query CC1101 status (s)."""
@@ -70,7 +76,7 @@ def factory_reset(self) -> str:
7076 def get_config (self ) -> str :
7177 """Read configuration (CG)."""
7278 # Response format: MS=1;MU=1;...
73- pattern = re .compile (r"^MS =.*" )
79+ pattern = re .compile (r"^M[S|N] =.*" )
7480 return self ._send ("CG" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
7581
7682 def set_decoder_state (self , decoder : str , enabled : bool ) -> None :
@@ -121,10 +127,24 @@ def set_message_type_enabled(self, message_type: str, enabled: bool) -> None:
121127 command = f"C{ flag_char } { cmd_char } "
122128 self ._send (command , expect_response = False , timeout = 0 , response_pattern = None )
123129
130+ def get_ccconf (self ) -> str :
131+ """Query CC1101 configuration (C0DnF)."""
132+ # Response format: C0Dnn=[A-F0-9a-f]+ (e.g., C0D11=0F)
133+ pattern = re .compile (r"C0Dn11=[A-F0-9a-f]+" )
134+ return self ._send ("C0DnF" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
135+
136+ def get_ccpatable (self ) -> str :
137+ """Query CC1101 PA Table (C3E)."""
138+ # Response format: C3E = ...
139+ pattern = re .compile (r"^C3E\s=\s.*" )
140+ return self ._send ("C3E" , expect_response = True , timeout = 2.0 , response_pattern = pattern )
141+
124142 def read_cc1101_register (self , register : int ) -> str :
125143 """Read CC1101 register (C<reg>). Register is int, sent as 2-digit hex."""
126144 reg_hex = f"{ register :02X} "
127- return self ._send (f"C{ reg_hex } " , expect_response = True , timeout = 2.0 , response_pattern = None )
145+ # Response format: Cnn = vv or ccreg 00: ...
146+ pattern = re .compile (r"^(?:C[A-Fa-f0-9]{2}\s=\s[0-9A-Fa-f]+$|ccreg 00:)" )
147+ return self ._send (f"C{ reg_hex } " , expect_response = True , timeout = 2.0 , response_pattern = pattern )
128148
129149 def write_register (self , register : int , value : int ) -> str :
130150 """Write to EEPROM/CC1101 register (W<reg><val>)."""
@@ -189,6 +209,13 @@ def send_raw(self, params: str) -> None:
189209 """Send Raw (SR...). params should be the full string after SR."""
190210 self ._send (f"SR{ params } " , expect_response = False , timeout = 0 , response_pattern = None )
191211
212+ def send_raw_message (self , message : str ) -> str :
213+ """Send the raw message/command directly as payload. Expects a response."""
214+ # The 'rawmsg' MQTT command sends the content of the payload directly as a command.
215+ # It is assumed that it will get a response which is why we expect one.
216+ # No specific pattern can be given here, rely on the default response matchers.
217+ return self ._send (message , expect_response = True , timeout = 2.0 , response_pattern = None )
218+
192219 def send_xfsk (self , params : str ) -> None :
193220 """Send xFSK (SN...). params should be the full string after SN."""
194221 self ._send (f"SN{ params } " , expect_response = False , timeout = 0 , response_pattern = None )
0 commit comments