1
1
var portList ;
2
2
/// webtrc instance when initialised
3
- var webrtc ;
3
+ var webrtc ;
4
4
/// If not true, the connection was requested from the top-left and we should just disconnect
5
- var connectionRequested = false ;
5
+ var connectionRequested = false ;
6
6
7
7
// THIS IS NEVER SHOWN AT THE MOMENT
8
8
Espruino . Core . Terminal . OVERRIDE_CONTENTS = `
9
9
<div style="max-width:400px;margin:auto;">
10
10
<b>Loading...</b>
11
11
</div>
12
12
` ;
13
- // ABOUT page
13
+ // ABOUT page
14
14
Espruino . Core . Config . addSection ( "About" , {
15
15
description : undefined ,
16
16
sortOrder : - 1000 ,
17
17
getHTML : function ( callback ) {
18
18
callback ( `<h2>Web IDE Remote Connection Bridge</h2>
19
19
<p>
20
- This Remote Connection Bridge exists so that you can connect
20
+ This Remote Connection Bridge exists so that you can connect
21
21
the Web IDE to your Espruino devices even if you do not have
22
22
direct access to them or your main PC doesn't have the required
23
23
communications (for instance Bluetooth).
@@ -32,7 +32,7 @@ that you want to use as the Bridge.
32
32
${ ( webrtc && webrtc . peerId ) ?`
33
33
<p>
34
34
If you want to connect to this instance of the Bridge, copy the following code
35
- and paste it into the <b>Remote Connection Bridge Peer ID</b> field in your
35
+ and paste it into the <b>Remote Connection Bridge Peer ID</b> field in your
36
36
Web IDE's settings:
37
37
</p><p style="text-align:center;"><b>${ webrtc . peerId } </b></p>` :`` } `) ;
38
38
}
@@ -59,7 +59,7 @@ Web IDE's settings:
59
59
60
60
61
61
webrtc = webrtcInit ( {
62
- bridge :true ,
62
+ bridge :true ,
63
63
onStatus : function ( s ) {
64
64
print ( s ) ;
65
65
} ,
@@ -77,7 +77,7 @@ Web IDE's settings:
77
77
clientPeerId = kv [ 1 ] ;
78
78
} ) ;
79
79
}
80
- if ( clientPeerId )
80
+ if ( clientPeerId )
81
81
webrtc . connectSendPeerId ( clientPeerId ) ;
82
82
} ,
83
83
onGetPorts : function ( cb ) {
@@ -98,7 +98,7 @@ Web IDE's settings:
98
98
onPortConnect : function ( serialPort , cb ) {
99
99
if ( Espruino . Core . Serial . isConnected ( ) )
100
100
Espruino . Core . Serial . close ( ) ;
101
- print ( "Connecting to " + serialPort ) ;
101
+ print ( "Connecting to " + serialPort ) ;
102
102
connectionRequested = true ;
103
103
Espruino . Core . Serial . open ( serialPort , function ( cInfo ) {
104
104
// Ensure that data from Espruino goes here
@@ -144,7 +144,7 @@ Web IDE's settings:
144
144
ports = ports . filter ( p => ! p . promptsUser ) ;
145
145
if ( ports . length )
146
146
print ( "The following devices are paired:\n " + ports . map ( p => p . path ) . join ( "\n " ) ) ;
147
- else
147
+ else
148
148
print ( "No devices are paired" ) ;
149
149
print ( "To add more devices please click the connect icon in the top left." ) ;
150
150
} ) ;
@@ -156,7 +156,8 @@ Web IDE's settings:
156
156
$ ( "#terminal" ) . css ( "font-size" , Espruino . Config . FONT_SIZE + "px" ) ;
157
157
158
158
print ( "Web IDE Remote Connection Bridge" ) ;
159
- Espruino . Core . Terminal . addNotification ( '<img src="../img/ide_logo.png" onclick="Espruino.Core.MenuSettings.show()"><br/>' , { noBorder :true } )
159
+
160
+ //Espruino.Core.Terminal.addNotification('<img src="../img/ide_logo.png" onclick="Espruino.Core.MenuSettings.show()"><br/>',{noBorder:true});
160
161
161
162
Espruino . addProcessor ( "connected" , function ( data , callback ) {
162
163
/* If the connection was initiated from the button in the top left
@@ -169,7 +170,7 @@ Web IDE's settings:
169
170
} , 500 ) ;
170
171
}
171
172
connectionRequested = false ;
172
- callback ( data ) ;
173
+ callback ( data ) ;
173
174
} ) ;
174
175
175
176
Espruino . addProcessor ( "disconnected" , function ( data , callback ) {
@@ -181,7 +182,7 @@ Web IDE's settings:
181
182
if ( data . visible && webrtc ) {
182
183
webrtc . connectVideo ( data . stream ) ;
183
184
}
184
-
185
+
185
186
callback ( data ) ;
186
187
} ) ;
187
188
@@ -195,13 +196,13 @@ Web IDE's settings:
195
196
196
197
function startWebSocket ( ) {
197
198
console . log ( "Disabling normal terminal" ) ;
198
-
199
-
199
+
200
+
200
201
201
202
console . log ( "Starting Websocket connection" ) ;
202
203
print ( "Starting Websocket connection" ) ;
203
204
// Create WebSocket connection.
204
-
205
+
205
206
socket . addEventListener ( 'open' , function ( event ) {
206
207
Espruino . Core . Notifications . success ( "Websocket connection open" , true ) ;
207
208
@@ -218,13 +219,13 @@ Web IDE's settings:
218
219
socketToBLE ( event . data ) ;
219
220
} ) ;
220
221
221
-
222
+
222
223
223
224
function socketToBLE ( data ) {
224
225
if ( data [ 0 ] == "\x01" ) {
225
226
console . log ( "BLE <- " + JSON . stringify ( data . substr ( 1 ) ) ) ;
226
227
// Data to send
227
-
228
+
228
229
} else if ( data [ 0 ] == "\x20" ) {
229
230
print ( "New client connected" ) ;
230
231
} else print ( "Unknown packet type " + JSON . stringify ( data [ 0 ] ) ) ;
0 commit comments