@@ -182,6 +182,60 @@ bool WiFiProvClass::disableAutoStop(uint32_t cleanup_delay) {
182182
183183// Copied from IDF example
184184
185+ #if __has_include("qrcode.h")
186+ static const char *lt[] = {
187+ /* 0 */ " " ,
188+ /* 1 */ " \u2580 " ,
189+ /* 2 */ " \u2580 " ,
190+ /* 3 */ " \u2580\u2580 " ,
191+ /* 4 */ " \u2584 " ,
192+ /* 5 */ " \u2588 " ,
193+ /* 6 */ " \u2584\u2580 " ,
194+ /* 7 */ " \u2588\u2580 " ,
195+ /* 8 */ " \u2584 " ,
196+ /* 9 */ " \u2580\u2584 " ,
197+ /* 10 */ " \u2588 " ,
198+ /* 11 */ " \u2580\u2588 " ,
199+ /* 12 */ " \u2584\u2584 " ,
200+ /* 13 */ " \u2588\u2584 " ,
201+ /* 14 */ " \u2584\u2588 " ,
202+ /* 15 */ " \u2588\u2588 " ,
203+ };
204+
205+ static Print *qr_out = NULL ;
206+
207+ static void _qrcode_print_console (esp_qrcode_handle_t qrcode) {
208+ int size = esp_qrcode_get_size (qrcode);
209+ int border = 2 ;
210+ unsigned char num = 0 ;
211+
212+ if (qr_out == NULL ) {
213+ return ;
214+ }
215+
216+ for (int y = -border; y < size + border; y += 2 ) {
217+ for (int x = -border; x < size + border; x += 2 ) {
218+ num = 0 ;
219+ if (esp_qrcode_get_module (qrcode, x, y)) {
220+ num |= 1 << 0 ;
221+ }
222+ if ((x < size + border) && esp_qrcode_get_module (qrcode, x + 1 , y)) {
223+ num |= 1 << 1 ;
224+ }
225+ if ((y < size + border) && esp_qrcode_get_module (qrcode, x, y + 1 )) {
226+ num |= 1 << 2 ;
227+ }
228+ if ((x < size + border) && (y < size + border) && esp_qrcode_get_module (qrcode, x + 1 , y + 1 )) {
229+ num |= 1 << 3 ;
230+ }
231+ qr_out->print (lt[num]);
232+ }
233+ qr_out->print (" \n " );
234+ }
235+ qr_out->print (" \n " );
236+ }
237+ #endif
238+
185239void WiFiProvClass::printQR (const char *name, const char *pop, const char *transport, Print &out) {
186240 if (!name || !transport) {
187241 log_w (" Cannot generate QR code payload. Data missing." );
@@ -204,12 +258,12 @@ void WiFiProvClass::printQR(const char *name, const char *pop, const char *trans
204258 );
205259 }
206260#if __has_include("qrcode.h")
207- if (out) {
208- esp_qrcode_config_t cfg = ESP_QRCODE_CONFIG_DEFAULT ( );
209- out. printf ( " Scan this QR code from the provisioning application for Provisioning. \n " ) ;
210- esp_qrcode_generate (&cfg, payload);
211- out. printf ( " If QR code is not visible, copy paste the below URL in a browser. \n %s?data=%s \n " , " https://rainmaker.espressif.com/qrcode.html " , payload) ;
212- }
261+ esp_qrcode_config_t cfg = ESP_QRCODE_CONFIG_DEFAULT ();
262+ out. printf ( " Scan this QR code from the provisioning application for Provisioning. \n " );
263+ qr_out = & out;
264+ esp_qrcode_generate (&cfg, payload);
265+ qr_out = NULL ;
266+ out. printf ( " If QR code is not visible, copy paste the below URL in a browser. \n https://rainmaker.espressif.com/qrcode.html?data=%s \n " , payload);
213267#else
214268 out.println (" If you are using Arduino as IDF component, install ESP Rainmaker:\n https://github.com/espressif/esp-rainmaker" );
215269#endif
0 commit comments