Skip to content

Commit

Permalink
Added check if PIN was donloaded from PM before issuing arm/disarm co…
Browse files Browse the repository at this point in the history
…mmands
  • Loading branch information
irekzielinski committed Jun 14, 2016
1 parent 15ea527 commit 23f3003
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/PMax/pmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class PowerMaxAlarm
static bool isBufferOK(const PlinkBuffer* commandBuffer);
const char* getZoneName(unsigned char zoneId);

bool isConfigParsed() const { return m_cfg.parsedOK; }
unsigned int getEnrolledZoneCnt() const;
unsigned long getSecondsFromLastComm() const;
void dumpToJson(IOutput* outputStream);
Expand Down
9 changes: 9 additions & 0 deletions PowerMaxEsp8266/PowerMaxEsp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ void handleTelnetRequests(PowerMaxAlarm* pm) {
if ( telnetClient.connected() && telnetClient.available() ) {
c = telnetClient.read();

if(pm->isConfigParsed() == false &&
(c == 'h' || //arm home
c == 'a' || //arm away
c == 'd')) //disarm
{
//DEBUG(LOG_NOTICE,"EPROM is not download yet (no PIN requred to perform this operation)");
return;
}

#ifdef PM_ALLOW_CONTROL
if ( c == 'h' ) {
DEBUG(LOG_NOTICE,"Arming home");
Expand Down
10 changes: 10 additions & 0 deletions PowerMaxWin/PowerMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ void KeyPressHandling(PowerMaxAlarm* pm) {
if ( _kbhit() ) {
c = getchar();

if(pm->isConfigParsed() == false &&
(c == 'h' || //arm home
c == 'a' || //arm away
c == 'd')) //disarm
{
DEBUG(LOG_NOTICE,"EPROM is not download yet (no PIN requred to perform this operation)");
return;
}

if ( c == 'c' ) {
printf("Exiting...");
exit(1);
Expand All @@ -70,6 +79,7 @@ void KeyPressHandling(PowerMaxAlarm* pm) {
pm->sendCommand(Pmax_ARMHOME);
}
else if ( c == 'd' ) {

DEBUG(LOG_NOTICE,"Disarm");
pm->sendCommand(Pmax_DISARM);
}
Expand Down

0 comments on commit 23f3003

Please sign in to comment.