Compare commits

...

5 Commits

Author SHA1 Message Date
457058859d fix bugs 2024-08-08 20:26:50 +02:00
190260bbf0 fix bugs 2024-08-08 20:23:16 +02:00
9a33f420c1 fix bugs 2024-08-08 20:20:40 +02:00
82fab1c7bf fix bugs 2024-08-08 20:17:27 +02:00
8a106c3717 fix bugs 2024-08-08 20:09:32 +02:00
3 changed files with 15 additions and 6 deletions

View File

@@ -144,8 +144,8 @@ async def newClient(clientId, ws):
return client
async def newBoat(boatId, name, ws):
boat = { "id": boatId, "name": name, "ws": ws, "state": "active" }
print("new client connected: " + client['id'])
boat = { "id": boatId, "name": name, "ws": ws, "state": BOAT_STATE_AVAILABLE }
print("new boat connected: " + boatId)
for bo in boats:
if (bo['id'] == boat['id']):
bo['state'] = 'terminated'

View File

@@ -29,11 +29,11 @@
var boatListEl = document.getElementById('boats');
var stickEl = document.getElementById('canvas');
var connection = new WebSocket('ws://' + "localhost" + ':8080/', ['mbcRcRf']);
var connection = new WebSocket('ws://' + "10.254.0.1" + ':8080/', ['mbcRcRf']);
connection.onopen = function ()
{
connection.send(clientId + ';3440;' + Math.floor(new Date().getTime()/1000.0).toString());
connection.send(clientId + ';4675;' + Math.floor(new Date().getTime()/1000.0).toString());
setTimeout(() => { connection.send(clientId + ';boats'); }, 100);
};
@@ -41,6 +41,8 @@
{
console.log('WebSocket Error ', error);
alert('WebSocket Error ', error);
//connection.onmessage({ data: "boats:50;test 1;available:164;tosti;available" })
};
connection.onmessage = function (e)
@@ -59,6 +61,13 @@
{
console.log("render boat", boat);
let el = document.createElement("div");
el.style.textAlign = "center";
el.style.borderRadius = "10px";
el.style.backgroundColor = "#242495";
el.style.padding = "10px";
el.style.margin = "5px 25%";
el.style.color = "white";
el.style.cursor = "pointer";
el.id = "boat" + boat[0];
el.innerHTML = boat[1];
el.addEventListener('click', selectBoat);
@@ -74,7 +83,7 @@
function selectBoat(e)
{
console.log('selectBoat:', e.target.id.split('boat')[1]);
console.log('ctrl:', e.target.id.split('boat')[1]);
stickEl.style.display = 'block';
boatListEl.style.display = 'none';
}

View File

@@ -29,7 +29,7 @@ static uint8_t BoatId = 1;
#define SERVOS_CH6
#define WS_RX_BUFFER_LEN 512
#define WS_URL "ws://10.254.0.2:8080/"
#define WS_URL "ws://10.254.0.1:8080/"
#define LOGGER_BUFFER_SIZE 65536