started with functionality in wifi selection
This commit is contained in:
@@ -7,7 +7,14 @@ export const ConnState = {
|
||||
CONNECTED_STOPPED: 'connected_stopped',
|
||||
CONNECTED_RUNNING: 'connected_running',
|
||||
CONNECTED_STARTING: 'connected_starting', // start message sent, but device hasn't ack'ed it yet
|
||||
CONNECTED_STOPPING: 'connected_stopping' // stop message sent..
|
||||
CONNECTED_STOPPING: 'connected_stopping' // stop message sent..
|
||||
}
|
||||
|
||||
export const WifiState = {
|
||||
UNKNOWN: 'unknown',
|
||||
STA: 'sta', // connected to regular wifi
|
||||
AP_PROVISIONING: 'ap_provisioning', // acting as access point for provisioning
|
||||
AP_SECURE: 'ap_secure', // acting as access point, password has been set
|
||||
}
|
||||
|
||||
// -------------------------------------------- Actions ---------------------------------------------
|
||||
@@ -21,6 +28,12 @@ export const SESSION_NEW_DATA = "SESSION_NEW_DATA";
|
||||
export const START_SESSION = "START_SESSION";
|
||||
export const STOP_SESSION = "STOP_SESSION";
|
||||
|
||||
export const WIFI_SET_STATE = "WIFI_SET_STATE";
|
||||
|
||||
export const reportNewWifiState = (newStateStr) => ({
|
||||
type: WIFI_SET_STATE,
|
||||
newStateStr: newStateStr
|
||||
});
|
||||
|
||||
export const reportSessionStarted = (sessionId) => ({
|
||||
type: SESSION_STARTED,
|
||||
@@ -107,6 +120,7 @@ const INITIAL_ANALYSIS = {
|
||||
|
||||
const INITIAL_DEVICE_STATE = {
|
||||
connState: ConnState.DISCONNECTED,
|
||||
wifiState: WifiState.UNKNOWN,
|
||||
sessionId: 0,
|
||||
measurements: List(),
|
||||
analysis: INITIAL_ANALYSIS,
|
||||
@@ -130,18 +144,25 @@ export const deviceStateReducer = (state = INITIAL_DEVICE_STATE, action) => {
|
||||
case SESSION_STOPPED:
|
||||
return { ...INITIAL_DEVICE_STATE, connState: ConnState.CONNECTED_STOPPED };
|
||||
case START_SESSION:
|
||||
if(state.connState === ConnState.SESSION_STARTED)
|
||||
if (state.connState === ConnState.SESSION_STARTED)
|
||||
return state;
|
||||
return { ...INITIAL_DEVICE_STATE, connState: ConnState.CONNECTED_STARTING };
|
||||
case STOP_SESSION:
|
||||
if(state.connState === ConnState.SESSION_STOPPED)
|
||||
if (state.connState === ConnState.SESSION_STOPPED)
|
||||
return state;
|
||||
return { ...INITIAL_DEVICE_STATE, connState: ConnState.CONNECTED_STOPPING };
|
||||
case WIFI_SET_STATE:
|
||||
console.log("here");
|
||||
let wifState = WifiState.UNKNOWN;
|
||||
if (action.data === "STATION_MODE") { wifState = WifiState.STA; }
|
||||
else if (action.data === "AP_PROVISIONING") { wifState = WifiState.AP_PROVISIONING; }
|
||||
else if (action.data === "AP_SECURE") { wifState = WifiState.AP_SECURE; }
|
||||
return { ...state, wifiState: wifState };
|
||||
default:
|
||||
console.log("Unhandled state in deviceStateReducer", action.type);
|
||||
console.log("Unhandled state in deviceStateReducer", action, action.type);
|
||||
return state
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const INITIAL_SETTINGS = {
|
||||
theme: "hot",
|
||||
username: "",
|
||||
//swimTrackerHost: "192.168.178.107", // am pool
|
||||
swimTrackerHost: "192.168.178.110", // testgeraet
|
||||
swimTrackerHost: "192.168.42.1", // testgeraet
|
||||
|
||||
analysis: {
|
||||
peaksPerLap: 30,
|
||||
|
||||
Reference in New Issue
Block a user