Debug blinky UI more

pull/1418/head
Rick Carlino 2019-09-06 09:33:23 -05:00
parent 709e779eca
commit 610b7b3706
4 changed files with 18 additions and 6 deletions

View File

@ -33,15 +33,22 @@ export const dispatchQosStart = (id: string) => {
};
export let dispatchNetworkUp = (edge: Edge, at: number, qosPingId?: string) => {
console.log("TODO: Insert ID HERE");
if (shouldThrottle(edge, at)) { return; }
store.dispatch(networkUp(edge, at, qosPingId));
bumpThrottle(edge, at);
};
const pingAlreadyComplete = (qosPingId?: string) => {
if (qosPingId) {
const ping =
store.getState().bot.connectivity.pings[qosPingId];
return (ping && ping.kind == "complete");
}
return false;
};
export let dispatchNetworkDown = (edge: Edge, at: number, qosPingId?: string) => {
console.log("TODO: Insert ID HERE");
if (shouldThrottle(edge, at)) { return; }
if (qosPingId && pingAlreadyComplete(qosPingId)) { return; }
store.dispatch(networkDown(edge, at, qosPingId));
bumpThrottle(edge, at);
};

View File

@ -1,4 +1,5 @@
import { TaggedResource } from "farmbot";
import { PingDictionary } from "../devices/connectivity/qos";
export type NetworkState = "up" | "down";
@ -27,7 +28,7 @@ type ConnectionRecord = Record<Edge, ConnectionStatus | undefined>;
* An `undefined` value means we don't know. */
export type ConnectionState = {
uptime: ConnectionRecord;
pings: {}
pings: PingDictionary;
};
export interface UpdateMqttData<T extends TaggedResource> {

View File

@ -10,7 +10,7 @@ import { API } from "../api/index";
import { FarmBotInternalConfig } from "farmbot/dist/config";
import { now } from "../devices/connectivity/qos";
export const PING_INTERVAL = 3000;
export const PING_INTERVAL = 4000;
export const ACTIVE_THRESHOLD = PING_INTERVAL * 2;
export const LAST_IN: keyof FarmBotInternalConfig = "LAST_PING_IN";
@ -40,7 +40,10 @@ export function sendOutboundPing(bot: Farmbot) {
const ok = () => markActive(id);
const no = () => markStale(id);
dispatchQosStart(id);
setTimeout(no, PING_INTERVAL);
// THEORY: The code below is not checking if the
// ping already succeeded, leading to
// blinky device availability.
// setTimeout(no, PING_INTERVAL);
bot.ping().then(ok, no);
}

View File

@ -26,7 +26,6 @@ export let connectivityReducer =
};
})
.add<EdgeStatus>(Actions.NETWORK_EDGE_CHANGE, (s, { payload }) => {
s.uptime[payload.name] = payload.status;
const { qosPingId, status } = payload;
if (qosPingId) {
if (status.state == "up") {
@ -35,6 +34,8 @@ export let connectivityReducer =
s.pings = failPing(s.pings, qosPingId);
}
}
s.uptime[payload.name] = payload.status;
return s;
})
.add<SyncBodyContents<TaggedDevice>>(Actions.RESOURCE_READY, (s, a) => {