mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
Updated SSH & Curl modules, some bugs fixed
Some minor changes
This commit is contained in:
@@ -34,6 +34,10 @@
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define LIBSSH2DEBUG
|
||||
#define HAVE_GETTIMEOFDAY
|
||||
#define LIBSSH2_DH_GEX_NEW
|
||||
|
||||
/* Headers */
|
||||
#define LIBSSH2_MBEDTLS
|
||||
#define HAVE_O_NONBLOCK
|
||||
|
||||
@@ -27,11 +27,16 @@
|
||||
*/
|
||||
|
||||
#include "py/builtin.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
const char esp32_help_text[] =
|
||||
"Welcome to MicroPython on the ESP32!\n"
|
||||
#if CONFIG_SPIRAM_SUPPORT
|
||||
"Welcome to LoBo MicroPython on the ESP32 with psRAM!\n"
|
||||
#else
|
||||
"Welcome to LoBo MicroPython on the ESP32!\n"
|
||||
#endif
|
||||
"\n"
|
||||
"For generic online docs please visit http://docs.micropython.org/\n"
|
||||
"For online documentation please visit:\nhttps://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki\n"
|
||||
"\n"
|
||||
"For access to the hardware use the 'machine' module:\n"
|
||||
"\n"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,28 @@
|
||||
/*
|
||||
* This file is part of the LoBo MicroPython project
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017-2018 LoBo (https://gihub.com/loboris)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ESPCURL_H_
|
||||
@@ -8,12 +33,23 @@
|
||||
#if defined(CONFIG_MICROPY_USE_CURL) || defined(CONFIG_MICROPY_USE_SSH)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MIN_HDR_BUF_LEN 128
|
||||
#define MIN_BODY_BUF_LEN 256
|
||||
|
||||
// ================
|
||||
// Public functions
|
||||
// ================
|
||||
|
||||
#ifdef CONFIG_MICROPY_USE_CURL
|
||||
|
||||
#include "curl/curl.h"
|
||||
|
||||
#define MIN_HDR_BODY_BUF_LEN 256
|
||||
#define GMAIL_SMTP "smtp.gmail.com"
|
||||
#define GMAIL_PORT 465
|
||||
#define GMAIL_SMTP "smtp.gmail.com"
|
||||
#define GMAIL_PORT 465
|
||||
|
||||
struct curl_httppost *formpost;
|
||||
struct curl_httppost *lastptr;
|
||||
|
||||
// Some configuration variables
|
||||
extern uint8_t curl_verbose; // show detailed info of what curl functions are doing
|
||||
@@ -22,20 +58,9 @@ extern uint16_t curl_timeout; // curl operations timeout in seconds
|
||||
extern uint32_t curl_maxbytes; // limit download length
|
||||
extern uint8_t curl_initialized;
|
||||
extern uint8_t curl_nodecode;
|
||||
|
||||
extern int hdr_maxlen;
|
||||
extern int body_maxlen;
|
||||
|
||||
struct curl_httppost *formpost;
|
||||
struct curl_httppost *lastptr;
|
||||
|
||||
|
||||
// ================
|
||||
// Public functions
|
||||
// ================
|
||||
|
||||
#ifdef CONFIG_MICROPY_USE_CURL
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------
|
||||
* int res = Curl_GET(url, fname, hdr, body, hdrlen, bodylen)
|
||||
@@ -117,21 +142,29 @@ int Curl_FTP(uint8_t upload, char *url, char *user_pass, char *fname, char *hdr,
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif //CONFIG_MICROPY_USE_CURL
|
||||
|
||||
//==================
|
||||
void Curl_cleanup();
|
||||
|
||||
#ifdef CONFIG_MICROPY_USE_SSH
|
||||
|
||||
//=======================================================================================================================================================
|
||||
int ssh_SCP(uint8_t type, char *server, char *port, char * scppath, char *user, char *pass, char *fname, char *hdr, char *body, int hdrlen, int bodylen);
|
||||
extern uint8_t ssh2_verbose;
|
||||
extern uint8_t ssh2_progress;
|
||||
extern uint16_t ssh2_session_trace;
|
||||
extern uint8_t ssh2_session_timeout;
|
||||
extern int ssh2_hdr_maxlen;
|
||||
extern int ssh2_body_maxlen;
|
||||
extern uint32_t ssh2_maxbytes;
|
||||
|
||||
#endif
|
||||
//==================================================================================================================================================================
|
||||
int ssh_SCP(uint8_t type, char *server, char *port, char * scppath, char *user, char *pass, char *key, char *fname, char *hdr, char *body, int hdrlen, int bodylen);
|
||||
|
||||
#endif // CONFIG_MICROPY_USE_SSH
|
||||
|
||||
//=====================
|
||||
void checkConnection();
|
||||
|
||||
#endif
|
||||
#endif // defined(CONFIG_MICROPY_USE_CURL) || defined(CONFIG_MICROPY_USE_SSH)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -154,6 +154,7 @@ soft_reset:
|
||||
else printf("Error mounting Flash file system\n");
|
||||
|
||||
// === Print some info ===
|
||||
char sbuff[24] = { 0 };
|
||||
gc_info_t info;
|
||||
gc_info(&info);
|
||||
// set gc.threshold to 87.5% of usable heap
|
||||
@@ -172,17 +173,20 @@ soft_reset:
|
||||
// Print partition info
|
||||
const esp_partition_t *running_partition = esp_ota_get_running_partition();
|
||||
if (running_partition != NULL) {
|
||||
printf("Running from %spartition at %X, type %X [%s].\n",
|
||||
((running_partition->encrypted) ? "encrypted " : ""), running_partition->address, running_partition->subtype, running_partition->label);
|
||||
if (running_partition->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) sprintf(sbuff, "Factory ");
|
||||
else if (running_partition->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) sprintf(sbuff, "OTA_0 ");
|
||||
else if (running_partition->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_1) sprintf(sbuff, "OTA_1 ");
|
||||
else sbuff[0] = '\0';
|
||||
printf("Running from %s%spartition starting at 0x%X, [%s].\n",
|
||||
((running_partition->encrypted) ? "encrypted " : ""), sbuff, running_partition->address, running_partition->label);
|
||||
}
|
||||
|
||||
char rst_reason[24] = { 0 };
|
||||
mpsleep_get_reset_desc(rst_reason);
|
||||
mpsleep_get_reset_desc(sbuff);
|
||||
if (mpsleep_get_wake_reason() != MPSLEEP_NONE_WAKE) printf(" ");
|
||||
printf("\n Reset reason: %s\n", rst_reason);
|
||||
printf("\n Reset reason: %s\n", sbuff);
|
||||
if (mpsleep_get_wake_reason() != MPSLEEP_NONE_WAKE) {
|
||||
mpsleep_get_wake_desc(rst_reason);
|
||||
printf("Wakeup source: %s\n", rst_reason);
|
||||
mpsleep_get_wake_desc(sbuff);
|
||||
printf("Wakeup source: %s\n", sbuff);
|
||||
}
|
||||
|
||||
printf(" uPY stack: %d bytes\n", MP_TASK_STACK_LEN-1024);
|
||||
|
||||
@@ -129,8 +129,8 @@ STATIC mp_obj_t curl_Options(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
||||
if (args[ARG_progress].u_int >= 0) curl_progress = args[ARG_progress].u_int;
|
||||
if (args[ARG_timeout].u_int >= 10) curl_timeout = args[ARG_timeout].u_int;
|
||||
if (args[ARG_maxfsize].u_int > 1000) curl_maxbytes = args[ARG_maxfsize].u_int;
|
||||
if (args[ARG_hdrlen].u_int > 128) hdr_maxlen = args[ARG_hdrlen].u_int;
|
||||
if (args[ARG_bodylen].u_int > MIN_HDR_BODY_BUF_LEN) body_maxlen = args[ARG_bodylen].u_int;
|
||||
if (args[ARG_hdrlen].u_int > MIN_HDR_BUF_LEN) hdr_maxlen = args[ARG_hdrlen].u_int;
|
||||
if (args[ARG_bodylen].u_int > MIN_BODY_BUF_LEN) body_maxlen = args[ARG_bodylen].u_int;
|
||||
if (args[ARG_nodecode].u_int >= 0) curl_nodecode = args[ARG_nodecode].u_int & 1;
|
||||
|
||||
if (args[ARG_print].u_bool) {
|
||||
@@ -176,7 +176,7 @@ STATIC mp_obj_t curl_GET(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
|
||||
}
|
||||
fname = fullname;
|
||||
}
|
||||
body_len = MIN_HDR_BODY_BUF_LEN;
|
||||
body_len = MIN_BODY_BUF_LEN;
|
||||
}
|
||||
|
||||
vstr_init_len(&header, hdr_len);
|
||||
@@ -476,7 +476,7 @@ STATIC mp_obj_t curl_FTP_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
}
|
||||
fname = fullname;
|
||||
}
|
||||
body_len = MIN_HDR_BODY_BUF_LEN;
|
||||
body_len = MIN_BODY_BUF_LEN;
|
||||
}
|
||||
else if (type == 1) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Expected file name for PUT command"));
|
||||
@@ -489,7 +489,7 @@ STATIC mp_obj_t curl_FTP_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
body.buf[0] = '\0';
|
||||
|
||||
MP_THREAD_GIL_EXIT();
|
||||
res = Curl_FTP(type&1, url, user, fname, header.buf, body.buf, header.len, body.len);
|
||||
res = Curl_FTP(type&1, url, userpass, fname, header.buf, body.buf, header.len, body.len);
|
||||
MP_THREAD_GIL_ENTER();
|
||||
|
||||
mp_obj_t tuple[3];
|
||||
@@ -530,19 +530,20 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(curl_FTP_LIST_obj, 3, curl_FTP_LIST);
|
||||
STATIC const mp_rom_map_elem_t curl_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_curl) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&curl_info_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_options), MP_ROM_PTR(&curl_Options_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&curl_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_post), MP_ROM_PTR(&curl_POST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_sendmail), MP_ROM_PTR(&curl_sendmail_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&curl_info_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_options), MP_ROM_PTR(&curl_Options_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&curl_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_post), MP_ROM_PTR(&curl_POST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_sendmail), MP_ROM_PTR(&curl_sendmail_obj) },
|
||||
#ifdef CONFIG_MICROPY_USE_CURLFTP
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_get), MP_ROM_PTR(&curl_FTP_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_put), MP_ROM_PTR(&curl_FTP_PUT_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_list), MP_ROM_PTR(&curl_FTP_LIST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_get), MP_ROM_PTR(&curl_FTP_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_put), MP_ROM_PTR(&curl_FTP_PUT_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ftp_list), MP_ROM_PTR(&curl_FTP_LIST_obj) },
|
||||
#endif
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SMTP), MP_ROM_INT(QUICKMAIL_PROT_SMTP) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SMTPS), MP_ROM_INT(QUICKMAIL_PROT_SMTPS) },
|
||||
// Constants
|
||||
{ MP_ROM_QSTR(MP_QSTR_SMTP), MP_ROM_INT(QUICKMAIL_PROT_SMTP) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SMTPS), MP_ROM_INT(QUICKMAIL_PROT_SMTPS) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(curl_module_globals, curl_module_globals_table);
|
||||
|
||||
|
||||
@@ -49,41 +49,40 @@
|
||||
#include "extmod/vfs_native.h"
|
||||
#include "libssh2.h"
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
STATIC mp_obj_t curl_SSH_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, uint8_t type)
|
||||
{
|
||||
checkConnection();
|
||||
enum { ARG_url, ARG_user, ARG_pass, ARG_file, ARG_port };
|
||||
enum { ARG_url, ARG_user, ARG_pass, ARG_key, ARG_file, ARG_port };
|
||||
const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_url, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_user, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_password, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_file, MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_port, MP_ARG_INT, { .u_int = 22 } },
|
||||
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_file, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } },
|
||||
{ MP_QSTR_port, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = 22 } },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
int res;
|
||||
int hdr_len = hdr_maxlen;
|
||||
int body_len = body_maxlen;
|
||||
int hdr_len = ssh2_hdr_maxlen;
|
||||
int body_len = ssh2_body_maxlen;
|
||||
vstr_t header;
|
||||
vstr_t body;
|
||||
char *url = NULL;
|
||||
char *user = NULL;
|
||||
char *pass = NULL;
|
||||
char *fname = NULL;
|
||||
char *key = NULL;
|
||||
|
||||
char server[128] = {'\0'};
|
||||
char fullname[128] = {'\0'};
|
||||
char fullkey[128] = {'\0'};
|
||||
char scppath[128] = {'\0'};
|
||||
|
||||
/*uint8_t type = (uint8_t)args[ARG_type].u_int;
|
||||
if (type > 4) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Unsupported operation type"));
|
||||
}*/
|
||||
|
||||
uint16_t port = (uint16_t)args[ARG_port].u_int;
|
||||
char sport[8] = {'\0'};
|
||||
sprintf(sport,"%u", port);
|
||||
@@ -104,7 +103,18 @@ STATIC mp_obj_t curl_SSH_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
}
|
||||
|
||||
user = (char *)mp_obj_str_get_str(args[ARG_user].u_obj);
|
||||
pass = (char *)mp_obj_str_get_str(args[ARG_pass].u_obj);
|
||||
|
||||
if (MP_OBJ_IS_STR(args[ARG_key].u_obj)) {
|
||||
// Authenticate using a key pair
|
||||
key = (char *)mp_obj_str_get_str(args[ARG_key].u_obj);
|
||||
res = physicalPath(key, fullkey);
|
||||
if ((res != 0) || (strlen(fullkey) == 0)) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Error resolving key file name"));
|
||||
}
|
||||
key = fullkey;
|
||||
if (args[ARG_pass].u_obj != mp_const_none) pass = (char *)mp_obj_str_get_str(args[ARG_pass].u_obj);
|
||||
}
|
||||
else pass = (char *)mp_obj_str_get_str(args[ARG_pass].u_obj);
|
||||
|
||||
if ((type == 0) || (type == 1)) {
|
||||
if (MP_OBJ_IS_STR(args[ARG_file].u_obj)) {
|
||||
@@ -115,7 +125,7 @@ STATIC mp_obj_t curl_SSH_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Error resolving file name"));
|
||||
}
|
||||
fname = fullname;
|
||||
body_len = MIN_HDR_BODY_BUF_LEN;
|
||||
body_len = MIN_BODY_BUF_LEN;
|
||||
}
|
||||
else if (type == 1) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Expected file name for upload"));
|
||||
@@ -128,7 +138,7 @@ STATIC mp_obj_t curl_SSH_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
body.buf[0] = '\0';
|
||||
|
||||
MP_THREAD_GIL_EXIT();
|
||||
res = ssh_SCP(type, server, sport, scppath, user, pass, fname, header.buf, body.buf, hdr_len, body_len);
|
||||
res = ssh_SCP(type, server, sport, scppath, user, pass, key, fname, header.buf, body.buf, hdr_len, body_len);
|
||||
MP_THREAD_GIL_ENTER();
|
||||
|
||||
mp_obj_t tuple[3];
|
||||
@@ -183,25 +193,90 @@ STATIC mp_obj_t SSH2_exec(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(SSH2_exec_obj, 3, SSH2_exec);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
STATIC mp_obj_t SSH2_Options(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
enum { ARG_print, ARG_verbose, ARG_progress, ARG_timeout, ARG_maxfsize, ARG_hdrlen, ARG_bodylen, ARG_trace };
|
||||
const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_print, MP_ARG_BOOL, { .u_bool = true } },
|
||||
{ MP_QSTR_verbose, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_progress, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_maxfsize, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_hdrlen, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_bodylen, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
{ MP_QSTR_trace, MP_ARG_KW_ONLY | MP_ARG_INT, { .u_int = -1 } },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
if (args[ARG_verbose].u_int >= 0) ssh2_verbose = args[ARG_verbose].u_int & 1;
|
||||
if (args[ARG_progress].u_int >= 0) ssh2_progress = args[ARG_progress].u_int;
|
||||
if (args[ARG_timeout].u_int >= 10) ssh2_session_timeout = args[ARG_timeout].u_int;
|
||||
if (args[ARG_maxfsize].u_int > 1000) ssh2_maxbytes = args[ARG_maxfsize].u_int;
|
||||
if (args[ARG_hdrlen].u_int > MIN_HDR_BUF_LEN) ssh2_hdr_maxlen = args[ARG_hdrlen].u_int;
|
||||
if (args[ARG_bodylen].u_int > MIN_BODY_BUF_LEN) ssh2_body_maxlen = args[ARG_bodylen].u_int;
|
||||
if (args[ARG_trace].u_int >= 0) ssh2_session_trace = args[ARG_trace].u_int & 0x3FF;
|
||||
|
||||
if (ssh2_session_timeout > CONFIG_TASK_WDT_TIMEOUT_S) ssh2_session_timeout = CONFIG_TASK_WDT_TIMEOUT_S - 2;
|
||||
if (ssh2_session_timeout < 2) ssh2_session_timeout = 2;
|
||||
if (ssh2_session_timeout > 30) ssh2_session_timeout = 30;
|
||||
|
||||
if (args[ARG_print].u_bool) {
|
||||
mp_printf(&mp_plat_print, "SSH options(\n Verbose: %s, Progress: %d, Timeout: %d s, Max fsize: %d, Header len: %d, Body len: %d, Trace: %s (0x%03X)\n)\n",
|
||||
((ssh2_verbose) ? "True" : "False"), ssh2_progress, ssh2_session_timeout, ssh2_maxbytes, ssh2_hdr_maxlen, ssh2_body_maxlen, ((ssh2_session_trace) ? "True" : "False"), ssh2_session_trace);
|
||||
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(SSH2_Options_obj, 0, SSH2_Options);
|
||||
|
||||
|
||||
//============================================================
|
||||
STATIC const mp_rom_map_elem_t curl_module_globals_table[] = {
|
||||
/*
|
||||
* Trace constants
|
||||
LIBSSH2_TRACE_TRANS (1<<1)
|
||||
LIBSSH2_TRACE_KEX (1<<2)
|
||||
LIBSSH2_TRACE_AUTH (1<<3)
|
||||
LIBSSH2_TRACE_CONN (1<<4)
|
||||
LIBSSH2_TRACE_SCP (1<<5)
|
||||
LIBSSH2_TRACE_SFTP (1<<6)
|
||||
LIBSSH2_TRACE_ERROR (1<<7)
|
||||
LIBSSH2_TRACE_PUBLICKEY (1<<8)
|
||||
LIBSSH2_TRACE_SOCKET (1<<9)
|
||||
*/
|
||||
|
||||
//===========================================================
|
||||
STATIC const mp_rom_map_elem_t ssh_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ssh) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&SSH2_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&SSH2_PUT_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_list), MP_ROM_PTR(&SSH2_LIST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_llist), MP_ROM_PTR(&SSH2_LLIST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&SSH2_mkdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_exec), MP_ROM_PTR(&SSH2_exec_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&SSH2_GET_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_put), MP_ROM_PTR(&SSH2_PUT_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_list), MP_ROM_PTR(&SSH2_LIST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_llist), MP_ROM_PTR(&SSH2_LLIST_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&SSH2_mkdir_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_exec), MP_ROM_PTR(&SSH2_exec_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_options), MP_ROM_PTR(&SSH2_Options_obj) },
|
||||
|
||||
// Constants
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_TRANS), MP_ROM_INT(LIBSSH2_TRACE_TRANS) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_KEX), MP_ROM_INT(LIBSSH2_TRACE_KEX) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_AUTH), MP_ROM_INT(LIBSSH2_TRACE_AUTH) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_CONN), MP_ROM_INT(LIBSSH2_TRACE_CONN) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_SCP), MP_ROM_INT(LIBSSH2_TRACE_SCP) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_SFTP), MP_ROM_INT(LIBSSH2_TRACE_SFTP) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_ERROR), MP_ROM_INT(LIBSSH2_TRACE_ERROR) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_PUBLICKEY), MP_ROM_INT(LIBSSH2_TRACE_PUBLICKEY) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_SOCKET), MP_ROM_INT(LIBSSH2_TRACE_SOCKET) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_NONE), MP_ROM_INT(0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TRACE_ALL), MP_ROM_INT(0x3FE) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(curl_module_globals, curl_module_globals_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(ssh_module_globals, ssh_module_globals_table);
|
||||
|
||||
//======================================
|
||||
const mp_obj_module_t mp_module_ssh = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&curl_module_globals,
|
||||
.globals = (mp_obj_dict_t*)&ssh_module_globals,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -230,7 +230,7 @@ extern const struct _mp_obj_module_t mp_module_curl;
|
||||
|
||||
#ifdef CONFIG_MICROPY_USE_SSH
|
||||
extern const struct _mp_obj_module_t mp_module_ssh;
|
||||
#define BUILTIN_MODULE_SSH { MP_OBJ_NEW_QSTR(MP_QSTR_curl), (mp_obj_t)&mp_module_ssh },
|
||||
#define BUILTIN_MODULE_SSH { MP_OBJ_NEW_QSTR(MP_QSTR_ssh), (mp_obj_t)&mp_module_ssh },
|
||||
#else
|
||||
#define BUILTIN_MODULE_SSH
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// MicroPython version info
|
||||
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.8"
|
||||
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.1.9"
|
||||
#define MICROPY_GIT_HASH "g2ddee729"
|
||||
#define MICROPY_BUILD_DATE "2017-01-19"
|
||||
#define MICROPY_BUILD_DATE "2017-01-21"
|
||||
#define MICROPY_VERSION_MAJOR (3)
|
||||
#define MICROPY_VERSION_MINOR (1)
|
||||
#define MICROPY_VERSION_MICRO (8)
|
||||
#define MICROPY_VERSION_STRING "3.1.8"
|
||||
#define MICROPY_VERSION_MICRO (9)
|
||||
#define MICROPY_VERSION_STRING "3.1.9"
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#if MICROPY_PY_BUILTINS_HELP
|
||||
|
||||
const char mp_help_default_text[] =
|
||||
"Welcome to MicroPython!\n"
|
||||
"Welcome to LoBo MicroPython\n"
|
||||
"\n"
|
||||
"For online docs please visit http://docs.micropython.org/\n"
|
||||
"For online documentation please visit\nhttps://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki\n"
|
||||
"\n"
|
||||
"Control commands:\n"
|
||||
" CTRL-A -- on a blank line, enter raw REPL mode\n"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user