@@ -102,33 +102,40 @@ class PairingCommand : public CHIPCommand,
102
102
case PairingMode::Ble:
103
103
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
104
104
AddArgument (" setup-pin-code" , 0 , 134217727 , &mSetupPINCode );
105
- AddArgument (" discriminator" , 0 , 4096 , &mDiscriminator );
105
+ AddArgument (" discriminator" , 0 , 4096 , &mDiscriminatorForBLEAndSoftAP );
106
+ mSetupPINCodeUsable = true ;
107
+ mDiscriminatorForBLEAndSoftAPUsable = true ;
106
108
break ;
107
109
case PairingMode::OnNetwork:
108
110
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
109
111
AddArgument (" setup-pin-code" , 0 , 134217727 , &mSetupPINCode );
110
112
AddArgument (" pase-only" , 0 , 1 , &mPaseOnly );
113
+ mSetupPINCodeUsable = true ;
111
114
break ;
112
115
case PairingMode::SoftAP:
113
116
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
114
117
AddArgument (" setup-pin-code" , 0 , 134217727 , &mSetupPINCode );
115
- AddArgument (" discriminator" , 0 , 4096 , &mDiscriminator );
118
+ AddArgument (" discriminator" , 0 , 4096 , &mDiscriminatorForBLEAndSoftAP );
116
119
AddArgument (" device-remote-ip" , &mRemoteAddr );
117
120
AddArgument (" device-remote-port" , 0 , UINT16_MAX, &mRemotePort );
118
121
AddArgument (" pase-only" , 0 , 1 , &mPaseOnly );
122
+ mSetupPINCodeUsable = true ;
123
+ mDiscriminatorForBLEAndSoftAPUsable = true ;
119
124
break ;
120
125
case PairingMode::AlreadyDiscovered:
121
126
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
122
127
AddArgument (" setup-pin-code" , 0 , 134217727 , &mSetupPINCode );
123
128
AddArgument (" device-remote-ip" , &mRemoteAddr );
124
129
AddArgument (" device-remote-port" , 0 , UINT16_MAX, &mRemotePort );
125
130
AddArgument (" pase-only" , 0 , 1 , &mPaseOnly );
131
+ mSetupPINCodeUsable = true ;
126
132
break ;
127
133
case PairingMode::AlreadyDiscoveredByIndex:
128
134
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
129
135
AddArgument (" setup-pin-code" , 0 , 134217727 , &mSetupPINCode );
130
136
AddArgument (" index" , 0 , UINT16_MAX, &mIndex );
131
137
AddArgument (" pase-only" , 0 , 1 , &mPaseOnly );
138
+ mSetupPINCodeUsable = true ;
132
139
break ;
133
140
case PairingMode::AlreadyDiscoveredByIndexWithCode:
134
141
AddArgument (" skip-commissioning-complete" , 0 , 1 , &mSkipCommissioningComplete );
@@ -246,7 +253,7 @@ class PairingCommand : public CHIPCommand,
246
253
mComplex_DSTOffsets ;
247
254
248
255
uint16_t mRemotePort ;
249
- uint16_t mDiscriminator ;
256
+ uint16_t mDiscriminatorForBLEAndSoftAP ;
250
257
uint32_t mSetupPINCode ;
251
258
uint16_t mIndex ;
252
259
chip::ByteSpan mOperationalDataset ;
@@ -257,6 +264,14 @@ class PairingCommand : public CHIPCommand,
257
264
char * mDiscoveryFilterInstanceName ;
258
265
259
266
bool mDeviceIsICD ;
267
+ // We only use mDiscriminatorForBLEAndSoftAP in some modes, but in those
268
+ // modes it's required (so we can't use an Optional for it). Use an
269
+ // out-of-band boolean to keep track of whether that field is valid at all.
270
+ bool mDiscriminatorForBLEAndSoftAPUsable = false ;
271
+ // We only use mSetupPINCode in some modes, but in those
272
+ // modes it's required (so we can't use an Optional for it). Use an
273
+ // out-of-band boolean to keep track of whether that field is valid at all.
274
+ bool mSetupPINCodeUsable = false ;
260
275
uint8_t mRandomGeneratedICDSymmetricKey [chip::Crypto::kAES_CCM128_Key_Length ];
261
276
262
277
// For unpair
0 commit comments