Update to basic.js and add mime types.

1.2-legacy
Jm Casler 2020-10-26 18:17:33 -07:00
rodzic 5981831bc0
commit 44aafd5b9c
2 zmienionych plików z 27 dodań i 34 usunięć

Wyświetl plik

@ -2,50 +2,42 @@ var meshtasticClient;
var connectionOne;
// run init when DOM is ready
document.addEventListener("DOMContentLoaded", function() {
// Create new client instance
meshtasticClient = new meshtasticjs.Client;
});
// Important: the connect action must be called from a user interaction (e.g. button press), otherwise the browsers won't allow the connect
function connect() {
// Create new connection
connectionOne = meshtasticClient.createBLEConnection();
var httpconn = new meshtasticjs.IHTTPConnection();
// Set connection params
let sslActive;
if (window.location.protocol === 'https:') {
sslActive = true;
} else {
sslActive = false;
}
let deviceIp = window.location.hostname; // Your devices IP here
// Add event listeners that get called when a new packet is received / state of device changes
connectionOne.addEventListener('dataPacket', function(packet) { console.log(packet)});
connectionOne.addEventListener('userPacket', function(packet) { console.log(packet)});
connectionOne.addEventListener('positionPacket', function(packet) { console.log(packet)});
connectionOne.addEventListener('connected', function() { console.log('connected!')});
connectionOne.addEventListener('disconnected', function() { console.log('disconnected!')});
httpconn.addEventListener('fromRadio', function (packet) { console.log(packet) });
// Connect to the device async, then send a text message
connectionOne.connect()
.then(result => {
httpconn.connect(deviceIp, sslActive)
.then(result => {
// This gets called when the connection has been established
// -> send a message over the mesh network. If no recipient node is provided, it gets sent as a broadcast
return connectionOne.sendText('meshtastic is awesome');
alert('device has been configured')
// This gets called when the connection has been established
// -> send a message over the mesh network. If no recipient node is provided, it gets sent as a broadcast
return httpconn.sendText('meshtastic is awesome');
})
.then(result => {
})
.then(result => {
// This gets called when the message has been sucessfully sent
console.log('Message sent!');})
// This gets called when the message has been sucessfully sent
console.log('Message sent!');
})
.catch(error => { console.log(error); });
.catch(error => { console.log(error); });
}

Wyświetl plik

@ -69,8 +69,9 @@ uint32_t timeSpeedUp = 0;
// We need to specify some content-type mapping, so the resources get delivered with the
// right content type and are displayed correctly in the browser
char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"}, {".js", "text/javascript"},
{".png", "image/png"}, {".jpg", "image/jpg"}, {"", ""}};
char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"}, {".js", "text/javascript"},
{".png", "image/png"}, {".jpg", "image/jpg"}, {".gz", "application/gzip"},
{".gif", "image/gif"}, {".json", "application/json"}, {"", ""}};
void handleWebResponse()
{