3838#include "py/mphal.h"
3939#endif
4040#include "extmod/modwebsocket.h"
41+ #include "genhdr/mpversion.h"
4142
4243#if MICROPY_PY_WEBREPL
4344
@@ -57,7 +58,7 @@ struct webrepl_file {
5758 char fname [64 ];
5859} __attribute__((packed ));
5960
60- enum { PUT_FILE = 1 , GET_FILE , LIST_DIR };
61+ enum { PUT_FILE = 1 , GET_FILE , GET_VER };
6162enum { STATE_PASSWD , STATE_NORMAL };
6263
6364typedef struct _mp_obj_webrepl_t {
@@ -128,6 +129,20 @@ STATIC int write_file_chunk(mp_obj_webrepl_t *self) {
128129}
129130
130131STATIC void handle_op (mp_obj_webrepl_t * self ) {
132+
133+ // Handle operations not requiring opened file
134+
135+ switch (self -> hdr .type ) {
136+ case GET_VER : {
137+ static char ver [] = {MICROPY_VERSION_MAJOR , MICROPY_VERSION_MINOR , MICROPY_VERSION_MICRO };
138+ write_webrepl (self -> sock , ver , sizeof (ver ));
139+ self -> hdr_to_recv = sizeof (struct webrepl_file );
140+ return ;
141+ }
142+ }
143+
144+ // Handle operations requiring opened file
145+
131146 mp_obj_t open_args [2 ] = {
132147 mp_obj_new_str (self -> hdr .fname , strlen (self -> hdr .fname ), false),
133148 MP_OBJ_NEW_QSTR (MP_QSTR_rb )
0 commit comments