Skip to content

Commit c9b9dd1

Browse files
committed
Fixed build errors if 'EVE' module was selected without 'TFT' module enabled
Updated 'Curl' module Adder custom request argument to 'getmail' method Updated frozen modules 'microWebSrv' and 'microWebSocket' Removed unneede import of 'websocket' module
1 parent 6a70343 commit c9b9dd1

File tree

7 files changed

+35
-10
lines changed

7 files changed

+35
-10
lines changed

MicroPython_BUILD/components/micropython/esp32/libs/espcurl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ char *url_encode(const char *str) {
397397
return buf;
398398
}
399399

400-
//=========================================================================================================================================================================================
401-
int Curl_IMAP_GET(const char *opts, char *fname, char *hdr, char *body, int hdrlen, int bodylen, const char* imapserver, unsigned int imapport, const char* username, const char* password)
400+
//=========================================================================================================================================================================================================
401+
int Curl_IMAP_GET(const char *opts, char *fname, char *hdr, char *body, int hdrlen, int bodylen, const char* imapserver, unsigned int imapport, const char* username, const char* password, char *cust_req)
402402
{
403403
CURL *curl = NULL;
404404
CURLcode res = 0;
@@ -487,6 +487,9 @@ int Curl_IMAP_GET(const char *opts, char *fname, char *hdr, char *body, int hdrl
487487
if (username && *username) curl_easy_setopt(curl, CURLOPT_USERNAME, username);
488488
if (password) curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
489489

490+
if (cust_req) {
491+
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, cust_req);
492+
}
490493
// Only allow IMAPS, we do not want this to work when unencrypted.
491494
curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_IMAPS);
492495

MicroPython_BUILD/components/micropython/esp32/libs/espcurl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ extern uint8_t curl_nodecode;
8484
int Curl_GET(char *url, char *fname, char *hdr, char *body, int hdrlen, int bodylen);
8585

8686

87-
//==========================================================================================================================================================================================
88-
int Curl_IMAP_GET(const char *opts, char *fname, char *hdr, char *body, int hdrlen, int bodylen, const char* imapserver, unsigned int imapport, const char* username, const char* password);
87+
//==========================================================================================================================================================================================================
88+
int Curl_IMAP_GET(const char *opts, char *fname, char *hdr, char *body, int hdrlen, int bodylen, const char* imapserver, unsigned int imapport, const char* username, const char* password, char *cust_req);
8989

9090

9191
/*

MicroPython_BUILD/components/micropython/esp32/modcurl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,21 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(curl_GET_obj, 1, curl_GET);
202202
STATIC mp_obj_t curl_GET_MAIL(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
203203
{
204204
network_checkConnection();
205-
enum { ARG_opts, ARG_user, ARG_pass, ARG_server, ARG_port, ARG_file };
205+
enum { ARG_opts, ARG_user, ARG_pass, ARG_server, ARG_port, ARG_file, ARG_req };
206206
const mp_arg_t allowed_args[] = {
207207
{ MP_QSTR_opts, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
208208
{ MP_QSTR_user, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
209209
{ MP_QSTR_password, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
210210
{ MP_QSTR_server, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } },
211211
{ MP_QSTR_port, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = GMAIL_IMAP_PORT } },
212212
{ MP_QSTR_file, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } },
213+
{ MP_QSTR_req, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } },
213214
};
214215

215216
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
216217
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
217218

219+
char *cust_req = NULL;
218220
char *opts = (char *)mp_obj_str_get_str(args[ARG_opts].u_obj);
219221
char *user = (char *)mp_obj_str_get_str(args[ARG_user].u_obj);
220222
char *pass = (char *)mp_obj_str_get_str(args[ARG_pass].u_obj);
@@ -228,6 +230,10 @@ STATIC mp_obj_t curl_GET_MAIL(size_t n_args, const mp_obj_t *pos_args, mp_map_t
228230
char fullname[128] = {'\0'};
229231

230232
uint32_t mail_port = args[ARG_port].u_int;
233+
if (MP_OBJ_IS_STR(args[ARG_req].u_obj)) {
234+
(char *)mp_obj_str_get_str(args[ARG_req].u_obj);
235+
}
236+
231237
if (MP_OBJ_IS_STR(args[ARG_server].u_obj)) sprintf(mail_server, "%s", (char *)mp_obj_str_get_str(args[ARG_server].u_obj));
232238
else sprintf(mail_server, GMAIL_IMAP);
233239

@@ -250,7 +256,7 @@ STATIC mp_obj_t curl_GET_MAIL(size_t n_args, const mp_obj_t *pos_args, mp_map_t
250256
body.buf[0] = '\0';
251257

252258
MP_THREAD_GIL_EXIT();
253-
res = Curl_IMAP_GET(opts, fname, header.buf, body.buf, header.len, body.len, mail_server, mail_port, user, pass);
259+
res = Curl_IMAP_GET(opts, fname, header.buf, body.buf, header.len, body.len, mail_server, mail_port, user, pass, cust_req);
254260
MP_THREAD_GIL_ENTER();
255261

256262
mp_obj_t tuple[3];

MicroPython_BUILD/components/micropython/esp32/moddisplay_eve.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,14 @@ static void adjust_ramg_objects(void *this_obj, uint32_t addr, uint32_t size)
374374
obj->addr -= size;
375375
}
376376
}
377+
#ifdef CONFIG_MICROPY_USE_TFT
377378
else if (base->type == &tft_eve_type) {
378379
tft_eve_obj_t *obj = (tft_eve_obj_t *)ptr;
379380
if (obj->addr > addr) {
380381
obj->addr -= size;
381382
}
382383
}
384+
#endif
383385
}
384386
}
385387
}
@@ -410,10 +412,12 @@ static void print_objects(const mp_print_t *print)
410412
console_eve_obj_t *obj = (console_eve_obj_t *)ptr;
411413
mp_printf(print, " %2d: Console, addr=%u, size=%u\n", i, obj->addr,obj->size);
412414
}
415+
#ifdef CONFIG_MICROPY_USE_TFT
413416
else if (base->type == &tft_eve_type) {
414417
tft_eve_obj_t *obj = (tft_eve_obj_t *)ptr;
415418
mp_printf(print, " %2d: Tft, addr=%u, size=%u\n", i, obj->addr,obj->size);
416419
}
420+
#endif
417421
else {
418422
mp_printf(print, " %2d: Unknown object type\n", i);
419423
}
@@ -505,6 +509,7 @@ STATIC void console_eve_printinfo(const mp_print_t *print, mp_obj_t self_in, mp_
505509
}
506510
}
507511

512+
#ifdef CONFIG_MICROPY_USE_TFT
508513
//--------------------------------------------------------------------------------------------
509514
STATIC void tft_eve_printinfo(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
510515
{
@@ -517,6 +522,7 @@ STATIC void tft_eve_printinfo(const mp_print_t *print, mp_obj_t self_in, mp_prin
517522
mp_printf(print, "EVE_TFT ( Unloaded )");
518523
}
519524
}
525+
#endif
520526

521527
//--------------------------------------------
522528
static esp_err_t _EVE_calibrate(bool nvs_read)
@@ -3958,12 +3964,11 @@ const mp_obj_type_t console_eve_type = {
39583964
// ^^^^ CONSOLE object end ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39593965

39603966

3967+
#ifdef CONFIG_MICROPY_USE_TFT
39613968

39623969
// ==== TFT object ===============================================
39633970

39643971

3965-
3966-
39673972
// constructor
39683973
//---------------------------------------------------------------------------------------------------------------
39693974
STATIC mp_obj_t tft_eve_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args)
@@ -4218,6 +4223,7 @@ const mp_obj_type_t tft_eve_type = {
42184223

42194224
// ^^^^ TFT object ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42204225

4226+
#endif
42214227

42224228
//================================================================
42234229
STATIC const mp_rom_map_elem_t display_eve_locals_dict_table[] = {
@@ -4294,7 +4300,9 @@ STATIC const mp_rom_map_elem_t display_eve_locals_dict_table[] = {
42944300
{ MP_OBJ_NEW_QSTR(MP_QSTR_Font), MP_ROM_PTR(&font_eve_type) },
42954301
{ MP_OBJ_NEW_QSTR(MP_QSTR_Image), MP_ROM_PTR(&image_eve_type) },
42964302
{ MP_OBJ_NEW_QSTR(MP_QSTR_Console), MP_ROM_PTR(&console_eve_type) },
4303+
#ifdef CONFIG_MICROPY_USE_TFT
42974304
{ MP_OBJ_NEW_QSTR(MP_QSTR_Tft), MP_ROM_PTR(&tft_eve_type) },
4305+
#endif
42984306

42994307
// SPI bus constants
43004308
{ MP_ROM_QSTR(MP_QSTR_HSPI), MP_ROM_INT(HSPI_HOST) },

MicroPython_BUILD/components/micropython/esp32/modules/microWebSocket.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import _thread
1111
import time
1212
import gc
13-
import websocket
1413

1514
class MicroWebSocket :
1615

MicroPython_BUILD/components/micropython/esp32/modules/microWebSrv.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import network
1212
import time
1313
import socket
14-
import websocket
1514
import gc
1615
import re
1716

MicroPython_BUILD/updates.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
=== 2018-09-03 ===
2+
Fixed build errors if EVE module was selected without TFT module enabled
3+
4+
Updated 'Curl' module
5+
Adder custom request argument to 'getmail' method
6+
7+
Updated frozen modules 'microWebSrv' and 'microWebSocket'
8+
Removed unneede import of 'websocket' module
9+
10+
111
=== 2018-09-01 ===
212
Fixed wrong method name in 'requests' module
313

0 commit comments

Comments
 (0)