18
18
19
19
#include " Options.h"
20
20
21
+ #include < app/server/OnboardingCodesUtil.h>
21
22
#include < platform/CHIPDeviceLayer.h>
22
23
23
24
#include < core/CHIPError.h>
@@ -32,9 +33,16 @@ LinuxDeviceOptions gDeviceOptions;
32
33
// Follow the code style of command line arguments in case we need to add more options in the future.
33
34
enum
34
35
{
35
- kDeviceOption_BleDevice = 0x1000 ,
36
- kDeviceOption_WiFi = 0x1001 ,
37
- kDeviceOption_Thread = 0x1002 ,
36
+ kDeviceOption_BleDevice = 0x1000 ,
37
+ kDeviceOption_WiFi = 0x1001 ,
38
+ kDeviceOption_Thread = 0x1002 ,
39
+ kDeviceOption_Version = 0x1003 ,
40
+ kDeviceOption_VendorID = 0x1004 ,
41
+ kDeviceOption_ProductID = 0x1005 ,
42
+ kDeviceOption_CustomFlow = 0x1006 ,
43
+ kDeviceOption_Capabilities = 0x1007 ,
44
+ kDeviceOption_Discriminator = 0x1008 ,
45
+ kDeviceOption_Passcode = 0x1009
38
46
};
39
47
40
48
constexpr unsigned kAppUsageLength = 64 ;
@@ -46,21 +54,50 @@ OptionDef sDeviceOptionDefs[] = { { "ble-device", kArgumentRequired, kDeviceOpti
46
54
#if CHIP_ENABLE_OPENTHREAD
47
55
{ " thread" , kNoArgument , kDeviceOption_Thread },
48
56
#endif // CHIP_ENABLE_OPENTHREAD
57
+ { " version" , kArgumentRequired , kDeviceOption_Version },
58
+ { " vendor-id" , kArgumentRequired , kDeviceOption_VendorID },
59
+ { " product-id" , kArgumentRequired , kDeviceOption_ProductID },
60
+ { " custom-flow" , kArgumentRequired , kDeviceOption_CustomFlow },
61
+ { " capabilities" , kArgumentRequired , kDeviceOption_Capabilities },
62
+ { " discriminator" , kArgumentRequired , kDeviceOption_Discriminator },
63
+ { " passcode" , kArgumentRequired , kDeviceOption_Passcode },
49
64
{} };
50
65
51
- const char * sDeviceOptionHelp = " --ble-device <number>\n "
52
- " The device number for CHIPoBLE, without 'hci' prefix, can be found by hciconfig.\n "
66
+ const char * sDeviceOptionHelp =
67
+ " --ble-device <number>\n "
68
+ " The device number for CHIPoBLE, without 'hci' prefix, can be found by hciconfig.\n "
53
69
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
54
- " \n "
55
- " --wifi\n "
56
- " Enable WiFi management via wpa_supplicant.\n "
70
+ " \n "
71
+ " --wifi\n "
72
+ " Enable WiFi management via wpa_supplicant.\n "
57
73
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA
58
74
#if CHIP_ENABLE_OPENTHREAD
59
- " \n "
60
- " --thread\n "
61
- " Enable Thread management via ot-agent.\n "
75
+ " \n "
76
+ " --thread\n "
77
+ " Enable Thread management via ot-agent.\n "
62
78
#endif // CHIP_ENABLE_OPENTHREAD
63
- " \n " ;
79
+ " \n "
80
+ " --version <version>\n "
81
+ " The version indication provides versioning of the setup payload.\n "
82
+ " \n "
83
+ " --vendor-id <id>\n "
84
+ " The Vendor ID is assigned by the Connectivity Standards Alliance.\n "
85
+ " \n "
86
+ " --product-id <id>\n "
87
+ " The Product ID is specified by vendor.\n "
88
+ " \n "
89
+ " --custom-flow <Standard = 0 | UserActionRequired = 1 | Custom = 2>\n "
90
+ " A 2-bit unsigned enumeration specifying manufacturer-specific custom flow options.\n "
91
+ " \n "
92
+ " --capabilities <None = 0, SoftAP = 1 << 0, BLE = 1 << 1, OnNetwork = 1 << 2>\n "
93
+ " Discovery Capabilities Bitmask which contains information about Device’s available technologies for device discovery.\n "
94
+ " \n "
95
+ " --discriminator <discriminator>\n "
96
+ " A 12-bit unsigned integer match the value which a device advertises during commissioning.\n "
97
+ " \n "
98
+ " --passcode <passcode>\n "
99
+ " A 27-bit unsigned integer, which serves as proof of possession during commissioning.\n "
100
+ " \n " ;
64
101
65
102
bool HandleOption (const char * aProgram, OptionSet * aOptions, int aIdentifier, const char * aName, const char * aValue)
66
103
{
@@ -85,6 +122,34 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
85
122
LinuxDeviceOptions::GetInstance ().mThread = true ;
86
123
break ;
87
124
125
+ case kDeviceOption_Version :
126
+ LinuxDeviceOptions::GetInstance ().payload .version = static_cast <uint8_t >(atoi (aValue));
127
+ break ;
128
+
129
+ case kDeviceOption_VendorID :
130
+ LinuxDeviceOptions::GetInstance ().payload .vendorID = static_cast <uint16_t >(atoi (aValue));
131
+ break ;
132
+
133
+ case kDeviceOption_ProductID :
134
+ LinuxDeviceOptions::GetInstance ().payload .productID = static_cast <uint16_t >(atoi (aValue));
135
+ break ;
136
+
137
+ case kDeviceOption_CustomFlow :
138
+ LinuxDeviceOptions::GetInstance ().payload .commissioningFlow = static_cast <CommissioningFlow>(atoi (aValue));
139
+ break ;
140
+
141
+ case kDeviceOption_Capabilities :
142
+ LinuxDeviceOptions::GetInstance ().payload .rendezvousInformation .SetRaw (static_cast <uint8_t >(atoi (aValue)));
143
+ break ;
144
+
145
+ case kDeviceOption_Discriminator :
146
+ LinuxDeviceOptions::GetInstance ().payload .discriminator = static_cast <uint16_t >(atoi (aValue));
147
+ break ;
148
+
149
+ case kDeviceOption_Passcode :
150
+ LinuxDeviceOptions::GetInstance ().payload .setUpPINCode = static_cast <uint32_t >(atoi (aValue));
151
+ break ;
152
+
88
153
default :
89
154
PrintArgError (" %s: INTERNAL ERROR: Unhandled option: %s\n " , aProgram, aName);
90
155
retval = false ;
0 commit comments