Skip to content

Commit

Permalink
Merge pull request project-chip#1628 in WMN_TOOLS/matter from cherry-…
Browse files Browse the repository at this point in the history
…pick/device-argument to RC_2.3.0-1.3-alpha.3

Auto-Merge: Pull request project-chip#1628: [AUTO] Cherry-Pick Pull request project-chip#1592: Provision: Added 'device' argument.

Merge in WMN_TOOLS/matter from cherry-pick/device-argument to RC_2.3.0-1.3-alpha.3

Squashed commit of the following:

commit e65b44b0bdc456b7db4554580bdf7aebedab0b3d
Author: Ricardo Casallas <[email protected]>
Date:   Wed Feb 28 19:17:42 2024 +0000

    Pull request project-chip#1592: Provision: Added 'device' argument.

    Merge in WMN_TOOLS/matter from feature/provision_device_argument to RC_2.3.0-1.3

    Squashed commit of the following:

    commit 9f713da2c653c0400954ec14a40b45631a64cf3b
    Author: Ricardo Casallas <[email protected]>
    Date:   Tue Feb 27 11:56:04 2024 -0500

        Provision: Added 'device' argument.
  • Loading branch information
mkardous-silabs authored and DevSensei Auto Merge committed Mar 8, 2024
1 parent 2b6af17 commit fa95650
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions provision/modules/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self):
self.discriminator = None
self.spake2p = None
self.rendezvous_flags = None
self.device = None

def configure(self, parser):
super().configure(parser)
Expand Down Expand Up @@ -141,6 +142,7 @@ def configure(self, parser):
parser.add_argument('-cf', '--commissioning_flow', type=parseInt, help='[int] Commissioning Flow: 0=Standard, 1=kUserActionRequired, 2=Custom (Default:Standard)')
parser.add_argument('-rf', '--rendezvous_flags', type=parseInt, help='[int] Rendez-vous flag: 1=SoftAP, 2=BLE 4=OnNetwork (Default=BLE Only)')
parser.add_argument('-d', '--discriminator', type=parseInt, help='[int] BLE pairing discriminator.')
parser.add_argument('-D', '--device', type=str, help='Target device.')
# Attestation
parser.add_argument('-ct', '--cert_tool', type=str, help='[boolean] Path to the `chip-cert` tool.')
parser.add_argument('-ki', '--key_id', type=parseInt, help='[int] Key ID')
Expand Down Expand Up @@ -186,6 +188,7 @@ def decode(self, d, args):
c.commissioning_flow = decode(d, 'commissioning_flow', args.commissioning_flow, Arguments.kDefaultCommissioningFlow)
c.rendezvous_flags = decode(d, 'rendezvous_flags', args.rendezvous_flags, Arguments.kDefaultRendezvousFlags)
c.discriminator = decode(d, 'discriminator', args.discriminator)
c.device = decode(d, 'device', args.device)
# Attestation
attest = decode(d, 'attestation', None, {})
c.cert_tool = decode(attest, 'cert_tool', args.cert_tool)
Expand Down Expand Up @@ -234,6 +237,7 @@ def encode(self):
encode(d, 'commissioning_flow', self.commissioning_flow)
encode(d, 'rendezvous_flags', self.rendezvous_flags)
encode(d, 'discriminator', self.discriminator)
encode(d, 'device', self.device)
# Attestation
attest = {}
encode(attest, 'cert_tool', self.attest.cert_tool)
Expand Down Expand Up @@ -264,6 +268,7 @@ def process(self, args):
# Connection
self.conn = ConnectionArguments()
self.conn.decode(args)
self.device = args.device

self.temp = args.temp
self.binary = args.binary
Expand Down
8 changes: 6 additions & 2 deletions provision/modules/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def __str__(self):

class Commander:

def __init__(self, conn):
self.conn = conn
def __init__(self, args):
self.conn = args.conn
self.device = args.device

def execute(self, args, output = True, check = False):
args.insert(0, 'commander')
Expand All @@ -68,6 +69,9 @@ def execute(self, args, output = True, check = False):
args.extend(["--ip", "{}:{}".format(self.conn.ip_addr, self.conn.port)])
else:
args.extend(["--ip", self.conn.ip_addr])
if self.device:
args.extend(["--device", self.device])

cmd = ' '.join(args)
return execute(args, output, check)

Expand Down
2 changes: 1 addition & 1 deletion provision/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def main(argv):
args.load()

# Gather device info
cmmd = Commander(args.conn)
cmmd = Commander(args)
info = cmmd.info()
paths = Paths(info, args)
if args.part_number is None:
Expand Down

0 comments on commit fa95650

Please sign in to comment.