How to limit the # of simultaneous connections to a webpage?
Posted: Tue May 10, 2016 10:50 am
So I'm running a website on an ESP8266 using Arduino and websockets (this methodology was introduced to me by the user bbx10node: https://gist.github.com/bbx10/667e3d4f5f2c0831d00b). I have noticed that once there are five connections, the server crashes, and so I would like to find a way to limit the number of connections possible to prevent the server from crashing when too many occur.
Does anyone know how this would be possible? Here is my current code:
Does anyone know how this would be possible? Here is my current code:
Code: Select all
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsServer.h>
#include <Hash.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
static const char ssid[] = "*****";
static const char password[] = "*****";
MDNSResponder mdns;
static void writeLED(bool);
ESP8266WiFiMulti WiFiMulti;
ESP8266WebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);
String teensyLEDstatus = "off";
uint8_t rxBuff[256];
uint8_t som = 0x11;
uint8_t eom = 0x12;
uint8_t subsys;
uint8_t receivedSubsys;
uint8_t rx_byte = 0x00;
uint8_t messageLength = 0;
uint8_t receivedMessageLength = 0;
uint8_t messageContent;
uint8_t serialCurrent;
int initialCounter = 0;
boolean messageBegun = false;
boolean messageInProgress = false;
int currNumRefresh = 0;
int currPressureC = 0;
int currPressureD = 0;
int currPressureE = 0;
int currValveStatusNumC = 0;
int currValveStatusNumD = 0;
int currValveStatusNumE = 0;
int currFluid = 0;
char statusbuf[256];
char status[] = "";
int statusIndex = 0;
String valveStatusC = "Closed";
String valveTubePropsC = "175px solid #00ADEF";
String valveColorC = "red";
String valveStatusD = "Closed";
String valveTubePropsD = "175px solid #00ADEF";
String valveColorD = "red";
String valveStatusE = "Closed";
String valveTubePropsE = "175px solid #00ADEF";
String valveColorE = "red";
uint8_t currCountdown = 0;
long prevTimeCountdown = 0;
long countdownInterval = 1000;
long countdownPostInterval = 100;
bool countdownFlag = true;
bool teensyLED = false;
void switchLEDon() {
//Serial.println("TEST LED ON");
int ledStatusLength = 1;
subsys = 0x13;
//Account for the end of message
messageLength = ledStatusLength + 2;
messageContent = 1;
Serial.write(som);
Serial.write(messageLength);
Serial.write(subsys);
Serial.write(messageContent);
Serial.write(eom);
//Serial.println("");
//Serial.println("TURN LED ON|");
teensyLEDstatus = "on";
//teensyLED = true;
} //end switchLEDon
void switchLEDoff() {
int ledStatusLength = 1;
subsys = 0x13;
//Account for the end of message
messageLength = ledStatusLength + 2;
messageContent = 0;
Serial.write(som);
Serial.write(messageLength);
Serial.write(subsys);
Serial.write(messageContent);
Serial.write(eom);
//Serial.println("");
//Serial.println("TURN LED OFF|");
teensyLEDstatus = "off";
teensyLED = false;
} //end switchLEDoff
void statusUpdate(uint8_t num) {
//Valve C
if(currValveStatusNumC == 0)
{
valveColorC = "red";
valveTubePropsC = "175px solid #00ADEF";
valveStatusC = "Closed";
} //end if
else if(currValveStatusNumC == 1)
{
valveColorC = "green";
valveTubePropsC = "350px solid #00ADEF";
valveStatusC = "Open";
} //end else if
//Valve D
if(currValveStatusNumD == 0)
{
valveColorD = "red";
valveTubePropsD = "175px solid #00ADEF";
valveStatusD = "Closed";
} //end if
else if(currValveStatusNumD == 1)
{
valveColorD = "green";
valveTubePropsD = "350px solid #00ADEF";
valveStatusD = "Open";
} //end else if
//Valve E
if(currValveStatusNumE == 0)
{
valveColorE = "red";
valveTubePropsE = "175px solid #00ADEF";
valveStatusE = "Closed";
} //end if
else if(currValveStatusNumE == 1)
{
valveColorE = "green";
valveTubePropsE = "350px solid #00ADEF";
valveStatusE = "Open";
} //end else if
String test = "";
test += currNumRefresh;
test += ",";
test += currPressureC;
test += ",";
test += currPressureD;
test += ",";
test += currPressureE;
test += ",";
test += valveColorC;
test += ",";
test += valveTubePropsC;
test += ",";
test += valveStatusC;
test += ",";
test += valveColorD;
test += ",";
test += valveTubePropsD;
test += ",";
test += valveStatusD;
test += ",";
test += valveColorE;
test += ",";
test += valveTubePropsE;
test += ",";
test += valveStatusE;
test += ",";
test += currFluid;
test.toCharArray(statusbuf, 256);
webSocket.sendTXT(num, statusbuf, strlen(statusbuf));
}
static const char PROGMEM INDEX_HTML[] = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
<title>Adafruit HUZZAH ESP8266</title>
<style type='text/css'>
/*Styles for on/off switch*/
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 18px; margin: 6px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 56px;
border: 2px solid #999999; border-radius: 20px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
/*Styles for Pressure Bar Gauge*/
.pressureRow{
width: 100%;
height: 200px;
}
.pressureContainer{
width:400px;
height:200px;
position: relative;
overflow: hidden;
text-align: center;
float:left;
display:block;
}
.gauge-a,.fluid-a{
z-index: 1;
position: absolute;
background-color: rgba(255,255,255,.2);
width: 400px;
height: 200px;
top: 0%;
border-radius:250px 250px 0px 0px;
}
.gauge-b{
z-index: 3;
position: absolute;
background-color: #222;
width: 250px; height: 125px;
top: 75px;
margin-left: 75px;
margin-right: auto;
border-radius:250px 250px 0px 0px ;
}
.gauge-c,.gauge-d,.gauge-e{
z-index: 2;
position: absolute;
background-color: #5664F9;
width: 400px;
height: 200px;
top: 200px;
margin-left: auto;
margin-right: auto;
border-radius:0px 0px 200px 200px;
transform-origin:center top;
transition: all 1.3s ease-in-out;
}
.gauge-data{
z-index: 4;
color: white;
font-size: 1.5em;
line-height: 25px;
position: absolute;
width: 400px;
height: 200px;
top: 90px;
margin-left: auto;
margin-right: auto;
transition: all 1s ease-out;
}
/*Styles for Fluid Level Container*/
.fluidContainer {
float:left;
position:relative;
margin-top: 180px;
display:block;
} /*clear:both;*/
meter {
margin: 0 auto 4.5em;
width: 300px;
height: 50px;
display: block;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
meter::-webkit-meter-optimum-value{
background: green;
}
meter::-webkit-meter-suboptimum-value{
background: yellow;
}
meter::-webkit-meter-even-less-good-value{
background: red;
}
.fluid-data {
background: #222222;
color:white;
font-size: 1.5em;
width:120px;
margin-left:175px;
}
/*Styles for Valves*/
*, *:before, *:after{
box-sizing: border-box;
}
.valveRow{
width: 100%;
height: 332px;
}
.valveTube-c,.valveTube-d,.valveTube-e{
position: relative;
height: 42px;
width: 350px;
padding: 0px;
background-color: #9B999A;
top: 50px;
transform: rotate(0deg) skew(0deg);
-webkit-transform: rotate(0deg) skew(0deg);
border-left: 175px solid #00ADEF;
margin-right: 50px;
}
.valve-c,.valve-d,.valve-e{
position: relative;
height: 42px;
width: 193px;
background-color: red;
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
margin-left: 20%;
}
.valveContainer
{
float:left;
position:relative;
margin-top: 80px;
display:block;
}
.valve-data {
background: #222222;
color:white;
font-size: 1.5em;
width:180px;
margin-left:80px;
margin-top: 80px;
text-align: center;
}
</style>
<script>
var currPressureTest = 0;
var currFluidTest = 0;
function LEDswitch(){
var LEDswitchCheck = document.getElementById('myonoffswitch').checked;
if(LEDswitchCheck){
websock.send("teensyLEDon");
}
else if(!LEDswitchCheck) {
websock.send("teensyLEDoff");
}
}
var websock;
var test = "open";
function start() {
websock = new WebSocket('ws://' + window.location.hostname + ':81/');
websock.onopen = function(evt) {
console.log('websock open');
statusUpdate();
};
websock.onclose = function(evt) {
console.log('websock close');
};
websock.onerror = function(evt) {
console.log(evt);
};
websock.onmessage = function(evt) {
console.log(evt);
var e = document.getElementById('ledstatus');
var te = document.getElementById('myonoffswitch');
if(evt.data === 'teensyLEDon')
{
te.checked = 'checked';
}
else if(evt.data === 'teensyLEDoff')
{
te.checked = '';
}
else if(evt.data === 'Update Status')
{
}
else {
console.log('status event');
var totalStatus = evt.data;
var splitStatus = totalStatus.split(',');
//alert("TEST: " + totalStatus);
//alert('Pressure C: ' + splitStatus[0] + ', Pressure D: ' + splitStatus[1] + ', Pressure E: ' + splitStatus[2]);
//Num Refresh
document.getElementById("demo").innerHTML = splitStatus[0];
//PRESSURE C
var pressureValue = document.querySelector('.gauge-c');
pressureValue.style.transform = 'rotate('+ splitStatus[1] +'deg)';
var pressureText = (((splitStatus[1])/180)*100).toFixed(0);
document.getElementById("pressurePercentC").innerHTML = pressureText + '%';
if(pressureText > 75){
pressureValue.style.background = 'red';
}
else if(pressureText > 25 && pressureText < 75){
pressureValue.style.background = 'yellow';
}
else if(pressureText < 25){
pressureValue.style.background = 'green';
}
//PRESSURE D
var pressureValue = document.querySelector('.gauge-d');
pressureValue.style.transform = 'rotate('+ splitStatus[2] +'deg)';
var pressureText = (((splitStatus[2])/180)*100).toFixed(0);
document.getElementById("pressurePercentD").innerHTML = pressureText + '%';
if(pressureText > 75){
pressureValue.style.background = 'red';
}
else if(pressureText > 25 && pressureText < 75){
pressureValue.style.background = 'yellow';
}
else if(pressureText < 25){
pressureValue.style.background = 'green';
}
//PRESSURE E
var pressureValue = document.querySelector('.gauge-e');
pressureValue.style.transform = 'rotate('+ splitStatus[3] +'deg)';
var pressureText = (((splitStatus[3])/180)*100).toFixed(0);
document.getElementById("pressurePercentE").innerHTML = pressureText + '%';
if(pressureText > 75){
pressureValue.style.background = 'red';
}
else if(pressureText > 25 && pressureText < 75){
pressureValue.style.background = 'yellow';
}
else if(pressureText < 25){
pressureValue.style.background = 'green';
}
//VALVE STATUS C
var valve = document.querySelector('.valve-c');
var valveTube = document.querySelector('.valveTube-c');
valve.style.background = splitStatus[4];
document.getElementById("valveStatus-c").innerHTML = splitStatus[6];
if(splitStatus[6] == "Open")
{
valveTube.style["border-left"] = splitStatus[5];
} //end if
else if(splitStatus[6] == "Closed")
{
valveTube.style["border-left"] = splitStatus[5];
}
//VALVE STATUS D
var valve = document.querySelector('.valve-d');
var valveTube = document.querySelector('.valveTube-d');
valve.style.background = splitStatus[7];
document.getElementById("valveStatus-d").innerHTML = splitStatus[9];
if(splitStatus[9] == "Open")
{
valveTube.style["border-left"] = splitStatus[8];
} //end if
else if(splitStatus[9] == "Closed")
{
valveTube.style["border-left"] = splitStatus[8];
}
//VALVE STATUS E
var valve = document.querySelector('.valve-e');
var valveTube = document.querySelector('.valveTube-e');
valve.style.background = splitStatus[10];
document.getElementById("valveStatus-e").innerHTML = splitStatus[12];
if(splitStatus[12] == "Open")
{
valveTube.style["border-left"] = splitStatus[11];
} //end if
else if(splitStatus[12] == "Closed")
{
valveTube.style["border-left"] = splitStatus[11];
}
//FLUID LEVEL
var fluidValue = document.querySelector('.fluidMeter');
if(splitStatus[13] >= 0 && splitStatus[13] <= 100)
{
fluidValue.value = splitStatus[13];
} //end if
else
{
fluidValue.value = 0;
} //end else
var fluidText = splitStatus[13];
document.getElementById("fluidPercent").innerHTML = fluidText + '%';
}
};
}
function statusUpdate() {
websock.send("Update Status");
setTimeout('statusUpdate()', 5000);
}
</script>
</head>
<body style='background-color:#558C89;' onload="start();">
<div style='background-color:#74AFAD;'>
<h1 style='text-decoration: underline;'>Adafruit HUZZAH ESP8266</h1>
</div>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<div style="clear:both;"></div>
<div style='background-color:#74AFAD;'>
<h2 style='color: red;'>LED Controls</h2>
<div id='LEDbtn' class='onoffswitch'>
<!--
if (LEDstatus == "on")
{
<input type='checkbox' name='onoffswitch' class='onoffswitch-checkbox' id='myonoffswitch' checked='checked' onclick='LEDswitch()'>
} //end if
-->
<!--
else if(LEDstatus == "off")
{*/
-->
<input type='checkbox' name='onoffswitch' class='onoffswitch-checkbox' id='myonoffswitch' onclick='LEDswitch()'>
<!--} //end else -->
<label class='onoffswitch-label' for='myonoffswitch'>
<span class='onoffswitch-inner'></span>
<span class='onoffswitch-switch'></span>
</label>
</div>
</div>
<div style='background-color:#74AFAD;'>
<h2 style='color: green;'>Num Refresh Test</h2>
<div id="demo"><h2>Let WEBSOCKET change this text</h2></div>
</div>
<div class='pressureRow'>
<div class='pressureContainer'>
<div class='gauge-a'></div>
<div class='gauge-b'></div>
<div class='gauge-c'></div>
<div class='gauge-data'><h1 id='pressurePercentC'>0%</h1></div>
</div>
<div class='pressureContainer'>
<div class='gauge-a'></div>
<div class='gauge-b'></div>
<div class='gauge-d'></div>
<div class='gauge-data'><h1 id='pressurePercentD'>0%</h1></div>
</div>
<div class='pressureContainer'>
<div class='gauge-a'></div>
<div class='gauge-b'></div>
<div class='gauge-e'></div>
<div class='gauge-data'><h1 id='pressurePercentE'>0%</h1></div>
</div>
</div>
<div class='valveRow'>
<div class='valveContainer'>
<div class="valveTube-c"></div>
<div class="valve-c"></div>
<div class='valve-data'><h1 id='valveStatus-c'>Closed</h1></div>
</div>
<div class='valveContainer'>
<div class="valveTube-d"></div>
<div class="valve-d"></div>
<div class='valve-data'><h1 id='valveStatus-d'>Closed</h1></div>
</div>
<div class='valveContainer'>
<div class="valveTube-e"></div>
<div class="valve-e"></div>
<div class='valve-data'><h1 id='valveStatus-e'>Closed</h1></div>
</div>
</div>
<div class='fluidContainer'>
<meter class='fluidMeter' max='100' value='50' low='25' high='75' optimum='100'></meter>
<div class='fluid-data'><h1 id='fluidPercent'>0%</h1></div>
</div>
</body>
</html>
)rawliteral";
// GPIO#0 is for Adafruit ESP8266 HUZZAH board. Your board LED might be on 13.
const int LEDPIN = 0;
// Current LED status
bool LEDStatus;
// Commands sent through Web Socket
const char LEDON[] = "ledon";
const char LEDOFF[] = "ledoff";
const char teensyLEDON[] = "teensyLEDon";
const char teensyLEDOFF[] = "teensyLEDoff";
const char statusIdentifier[] = "Update Status";
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length)
{
//Serial.printf("webSocketEvent(%d, %d, ...)\r\n", num, type);
switch(type) {
case WStype_DISCONNECTED:
//Serial.printf("[%u] Disconnected!\r\n", num);
break;
case WStype_CONNECTED:
{
IPAddress ip = webSocket.remoteIP(num);
//Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\r\n", num, ip[0], ip[1], ip[2], ip[3], payload);
// Send the current LED status
if (LEDStatus) {
webSocket.sendTXT(num, LEDON, strlen(LEDON));
}
else if(!LEDStatus) {
webSocket.sendTXT(num, LEDOFF, strlen(LEDOFF));
}
else if(teensyLED) {
webSocket.sendTXT(num, teensyLEDON, strlen(teensyLEDON));
}
else if(!teensyLED) {
webSocket.sendTXT(num, teensyLEDOFF, strlen(teensyLEDOFF));
}
}
break;
case WStype_TEXT:
//Serial.printf("[%u] get Text: %s\r\n", num, payload);
if (strcmp(LEDON, (const char *)payload) == 0) {
writeLED(true);
}
else if (strcmp(LEDOFF, (const char *)payload) == 0) {
writeLED(false);
}
else if(strcmp(teensyLEDON, (const char *)payload) == 0) {
switchLEDon();
}
else if(strcmp(teensyLEDOFF, (const char *)payload) == 0) {
switchLEDoff();
}
else if(strcmp(statusIdentifier, (const char *)payload) == 0) {
statusUpdate(num);
}
else {
//Serial.println("Unknown command");
}
// send data to all connected clients
webSocket.broadcastTXT(payload, length);
break;
case WStype_BIN:
//Serial.printf("[%u] get binary length: %u\r\n", num, length);
hexdump(payload, length);
// echo data back to browser
webSocket.sendBIN(num, payload, length);
break;
default:
//Serial.printf("Invalid WStype [%d]\r\n", type);
break;
}
}
void handleRoot()
{
server.send(200, "text/html", INDEX_HTML);
}
void handleNotFound()
{
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
static void writeLED(bool LEDon)
{
LEDStatus = LEDon;
// Note inverted logic for Adafruit HUZZAH board
if (LEDon) {
digitalWrite(LEDPIN, 0);
}
else {
digitalWrite(LEDPIN, 1);
}
}
void setup()
{
pinMode(LEDPIN, OUTPUT);
writeLED(false);
Serial.begin(115200);
//Serial.setDebugOutput(true);
Serial.println();
Serial.println();
Serial.println();
currCountdown = 4;
for(uint8_t t = 4; t > 0; t--) {
unsigned long currTime = millis();
if(countdownFlag == true)
{
Serial.printf("[SETUP] BOOT WAIT %d...\r\n", t);
Serial.flush();
countdownFlag = false;
}
if(currTime - prevTimeCountdown > countdownInterval)
{
prevTimeCountdown = currTime;
countdownFlag = true;
} //end if
else
{
t++;
} //end else
} //end for
WiFiMulti.addAP(ssid, password);
/*
prevTimeCountdown = 0;
countdownFlag = true;
*/
while(WiFiMulti.run() != WL_CONNECTED) {
/*
unsigned long currTime = millis();
if(countdownFlag == true)
{
Serial.print(".");
countdownFlag = false;
} //end if
if(currTime - prevTimeCountdown > countdownInterval)
{
prevTimeCountdown = currTime;
countdownFlag = true;
} //end if
*/
Serial.print(".");
delay(1000);
} //end while
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (mdns.begin("espWebSock", WiFi.localIP())) {
Serial.println("MDNS responder started");
mdns.addService("http", "tcp", 80);
mdns.addService("ws", "tcp", 81);
}
else {
Serial.println("MDNS.begin failed");
}
Serial.print("Connect to http://espWebSock.local or http://");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
server.begin();
webSocket.begin();
webSocket.onEvent(webSocketEvent);
}
void loop()
{
//Communication Protocol
if(Serial.available() > 0)
{
//Serial.print("SERIAL.AVAILABLE: ");
//Serial.println(Serial.available());
if(initialCounter == 0)
{
rx_byte = Serial.read();
/*
//Print Start of Message
Serial.print("0x");
if(rx_byte<0x10)
{
Serial.print("0");
}
Serial.println(rx_byte, HEX);
*/
//Serial.println(rx_byte, BIN);
//Serial.println(rx_byte);
initialCounter++;
}
if((!messageBegun) && (rx_byte == som))
{
messageBegun = true;
//Serial.println("MESSAGE BEGUN TRUE");
} //end if (messageInProgress && rx_byte)
if((messageBegun) && (!messageInProgress))
{
serialCurrent = Serial.available();
if(serialCurrent > 0)
{
receivedMessageLength = (uint8_t)Serial.read();
/*
Serial.print("MESSAGE LENGTH: ");
Serial.println(receivedMessageLength);
*/
messageBegun = false;
messageInProgress = true;
//Serial.println("MESSAGE IN PROGRESS TRUE");
} //end if (serialCurrent)
} //end if (messageBegun && messageInProgress)
if(messageInProgress)
{
serialCurrent = Serial.available();
if(serialCurrent >= receivedMessageLength)
{
Serial.readBytes(rxBuff, receivedMessageLength);
if((byte)rxBuff[receivedMessageLength-1] != eom)
{
//Serial.println("ERROR");
//Serial.write(Serial.read());
} //end if (rxBuff != eom)
else
{
messageInProgress = false;
for(int i=0; i<receivedMessageLength; i++)
{
if(rxBuff[i] == eom)
{
/*
//Print End of Message
Serial.print("0x");
if(rx_byte<0x10)
{
Serial.print("0");
}
Serial.println(rxBuff[i], HEX);
*/
initialCounter = 0;
receivedMessageLength = 0;
} //end if
else if(i == 0)
{
receivedSubsys = rxBuff[i];
/*
//Print Subsystem
Serial.print("0x");
if(rx_byte<0x10)
{
Serial.print("0");
}
Serial.println(rxBuff[i], HEX);
*/
} //end if
else
{
if(receivedSubsys == 0x14)
{
currNumRefresh = rxBuff[i];
} //end if
else if(receivedSubsys == 0x15)
{
currPressureC = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x16)
{
currPressureD = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x17)
{
currPressureE = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x18)
{
currValveStatusNumC = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x19)
{
currValveStatusNumD = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x20)
{
currValveStatusNumE = rxBuff[i];
} //end else if
else if(receivedSubsys == 0x21)
{
currFluid = rxBuff[i];
} //end else if
} //end else
} //end for
} //end else
} //end if (serialCurrent)
} //end if (messageInProgress)
} //end if (Serial.available)
webSocket.loop();
server.handleClient();
}