@@ -222,24 +222,7 @@ CHIP_ERROR BaseApplication::Init()
222
222
223
223
ConfigurationMgr ().LogDeviceConfig ();
224
224
225
- // Create buffer for QR code that can fit max size and null terminator.
226
- char qrCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1 ];
227
- chip::MutableCharSpan QRCode (qrCodeBuffer);
228
-
229
- if (Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider ().GetSetupPayload (QRCode) == CHIP_NO_ERROR)
230
- {
231
- // Print setup info on LCD if available
232
- #ifdef QR_CODE_ENABLED
233
- slLCD.SetQRCode ((uint8_t *) QRCode.data (), QRCode.size ());
234
- slLCD.ShowQRCode (true , true );
235
- #else
236
- PrintQrCodeURL (QRCode);
237
- #endif // QR_CODE_ENABLED
238
- }
239
- else
240
- {
241
- SILABS_LOG (" Getting QR code failed!" );
242
- }
225
+ OutputQrCode (true /* refreshLCD at init*/ );
243
226
244
227
PlatformMgr ().AddEventHandler (OnPlatformEvent, 0 );
245
228
#ifdef SL_WIFI
@@ -457,6 +440,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
457
440
CancelFunctionTimer ();
458
441
mFunction = kFunction_NoneSelected ;
459
442
443
+ OutputQrCode (false );
460
444
#ifdef QR_CODE_ENABLED
461
445
// TOGGLE QRCode/LCD demo UI
462
446
slLCD.ToggleQRCode ();
@@ -700,3 +684,30 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
700
684
sIsProvisioned = event->ServiceProvisioningChange .IsServiceProvisioned ;
701
685
}
702
686
}
687
+
688
+ void BaseApplication::OutputQrCode (bool refreshLCD)
689
+ {
690
+ (void ) refreshLCD; // could be unused
691
+
692
+ // Create buffer for the Qr code setup payload that can fit max size and null terminator.
693
+ char setupPayloadBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1 ];
694
+ chip::MutableCharSpan setupPayload (setupPayloadBuffer);
695
+
696
+ if (Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider ().GetSetupPayload (setupPayload) == CHIP_NO_ERROR)
697
+ {
698
+ // Print setup info on LCD if available
699
+ #ifdef QR_CODE_ENABLED
700
+ if (refreshLCD)
701
+ {
702
+ slLCD.SetQRCode ((uint8_t *) setupPayload.data (), setupPayload.size ());
703
+ slLCD.ShowQRCode (true , true );
704
+ }
705
+ #endif // QR_CODE_ENABLED
706
+
707
+ PrintQrCodeURL (setupPayload);
708
+ }
709
+ else
710
+ {
711
+ SILABS_LOG (" Getting QR code failed!" );
712
+ }
713
+ }
0 commit comments