Skip to content

Commit 85a73ee

Browse files
committed
devices: raise an exception when setting a non API mode for a local XBee
Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
1 parent 39820e3 commit 85a73ee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

digi/xbee/devices.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ def _send_at_command(self, command, apply=None):
457457
if (not self.is_remote() and command.parameter
458458
and command.command.upper() == ATStringCommand.AP.command
459459
and not self._packet_sender.is_op_mode_valid(command.parameter)):
460-
return None
460+
op_mode_val = utils.bytes_to_int(command.parameter)
461+
op_mode = OperatingMode.get(op_mode_val)
462+
raise ATCommandException(
463+
message="Operating mode '%d' (%s) not set not to loose XBee connection"
464+
% (op_mode_val, op_mode.description if op_mode else "Unknown"))
461465

462466
operating_mode = self._get_operating_mode()
463467
if operating_mode not in (OperatingMode.API_MODE, OperatingMode.ESCAPED_API_MODE):

0 commit comments

Comments
 (0)