@@ -1576,6 +1576,10 @@ def get_env(self):
1576
1576
for c in compilers :
1577
1577
if self .get_cfg (c + '_PATH' ):
1578
1578
env ['MBED_' + c + '_PATH' ] = self .get_cfg (c + '_PATH' )
1579
+ config_options = ['COLOR' , 'CLOUD_SDK_API_KEY' , 'CLOUD_SDK_HOST' ]
1580
+ for opt in config_options :
1581
+ if self .get_cfg (opt ):
1582
+ env ['MBED_' + opt ] = self .get_cfg (opt )
1579
1583
1580
1584
return env
1581
1585
@@ -2691,6 +2695,57 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
2691
2695
program .set_defaults (target = target , toolchain = tchain )
2692
2696
2693
2697
2698
+ # device management commands
2699
+ @subcommand ('device-management' ,
2700
+ dict (name = ['-t' , '--toolchain' ], help = 'Toolchain used for mbed compile' ),
2701
+ dict (name = ['-m' , '--target' ], help = 'Target used for compile for target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...' ),
2702
+ dict (name = ['--profile' ], help = "" ),
2703
+ dict (name = '--build' , help = 'Build directory. Default: build/' ),
2704
+ dict (name = '--source' , action = 'append' , help = 'Source directory. Default: . (current dir)' ),
2705
+ help = 'device management supcommand' ,
2706
+ hidden_aliases = ['dev-mgmt' , 'dm' ],
2707
+ description = ("Manage Device with Pelion" ))
2708
+ def dev_mgmt (toolchain = None , target = None , source = False , profile = False , build = False ):
2709
+ orig_path = getcwd ()
2710
+ program = Program (getcwd (), True )
2711
+ program .check_requirements (True )
2712
+ with cd (program .path ):
2713
+ tools_dir = program .get_tools ()
2714
+
2715
+ script = os .path .join (tools_dir , 'device_management.py' )
2716
+ if not os .path .exists (script ):
2717
+ error ('device management is not supported by this version of Mbed OS. Please upgrade.' )
2718
+
2719
+
2720
+ target = target or program .get_cfg ("TARGET" )
2721
+ toolchain = toolchain or program .get_cfg ("TOOLCHAIN" )
2722
+
2723
+ if build :
2724
+ build_path = build
2725
+ elif (not build ) and target and toolchain :
2726
+ build_path = os .path .join (
2727
+ os .path .relpath (program .path , orig_path ),
2728
+ program .build_dir ,
2729
+ target .upper (),
2730
+ toolchain .upper ()
2731
+ )
2732
+ build_path = _safe_append_profile_to_build_path (build_path , profile )
2733
+ else :
2734
+ build_path = None
2735
+
2736
+ args = remainder
2737
+ if args [0 ] in ('update' , 'create' ):
2738
+ args += (['--toolchain' , toolchain ] if toolchain else [])
2739
+ args += (['--mcu' , target ] if target else [])
2740
+ args += (['--build' , build_path ] if build_path else [])
2741
+ env = program .get_env ()
2742
+ if "MBED_CLOUD_SDK_HOST" not in env :
2743
+ env ["MBED_CLOUD_SDK_HOST" ] = "https://api.us-east-1.mbedcloud.com"
2744
+ popen ([python_cmd , '-u' , script ]
2745
+ + args
2746
+ + list (chain .from_iterable (zip (repeat ('--source' ), source or []))),
2747
+ env = env )
2748
+
2694
2749
# Export command
2695
2750
@subcommand ('export' ,
2696
2751
dict (name = ['-i' , '--ide' ], help = 'IDE to create project files for. Example: UVISION4, UVISION5, GCC_ARM, IAR, COIDE' ),
0 commit comments