8000 extmod/modwebrepl: Add GET_VER operation to query MicroPython version. · alexbartlow/circuitpython@e15fb33 · GitHub
[go: up one dir, main page]

Skip to content

Commit e15fb33

Browse files
committed
extmod/modwebrepl: Add GET_VER operation to query MicroPython version.
1 parent cbef0db commit e15fb33

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extmod/modwebrepl.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
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 };
6162
enum { STATE_PASSWD, STATE_NORMAL };
6263

6364
typedef struct _mp_obj_webrepl_t {
@@ -128,6 +129,20 @@ STATIC int write_file_chunk(mp_obj_webrepl_t *self) {
128129
}
129130

130131
STATIC 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

Comments
 (0)
0