Skip to content

Commit

Permalink
Add execute option and meta information
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-dietrich committed Nov 25, 2024
1 parent 0c8d96d commit 01a7994
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ To use this module, you need to have a MicroPython board with WebREPL enabled. Y
https://edrys-labs.github.io/module-micropython-webrepl/
```

You can preset the WebSocket connection with the following station-configuration:
You can preset the WebSocket connection with the following station-configuration.
Additionally you can define a topic onto which the module will listen, thus if an external module publishes code under the following topic, then this code will be directly executed.
This is useful when using an editor with an execute procedure.

```
websocket: wss?://...
execute: topic
```

However, in most cases your MicroPython board will **NOT** be able to offer a secure wss connection, that is why you either need to install a browser-plugin at the Station-Browser. Or your run, the included [`proxy.py`](./proxy.py) script on a local machine, which will forward the WebSocket connection to the MicroPython board.
Expand Down
15 changes: 12 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<title>MicroPython WebREPL</title>

<script src="https://edrys-labs.github.io/module/edrys.js"></script>
<meta
name="description"
content="Allows to connect to a webrepl via a WebSocket.<br/> Form more information, visit: <a href='https://github.com/edrys-labs/module-micropython-webrepl' target='_blank'>https://github.com/edrys-labs/module-micropython-webrepl</a>"
/>
<meta name="show-in" content="station" />

<script
defer
Expand Down Expand Up @@ -125,9 +130,10 @@
const urlInput = document.getElementById('url')
const fileStatus = document.getElementById('file-status')
const connectionButton = document.getElementById('button')
var execute = 'execute'

Edrys.onMessage((message) => {
if (message.subject === 'execute' && Edrys.role === 'station') {
if (message.subject === execute && Edrys.role === 'station') {
console.log('execute', message.body)

let code = message.body.split('\n')
Expand Down Expand Up @@ -166,7 +172,6 @@
}, (promiscuous = true))

Edrys.onReady(() => {
console.warn('Ready', Edrys)
if (Edrys.role === 'student') {
urlInput.disabled = true
}
Expand All @@ -185,9 +190,13 @@
}
}

if (Edrys.role === 'station') {
execute = Edrys.module.stationConfig.execute || 'execute'
}

Edrys.updateState(() => {
if (Edrys.getState('url', 'Value') == undefined) {
Edrys.getState('url', 'Value', drys.module.stationConfig || 'ws://')
Edrys.getState('url', 'Value', Edrys.module.stationConfig || 'ws://')
}

if (Edrys.getState('file_status', 'Value') == undefined) {
Expand Down
2 changes: 1 addition & 1 deletion webrepl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function calculate_size(win) {
cursorBlink: false,
})
term.open(document.getElementById('term'))
show_https_warning()
// show_https_warning()
}
window.addEventListener('resize', function () {
var size = calculate_size(self)
Expand Down

0 comments on commit 01a7994

Please sign in to comment.