mirror of https://github.com/espruino/BangleApps
Handle multiple clicks of webrtc button
parent
3006552b2c
commit
017643f452
67
android.html
67
android.html
|
@ -377,36 +377,55 @@ if (typeof Android!=="undefined") {
|
||||||
if ("object"==typeof err) console.log(err.stack);
|
if ("object"==typeof err) console.log(err.stack);
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
|
} else {
|
||||||
|
showToast("You're running the App Loader version for Gadgetbridge, but you don't seem to be in Gadgetbridge!","error");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showWebRTCID(id) {
|
||||||
|
showToast("Bridge's Peer ID: "+id);
|
||||||
|
showPrompt("Web IDE Remote Access",`
|
||||||
|
Remote access enabled. Peer ID:
|
||||||
|
<br/><br/>
|
||||||
|
<b>${id}</b>
|
||||||
|
<br/><br/>
|
||||||
|
Go to <b>espruino.com/ide</b> on your
|
||||||
|
desktop and enter this code under
|
||||||
|
<b>Remote Connection Bridge Peer ID</b> in Settings.
|
||||||
|
Then connect to the <b>Android</b> device.
|
||||||
|
`,{ok:1},false/*shouldEscapeHtml*/).then(() => {
|
||||||
|
}, function() { /* cancelled */ });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Button to Enable Remote Web IDE
|
// Button to Enable Remote Web IDE
|
||||||
var el = document.getElementById("webideremote");
|
var el = document.getElementById("webideremote");
|
||||||
|
var webrtc;
|
||||||
if (el) el.addEventListener("click", event=>{
|
if (el) el.addEventListener("click", event=>{
|
||||||
webrtc = webrtcInit({
|
if (webrtc) showWebRTCID(webrtc.peerId);
|
||||||
bridge:true,
|
else {
|
||||||
onStatus : function(s) {
|
webrtc = webrtcInit({
|
||||||
showToast(s);
|
bridge:true,
|
||||||
},
|
onStatus : function(s) {
|
||||||
onPeerID : function(s) {
|
showToast(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) {
|
onPeerID : function(id) {
|
||||||
cb(); // we're already connected...
|
showWebRTCID(id);
|
||||||
},
|
},
|
||||||
onPortDisconnect : function(serialPort) {
|
onGetPorts : function(cb) {
|
||||||
},
|
cb([{path:"Android",description:"Remote Device Connection",type:"socket"}]);
|
||||||
onPortWrite : function(data, cb) {
|
},
|
||||||
Puck.write(data, cb);
|
onPortConnect : function(serialPort, cb) {
|
||||||
}
|
cb(); // we're already connected...
|
||||||
});
|
},
|
||||||
connection.on("data", function(d) {
|
onPortDisconnect : function(serialPort) {
|
||||||
webrtc.onPortReceived(d);
|
},
|
||||||
});
|
onPortWrite : function(data, cb) {
|
||||||
|
Puck.write(data, cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connection.on("data", function(d) {
|
||||||
|
webrtc.onPortReceived(d);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue