Added homeSpan methods setSerialInputDisable() and getSerialInputDisable()
Provides ability to disable HomeSpan from reading from Serial port (which is otherwise normally enabled)
This commit is contained in:
parent
33a79cf51b
commit
40bb97215f
|
|
@ -206,7 +206,7 @@ void Span::pollTask() {
|
||||||
|
|
||||||
char cBuf[65]="?";
|
char cBuf[65]="?";
|
||||||
|
|
||||||
if(Serial.available()){
|
if(!serialInputDisabled && Serial.available()){
|
||||||
readSerial(cBuf,64);
|
readSerial(cBuf,64);
|
||||||
processSerialCommand(cBuf);
|
processSerialCommand(cBuf);
|
||||||
}
|
}
|
||||||
|
|
@ -708,6 +708,9 @@ void Span::processSerialCommand(const char *c){
|
||||||
|
|
||||||
case 'W': {
|
case 'W': {
|
||||||
|
|
||||||
|
if(serialInputDisabled || logLevel<0) // do not proceed if serial input/output is not fully enabled
|
||||||
|
return;
|
||||||
|
|
||||||
if(strlen(network.wifiData.ssid)>0){
|
if(strlen(network.wifiData.ssid)>0){
|
||||||
LOG0("*** Stopping all current WiFi services...\n\n");
|
LOG0("*** Stopping all current WiFi services...\n\n");
|
||||||
hapServer->end();
|
hapServer->end();
|
||||||
|
|
@ -817,14 +820,13 @@ void Span::processSerialCommand(const char *c){
|
||||||
int level=0;
|
int level=0;
|
||||||
sscanf(c+1,"%d",&level);
|
sscanf(c+1,"%d",&level);
|
||||||
|
|
||||||
if(level<0)
|
if(level<-1)
|
||||||
level=0;
|
level=-1;
|
||||||
if(level>2)
|
if(level>2)
|
||||||
level=2;
|
level=2;
|
||||||
|
|
||||||
LOG0("\n*** Log Level set to %d\n\n",level);
|
|
||||||
delay(1000);
|
|
||||||
setLogLevel(level);
|
setLogLevel(level);
|
||||||
|
LOG0("\n*** Log Level set to %d\n\n",level);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ class Span{
|
||||||
char pairingCodeCommand[12]=""; // user-specified Pairing Code - only needed if Pairing Setup Code is specified in sketch using setPairingCode()
|
char pairingCodeCommand[12]=""; // user-specified Pairing Code - only needed if Pairing Setup Code is specified in sketch using setPairingCode()
|
||||||
String lastClientIP="0.0.0.0"; // IP address of last client accessing device through encrypted channel
|
String lastClientIP="0.0.0.0"; // IP address of last client accessing device through encrypted channel
|
||||||
boolean newCode; // flag indicating new application code has been loaded (based on keeping track of app SHA256)
|
boolean newCode; // flag indicating new application code has been loaded (based on keeping track of app SHA256)
|
||||||
|
boolean serialInputDisabled=false; // flag indiating that serial input is disabled
|
||||||
|
|
||||||
int connected=0; // WiFi connection status (increments upon each connect and disconnect)
|
int connected=0; // WiFi connection status (increments upon each connect and disconnect)
|
||||||
unsigned long waitTime=60000; // time to wait (in milliseconds) between WiFi connection attempts
|
unsigned long waitTime=60000; // time to wait (in milliseconds) between WiFi connection attempts
|
||||||
|
|
@ -309,6 +310,8 @@ class Span{
|
||||||
void setCommandTimeout(uint16_t nSec){comModeLife=nSec*1000;} // sets Command Mode Timeout (seconds)
|
void setCommandTimeout(uint16_t nSec){comModeLife=nSec*1000;} // sets Command Mode Timeout (seconds)
|
||||||
void setLogLevel(int level){logLevel=level;} // sets Log Level for log messages (0=baseline, 1=intermediate, 2=all, -1=disable all serial input/output)
|
void setLogLevel(int level){logLevel=level;} // sets Log Level for log messages (0=baseline, 1=intermediate, 2=all, -1=disable all serial input/output)
|
||||||
int getLogLevel(){return(logLevel);} // get Log Level
|
int getLogLevel(){return(logLevel);} // get Log Level
|
||||||
|
void setSerialInputDisable(boolean val){serialInputDisabled=val;} // sets whether serial input is disabled (true) or enabled (false)
|
||||||
|
boolean getSerialInputDisable(){return(serialInputDisabled);} // returns true if serial input is disabled, or false if serial input in enabled
|
||||||
void reserveSocketConnections(uint8_t n){maxConnections-=n;} // reserves n socket connections *not* to be used for HAP
|
void reserveSocketConnections(uint8_t n){maxConnections-=n;} // reserves n socket connections *not* to be used for HAP
|
||||||
void setHostNameSuffix(const char *suffix){hostNameSuffix=suffix;} // sets the hostName suffix to be used instead of the 6-byte AccessoryID
|
void setHostNameSuffix(const char *suffix){hostNameSuffix=suffix;} // sets the hostName suffix to be used instead of the 6-byte AccessoryID
|
||||||
void setPortNum(uint16_t port){tcpPortNum=port;} // sets the TCP port number to use for communications between HomeKit and HomeSpan
|
void setPortNum(uint16_t port){tcpPortNum=port;} // sets the TCP port number to use for communications between HomeKit and HomeSpan
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,12 @@
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
char *Utils::readSerial(char *c, int max){
|
char *Utils::readSerial(char *c, int max){
|
||||||
|
|
||||||
|
if(homeSpan.getSerialInputDisable()){
|
||||||
|
c[0]='\0';
|
||||||
|
return(c);
|
||||||
|
}
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
char buf;
|
char buf;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// homeSpan.setLogLevel(-1);
|
// homeSpan.setLogLevel(-1);
|
||||||
|
homeSpan.setSerialInputDisable(true);
|
||||||
homeSpan.enableOTA();
|
homeSpan.enableOTA();
|
||||||
|
|
||||||
homeSpan.setStatusPin(13);
|
homeSpan.setStatusPin(13);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue