Skip to content

Add base64 encoding where it was missing #96

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

Open
wants to merge 2 commits 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
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ function connect_ws(ws_port, url_path) {
setTimeout(function() {loadPropeller(socket, ws_msg.portPath, ws_msg.action, ws_msg.payload, ws_msg.debug)}, 10); // success is a JSON that the browser generates and expects back to know if the load was successful or not
} else if (ws_msg.type === "serial-terminal") {
// open or close the serial port for terminal/debug
serialTerminal(socket, ws_msg.action, ws_msg.portPath, ws_msg.baudrate, ws_msg.msg); // action is "open", "close" or "msg"
serialTerminal(socket, ws_msg.action, ws_msg.portPath, ws_msg.baudrate, atob(ws_msg.msg)); // action is "open", "close" or "msg"
} else if (ws_msg.type === "port-list-request") {
// send an updated port list (and continue on scheduled interval)
// log("Browser requested port-list for socket " + socket.pSocket_.socketId, mDbug);
Expand Down Expand Up @@ -455,7 +455,7 @@ function sendPortList(socket) {


function helloClient(sock, baudrate) {
var msg_to_send = {type:'hello-client', version:clientVersion};
var msg_to_send = {type:'hello-client', version:clientVersion, rxBase64:true};
sock.send(JSON.stringify(msg_to_send));
}

Expand All @@ -477,7 +477,7 @@ function serialTerminal(sock, action, portName, baudrate, msg) {
.then(function() {log('Connected terminal to ' + portName + ' at ' + baudrate + ' baud.');})
.catch(function() {
log('Unable to connect terminal to ' + portName);
var msg_to_send = {type:'serial-terminal', msg:'Failed to connect.\rPlease close this terminal and select a connected port.'};
var msg_to_send = {type:'serial-terminal', msg:btoa('Failed to connect to ' + portName + '.\rPlease close this terminal and select a connected port.')};
sock.send(JSON.stringify(msg_to_send));
});
} else if (action === "close") {
Expand All @@ -492,7 +492,7 @@ function serialTerminal(sock, action, portName, baudrate, msg) {
}
}
} else {
var msg_to_send = {type:'serial-terminal', msg:'Port ' + portName + ' not found.\rPlease close this terminal and select an existing port.'};
var msg_to_send = {type:'serial-terminal', msg:btoa('No device connected.\rPlease close this terminal and select an existing port.')};
sock.send(JSON.stringify(msg_to_send));
}
}
Expand Down