-
Notifications
You must be signed in to change notification settings - Fork 1.4k
samples: openthread: align nRF_Connect_SDK_13_14.py with GRLv64 #25848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,3 @@ | ||||||||
| #!/usr/bin/env python | ||||||||
| # | ||||||||
| # Copyright (c) 2016, The OpenThread Authors. | ||||||||
|
|
@@ -48,6 +48,7 @@ | |||||||
|
|
||||||||
| import serial | ||||||||
| from serial.serialutil import SerialException | ||||||||
| from typing import Literal | ||||||||
|
|
||||||||
| import commissioner | ||||||||
| from GRLLibs.ThreadPacket.PlatformPackets import ( | ||||||||
|
|
@@ -335,9 +336,10 @@ | |||||||
| if line is None: | ||||||||
| time.sleep(0.01) | ||||||||
| continue | ||||||||
| line = line.replace("\x1b[J", "") | ||||||||
|
|
||||||||
| # self.log("readline: %s", line) | ||||||||
| # skip empty lines | ||||||||
| line = line.replace("\x1b[J", "") | ||||||||
| if line: | ||||||||
| response.append(line) | ||||||||
|
|
||||||||
|
|
@@ -347,6 +349,8 @@ | |||||||
| m = OpenThreadTHCI._COMMAND_OUTPUT_ERROR_PATTERN.match(line) | ||||||||
| if m is not None: | ||||||||
| code, msg = m.groups() | ||||||||
| if ignore_exec: | ||||||||
| return True | ||||||||
| raise CommandError(int(code), msg) | ||||||||
| else: | ||||||||
| if ignore_exec: | ||||||||
|
|
@@ -964,7 +968,9 @@ | |||||||
| specific type of MAC address | ||||||||
| """ | ||||||||
| # if power down happens, return extended address assigned previously | ||||||||
| if self.isPowerDown: | ||||||||
| if self.isPowerDown and bType == MacType.EthMac: | ||||||||
| return self._deviceGetEtherMac() | ||||||||
| elif self.isPowerDown: | ||||||||
| macAddr64 = self.mac | ||||||||
| else: | ||||||||
| if bType == MacType.FactoryMac: | ||||||||
|
|
@@ -2234,9 +2240,9 @@ | |||||||
|
|
||||||||
| @API | ||||||||
| def vendorInfo(self, name="", model="", version=""): | ||||||||
| vn = "vendor name %s" % name | ||||||||
| vm = "vendor model %s" % model | ||||||||
| vv = "vendor swversion %s" % version | ||||||||
| vn = "vendor name %s" % name.replace(" ", "") | ||||||||
| vm = "vendor model %s" % model.replace(" ", "") | ||||||||
| vv = "vendor swversion %s" % version.replace(" ", "") | ||||||||
| self.__executeCommand(vn) | ||||||||
| self.__executeCommand(vm) | ||||||||
| self.__executeCommand(vv) | ||||||||
|
|
@@ -3050,10 +3056,10 @@ | |||||||
| # elif self.DeviceCapability == OT12_CAPBS: | ||||||||
| # return OT12_VERSION in self.UIStatusMsg | ||||||||
| if self.DeviceCapability == OT13_CAPBS: | ||||||||
| return [ | ||||||||
| True if OT13_VER in self.UIStatusMsg else False | ||||||||
| for OT13_VER in OT13_VERSION | ||||||||
| ] | ||||||||
| OT13_FirmwareCheck = any( | ||||||||
|
Check warning on line 3059 in samples/openthread/cli/harness-thci/nRF_Connect_SDK_13_14.py
|
||||||||
| OT13_VER in self.UIStatusMsg for OT13_VER in OT13_VERSION | ||||||||
| ) | ||||||||
| return OT13_FirmwareCheck | ||||||||
| else: | ||||||||
| return False | ||||||||
|
|
||||||||
|
|
@@ -3262,26 +3268,45 @@ | |||||||
| return self.__executeCommand(cmd)[-1] == "Done" | ||||||||
|
|
||||||||
| @API | ||||||||
| def send_udp(self, interface, destination, port, payload="12ABcd"): | ||||||||
| def send_udp( | ||||||||
| self, | ||||||||
| interface, | ||||||||
| destination, | ||||||||
| port, | ||||||||
| payload="12ABcd", | ||||||||
| return_result=False, | ||||||||
| spiff_udp_ip="", | ||||||||
| ): | ||||||||
| """payload hexstring""" | ||||||||
| assert payload is not None, "payload should not be none" | ||||||||
| assert interface == 0, "non-BR must send UDP to Thread interface" | ||||||||
| self.__udpOpen() | ||||||||
| self.__udpOpen(spiff_udp_ip, port) | ||||||||
| time.sleep(0.5) | ||||||||
| cmd_ = "test tmforiginfilter disable" | ||||||||
| self.__executeCommand(cmd_) | ||||||||
| cmd = "udp send %s %s -x %s" % (destination, port, payload) | ||||||||
| result = self.__executeCommand(cmd)[-1] == "Done" | ||||||||
|
|
||||||||
| if not return_result: | ||||||||
| result = self.__executeCommand(cmd)[-1] == "Done" | ||||||||
| else: | ||||||||
| result = self.__executeCommand(cmd)[0] | ||||||||
| _cmd = "test tmforiginfilter enable" | ||||||||
| self.__executeCommand(_cmd) | ||||||||
| return result | ||||||||
|
|
||||||||
| def __udpOpen(self): | ||||||||
| def __udpOpen(self, spiff_udp_ip="", port=""): | ||||||||
|
Check warning on line 3296 in samples/openthread/cli/harness-thci/nRF_Connect_SDK_13_14.py
|
||||||||
| if spiff_udp_ip != "": | ||||||||
| self.__isUdpOpened = False | ||||||||
| self.__executeCommand("udp close") | ||||||||
| if not self.__isUdpOpened: | ||||||||
| cmd = "udp open" | ||||||||
| self.__executeCommand(cmd) | ||||||||
|
|
||||||||
| # Bind to RLOC address and first dynamic port | ||||||||
| rlocAddr = self.getRloc() | ||||||||
|
|
||||||||
| cmd = "udp bind %s 49152" % rlocAddr | ||||||||
| if spiff_udp_ip == "": | ||||||||
| cmd = "udp bind %s 49152" % rlocAddr | ||||||||
| else: | ||||||||
| cmd = "udp connect %s %s" % (spiff_udp_ip, port) | ||||||||
| self.__executeCommand(cmd) | ||||||||
|
|
||||||||
| self.__isUdpOpened = True | ||||||||
|
|
@@ -3404,6 +3429,10 @@ | |||||||
| cmd = "discover %s" % channel | ||||||||
| return self.__executeCommand(cmd) | ||||||||
|
|
||||||||
| @API | ||||||||
| def icmp_ping_req(self, addr): | ||||||||
| return self.__executeCommand("ping %s 2" % addr) | ||||||||
|
|
||||||||
| ######################################################################################################################## | ||||||||
| # 1.3 THCI Commands | ||||||||
| # | ||||||||
|
|
@@ -3736,7 +3765,9 @@ | |||||||
|
|
||||||||
| def srp_client_remove(self, instancename, servicename): | ||||||||
| cmd = "srp client service remove %s %s" % (instancename, servicename) | ||||||||
| # cmd = 'srp client service remove service-test-1 _thread-test._udp' | ||||||||
|
Check warning on line 3768 in samples/openthread/cli/harness-thci/nRF_Connect_SDK_13_14.py
|
||||||||
jaul-nsc marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| self.__executeCommand(cmd) | ||||||||
| # self.__executeCommand("netdata register") | ||||||||
|
||||||||
| # self.__executeCommand("netdata register") |
jaul-nsc marked this conversation as resolved.
Show resolved
Hide resolved
Check failure on line 3888 in samples/openthread/cli/harness-thci/nRF_Connect_SDK_13_14.py
SonarQubeCloud / SonarCloud Code Analysis
Define a constant instead of duplicating this literal "srp client keyleaseinterval %s" 3 times.
See more on https://sonarcloud.io/project/issues?id=nrfconnect_sdk-nrf&issues=AZrEumc7caPpW9znHFgQ&open=AZrEumc7caPpW9znHFgQ&pullRequest=25848
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace print statement with proper logging using self.log() as used elsewhere in the file.
jaul-nsc marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace print statement with proper logging using self.log() as used elsewhere in the file.
| print(tcp_request) | |
| self.log(tcp_request) |
jaul-nsc marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is inverted and confusing. When tcp_request is True (success with ignore_exec), it returns 'Failed' string. When it's not True, it returns True boolean. This should return consistent boolean values: return tcp_request is not True.
| return "Failed" if tcp_request is True else True | |
| return tcp_request is not True |
jaul-nsc marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else-continue is unnecessary. Remove the else clause since continue is only needed when the condition is false.
| else: | |
| continue | |
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out code. If this is an example, consider adding it to documentation instead.