diff --git a/examples/lighting-app/linux/include/CHIPProjectAppConfig.h b/examples/lighting-app/linux/include/CHIPProjectAppConfig.h index e919666bb9fda5..97f9ed61d6bacf 100644 --- a/examples/lighting-app/linux/include/CHIPProjectAppConfig.h +++ b/examples/lighting-app/linux/include/CHIPProjectAppConfig.h @@ -43,4 +43,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1 +#define CHIP_DEVICE_ENABLE_PORT_PARAMS 1 + #define CHIP_DEVICE_CONFIG_DEVICE_NAME "Test Bulb" diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index ce107b340ee609..d9bdbd5f87bdb2 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -402,7 +402,7 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE ChipLogProgress(AppServer, "Starting commissioner"); - VerifyOrReturn(InitCommissioner(LinuxDeviceOptions::GetInstance().securedCommissionerPort + 10, + VerifyOrReturn(InitCommissioner(LinuxDeviceOptions::GetInstance().securedCommissionerPort, LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort, LinuxDeviceOptions::GetInstance().commissionerFabricId) == CHIP_NO_ERROR); ChipLogProgress(AppServer, "Started commissioner"); diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 53969060f99034..f31af9f2725c2c 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -41,19 +41,23 @@ LinuxDeviceOptions gDeviceOptions; // Follow the code style of command line arguments in case we need to add more options in the future. enum { - kDeviceOption_BleDevice = 0x1000, - kDeviceOption_WiFi = 0x1001, - kDeviceOption_Thread = 0x1002, - kDeviceOption_Version = 0x1003, - kDeviceOption_VendorID = 0x1004, - kDeviceOption_ProductID = 0x1005, - kDeviceOption_CustomFlow = 0x1006, - kDeviceOption_Capabilities = 0x1007, - kDeviceOption_Discriminator = 0x1008, - kDeviceOption_Passcode = 0x1009, - kDeviceOption_SecuredDevicePort = 0x100a, - kDeviceOption_SecuredCommissionerPort = 0x100b, - kDeviceOption_UnsecuredCommissionerPort = 0x100c, + kDeviceOption_BleDevice = 0x1000, + kDeviceOption_WiFi = 0x1001, + kDeviceOption_Thread = 0x1002, + kDeviceOption_Version = 0x1003, + kDeviceOption_VendorID = 0x1004, + kDeviceOption_ProductID = 0x1005, + kDeviceOption_CustomFlow = 0x1006, + kDeviceOption_Capabilities = 0x1007, + kDeviceOption_Discriminator = 0x1008, + kDeviceOption_Passcode = 0x1009, +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS + kDeviceOption_SecuredDevicePort = 0x100a, + kDeviceOption_UnsecuredCommissionerPort = 0x100b, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + kDeviceOption_SecuredCommissionerPort = 0x100c, +#endif kDeviceOption_Command = 0x100d, kDeviceOption_PICS = 0x100e, kDeviceOption_KVS = 0x100f, @@ -98,9 +102,13 @@ OptionDef sDeviceOptionDefs[] = { { "spake2p-verifier-base64", kArgumentRequired, kDeviceOption_Spake2pVerifierBase64 }, { "spake2p-salt-base64", kArgumentRequired, kDeviceOption_Spake2pSaltBase64 }, { "spake2p-iterations", kArgumentRequired, kDeviceOption_Spake2pIterations }, +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS { "secured-device-port", kArgumentRequired, kDeviceOption_SecuredDevicePort }, - { "secured-commissioner-port", kArgumentRequired, kDeviceOption_SecuredCommissionerPort }, { "unsecured-commissioner-port", kArgumentRequired, kDeviceOption_UnsecuredCommissionerPort }, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + { "secured-commissioner-port", kArgumentRequired, kDeviceOption_SecuredCommissionerPort }, +#endif { "command", kArgumentRequired, kDeviceOption_Command }, { "PICS", kArgumentRequired, kDeviceOption_PICS }, { "KVS", kArgumentRequired, kDeviceOption_KVS }, @@ -175,16 +183,20 @@ const char * sDeviceOptionHelp = " passed, the iteration counts must match that used to generate the verifier otherwise failure will\n" " arise.\n" "\n" +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS " --secured-device-port \n" " A 16-bit unsigned integer specifying the listen port to use for secure device messages (default is 5540).\n" "\n" - " --secured-commissioner-port \n" - " A 16-bit unsigned integer specifying the listen port to use for secure commissioner messages (default is 5542). Only " - "valid when app is both device and commissioner\n" - "\n" " --unsecured-commissioner-port \n" " A 16-bit unsigned integer specifying the port to use for unsecured commissioner messages (default is 5550).\n" "\n" +#endif +#if CHIP_DEVICE_ENABLE_PORT_PARAMS + " --secured-commissioner-port \n" + " A 16-bit unsigned integer specifying the listen port to use for secure commissioner messages (default is 5552). Only " + "valid when app is both device and commissioner\n" + "\n" +#endif " --commissioner-fabric-id \n" " The fabric ID to be used when this device is a commissioner (default in code is 1).\n" "\n" @@ -377,18 +389,23 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, break; } +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS case kDeviceOption_SecuredDevicePort: LinuxDeviceOptions::GetInstance().securedDevicePort = static_cast(atoi(aValue)); break; - case kDeviceOption_SecuredCommissionerPort: - LinuxDeviceOptions::GetInstance().securedCommissionerPort = static_cast(atoi(aValue)); - break; - case kDeviceOption_UnsecuredCommissionerPort: LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort = static_cast(atoi(aValue)); break; +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + case kDeviceOption_SecuredCommissionerPort: + LinuxDeviceOptions::GetInstance().securedCommissionerPort = static_cast(atoi(aValue)); + break; +#endif + case kDeviceOption_Command: LinuxDeviceOptions::GetInstance().command = aValue; break; diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index 7f2a5f258d2d69..3f15872f0f190d 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -43,13 +43,17 @@ struct LinuxDeviceOptions chip::Optional discriminator; chip::Optional> spake2pVerifier; chip::Optional> spake2pSalt; - uint32_t spake2pIterations = 0; // When not provided (0), will default elsewhere - uint32_t mBleDevice = 0; - bool mWiFi = false; - bool mThread = false; - uint32_t securedDevicePort = CHIP_PORT; - uint32_t securedCommissionerPort = CHIP_PORT + 2; - uint32_t unsecuredCommissionerPort = CHIP_UDC_PORT; + uint32_t spake2pIterations = 0; // When not provided (0), will default elsewhere + uint32_t mBleDevice = 0; + bool mWiFi = false; + bool mThread = false; +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS + uint32_t securedDevicePort = CHIP_PORT; + uint32_t unsecuredCommissionerPort = CHIP_UDC_PORT; +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE +#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE + uint32_t securedCommissionerPort = CHIP_PORT + 12; // TODO: why + 12? +#endif // CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE const char * command = nullptr; const char * PICS = nullptr; const char * KVS = nullptr; diff --git a/examples/platform/nxp/se05x/linux/AppMain.cpp b/examples/platform/nxp/se05x/linux/AppMain.cpp index 9d83e354cce466..2f38e784dd395c 100644 --- a/examples/platform/nxp/se05x/linux/AppMain.cpp +++ b/examples/platform/nxp/se05x/linux/AppMain.cpp @@ -431,7 +431,7 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE ChipLogProgress(AppServer, "Starting commissioner"); - VerifyOrReturn(InitCommissioner(LinuxDeviceOptions::GetInstance().securedCommissionerPort + 10, + VerifyOrReturn(InitCommissioner(LinuxDeviceOptions::GetInstance().securedCommissionerPort, LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort) == CHIP_NO_ERROR); ChipLogProgress(AppServer, "Started commissioner"); #if defined(ENABLE_CHIP_SHELL)