You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
5.9 KiB
123 lines
5.9 KiB
//#############################################################################################################################################################################################################
|
|
#ifndef _IDIBUS_SLAVE_H_
|
|
#define _IDIBUS_SLAVE_H_
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
#include "IdiBusSystem.h"
|
|
#include "IdiBusDateTime.h"
|
|
#include "IdiBusMes.h"
|
|
#include "IdiBusSerialLine.h"
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
class IdiMasterState {
|
|
public :
|
|
IDISTATUS_STATE_TYPE STATE;
|
|
struct {
|
|
struct {
|
|
uint8_t GS1_country[3];
|
|
uint8_t GS1_company[6];
|
|
uint8_t ModuleType[3];
|
|
uint8_t HW_rev[2];
|
|
uint8_t Serial[7];
|
|
uint8_t MAC[6];
|
|
} FIX;
|
|
struct VAR {
|
|
VAR() : VerifDate(0,0,0,0), VerifExpDate(0,0,0,0) {}
|
|
uint8_t SW_rev[2];
|
|
IdiDateFormat VerifDate;
|
|
IdiDateFormat VerifExpDate;
|
|
uint8_t IPv4[4];
|
|
uint8_t IPv6[16];
|
|
uint8_t AES[32];
|
|
} VAR;
|
|
} SN;
|
|
void parseSmesDataNoAes(uint8_t *Data);
|
|
};
|
|
//=============================================================================================================================================================================================================
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
//=============================================================================================================================================================================================================
|
|
class IdiBusLongOpData {
|
|
public :
|
|
IdiBusLongOpData() { this->State = IDILONGOP_STATE_COMPLETE_NO_ERR; this->Timeout = 0; }
|
|
uint8_t State;
|
|
uint32_t Timeout;
|
|
};
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
class IdiBusChannel {
|
|
public :
|
|
IdiBusChannel() { this->MMES_Error = IDIER_NOPE; }
|
|
IdiBusLongOpData LONG_OP;
|
|
uint8_t MMES_Error;
|
|
};
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
class IdiBusDevice {
|
|
public :
|
|
IdiBusDevice (void *ParentModule) { this->Module = ParentModule; }
|
|
virtual IdiBusChannel *getChannel(uint8_t Num) { return NULL; }
|
|
protected :
|
|
void *Module;
|
|
};
|
|
//=============================================================================================================================================================================================================
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
//=============================================================================================================================================================================================================
|
|
class IdiBusSlave {
|
|
|
|
public :
|
|
// Constructors and init
|
|
IdiBusSlave(IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);
|
|
IdiBusSlave(void);
|
|
void Init(IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);
|
|
|
|
// Standard communication API
|
|
uint8_t SendRequestMMES(IdiBusMMES *MMES);
|
|
uint8_t SendRequestMMESG(IdiBusMMESG *MMESG);
|
|
|
|
//Module commands (return ErrorCode)
|
|
uint8_t c_Init (void);
|
|
uint8_t c_Init (uint8_t Gpoup);
|
|
uint8_t c_ShtDown (void);
|
|
uint8_t c_Freeze (void);
|
|
uint8_t c_Resume (void);
|
|
uint8_t c_ReadDevFullSN_MS(void);
|
|
uint8_t c_WriteSnIPv4IPv6(uint32_t IPv4, uint32_t IPv6_B3, uint32_t IPv6_B2, uint32_t IPv6_B1, uint32_t IPv6_B0);
|
|
uint8_t c_WriteSnVerifyDates(IdiDateFormat VDate, IdiDateFormat VEXPDate);
|
|
uint8_t c_WriteSnAES256(uint8_t *AES256_key);
|
|
uint8_t c_SendTimeDate(IdiTimeFormat Time, IdiDateFormat Date);
|
|
uint8_t c_DummyModule(void);
|
|
uint8_t c_CheckModuleLongOp(void);
|
|
|
|
// Channel Commands
|
|
uint8_t c_Dummy(uint8_t Device, uint8_t Channel);
|
|
uint8_t c_AssignGroup(uint8_t Device, uint8_t Channel, uint8_t Group);
|
|
uint8_t c_CheckChannelLongOp(uint8_t Device, uint8_t Channel);
|
|
|
|
// Utils
|
|
uint8_t getAddress(void);
|
|
void setAes256ToSn(uint8_t *AES256_key);
|
|
IdiBusLongOpData getModuleLongOpData(void);
|
|
IdiBusLongOpData getChLongOpData(uint8_t Device, uint8_t Channel);
|
|
IdiMasterState getModuleSN(void);
|
|
|
|
// Interface - must be overridden in derived classes
|
|
virtual IdiBusDevice *getDevice(uint8_t Num) { return NULL; }
|
|
|
|
protected :
|
|
IdiBusSerialLine *Line;
|
|
uint8_t Address;
|
|
IdiMasterState ModuleST;
|
|
uint8_t ModuleError;
|
|
IdiBusLongOpData ModuleLongOpData;
|
|
uint8_t CRC_MultipleError;
|
|
struct {
|
|
uint8_t CRC_ErrAvrBuf[16];
|
|
uint8_t CRC_ErrAvrBufCounter;
|
|
uint8_t CRC_ErrAvrBufPos;
|
|
uint8_t CRC_ErrAvrBufSum;
|
|
} CRC_AVR;
|
|
|
|
uint8_t SendModuleSimpleSetCommand(uint8_t Command);
|
|
uint8_t SendModuleSimpleSetCommand(uint8_t Command, uint8_t *TxData, uint16_t TxDataLength);
|
|
void CrcAvrErrorCalc(uint8_t ErrorCode);
|
|
};
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
#endif //#define _IDIBUS_SLAVE_H_
|
|
//#############################################################################################################################################################################################################
|