Skip to content

Commit

Permalink
added date and time decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
irekzielinski committed Jul 16, 2016
1 parent 38a10f7 commit c34db9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
15 changes: 11 additions & 4 deletions Libraries/PMax/pmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Private VMSG_PMASTER_STAT1 {&HB0, &H01, &H04, &H06, &H02, &HFF, &H08, &H03, &H00
#define VMSG_DL_ZONESTR {0x3E, 0x00, 0x19, 0x00, 0x02, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
#define VMSG_DL_SERIAL {0x3E, 0x30, 0x04, 0x08, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
//'Private VMSG_DL_EVENTLOG {0x3E, 0xDF, 0x04, 0x28, 0x03, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00] '0x3F
//#define VMSG_DL_TIME {0x3E, 0xF8, 0x00, 0x20, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
#define VMSG_DL_TIME {0x3E, 0xF8, 0x00, 0x20, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
#define VMSG_DL_COMMDEF {0x3E, 0x01, 0x01, 0x1E, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
#define VMSG_DL_USERPINCODES {0x3E, 0xFA, 0x01, 0x10, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
#define VMSG_DL_OTHERPINCODES {0x3E, 0x0A, 0x02, 0x0A, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
Expand All @@ -76,9 +76,6 @@ Private VMSG_PMASTER_STAT1 {&HB0, &H01, &H04, &H06, &H02, &HFF, &H08, &H03, &H00
#define VMSG_DL_MASTER_ZONES {0x3E, 0x72, 0xB8, 0x80, 0x02, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00}
//Private VMSG_DL_MASTER10_EVENTLOG {0x3E, 0xFF, 0xFF, 0xD2, 0x07, 0xB0, 0x05, 0x48, 0x01, 0x00, 0x00] '0x3F
//Private VMSG_DL_MASTER30_EVENTLOG {0x3E, 0xFF, 0xFF, 0x42, 0x1F, 0xB0, 0x05, 0x48, 0x01, 0x00, 0x00] '0x3F
//
//Private VMSG_SET_DATETIME {0x46, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF] '0x46


//########################################################
// PowerMax/Master definitions for partitions, events, keyfobs, etc
Expand Down Expand Up @@ -1023,6 +1020,16 @@ void PowerMaxAlarm::processSettings()
}
}

{ //Get panel date and time
unsigned char dateAndTime[32] = {0};
const unsigned char msg[] = VMSG_DL_TIME;
int bytesRead = readMemoryMap(msg, dateAndTime, sizeof(dateAndTime));
if(bytesRead >= 6)
{
OnPanelDateTime(dateAndTime[5],dateAndTime[4],dateAndTime[3],dateAndTime[2],dateAndTime[1],dateAndTime[0]);
}
}

{ //Retrieve detailed zone information
unsigned char masterReadBuff[128] = {0};

Expand Down
15 changes: 9 additions & 6 deletions Libraries/PMax/pmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ class PowerMaxAlarm

bool sendCommand(PmaxCommand cmd);
void handlePacket(PlinkBuffer * commandBuffer);

//hours must be specified in 24 hour format
//day must be the day of the month (1-31)
//month must be between 1-12
//year must be specified as the years since 2000.
//note: works only in programming (donload) mode.
//Sets the date and time of the panel (works only in programming (download) mode)
//year : must be specified as the years since 2000
//month : must be between 1-12
//day : must be the day of the month (1-31)
//hours : must be in 24 hour format
bool setDateTime(unsigned char year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minutes, unsigned char seconds);

static bool isBufferOK(const PlinkBuffer* commandBuffer);
Expand Down Expand Up @@ -324,6 +324,9 @@ class PowerMaxAlarm
//whoDisarmedStr : text representation of who disarmed
virtual void OnAlarmCancelled(unsigned char whoDisarmed, const char* whoDisarmedStr){};

//Fired when date and time is downloaded from the panel (can be used for example to compare date against external source, and reset it using setDateTime if it's not accurate)
//parameters : see setDateTime function
virtual void OnPanelDateTime(unsigned char year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minutes, unsigned char seconds){};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//those functions provide string representation of various types in alarm, you can override to provide your own text
Expand Down
5 changes: 5 additions & 0 deletions PowerMaxWin/PowerMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ class MyPowerMax : public PowerMaxAlarm
break;
}
}

virtual void OnPanelDateTime(unsigned char year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minutes, unsigned char seconds)
{
printf("Date/time of panel: %d/%02d/%02d %02d:%02d:%02d\r\n", year+2000, month, day, hour, minutes, seconds);
}
};

BOOL WriteAllBytes(HANDLE hHandle, const unsigned char* buff, int bytesToWrite, DWORD* totalWritten)
Expand Down

0 comments on commit c34db9b

Please sign in to comment.