mirror of https://github.com/espruino/BangleApps
Support for Web IDE remote from Gadgetbridge
parent
3e26732693
commit
b6ca665724
46
android.html
46
android.html
|
@ -144,6 +144,7 @@
|
||||||
<button class="btn tooltip" id="downloadallapps" data-tooltip="Download all Bangle.js files to a ZIP file">Backup</button>
|
<button class="btn tooltip" id="downloadallapps" data-tooltip="Download all Bangle.js files to a ZIP file">Backup</button>
|
||||||
<button class="btn tooltip" id="uploadallapps" data-tooltip="Restore Bangle.js from a ZIP file">Restore</button>
|
<button class="btn tooltip" id="uploadallapps" data-tooltip="Restore Bangle.js from a ZIP file">Restore</button>
|
||||||
<button class="btn tooltip" id="defaultbanglesettings" data-tooltip="Reset your Bangle's settings to the defaults">Reset Settings</button>
|
<button class="btn tooltip" id="defaultbanglesettings" data-tooltip="Reset your Bangle's settings to the defaults">Reset Settings</button>
|
||||||
|
<button class="btn tooltip" id="webideremote" data-tooltip="Enable the Web IDE remote server">Web IDE Remote</button>
|
||||||
</p>
|
</p>
|
||||||
<h3>Settings</h3>
|
<h3>Settings</h3>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -203,6 +204,9 @@
|
||||||
<script src="core/js/appinfo.js"></script>
|
<script src="core/js/appinfo.js"></script>
|
||||||
<script src="core/js/index.js"></script>
|
<script src="core/js/index.js"></script>
|
||||||
<script src="core/js/pwa.js" defer></script>
|
<script src="core/js/pwa.js" defer></script>
|
||||||
|
<!-- FIXME - use espruino.com/ide, github -->
|
||||||
|
<script src="https://espruino.github.io/EspruinoWebIDE/js/libs/peerjs.min.js"></script>
|
||||||
|
<script src="https://espruino.github.io/EspruinoWebIDE/EspruinoTools/libs/webrtc-connection.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/*Android = {
|
/*Android = {
|
||||||
bangleTx : function(data) {
|
bangleTx : function(data) {
|
||||||
|
@ -228,8 +232,10 @@ if (typeof Android!=="undefined") {
|
||||||
if (writecb) setTimeout(writecb,10);
|
if (writecb) setTimeout(writecb,10);
|
||||||
},
|
},
|
||||||
close : function() {},
|
close : function() {},
|
||||||
|
on : function(evt,cb) { handlers[evt] = cb; },
|
||||||
received : "",
|
received : "",
|
||||||
hadData : false
|
hadData : false,
|
||||||
|
handlers : []
|
||||||
}
|
}
|
||||||
|
|
||||||
function bangleRx(data) {
|
function bangleRx(data) {
|
||||||
|
@ -237,6 +243,9 @@ if (typeof Android!=="undefined") {
|
||||||
connection.received += data;
|
connection.received += data;
|
||||||
connection.hadData = true;
|
connection.hadData = true;
|
||||||
if (connection.cb) connection.cb(data);
|
if (connection.cb) connection.cb(data);
|
||||||
|
// call data event
|
||||||
|
if (connection.handlers["data"])
|
||||||
|
connection.handlers["data"](data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(level, s) {
|
function log(level, s) {
|
||||||
|
@ -321,6 +330,7 @@ if (typeof Android!=="undefined") {
|
||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
Puck = {
|
Puck = {
|
||||||
/// Are we writing debug information? 0 is no, 1 is some, 2 is more, 3 is all.
|
/// Are we writing debug information? 0 is no, 1 is some, 2 is more, 3 is all.
|
||||||
debug : Puck.debug,
|
debug : Puck.debug,
|
||||||
|
@ -331,7 +341,8 @@ if (typeof Android!=="undefined") {
|
||||||
/// Called with the current send progress or undefined when done - you can replace this with your own function
|
/// Called with the current send progress or undefined when done - you can replace this with your own function
|
||||||
writeProgress : Puck.writeProgress,
|
writeProgress : Puck.writeProgress,
|
||||||
connect : function(callback) {
|
connect : function(callback) {
|
||||||
setTimeout(callback, 10);
|
setTimeout(callback, 10, connection);
|
||||||
|
return connection;
|
||||||
},
|
},
|
||||||
write : write,
|
write : write,
|
||||||
eval : function(expr, cb) {
|
eval : function(expr, cb) {
|
||||||
|
@ -367,6 +378,37 @@ if (typeof Android!=="undefined") {
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Button to Enable Remote Web IDE
|
||||||
|
var el = document.getElementById("webideremote");
|
||||||
|
if (el) el.addEventListener("click", event=>{
|
||||||
|
webrtc = webrtcInit({
|
||||||
|
bridge:true,
|
||||||
|
onStatus : function(s) {
|
||||||
|
showToast(s);
|
||||||
|
},
|
||||||
|
onPeerID : function(s) {
|
||||||
|
showToast("Bridge's Peer ID: "+s);
|
||||||
|
showPrompt("Web IDE Remote Access","Remote access enabled\nPeer ID: "+s).then(() => {
|
||||||
|
}, function() { /* cancelled */ });
|
||||||
|
},
|
||||||
|
onGetPorts : function(cb) {
|
||||||
|
cb([{path:"Android",description:"Remote Device Connection",type:"socket"}]);
|
||||||
|
},
|
||||||
|
onPortConnect : function(serialPort, cb) {
|
||||||
|
cb(); // we're already connected...
|
||||||
|
},
|
||||||
|
onPortDisconnect : function(serialPort) {
|
||||||
|
},
|
||||||
|
onPortWrite : function(data, cb) {
|
||||||
|
Puck.write(data, cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connection.on("data", function(d) {
|
||||||
|
webrtc.onPortReceived(d);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit 83d92f2178901aa3130643e3a580fdda0801f8c1
|
Subproject commit 4ef47c139ef3091f230697667acba622b69b7c55
|
Loading…
Reference in New Issue