88
99#define QRDECODE_DEBUG_PRINT (...) mp_printf(&mp_plat_print, __VA_ARGS__);
1010
11- static const char * TAG = "qrdecode" ;
12-
1311// Function to decode a QR code from a grayscale image buffer
1412static mp_obj_t qrdecode (mp_uint_t n_args , const mp_obj_t * args ) {
1513 QRDECODE_DEBUG_PRINT ("qrdecode: Starting\n" );
1614
1715 // Check argument count (expecting buffer, width, height)
1816 QRDECODE_DEBUG_PRINT ("qrdecode: Checking argument count\n" );
19- ESP_LOGI (TAG , "Checking argument count" );
2017 fflush (stdout );
2118 if (n_args != 3 ) {
2219 mp_raise_ValueError (MP_ERROR_TEXT ("quirc_decode expects 3 arguments: buffer, width, height" ));
2320 }
2421
2522 // Extract buffer
2623 QRDECODE_DEBUG_PRINT ("qrdecode: Extracting buffer\n" );
27- ESP_LOGI (TAG , "Extracting buffer" );
2824 fflush (stdout );
2925 mp_buffer_info_t bufinfo ;
3026 mp_get_buffer_raise (args [0 ], & bufinfo , MP_BUFFER_READ );
3127 printf ("qrdecode: Buffer extracted, len=%zu\n" , bufinfo .len );
32- ESP_LOGI (TAG , "Buffer extracted, len=%zu" , bufinfo .len );
3328
3429 // Extract width and height
3530 QRDECODE_DEBUG_PRINT ("qrdecode: Extracting width and height\n" );
@@ -108,8 +103,8 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) {
108103 QRDECODE_DEBUG_PRINT ("qrdecode: QR code extracted\n" );
109104 fflush (stdout );
110105 // it works until here!
111-
112- // Decode the QR code
106+ /*
107+ // Decode the QR code - this is the part that fails:
113108 QRDECODE_DEBUG_PRINT("qrdecode: Decoding QR code\n");
114109 fflush(stdout);
115110 struct quirc_data data;
@@ -120,15 +115,16 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) {
120115 }
121116 QRDECODE_DEBUG_PRINT("qrdecode: QR code decoded, payload_len=%d\n", data.payload_len);
122117 fflush(stdout);
118+
123119 QRDECODE_DEBUG_PRINT("qrdecode: got result: %s\n", data.payload);
124120 fflush(stdout);
125121 QRDECODE_DEBUG_PRINT("ok so now what?!");
126- /*
122+
127123 // Convert decoded data to Python string
128124 QRDECODE_DEBUG_PRINT("qrdecode: Creating Python string\n");
129125 fflush(stdout);
130126 mp_obj_t result = mp_obj_new_str((const char *)data.payload, data.payload_len);
131- printf ("qrdecode: Python string created\n");
127+ QRDECODE_DEBUG_PRINT ("qrdecode: Python string created\n");
132128 fflush(stdout);
133129
134130 // Clean up
0 commit comments