Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display MicroPython version on connect/authenticate #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions webrepl.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<form>
<input type="text" name="webrepl_url" id="url" value="ws://192.168.4.1:8266/" />
<input type="submit" id="button" value="Connect" onclick="button_click(); return false;" />
<span id="version"></span>
</form>
<div id="term">
</div>
Expand Down Expand Up @@ -88,6 +89,7 @@
var put_file_data = null;
var get_file_name = null;
var get_file_data = null;
var version = null;

function calculate_size(win) {
var cols = Math.max(80, Math.min(150, (win.innerWidth - 280) / 7)) | 0;
Expand Down Expand Up @@ -154,6 +156,9 @@
term.write('\x1b[31mWelcome to MicroPython!\x1b[m\r\n');

ws.onmessage = function(event) {
if (version == undefined && typeof event.data == 'string' && event.data.indexOf('WebREPL connected') > 0) {
get_ver();
}
if (event.data instanceof ArrayBuffer) {
var data = new Uint8Array(event.data);
switch (binary_state) {
Expand Down Expand Up @@ -224,6 +229,8 @@
case 31:
// first (and last) response for GET_VER
console.log('GET_VER', data);
version = data.join('.');
document.getElementById('version').innerText = 'MicroPython ' + version;
binary_state = 0;
break;
}
Expand Down