Lots of changes
- internationalization - new logo - connection screen improved - always try provisioning IP for connection
This commit is contained in:
@@ -28,6 +28,7 @@ const OpCodes = {
|
||||
};
|
||||
|
||||
const HEARTBEAT_TIMEOUT = 3000;
|
||||
const PROVISIONING_IP = "192.168.42.1";
|
||||
|
||||
export default class SwimTrackerWebsocketConnection {
|
||||
constructor(swimTrackerHost, onData, onStarted, onStopped, onWifiStateInfo, onConnect, onDisconnect) {
|
||||
@@ -40,11 +41,13 @@ export default class SwimTrackerWebsocketConnection {
|
||||
this.onConnect = onConnect;
|
||||
this.onDisconnect = onDisconnect;
|
||||
|
||||
const wsOptions = {
|
||||
maxReconnectionDelay: 4000
|
||||
};
|
||||
|
||||
// try configured URL and provisioning URL
|
||||
const urls = [`ws://${swimTrackerHost}:81`, `ws://${PROVISIONING_IP}:81`];
|
||||
let urlIndex = 0;
|
||||
const urlProvider = () => urls[urlIndex++ % urls.length]; // round robin url provider
|
||||
|
||||
this.ws = new ReconnectingWebSocket(`ws://${swimTrackerHost}:81`, [], wsOptions);
|
||||
this.ws = new ReconnectingWebSocket(urlProvider, [], { maxReconnectionDelay: 3000 });
|
||||
this.ws.onmessage = this._onMessage;
|
||||
this.ws.onopen = this.onConnect;
|
||||
this.ws.onclose = this.onDisconnect;
|
||||
@@ -67,7 +70,8 @@ export default class SwimTrackerWebsocketConnection {
|
||||
|
||||
let connection = this;
|
||||
this.pingTimeout = setTimeout(() => {
|
||||
connection.ws.reconnect();
|
||||
if(connection.ws !== null)
|
||||
connection.ws.reconnect();
|
||||
}, HEARTBEAT_TIMEOUT);
|
||||
}
|
||||
|
||||
@@ -90,7 +94,7 @@ export default class SwimTrackerWebsocketConnection {
|
||||
this._sendMsg(OpCodes.STOP_SESSION);
|
||||
}
|
||||
|
||||
sendTareCommand() {
|
||||
sendTareCommand = () => {
|
||||
this._sendMsg(OpCodes.TARE);
|
||||
}
|
||||
|
||||
@@ -105,7 +109,7 @@ export default class SwimTrackerWebsocketConnection {
|
||||
|
||||
}
|
||||
|
||||
wifiResetToProvisioning() {
|
||||
sendTareCommand = () => {
|
||||
this._sendMsg(OpCodes.WIFI_STATE_SET, {
|
||||
"reset_to_provisioning": true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user