Rework backend add MQTT and WebSocket support
* Update back end to add MQTT and WebSocket support * Update demo project to demonstrate MQTT and WebSockets * Update documentation to describe newly added and modified functionallity * Introduce separate MQTT pub/sub, HTTP get/post and WebSocket rx/tx classes * Significant reanaming - more accurate class names * Use PROGMEM_WWW as default * Update README documenting PROGMEM_WWW as default * Update README with API changes
This commit is contained in:
		@@ -9,6 +9,8 @@ export const LIST_NETWORKS_ENDPOINT = ENDPOINT_ROOT + "listNetworks";
 | 
			
		||||
export const WIFI_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "wifiSettings";
 | 
			
		||||
export const WIFI_STATUS_ENDPOINT = ENDPOINT_ROOT + "wifiStatus";
 | 
			
		||||
export const OTA_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "otaSettings";
 | 
			
		||||
export const MQTT_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "mqttSettings";
 | 
			
		||||
export const MQTT_STATUS_ENDPOINT = ENDPOINT_ROOT + "mqttStatus";
 | 
			
		||||
export const SYSTEM_STATUS_ENDPOINT = ENDPOINT_ROOT + "systemStatus";
 | 
			
		||||
export const SIGN_IN_ENDPOINT = ENDPOINT_ROOT + "signIn";
 | 
			
		||||
export const VERIFY_AUTHORIZATION_ENDPOINT = ENDPOINT_ROOT + "verifyAuthorization";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,24 @@
 | 
			
		||||
export const PROJECT_NAME = process.env.REACT_APP_PROJECT_NAME!;
 | 
			
		||||
export const PROJECT_PATH = process.env.REACT_APP_PROJECT_PATH!;
 | 
			
		||||
export const ENDPOINT_ROOT = process.env.REACT_APP_ENDPOINT_ROOT!;
 | 
			
		||||
 | 
			
		||||
export const ENDPOINT_ROOT = calculateEndpointRoot("/rest/");
 | 
			
		||||
export const WEB_SOCKET_ROOT = calculateWebSocketRoot("/ws/");
 | 
			
		||||
 | 
			
		||||
function calculateEndpointRoot(endpointPath: string) {
 | 
			
		||||
    const httpRoot = process.env.REACT_APP_HTTP_ROOT;
 | 
			
		||||
    if (httpRoot) {
 | 
			
		||||
        return httpRoot + endpointPath;
 | 
			
		||||
    }
 | 
			
		||||
    const location = window.location;
 | 
			
		||||
    return location.protocol + "//" + location.host + endpointPath;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function calculateWebSocketRoot(webSocketPath: string) {
 | 
			
		||||
    const webSocketRoot = process.env.REACT_APP_WEB_SOCKET_ROOT;
 | 
			
		||||
    if (webSocketRoot) {
 | 
			
		||||
        return webSocketRoot + webSocketPath;
 | 
			
		||||
    }
 | 
			
		||||
    const location = window.location;
 | 
			
		||||
    const webProtocol = location.protocol === "https:" ? "wss:" : "ws:";
 | 
			
		||||
    return webProtocol + "//" + location.host + webSocketPath;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user