C12Adapter Opensource C++ Interface
MProtocolC1222 Class Reference

ANSI C12.22 protocol implementation. More...

Inheritance diagram for MProtocolC1222:

Public Types

enum  SecurityModeEnum {
  SecurityUndefined = -1,
  SecurityClearText = 0,
  SecurityClearTextWithAuthentication = 1,
  SecurityCipherTextWithAuthentication = 2
}
 Values for security mode property. More...
 
enum  ResponseControlEnum {
  ResponseControlAlways = 0,
  ResponseControlOnException = 1,
  ResponseControlNever = 2
}
 EPSEM Response control bits. More...
 
enum  {
  MaximumProperApduHeaderSize = 160,
  MaximumLegacyApduHeaderSize = 1024,
  MaximumEpsemServiceLengthSize = 3,
  MinimumMaximumApduTotalSize = 512,
  MaximumMaximumApduTotalSize = 0x1000000
}
 
- Public Types inherited from MProtocolC12
enum  ReadFunctionResponseEnum {
  ReadFunctionResponseWhenPresent = 0,
  ReadFunctionResponseWhenDesired = 1,
  ReadFunctionResponseAlways = 2
}
 Logic of when ST8 has to be read during execution of function. More...
 
enum  {
  READ_SERVICE_OVERHEAD = 4,
  WRITE_SERVICE_OVERHEAD = 7,
  PARTIAL_WRITE_SERVICE_OVERHEAD = 9
}
 
- Public Types inherited from MProtocol
enum  {
  MAXIMUM_NUMBER_STRING_SIZE = 64,
  MAXIMUM_SERVICE_NAME_STRING_SIZE = MAXIMUM_NUMBER_STRING_SIZE + 64,
  DEFAULT_ESTIMATED_RESPONSE_SIZE = 0x1000,
  MAXIMUM_POSSIBLE_TABLE_OFFSET = 0xFFFFFF,
  MAXIMUM_POSSIBLE_TABLE_LENGTH = 0xFFFFFF
}
 
typedef std::vector< TableRawDataTableRawDataVector
 Vector of table raw data.
 

Public Member Functions

 MProtocolC1222 (MChannel *channel=NULL, bool channelIsOwned=true)
 Create C12.22 protocol object. More...
 
virtual ~MProtocolC1222 ()
 Destroy the protocol object.
 
void DisconnectService ()
 Perform ANSI C12 Disconnect request. More...
 
virtual void SetIssueSecurityOnStartSession (bool)
 Whether the start session includes the security service or the authenticate service. More...
 
unsigned GetNegotiatedMaximumApduSizeIncoming () const
 Get the incoming negotiated maximum size of the APDU. More...
 
unsigned GetNegotiatedMaximumApduSize () const
 Get the outgoing negotiated maximum size of the APDU. More...
 
virtual void ChangeNegotiatedMaximumApduSizeIncoming (unsigned size)
 Change the negotiated incoming maximum APDU size parameter in a way so that all dependents are also updated.
 
virtual void ChangeNegotiatedMaximumApduSizeOutgoing (unsigned size)
 Change the negotiated outgoing maximum APDU size parameter in a way so that all dependents are also updated.
 
int GetIncomingCallingAeQualifier () const
 The Incoming Application Entity Qualifier is to supply additional information about the message. More...
 
MByteString GetIncomingEpsem () const
 The whole incoming application EPSEM. More...
 
MByteString GetOutgoingApdu () const
 Get the whole outgoing application data unit. More...
 
const MStdStringGetIncomingEdClass () const
 Get the EPSEM EdClass that was used in the last EPSEM response. More...
 
const MStdStringGetIncomingCalledApTitle () const
 The Called Application Title of the incoming EPSEM packet. More...
 
const MStdStringGetIncomingCallingApTitle () const
 The Calling Application Title of the incoming EPSEM packet. More...
 
SecurityModeEnum GetIncomingSecurityMode () const
 Security Mode of the incoming EPSEM packet. More...
 
ResponseControlEnum GetIncomingResponseControl () const
 The Response Control of the incoming EPSEM packet, as defined by the ANSI Standard C12.22 documentation. More...
 
unsigned GetIncomingSecurityKeyId () const
 The value of security key ID, as received from the peer in the most recent APDU. More...
 
unsigned GetIncomingInitializationVector () const
 The value of initialization vector, as received from the peer in the most recent APDU. More...
 
unsigned GetIncomingCallingApInvocationId () const
 The value of invocation ID received from the peer in the most recent APDU. More...
 
int GetSecurityKeyListSuccessfulEntry () const
 Return the entry which was successfully tried with the meter.
 
void ServerStart ()
 Start processing of the incoming APDU. More...
 
void ServerReset ()
 Reset server so that it is ready to send back the outgoing APDU. More...
 
void ProcessIncomingEPSEM ()
 Initialize protocol machine for processing the incoming EPSEM. More...
 
void ServerEnd ()
 End the processing of incoming request by making and sending back the response. More...
 
void SendStart ()
 Start making the outgoing EPSEM packet.
 
void SendEnd ()
 Finish making the outgoing EPSEM packet and send it out to client.
 
bool SendEndReceiveStart ()
 Combines SendEnd and ReceiveStart. More...
 
virtual void ReadApdu ()
 Read raw incoming APDU. More...
 
void WriteApdu (const MByteString &buffer)
 Write raw incoming APDU. More...
 
void ReceiveStart ()
 Start parsing the incoming EPSEM.
 
void ReceiveEnd ()
 End parsing the incoming EPSEM.
 
void SendService (char command)
 Send command-only service. More...
 
void SendServiceWithData (char command, const MByteString &data)
 Send service with command and data. More...
 
unsigned ReceiveServiceLength ()
 Receive service length. More...
 
char ReceiveServiceCodeIgnoreLength ()
 Receive and ignore service length, then service code or status. More...
 
virtual void Logon ()
 Perform ANSI C12 Logon request, both request and response. More...
 
virtual void ApplyChannelParameters ()
 Setup the configuration of the channel according to C12.22 protocol handshake settings.
 
void SetSecurityMode (SecurityModeEnum mode)
 
SecurityModeEnum GetSecurityMode () const
 
void SetSecurityKey (const MStdString &)
 
MStdString GetSecurityKey () const
 
void SetSecurityKeyId (int)
 
int GetSecurityKeyId () const
 
void SetSessionless (bool)
 
bool GetSessionless () const
 
bool GetOneServicePerApdu () const
 When OneServicePerApdu is true the behavior differs. More...
 
void SetOneServicePerApdu (bool yes)
 When OneServicePerApdu is true the behavior differs. More...
 
ResponseControlEnum GetResponseControl () const
 
void SetResponseControl (ResponseControlEnum c)
 
bool GetIssueTerminateOnEndSession () const
 
void SetIssueTerminateOnEndSession (bool yes)
 
bool GetNegotiatedSessionIdleTimeoutPresent () const
 
unsigned GetNegotiatedSessionIdleTimeout () const
 
unsigned GetResponseTimeout () const
 
void SetResponseTimeout (unsigned timeout)
 
unsigned GetMaximumApduSizeIncoming () const
 
void SetMaximumApduSizeIncoming (unsigned size)
 
unsigned GetMaximumApduSize () const
 
void SetMaximumApduSize (unsigned size)
 
int GetCallingAeQualifier () const
 
void SetCallingAeQualifier (int q)
 
void SetApplicationContext (const MStdString &)
 
const MStdStringGetApplicationContext () const
 
void SetCallingApTitle (const MStdString &)
 
const MStdStringGetCallingApTitle () const
 
unsigned GetSessionIdleTimeout () const
 
void SetSessionIdleTimeout (unsigned timeout)
 
void SetCalledApTitle (const MStdString &calledApTitle)
 
const MStdStringGetCalledApTitle () const
 
const MStdStringGetEdClass () const
 
void SetEdClass (const MStdString &edClass)
 
MByteString GetIncomingApdu () const
 
void SetIncomingApdu (const MByteString &)
 
unsigned GetInitializationVector () const
 
void SetInitializationVector (unsigned id)
 
unsigned GetCallingApInvocationId () const
 
void SetCallingApInvocationId (unsigned id)
 
const MByteStringVectorGetSecurityKeyList () const
 
void SetSecurityKeyList (const MByteStringVector &)
 
void SendLogon ()
 
void ReceiveLogon ()
 
void SendSecurity ()
 
void ReceiveSecurity ()
 
void SendTableRead (MCOMNumberConstRef number)
 
MByteString ReceiveTableRead (MCOMNumberConstRef number)
 
void SendTableWrite (MCOMNumberConstRef number, const MByteString &request)
 
void ReceiveTableWrite (MCOMNumberConstRef number, const MByteString &request)
 
void SendTableReadPartial (MCOMNumberConstRef number, int offset, int length)
 
MByteString ReceiveTableReadPartial (MCOMNumberConstRef number, int offset, int length)
 
void SendTableWritePartial (MCOMNumberConstRef number, const MByteString &request, int offset)
 
void ReceiveTableWritePartial (MCOMNumberConstRef number, const MByteString &request, int offset)
 
void FunctionExecuteSend (MCOMNumberConstRef number)
 
void FunctionExecuteReceive (MCOMNumberConstRef number)
 
void FunctionExecuteRequestSend (MCOMNumberConstRef number, const MByteString &request)
 
void FunctionExecuteRequestReceive (MCOMNumberConstRef number, const MByteString &request)
 
void FunctionExecuteResponseSend (MCOMNumberConstRef number)
 
MByteString FunctionExecuteResponseReceive (MCOMNumberConstRef number)
 
void FunctionExecuteRequestResponseSend (MCOMNumberConstRef number, const MByteString &request)
 
MByteString FunctionExecuteRequestResponseReceive (MCOMNumberConstRef number, const MByteString &request)
 
- Public Member Functions inherited from MProtocolC12
virtual ~MProtocolC12 ()
 Destroy the C12 protocol object. More...
 
virtual void Security ()
 Perform ANSI C12 Security service. More...
 
virtual void FullLogin ()
 Perform whatever is required by the protocol to clear security with the meter. More...
 
virtual void Logoff ()
 Perform ANSI C12 Logoff service. More...
 
virtual void Wait (unsigned seconds)
 Perform ANSI C12 Wait service. More...
 
virtual void Terminate ()
 Perform ANSI C12 Terminate service. More...
 
virtual Muint16 CalculateCRC16FromBuffer (const char *buffer, unsigned length) const
 Two-byte CRC calculation procedure specific to C12 protocol. More...
 
unsigned GetMaximumReadTableSize () const
 Return the maximum possible size of a table to read partially or fully in a single application layer packet. More...
 
virtual unsigned CalculateChecksumFromBuffer (const char *buffer, unsigned length) const
 Protocol dependent one-byte checksum calculation procedure that uses buffer and its size. More...
 
MByteString ApplicationLayerRequestResponse (char command, const MByteString &request)
 Perform the full application layer request and return a response. More...
 
char ReceiveServiceCode ()
 Read a code of the incoming application layer data packet. More...
 
Muint8 ReceiveServiceByte ()
 Read one byte from the incoming application layer data packet. More...
 
unsigned ReceiveServiceUInt (unsigned size)
 Read several bytes from the incoming application layer data packet. More...
 
MByteString ReceiveServiceBytes (unsigned length)
 Read several bytes of the incoming application layer data packet. More...
 
MByteString ReceiveServiceRemainingBytes ()
 Read bytes of the incoming application layer data packet. More...
 
unsigned GetLinkLayerRetries () const
 
void SetLinkLayerRetries (unsigned retries)
 
bool GetIssueSecurityOnStartSession () const
 
ReadFunctionResponseEnum GetAlwaysReadFunctionResponse () const
 
void SetAlwaysReadFunctionResponse (ReadFunctionResponseEnum value)
 
bool GetAlwaysUsePartial () const
 
void SetAlwaysUsePartial (bool yes)
 
bool GetUseReadInKeepSessionAlive () const
 
void SetUseReadInKeepSessionAlive (bool yes)
 
unsigned GetUserId () const
 
void SetUserId (unsigned userId)
 
const MByteStringGetUser () const
 
void SetUser (const MByteString &userName)
 
unsigned GetTurnAroundDelay () const
 
void SetTurnAroundDelay (unsigned delay)
 
unsigned GetApplicationLayerRetries () const
 
void SetApplicationLayerRetries (unsigned retries)
 
unsigned GetApplicationLayerRetryDelay () const
 
void SetApplicationLayerRetryDelay (unsigned milliseconds)
 
unsigned GetApplicationLayerProcedureRetries () const
 
void SetApplicationLayerProcedureRetries (unsigned retries)
 
unsigned GetApplicationLayerProcedureRetryDelay () const
 
void SetApplicationLayerProcedureRetryDelay (unsigned milliseconds)
 
unsigned GetProcedureSequenceNumber () const
 
void SetProcedureSequenceNumber (unsigned number)
 
void SetEndSessionOnApplicationLayerError (bool endSessionOnApplicationLayerError)
 
bool GetEndSessionOnApplicationLayerError () const
 
- Public Member Functions inherited from MProtocol
virtual MProtocolCreateClone () const
 Virtual copy constructor, creates the protocol which is a clone of current. More...
 
virtual ~MProtocol ()=0
 Destroy the protocol object. More...
 
void Finalize ()
 Execute this method as first action in the destructor of any child protocol. More...
 
unsigned GetCountApplicationLayerServicesSuccessful () const
 The number of Application Layer services that have been successfully processed. More...
 
void IncrementCountApplicationLayerServicesSuccessful ()
 Increment the number of application layer services successfully processed. More...
 
unsigned GetCountApplicationLayerServicesRetried () const
 The number of Application Layer services that have been retried. More...
 
void IncrementCountApplicationLayerServicesRetried ()
 Increment the number of application layer services retried. More...
 
unsigned GetCountApplicationLayerServicesFailed () const
 The number of Application Layer services that have failed. More...
 
void IncrementCountApplicationLayerServicesFailed ()
 Increment the number of application layer services failed. More...
 
unsigned GetCountLinkLayerPacketsSuccessful () const
 The number of Link Layer packets that have been successfully processed. More...
 
void IncrementCountLinkLayerPacketsSuccessful ()
 Increment the number of data link layer packets successfully processed. More...
 
unsigned GetCountLinkLayerPacketsRetried () const
 The number of Link Layer packets that have been retried. More...
 
void IncrementCountLinkLayerPacketsRetried ()
 Increment the number of data link layer packets retried. More...
 
unsigned GetCountLinkLayerPacketsFailed () const
 Get number of data link layer packets failed. More...
 
void IncrementCountLinkLayerPacketsFailed ()
 Increment the number of data link layer packets failed. More...
 
unsigned GetMaximumRoundTripTime () const
 Gets the maximum measured approximate packet round trip time over the link layer. More...
 
unsigned GetMinimumRoundTripTime () const
 Gets the minimum measured approximate packet round trip time over the link layer. More...
 
unsigned GetAverageRoundTripTime () const
 Gets the average measured approximate packet round trip time over the link layer. More...
 
void ClearPasswordList ()
 Set the password list for the protocol to none, so the SetPassword property is used. More...
 
void AddToPasswordList (const MByteString &password)
 Add a password to the password list. More...
 
int GetPasswordListSuccessfulEntry () const
 Return the entry, which was successfully tried with the meter. More...
 
void ResetCounts ()
 Clear the statistical data for the channel. More...
 
void Connect ()
 Initializes the channel and establishes the connection with the peer. More...
 
void Disconnect ()
 Severs the connection between the computer and the end device. More...
 
bool IsConnected () const
 Tells whether the protocol is currently connected. More...
 
bool IsInSession () const
 Whether the protocol is in session. More...
 
MProgressActionCreateRootProgressAction ()
 Create root of the progress actions hierarchy. More...
 
MProgressActionGetLocalProgressAction ()
 Read-only access to the currently preset local action in progress monitor. More...
 
bool QNeedToCommit () const
 Whether or not it is time to call QCommit(true) in order to sync with the background thread. More...
 
bool QIsBackgroundCommunicationProgressing () const
 True if the background communication is still progressing. More...
 
bool QIsDone ()
 Combines QNeedToCommit with the following QCommit in case all commands in the queue have been sent. More...
 
void QAbort ()
 Clears the commands in the queue, or cancel the ongoing background communication. More...
 
void QWriteToMonitor (const MStdString &message)
 Add the message to write to the Monitor log file to MProtocol's command queue. More...
 
void QConnect ()
 Places a Connect command in the queue. More...
 
void QDisconnect ()
 Places a Disconnect command in the queue. More...
 
void QIdentifyMeter ()
 Places an IdentifyMeter task in the queue. More...
 
void QStartSession ()
 Adds a start session command to MProtocol's command queue. More...
 
void QEndSession ()
 Adds an end session command to MProtocol's command queue. More...
 
void QEndSessionNoThrow ()
 EndSessionNoThrow request is queued. More...
 
void QTableRead (MCOMNumberConstRef number, unsigned expectedSize, int id)
 Adds a ReadTable command to MProtocol's command queue. More...
 
void QTableWrite (MCOMNumberConstRef number, const MByteString &data)
 Adds a table write command to MProtocol's command queue. More...
 
void QTableReadPartial (MCOMNumberConstRef number, int offset, int size, int id)
 Adds a partial table read command to MProtocol's command queue. More...
 
void QTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset)
 Adds a partial table write command to MProtocol's command queue. More...
 
void QFunctionExecute (MCOMNumberConstRef number)
 Place a function without data request in MProtocol command queue. More...
 
void QFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request)
 Place a function with request data in MProtocol's command queue. More...
 
void QFunctionExecuteResponse (MCOMNumberConstRef number, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE)
 Place a function with response data in MProtocol's command queue. More...
 
void QFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE)
 Place a function with request and response data in MProtocol's command queue. More...
 
virtual void QCommit (bool asynchronously=false)
 Executes all operations in MProtocol's command queue. More...
 
MByteString QGetTableData (MCOMNumberConstRef number, int id=-1)
 Fetch the table data after the table read has been successfully performed by QCommit. More...
 
MByteString QGetFunctionData (MCOMNumberConstRef number, int id=-1)
 Fetch the function response data after the function has been successfully executed in QCommit. More...
 
MStdString QGetIdentifyMeterData ()
 Fetch the identify meter string after the QIdentifyMeter has been successfully performed in QCommit. More...
 
virtual void WriteToMonitor (const MStdString &message)
 Synchronously write a message to the monitor, if it is connected. More...
 
void WriteCountsToMonitor ()
 Write running values of communication quality counters to monitor. More...
 
void StartSession ()
 Synchronously start the session. More...
 
void EndSession ()
 Synchronously end the session. More...
 
void EndSessionNoThrow ()
 End the session, but do not throw errors. More...
 
Muint8 ReadStartByte (const MByteString &setOfValidStartBytes, unsigned trafficTimeout)
 Read the start byte of the packet in a proper way, taking into consideration timeouts and ignoring garbage. More...
 
MByteString TableRead (MCOMNumberConstRef number, unsigned expectedSize=0)
 Synchronously read the whole table with number given as parameter. More...
 
void TableReadBuffer (MCOMNumberConstRef number, void *buff, unsigned size)
 Same as ReadTable, but instead of returning a byte string, read table into a given buffer. More...
 
template<class T >
void TableReadBuffer (MCOMNumberConstRef number, T &table)
 Same as ReadTable, but instead of returning a byte string, read table into a given template variable. More...
 
MByteString TableReadNoThrow (MCOMNumberConstRef number, MException **exception, unsigned expectedSize=0)
 Synchronously read the whole table with number given as parameter, do not throw an exception, but rather return it. More...
 
void TableWrite (MCOMNumberConstRef number, const MByteString &data)
 Synchronously write the whole table with number given as parameter. More...
 
void TableWriteBuffer (MCOMNumberConstRef number, const void *data, unsigned size)
 Same as TableWrite, but uses buffer, given as data and size parameters. More...
 
template<class T >
void TableWriteBuffer (MCOMNumberConstRef number, const T &table)
 Same as WriteTable, but uses variable of some specific template class or structure. More...
 
MByteString TableReadPartial (MCOMNumberConstRef number, int offset, int size)
 Synchronously read part of the table with number given as parameter. More...
 
void TableReadPartialBuffer (MCOMNumberConstRef number, int offset, void *buff, unsigned size)
 Same as TableReadPartial, but instead of returning a byte string, read table into a given buffer. More...
 
template<class T >
void TableReadPartialBuffer (MCOMNumberConstRef number, T &table, int offset)
 Same as TableReadPartial, but instead of returning a byte string, partially read table into a given template variable. More...
 
void TableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset)
 Synchronously write part of the table with number given as parameter. More...
 
void TableWritePartialBuffer (MCOMNumberConstRef number, int offset, const void *buff, unsigned size)
 Same as TableWritePartial, but instead of using a byte string, write table using a given buffer. More...
 
template<class T >
void TableWritePartialBuffer (MCOMNumberConstRef number, const T &table, int offset)
 Same as TableWritePartial, but instead of using a byte string, write table using a given template class contents. More...
 
void FunctionExecute (MCOMNumberConstRef number)
 Synchronously execute the function with no parameters, the number of the function is given as parameter. More...
 
void FunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request)
 Synchronously execute the function with request data, the number of the function is given as parameter. More...
 
MByteString FunctionExecuteResponse (MCOMNumberConstRef number)
 Synchronously execute the function with response data, the number of the function is given as parameter. More...
 
MByteString FunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request)
 Synchronously execute the function with request and response data, the number of the function is given as parameter. More...
 
virtual unsigned GetNumberOfDataLinkPackets (MCommunicationCommand::CommandType typeOfRequest, unsigned applicationLayerDataSize=0)
 Return the number of data link packets that are required for a given request, provided an optional size of the application data. More...
 
MStdString IdentifyMeterWithContext (bool sessionIsStarted=false, TableRawDataVector *tablesRead=NULL)
 Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More...
 
unsigned CalculateChecksum (const MByteString &buffer) const
 Protocol dependent one-byte checksum calculation procedure that uses byte string. More...
 
unsigned CalculateCRC16 (const MByteString &buffer) const
 Protocol dependent two-byte CRC calculation procedure that accepts the byte string. More...
 
void Sleep (unsigned milliseconds)
 Calls channel's Sleep method if the channel is present. More...
 
bool GetMeterIsLittleEndian () const
 
void SetMeterIsLittleEndian (bool isLittleEndian)
 
MChannelGetChannel () const
 
void SetChannel (MChannel *channel)
 
bool IsChannelOwned () const
 
void SetIsChannelOwned (bool yes)
 
bool GetKeepSessionAlive () const
 
void SetKeepSessionAlive (bool alive)
 
MByteString GetPassword () const
 
void SetPassword (const MByteString &password)
 
const MByteStringVectorGetPasswordList () const
 
void SetPasswordList (const MByteStringVector &passwordList)
 
MProgressMonitorGetProgressMonitor () const
 
void SetProgressMonitor (MProgressMonitor *p)
 
MCommunicationQueue & GetCommandQueue ()
 M_NO_PROGRESS_MONITOR. More...
 
const MCommunicationQueue & GetCommandQueue () const
 M_NO_PROGRESS_MONITOR. More...
 
MStdString IdentifyMeter (bool sessionIsStarted=false)
 
MStdString DoIdentifyMeter0 ()
 
- Public Member Functions inherited from MCOMObject
virtual ~MCOMObject ()
 Object destructor.
 
virtual MStdStringVector GetAllPropertyNames () const
 Return the list of publicly available properties in MCOM syntax. More...
 
virtual MStdStringVector GetAllPersistentPropertyNames () const
 Return the list of publicly available persistent properties in MCOM syntax. More...
 
MStdString GetPersistentPropertyValues (bool onlyNondefaults=false, bool excludeSecurityRelated=false) const
 Get the string with the list of persistent property names and their values. More...
 
void SetPersistentPropertyValues (const MStdString &values)
 Set the persistent properties for the object using the string with the following format: More...
 
void SetPropertyValues (const MDictionary &values)
 Set the properties for the object using the property list object. More...
 
void WritePropertiesToMonitor ()
 Write all non-default values of protocol properties into monitor. More...
 
MStdString DoGetPersistentPropertyValues0 () const
 Get the string with the whole list of persistent property names and their values. More...
 
MStdString DoGetPersistentPropertyValues1 (bool onlyNondefaults) const
 Get the string with the list of persistent property names and their values. More...
 
- Public Member Functions inherited from MObject
virtual ~MObject ()
 Object destructor.
 
virtual const MClassGetClass () const =0
 Get the final class of the object. More...
 
virtual unsigned GetEmbeddedSizeof () const
 For embedded object types, return the size of the class. More...
 
bool IsEmbeddedObject () const
 Tell if the object is of embedded kind. More...
 
SHOW_INTERNAL MVariant Call (const MStdString &name, const MVariant &params)
 Call the object service with parameters, given as variant. More...
 
MVariant Call0 (const MStdString &name)
 Call the object service with no parameters. More...
 
MVariant Call1 (const MStdString &name, const MVariant &p1)
 Call the object service with one parameter. More...
 
MVariant Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2)
 Call the object service with two parameter. More...
 
MVariant Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3)
 Call the object service with three parameter. More...
 
MVariant Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4)
 Call the object service with four parameter. More...
 
MVariant Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5)
 Call the object service with five parameter. More...
 
MVariant Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6)
 Call the object service with six parameter. More...
 
virtual MVariant CallV (const MStdString &name, const MVariant::VariantVector &params)
 Call the object service with parameters, given as variant vector. More...
 
virtual bool IsPropertyPresent (const MStdString &name) const
 Tell if the property with the given name exists.
 
virtual bool IsServicePresent (const MStdString &name) const
 Tell if the service with the given name exists.
 
virtual MVariant GetProperty (const MStdString &name) const
 Get the property value using name of the property. More...
 
virtual void SetProperty (const MStdString &name, const MVariant &value)
 Set the property using name of the property, and value. More...
 
virtual void SetPersistentPropertiesToDefault ()
 Set the persistent properties of the object to their default values. More...
 
virtual MVariant GetPersistentPropertyDefaultValue (const MStdString &name) const
 Get the default value of persistent property with the name given. More...
 
virtual void SetPersistentPropertyToDefault (const MStdString &name)
 Set the persistent property with the name given to default value. More...
 
virtual const char * GetType () const
 Get the name of the type for the object (could be the same as class name).
 
virtual void SetType (const MStdString &)
 Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More...
 
virtual void Validate ()
 Validate internal structures of the object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MProtocolC12
static unsigned StaticCalculateChecksum (const MByteString &buff)
 Compute checksum of the byte string given as parameters. More...
 
static unsigned StaticCalculateChecksumFromBuffer (const char *data, unsigned size)
 Compute checksum of the buffer and length given as parameters. More...
 
static Muint16 StaticCalculateCRC16FromBuffer (const char *buffer, unsigned length)
 Two-byte CRC calculation static procedure specific to C12 protocol. More...
 
static unsigned CRC16 (const MByteString &buffer)
 Same as above, but taking byte string, reflected. More...
 
- Static Public Member Functions inherited from MProtocol
static unsigned StaticCalculateChecksumFromBuffer (const char *buff, unsigned size)
 Most popular one-byte checksum calculation procedure, a sum of all bytes. More...
 
static unsigned StaticCalculateChecksum (const MByteString &buffer)
 Compute checksum of the byte string given as parameters. More...
 
- Static Public Member Functions inherited from MObject
static const MClassGetStaticClass ()
 Get the declared class of this particular object. More...
 
static bool IsClassPresent (const MStdString &name)
 Tells if the given class name is available. More...
 
- Static Public Attributes inherited from MObject
static const MClass s_class
 Class of MObject.
 
- Protected Member Functions inherited from MProtocolC12
 MProtocolC12 (MChannel *channel, bool channelIsOwned=true)
 Create a new abstract ANSI C12 protocol with the channel given. More...
 
- Protected Member Functions inherited from MProtocol
 MProtocol (MChannel *channel, bool channelIsOwned=true)
 Create a new abstract protocol with the channel given. More...
 
virtual void DoStartSession ()
 Synchronously start the session, don't do service count. More...
 
virtual void DoEndSession ()
 Synchronously end the session, don't do service count. More...
 
virtual void DoTableRead (MCOMNumberConstRef number, MByteString &data, unsigned expectedSize=0)
 Synchronously read the whole table with number given as parameter, don't do service count. More...
 
virtual void DoTableWrite (MCOMNumberConstRef number, const MByteString &data)
 Synchronously write the whole table with number given as parameter, don't do service count. More...
 
virtual void DoTableReadPartial (MCOMNumberConstRef number, MByteString &data, int offset, int size)
 Synchronously read part of the table with number given as parameter, don't do service count. More...
 
virtual void DoTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset)
 Synchronously write part of the table with number given as parameter, don't do service count. More...
 
virtual void DoFunctionExecute (MCOMNumberConstRef number)
 Synchronously execute the function with no parameters, the number of the function is given as parameter, don't do service count. More...
 
virtual void DoFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request)
 Synchronously execute the function with request data, the number of the function is given as parameter, don't do service count. More...
 
virtual void DoFunctionExecuteResponse (MCOMNumberConstRef number, MByteString &response)
 Synchronously execute the function with response data, the number of the function is given as parameter, don't do service count. More...
 
virtual void DoFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, MByteString &response)
 Synchronously execute the function with request and response data, the number of the function is given as parameter, don't do service count. More...
 
virtual MStdString DoIdentifyMeter (bool sessionIsStarted, TableRawDataVector *tablesRead)
 Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More...
 
void DoTryPasswordOrPasswordList ()
 Try password or passwords for the protocol according to the PASSWORD and PasswordList settings. More...
 
virtual void DoTryPasswordEntry (const MByteString &entry)
 Try one password, throw if error. More...
 
virtual void DoBuildComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, int par1=-1, int par2=-1)
 Build service name with a number and given parameters. More...
 
void DoBuildPossiblyNumericComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, bool isHex, int par1=-1, int par2=-1)
 Helper service name builder that can interpret numeric values either as hex or as decimal. More...
 
- Protected Member Functions inherited from MCOMObject
 MCOMObject ()
 Object constructor, protected as the class is abstract.
 
- Protected Member Functions inherited from MObject
 MObject ()
 Object constructor, protected as the class is abstract.
 
void DoSetPersistentPropertiesToDefault (const MClass *staticClass)
 Set the persistent properties to their default values for one object provided the class for that object. More...
 

Detailed Description

ANSI C12.22 protocol implementation.

ANSI Std C12.22-200x "PROTOCOL SPECIFICATION FOR INTERFACING TO DATA COMMUNICATION NETWORKS", is intended as a single communications standard for Water, Gas, and Electricity meters that will work on any manufacturer's conforming product. The ANSI C12.22 protocol was developed to transport table data over a networking communications system. It does not have a data link layer, so the link layer counter properties will remain zero for this protocol. A copy of the document can be obtained through NEMA or ANSI.

MProtocolC1222 is intended for communications through the socket channel, MChannelSocket.

Member Enumeration Documentation

anonymous enum
Enumerator
MaximumProperApduHeaderSize 

Maximum possible size of APDU header (everything but data), calculated correctly.

MaximumLegacyApduHeaderSize 

Maximum possible size of APDU header (everything but data), calculated by legacy former devices.

MaximumEpsemServiceLengthSize 

Maximum size in bytes of ISO length of a PSEM within EPSEM.

The length will be is 1 to 3 bytes. 3 bytes is when it is bigger than 0xFF.

MinimumMaximumApduTotalSize 

Minimum supported total size of APDU.

As applied to GetMaximumApduSize and GetMaximumApduSizeIncoming

MaximumMaximumApduTotalSize 

Maximum supported total size of APDU.

As applied to GetMaximumApduSize and GetMaximumApduSizeIncoming

EPSEM Response control bits.

Comprises all possible values of property GetResponseControl

Enumerator
ResponseControlAlways 

Always respond to a C12.22 request.

ResponseControlOnException 

Respond only on exception.

ResponseControlNever 

Never respond, one way communication.

Values for security mode property.

Property GetSecurityMode is based on ASCII standard's definition of security modes.

Enumerator
SecurityUndefined 

Undefined security, special option used at configuration to mark protocols with unknown security.

SecurityClearText 

Clear text, no authentication or encryption.

SecurityClearTextWithAuthentication 

Clear text with authentication.

SecurityCipherTextWithAuthentication 

Encryption and authentication is on.

Constructor & Destructor Documentation

MProtocolC1222::MProtocolC1222 ( MChannel channel = NULL,
bool  channelIsOwned = true 
)
explicit

Create C12.22 protocol object.

Parameters
channelThe channel object. Most often used object here will be MChannelSocket, When this parameter is NULL, the channel shall be given later to SetChannel property prior to any communication attempt.
channelIsOwnedWhether the channel object is owned by the protocol. The value can be set later using SetIsChannelOwned property.
  • If true, the channel will be deleted when the protocol itself is deleted, or when the channel is reassigned to the protocol with property SetChannel.
  • If false, the channel will not be deleted internally by the protocol, and it is expected the channel is deleted elsewhere.

Member Function Documentation

void MProtocolC1222::DisconnectService ( )

Perform ANSI C12 Disconnect request.

This is named DisconnectService because the name Disconnect is already used in class MProtocol.

Precondition
The channel is open, and the protocol state allows Disconnect to be called.
void MProtocolC1222::FunctionExecuteReceive ( MCOMNumberConstRef  number)

Process PSEM with C12 function (procedure) execute service, no request or response.

void MProtocolC1222::FunctionExecuteRequestReceive ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 function (procedure) execute service, request is present.

MByteString MProtocolC1222::FunctionExecuteRequestResponseReceive ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 function (procedure) execute service, both request and response are present.

void MProtocolC1222::FunctionExecuteRequestResponseSend ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 function (procedure) execute service, both request and response are present.

void MProtocolC1222::FunctionExecuteRequestSend ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 function (procedure) execute service, request is present.

MByteString MProtocolC1222::FunctionExecuteResponseReceive ( MCOMNumberConstRef  number)

Process PSEM with C12 function (procedure) execute service, response is present.

void MProtocolC1222::FunctionExecuteResponseSend ( MCOMNumberConstRef  number)

Process PSEM with C12 function (procedure) execute service, response is present.

void MProtocolC1222::FunctionExecuteSend ( MCOMNumberConstRef  number)

Process PSEM with C12 function (procedure) execute service, no request or response.

const MStdString& MProtocolC1222::GetApplicationContext ( ) const
inline

Application context is the ISO8825 Universal Identifier of the common context for all Relative IOS8825 Universal Identifiers used by the protocol.

When ApplicationContext is "", it is not included in the message. Both the C12.22 Client and C12.22 Communication Module assume that the ApplicationContext is "2.16.124.113620.1.22", which is the identifier reserved to C12.22.

The following text is taken, nearly verbatim, from the ANSI C12.22 standard:

The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (<application-context-oid>.0).

The value of <application-context-oid> is set by ApplicationContext. The value of the called application title is set by GetCalledApTitle. Here is an example of how to use Relative Universal Identifiers:

ApplicationContext = "1.1.112"
CalledApTitle = ".0"

When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.

Here is an example of how to use Absolute Universal Identifiers:

ApplicationContext = ""
CalledApTitle = "1.1.112"

When MeteringSDK assembles the message, the ApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the GetCalledApTitle is sent in the Called AP Title Element (0xA2).

For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
const MStdString& MProtocolC1222::GetCalledApTitle ( ) const
inline

Called Ap Title is the ISO8825 Universal Identifier of the called application. If the string is empty, no Application Title will be associated with the called application and it will not be sent to the device.

The following is taken, nearly verbatim from the ANSI C12.22 standard:

The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (application-context-oid.0).

The value of application-context-oid is set by GetApplicationContext. Here is an example of how to use Absolute Universal Identifiers:

ApplicationContext = ""
CalledApTitle = "1.1.112"

Here is an example of how to use Relative Universal Identifiers:

ApplicationContext = "1.1.112"
CalledApTitle = ".0"

When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.

When MeteringSDK assembles the message, the GetApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the CalledApTitle is sent in the Called AP Title Element (0xA2).

The effect of setting this property will take place next time the session is started, or the logon procedure is performed.

For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.

Since
MeteringSDK Version 2.2.17.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
int MProtocolC1222::GetCallingAeQualifier ( ) const
inline

Calling Application Entity Qualifier is to supply additional information about the message.

In MeteringSDK 6.1.0.3832, this property was renamed from IncomingAeQualifier to IncomingCallingAeQualifier

This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. The property stands for the outgoing message, while there is also a read-only property IncomingCallingAeQualifier. When the device does not support Calling AE Qualifier, the incoming property will not be present (will return -1).

The ANSI C12.22 standard defines the following bits for the AE Qualifier:

  • Bit 0 : When this is set, the message is a test, and it shall not affect the state of the device. If the device supports this, the device shall include a calling-AE-qualifier-element in its response with this bit set.
  • Bit 1 : Urgent message, should be processed in priority manner through relays and by devices.
  • Bit 2 : Notification bit.
Since
MeteringSDK Version 6.1.0.3832.
Default value:
-1, the AE Qualifier element is not included in the message.
Possible values:
  • -1 : AE Qualifier is not included in the message.
  • 0 .. 7 : Possible values for Bits 0 .. 2.
  • 8 .. 255 : Bits 3 .. 7 are reserved, so these values have no meaning.

GetIncomingCallingAeQualifier

unsigned MProtocolC1222::GetCallingApInvocationId ( ) const
inline

The value of calling invocation ID as used in the outgoing APDU.

Accessing this property has debugging and security purpose only. MCOM will always send the invocation ID in the outgoing packet, behaving as the standard requires, but if this property is assigned by the application, the newly assigned value will be used exactly once in the next APDU, after which MCOM will be using its default behavior again.

Since
MeteringSDK Version 4.0.70.
const MStdString& MProtocolC1222::GetCallingApTitle ( ) const
inline

Calling Ap Title is the ISO8825 Universal Identifier of the calling application.

If the string is empty, no Application Title will be associated with the calling application. The calling application title uniquely identifies the initiator of an ASCE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of a absolute or relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (1.2.840.10066.3).

The effect of setting this property will take place next time the session is started, or the logon procedure is performed.

Since
MeteringSDK Version 2.2.17.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
const MStdString& MProtocolC1222::GetEdClass ( ) const
inline

The EdClass string to place in the outgoing packet.

If this is an empty string, EdClass will not be included into the EPSEM outgoing request. The EdClass is encoded in the General Configuration Table (Table 0) of ANSI C12.19 Version 2.0 or the MANUFACTURER code as defined in the General Configuration Table (Table 0) of ANSI C12.19-1997 (Version 1.0).

Since
MeteringSDK Version 4.0.46.
Default value:
"" - empty string, no EdClass will be sent in the outgoing packet.
Possible values:
  • Any string with printable characters, maximum of 4 characters. If it is an empty string, there will be no EdClass in the outgoing EPSEM request. If it is one to three characters, the outgoing EPSEM request will be filled with blanks up to four characters in length.
MByteString MProtocolC1222::GetIncomingApdu ( ) const

The whole incoming application data unit.

After any successfully accepted APDU, this property will hold the whole byte representation of the arrived APDU, convenient for custom logging, data forwarding, or any other purpose. If there was no successful APDU received, this property will return an empty byte string.

When the property is assigned a byte string, the given representation of APDU will be parsed up to the ACSE that comprises the header of the APDU, everything except the EPSEM of the packet. This should be sufficient to use the calling AP title to fetch the key from the storage, and assign it to the protocol. After that, ProcessIncomingEPSEM can be called in order to decrypt the packet and initialize GetIncomingEpsem property.

Since
MeteringSDK Version 6.0.0.3136 there is a read-only version.
MeteringSDK Version 6.6.0.5979 there is a read-write version.
const MStdString& MProtocolC1222::GetIncomingCalledApTitle ( ) const
inline

The Called Application Title of the incoming EPSEM packet.

If no incoming packet has been received, this property returns an empty string. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.

Since
MeteringSDK Version 4.0.46.
Default value:
"" (empty string)
Possible values:
  • Any valid Universal Identifier.
int MProtocolC1222::GetIncomingCallingAeQualifier ( ) const
inline

The Incoming Application Entity Qualifier is to supply additional information about the message.

In MeteringSDK 6.1.0.3832, this property was renamed from AeQualifier to CallingAeQualifier

This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. If the outgoing message had a calling AE qualifier but the corresponding incoming one does not, according to standard this means that incoming AE qualifier is not supported by the callee.

Since
MeteringSDK Version 6.1.0.3832.
Possible values:
  • -1 : Incoming AE Qualifier is not included in the message.
  • 0 .. 255 : Refer to CallingAeQualifier for description of values.

GetCallingAeQualifier

unsigned MProtocolC1222::GetIncomingCallingApInvocationId ( ) const
inline

The value of invocation ID received from the peer in the most recent APDU.

If there was no APDU exchanged, the property will return zero. MCOM will unconditionally throw an exception if the incoming APDU has no invocation ID, and zero is a valid invocation id. Therefore, the presence of the actual value can be detected by the fact that the communication succeeded at the ACSE level.

Since
MeteringSDK Version 4.0.70.
const MStdString& MProtocolC1222::GetIncomingCallingApTitle ( ) const
inline

The Calling Application Title of the incoming EPSEM packet.

If no incoming packet has been received, this property returns an empty string. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.

Since
MeteringSDK Version 4.0.46.
Default value:
"" (empty string)
Possible values:
  • Any valid Universal Identifier.
const MStdString& MProtocolC1222::GetIncomingEdClass ( ) const
inline

Get the EPSEM EdClass that was used in the last EPSEM response.

If this is an empty string, EdClass was not included into the last response, or there was no EPSEM issued.

Precondition
EPSEM response information shall be present, or an exception is thrown.

The EdClass string retrieved from the incoming packet. If there was no incoming packet, then it is an empty string. For more information about this property, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.46.
Possible values:
  • Any string with printable characters, maximum of 4 characters.
MByteString MProtocolC1222::GetIncomingEpsem ( ) const

The whole incoming application EPSEM.

This property is an empty string until ProcessIncomingEPSEM is called after receiving or initializing the incoming APDU. After a successful ProcessIncomingEPSEM call, this property is a byte string that represents a sequence of PSEM data.

Since
MeteringSDK Version 6.6.0.5978 there is a read-write version.
unsigned MProtocolC1222::GetIncomingInitializationVector ( ) const
inline

The value of initialization vector, as received from the peer in the most recent APDU.

If IncomingSecurityMode is nonzero, and initialization vector ACSE was not sent by the peer, or if IncomingInitializationVector is zero, MCOM is going to unconditionally throw an error. Therefore, zero value of this property will mean the incoming packet's security is clear text, and the initialization vector was not obtained.

Since
MeteringSDK Version 4.0.70.
ResponseControlEnum MProtocolC1222::GetIncomingResponseControl ( ) const
inline

The Response Control of the incoming EPSEM packet, as defined by the ANSI Standard C12.22 documentation.

Possible values:
  • 0 = always respond
  • 1 = only respond on error
  • 2 = never respond
unsigned MProtocolC1222::GetIncomingSecurityKeyId ( ) const
inline

The value of security key ID, as received from the peer in the most recent APDU.

The property behaves like GetIncomingInitializationVector, except that zero is a valid incoming value. To know whether or not GetIncomingSecurityKeyId was obtained from peer, one will need to check GetIncomingInitializationVector for being nonzero.

Since
MeteringSDK Version 4.0.70.
SecurityModeEnum MProtocolC1222::GetIncomingSecurityMode ( ) const
inline

Security Mode of the incoming EPSEM packet.

If no incoming packet has been received, this property returns a value of zero. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.

Since
MeteringSDK Version 4.0.46.
Default value:
0 = clear text
Possible values:
  • 0 = clear text
  • 1 = clear text with authentication
  • 2 = cipher text with authentication
  • Any other value results in an error
unsigned MProtocolC1222::GetInitializationVector ( ) const
inline

Initialization vector, as used in the outgoing APDU. Initialization vector will return zero if MCOM has not sent the ACSE initialization vector parameter to the peer. At the event of secure message exchange, MCOM will initialize the value of the property according to C12.22 standard, unless it was changed programmatically by the client application through assigning the value to InitializationVector. After the value is assigned by the application, even if it is zero, MProtocolC1222 will use it exactly once in the following APDU - if security settings require initialization vector ACSE to be sent. After that, if InitializationVector is not assigned by client again, MCOM will be free to fall into its way of changing initialization vector.

Since
MeteringSDK Version 4.0.70.
bool MProtocolC1222::GetIssueTerminateOnEndSession ( ) const
inline

Whether the end of the session shall be completed with Terminate (or Logoff) C12 service.

When true, the session is ended with C12.22 Terminate service. When false, the session is ended with C12.22 Logoff service. This property is applied only when GetSessionless = False.

For more information regarding the end session behavior, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 5.0.0.
Default value:
False [0]
Possible values:
  • False [0] = End session with C12.22 Logoff service
  • True [1] = End session with C12.22 Terminate service
unsigned MProtocolC1222::GetMaximumApduSize ( ) const
inline

Maximum size of the outgoing application protocol data unit (APDU).

Prior to the introduction of GetMaximumApduSizeIncoming, this property set the maximum size of both the incoming and outgoing APDU. If GetMaximumApduSizeIncoming is zero, this property still sets the maximum limit for both the incoming and outgoing APDU size.

For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.43.
Default value:
Possible values:
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability. MeteringSDK versions prior to 6.4.0.4830 had 0x400 as the minimum value. MeteringSDK versions prior to 6.2.0.4200 had 0x800 as the minimum value.
See also
GetMaximumApduSizeIncoming - incoming APDU size that can be the same as outgoing, or different.
unsigned MProtocolC1222::GetMaximumApduSizeIncoming ( ) const
inline

Maximum size of the incoming application protocol data unit (APDU).

The property was introduced in MeteringSDK 6.1 with compatibility in mind. When this property is zero, GetMaximumApduSize sets both the incoming and outgoing maximum APDU size, as it did before the introduction of this property. When this property is not zero, it sets the maximum size of the incoming APDU.

For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 6.1.0.3833.
Default value:
Possible values:
  • 0 - use the value of GetMaximumApduSize as the maximum incoming APDU size.
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability. MeteringSDK versions prior to 6.4.0.4830 had 0x400 as the minimum value. MeteringSDK versions prior to 6.2.0.4200 had 0x800 as the minimum value.
See also
GetMaximumApduSize - outgoing or common APDU size (if maximum incoming APDU size is zero).
unsigned MProtocolC1222::GetNegotiatedMaximumApduSize ( ) const
inline

Get the outgoing negotiated maximum size of the APDU.

This value in the beginning of the session is equal to GetMaximumApduSize. Later on the value of negotiated maximum APDU size can change if RQTL C12 NOK response is received.

Since
MeteringSDK Version 5.3.0.2202.
Default value:
0x7FFF, which is 32767
Possible values:
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability.
See also
GetMaximumApduSizeIncoming
GetMaximumApduSize
GetNegotiatedMaximumApduSizeIncoming
unsigned MProtocolC1222::GetNegotiatedMaximumApduSizeIncoming ( ) const
inline

Get the incoming negotiated maximum size of the APDU.

This value in the beginning of the session is equal to the maximum incoming APDU size, whether it is determined by a dedicated property GetMaximumApduSizeIncoming, or, if this is zero, by GetMaximumApduSize. Later on the value of negotiated maximum APDU size can change if RSTL C12 Nok response is received.

Since
MeteringSDK Version 6.1.0.3833.
Default value:
0x7FFF, which is 32767
Possible values:
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability.
See also
GetMaximumApduSizeIncoming
GetMaximumApduSize
GetNegotiatedMaximumApduSize
unsigned MProtocolC1222::GetNegotiatedSessionIdleTimeout ( ) const

Tells whether or not the GetNegotiatedSessionIdleTimeout property is available.

For more information regarding the session idle timeout properties, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.11.
Possible values:
bool MProtocolC1222::GetNegotiatedSessionIdleTimeoutPresent ( ) const
inline

Tells whether or not the GetNegotiatedSessionIdleTimeout property is available.

For more information regarding the session idle timeout properties, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.11.
Possible values:
bool MProtocolC1222::GetOneServicePerApdu ( ) const
inline

When OneServicePerApdu is true the behavior differs.

Whether the protocol should transmit services one at a time (only one service per APDU).

When OneServicePerApdu is false the protocol will attempt to place as many C12 services as possible into the packet.on whether the protocol is sessionless:

  • If GetSessionless=false each C12 service will be sent in a separate packet resulting in a very long start and end session sequence. Each packet will always have only one C12 service.
  • If GetSessionless=true each packet will consist of Security service followed by the payload service such as table read or write. The name 'one service per APDU' is somewhat misleading as there will be a pair of services sent in each packet.
Since
MeteringSDK Version 5.0.0.980.
Default value:
False [0]
Possible values:
  • True [1] = One payload service per APDU mode is in effect.
  • False [0] = Multiple services packed into a single APDU.
MByteString MProtocolC1222::GetOutgoingApdu ( ) const

Get the whole outgoing application data unit.

After any successfully sent APDU, this property will have its whole byte representation, convenient for monitoring or debugging. If there was no successful APDU sent this property will return an empty byte string.

Since
MeteringSDK Version 6.4.0.4699.
ResponseControlEnum MProtocolC1222::GetResponseControl ( ) const
inline

Whether the protocol EPSEM request is going to be one-way. One way requests cannot pass information back from devices, therefore table reads and function executions with response cannot be handled.

Response control of the outgoing EPSEM packet, as defined by the ANSI Standard C12.22 documentation. When ResponseControl <> 0, GetSessionless = False is not supported and an error is thrown. When ResponseControl <> 0, an error is thrown for any request that requires application- level information to be returned from the peer. Examples are: full/partial table read, and executing a function that has RESPONSE data.

Since
MeteringSDK Version 4.0.46.
Default value:
0 = always respond
Possible values:
  • 0 = always respond
  • 1 = only respond on error
  • 2 = never respond
  • An error is thrown for any other value.
unsigned MProtocolC1222::GetResponseTimeout ( ) const
inline

The number of seconds to wait after sending a packet to get a response.

Should this timeout be exceeded, a timeout error is raised.

Since
MeteringSDK Version 4.0.43.
Default value:
  • 300 seconds for MProtocolC1222 and MeteringSDK Versions 5.0.0 and later. Prior to MeteringSDK Version 5.0.0, the default was 60 seconds. Note that the standard specifies a default of 300 seconds.
Possible values:
0 .. MAX_INT in seconds, while having it at zero is not practical. Very large values will represent practically infinite timeout, while due to the implementation constraint, values bigger than 2147483 will have the same effect as 2147483 seconds, which is about 24 days.
MStdString MProtocolC1222::GetSecurityKey ( ) const

The security key used for encryption and authentication.

The security key is a hex string of exactly 32 characters (representing 16 bytes). The property is only used when GetSecurityMode <> 0. For more information regarding the security key, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • "00000000000000000000000000000000"
Possible values:
  • Any 32 character string that uses hex characters, 0 .. 9, A .. F.
int MProtocolC1222::GetSecurityKeyId ( ) const
inline

Security key ID identifies the key used to encrypt and decrypt the information.

The SecurityKeyID is matched with an entry in the KEY_ENTRIES array located in the Security Table (Table 45, KEY_TBL or Table 46, EXTENDED_KEY_TBL) of the target C12.22 Node. This element is optional, and when not provided in a sessionless message, the SecurityKeyId shall be 0, otherwise the previous SecurityKeyId of the session shall be used.

The SecurityKeyId may be different in each C12.22 Message transmitted. The SecurityKeyId used in a request may be different from the SecurityKeyId used in the response message. For more information regarding the security key ID, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
0
Possible values:
  • 0 .. 255, though it can be limited further by the device capability.
const MByteStringVector& MProtocolC1222::GetSecurityKeyList ( ) const
inline

Security key list for the protocol.

The security key lists overwrite the security key property, when given. These are used to try multiple keys through a single connection, which is, no doubt, a too nice security invention.

SecurityModeEnum MProtocolC1222::GetSecurityMode ( ) const
inline

Protocol security mode.

Determines whether or not the request and response messages are encrypted. For more information regarding the security mode, refer to the ANSI Standard C12.22 documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • 0 (clear text)
Possible values:
  • 0 = clear text
  • 1 = clear text with authentication
  • 2 = cipher text with authentication
  • -1 = Undefined security mode, special value used by applications. Communication attempts with this value will fail.
  • Any other value results in an error
unsigned MProtocolC1222::GetSessionIdleTimeout ( ) const
inline

Session idle timeout, value to use in C12 Logon service.

The maximum number of seconds a session may be idle on the C12.22 Server side before the C12.22 Server may terminate the session. There is also a special value, zero, that means the session will never time out.

Since
MeteringSDK Version 4.0.11.
Default value:
60 seconds
Possible values:
  • 0 : Special value, session will never time out.
  • 1 .. MAX_INT : Number of seconds to allow the session to be idle. Very large values will represent practically infinite timeout, while due to the implementation constraint, values bigger than 2147483 will have the same effect as 2147483 seconds, which is about 24 days.
bool MProtocolC1222::GetSessionless ( ) const
inline

Whether the protocol mode is sessionless.

When Sessionless = true, communications are done in the sessionless mode, and start and end session requires are ignored. Sessionless mode is more efficient for connections with high latency, as it puts many services into one request. There is no guarantee that the whole queue will be done in one trip in sessionless mode.

For more information regarding the sessionless behavior, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.11.
Default value:
True [1]
Possible values:
  • True [1] = Sessionless mode
  • False [0] = Session mode
virtual void MProtocolC1222::Logon ( )
virtual

Perform ANSI C12 Logon request, both request and response.

The particular implementation of this abstract service is typically called from StartSession, but it can also be called directly by the user for testing purpose.

Precondition
The channel is open, and the protocol state allows Logon to be called.

Reimplemented from MProtocolC12.

void MProtocolC1222::ProcessIncomingEPSEM ( )

Initialize protocol machine for processing the incoming EPSEM.

Do all necessary checking such as security mode check, and reset EPSEM buffer for parsing.

virtual void MProtocolC1222::ReadApdu ( )
virtual

Read raw incoming APDU.

Serial variant of the protocol processes the necessary link layer wrapping.

void MProtocolC1222::ReceiveLogon ( )

Process PSEM with C12 Logon service.

void MProtocolC1222::ReceiveSecurity ( )

Process PSEM with C12 Security service.

char MProtocolC1222::ReceiveServiceCodeIgnoreLength ( )

Receive and ignore service length, then service code or status.

This call should be made within ReceiveStart/ReceiveEnd pair of calls. Length parameter, not made available to the caller, is used for initialization of application layer buffer.

Returns
Service code or status code.
unsigned MProtocolC1222::ReceiveServiceLength ( )

Receive service length.

This call should be made within ReceiveStart/ReceiveEnd pair of calls.

Returns
length of the incoming PSEM
MByteString MProtocolC1222::ReceiveTableRead ( MCOMNumberConstRef  number)

Process PSEM with C12 table read service.

MByteString MProtocolC1222::ReceiveTableReadPartial ( MCOMNumberConstRef  number,
int  offset,
int  length 
)

Process PSEM with C12 partial table read service.

void MProtocolC1222::ReceiveTableWrite ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 table write service.

void MProtocolC1222::ReceiveTableWritePartial ( MCOMNumberConstRef  number,
const MByteString request,
int  offset 
)

Process PSEM with C12 partial table write service.

bool MProtocolC1222::SendEndReceiveStart ( )

Combines SendEnd and ReceiveStart.

See also
SendEnd
ReceiveStart
void MProtocolC1222::SendLogon ( )

Process PSEM with C12 Logon service.

void MProtocolC1222::SendSecurity ( )

Process PSEM with C12 Security service.

void MProtocolC1222::SendService ( char  command)

Send command-only service.

This call should be made within SendStart/SendEnd pair of calls.

Parameters
commandC12 command or status code that has to be sent.
void MProtocolC1222::SendServiceWithData ( char  command,
const MByteString data 
)

Send service with command and data.

This call should be made within SendStart/SendEnd pair of calls.

Parameters
commandC12 command or status code that has to be sent.
dataData associated with the command.
void MProtocolC1222::SendTableRead ( MCOMNumberConstRef  number)

Process PSEM with C12 table read service.

void MProtocolC1222::SendTableReadPartial ( MCOMNumberConstRef  number,
int  offset,
int  length 
)

Process PSEM with C12 partial table read service.

void MProtocolC1222::SendTableWrite ( MCOMNumberConstRef  number,
const MByteString request 
)

Process PSEM with C12 table write service.

void MProtocolC1222::SendTableWritePartial ( MCOMNumberConstRef  number,
const MByteString request,
int  offset 
)

Process PSEM with C12 partial table write service.

void MProtocolC1222::ServerEnd ( )

End the processing of incoming request by making and sending back the response.

This call does SendEnd inside.

void MProtocolC1222::ServerReset ( )

Reset server so that it is ready to send back the outgoing APDU.

Outgoing EPSEM is cleared, ready to be filled. AP titles are initialized: calling AP Title will be set to be equal to the incoming called AP title, and called AP title will be set to the incoming calling AP title.

void MProtocolC1222::ServerStart ( )

Start processing of the incoming APDU.

Accept the whole incoming APDU and parse all its ACSE headers. This call can be used by software for implementing C12.22 server.

Initialize GetIncomingApdu with the whole contents of what is read.

All other Incoming properties are initialized, and EPSEM part is loaded into the protocol, available for processing.

void MProtocolC1222::SetApplicationContext ( const MStdString )

Application context is the ISO8825 Universal Identifier of the common context for all Relative IOS8825 Universal Identifiers used by the protocol.

When ApplicationContext is "", it is not included in the message. Both the C12.22 Client and C12.22 Communication Module assume that the ApplicationContext is "2.16.124.113620.1.22", which is the identifier reserved to C12.22.

The following text is taken, nearly verbatim, from the ANSI C12.22 standard:

The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (<application-context-oid>.0).

The value of <application-context-oid> is set by ApplicationContext. The value of the called application title is set by GetCalledApTitle. Here is an example of how to use Relative Universal Identifiers:

ApplicationContext = "1.1.112"
CalledApTitle = ".0"

When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.

Here is an example of how to use Absolute Universal Identifiers:

ApplicationContext = ""
CalledApTitle = "1.1.112"

When MeteringSDK assembles the message, the ApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the GetCalledApTitle is sent in the Called AP Title Element (0xA2).

For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
void MProtocolC1222::SetCalledApTitle ( const MStdString calledApTitle)

Called Ap Title is the ISO8825 Universal Identifier of the called application. If the string is empty, no Application Title will be associated with the called application and it will not be sent to the device.

The following is taken, nearly verbatim from the ANSI C12.22 standard:

The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (application-context-oid.0).

The value of application-context-oid is set by GetApplicationContext. Here is an example of how to use Absolute Universal Identifiers:

ApplicationContext = ""
CalledApTitle = "1.1.112"

Here is an example of how to use Relative Universal Identifiers:

ApplicationContext = "1.1.112"
CalledApTitle = ".0"

When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.

When MeteringSDK assembles the message, the GetApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the CalledApTitle is sent in the Called AP Title Element (0xA2).

The effect of setting this property will take place next time the session is started, or the logon procedure is performed.

For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.

Since
MeteringSDK Version 2.2.17.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
void MProtocolC1222::SetCallingAeQualifier ( int  q)
inline

Calling Application Entity Qualifier is to supply additional information about the message.

In MeteringSDK 6.1.0.3832, this property was renamed from IncomingAeQualifier to IncomingCallingAeQualifier

This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. The property stands for the outgoing message, while there is also a read-only property IncomingCallingAeQualifier. When the device does not support Calling AE Qualifier, the incoming property will not be present (will return -1).

The ANSI C12.22 standard defines the following bits for the AE Qualifier:

  • Bit 0 : When this is set, the message is a test, and it shall not affect the state of the device. If the device supports this, the device shall include a calling-AE-qualifier-element in its response with this bit set.
  • Bit 1 : Urgent message, should be processed in priority manner through relays and by devices.
  • Bit 2 : Notification bit.
Since
MeteringSDK Version 6.1.0.3832.
Default value:
-1, the AE Qualifier element is not included in the message.
Possible values:
  • -1 : AE Qualifier is not included in the message.
  • 0 .. 7 : Possible values for Bits 0 .. 2.
  • 8 .. 255 : Bits 3 .. 7 are reserved, so these values have no meaning.

GetIncomingCallingAeQualifier

void MProtocolC1222::SetCallingApInvocationId ( unsigned  id)
inline

The value of calling invocation ID as used in the outgoing APDU.

Accessing this property has debugging and security purpose only. MCOM will always send the invocation ID in the outgoing packet, behaving as the standard requires, but if this property is assigned by the application, the newly assigned value will be used exactly once in the next APDU, after which MCOM will be using its default behavior again.

Since
MeteringSDK Version 4.0.70.
void MProtocolC1222::SetCallingApTitle ( const MStdString )

Calling Ap Title is the ISO8825 Universal Identifier of the calling application.

If the string is empty, no Application Title will be associated with the calling application. The calling application title uniquely identifies the initiator of an ASCE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of a absolute or relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (1.2.840.10066.3).

The effect of setting this property will take place next time the session is started, or the logon procedure is performed.

Since
MeteringSDK Version 2.2.17.
Default value:
  • "" (empty string)
Possible values:
  • Any valid Universal Identifier.
void MProtocolC1222::SetEdClass ( const MStdString edClass)

The EdClass string to place in the outgoing packet.

If this is an empty string, EdClass will not be included into the EPSEM outgoing request. The EdClass is encoded in the General Configuration Table (Table 0) of ANSI C12.19 Version 2.0 or the MANUFACTURER code as defined in the General Configuration Table (Table 0) of ANSI C12.19-1997 (Version 1.0).

Since
MeteringSDK Version 4.0.46.
Default value:
"" - empty string, no EdClass will be sent in the outgoing packet.
Possible values:
  • Any string with printable characters, maximum of 4 characters. If it is an empty string, there will be no EdClass in the outgoing EPSEM request. If it is one to three characters, the outgoing EPSEM request will be filled with blanks up to four characters in length.
void MProtocolC1222::SetIncomingApdu ( const MByteString )

The whole incoming application data unit.

After any successfully accepted APDU, this property will hold the whole byte representation of the arrived APDU, convenient for custom logging, data forwarding, or any other purpose. If there was no successful APDU received, this property will return an empty byte string.

When the property is assigned a byte string, the given representation of APDU will be parsed up to the ACSE that comprises the header of the APDU, everything except the EPSEM of the packet. This should be sufficient to use the calling AP title to fetch the key from the storage, and assign it to the protocol. After that, ProcessIncomingEPSEM can be called in order to decrypt the packet and initialize GetIncomingEpsem property.

Since
MeteringSDK Version 6.0.0.3136 there is a read-only version.
MeteringSDK Version 6.6.0.5979 there is a read-write version.
void MProtocolC1222::SetInitializationVector ( unsigned  id)
inline

Initialization vector, as used in the outgoing APDU. Initialization vector will return zero if MCOM has not sent the ACSE initialization vector parameter to the peer. At the event of secure message exchange, MCOM will initialize the value of the property according to C12.22 standard, unless it was changed programmatically by the client application through assigning the value to InitializationVector. After the value is assigned by the application, even if it is zero, MProtocolC1222 will use it exactly once in the following APDU - if security settings require initialization vector ACSE to be sent. After that, if InitializationVector is not assigned by client again, MCOM will be free to fall into its way of changing initialization vector.

Since
MeteringSDK Version 4.0.70.
virtual void MProtocolC1222::SetIssueSecurityOnStartSession ( bool  )
virtual

Whether the start session includes the security service or the authenticate service.

When it is set to False, neither the security nor the authenticate service is sent, allowing data that is not password protected to be accessed without the password.

Refer to the ANSI protocol standards for more information on the start session, security, and authenticate services.

  • ANSI Std C12.18-1995 "PROTOCOL SPECIFICATION FOR ANSI TYPE 2 OPTICAL PORT"
  • ANSI Std C12.21-1998 "PROTOCOL SPECIFICATION FOR TELEPHONE MODEM COMMUNICATION"
  • ANSI Std C12.22-2008 "PROTOCOL SPECIFICATION FOR INTERFACING TO DATA COMMUNICATION NETWORKS"
Since
MeteringSDK Version 2.1.27.
Default value:
True
Possible values:
  • True [1] : The security or authenticate service is issued with the password.
  • False [0] : The security or authenticate service is NOT issued. Data that does not require a password can be read. Attempting to access data that requires a password will generate an error.

Reimplemented from MProtocolC12.

void MProtocolC1222::SetIssueTerminateOnEndSession ( bool  yes)
inline

Whether the end of the session shall be completed with Terminate (or Logoff) C12 service.

When true, the session is ended with C12.22 Terminate service. When false, the session is ended with C12.22 Logoff service. This property is applied only when GetSessionless = False.

For more information regarding the end session behavior, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 5.0.0.
Default value:
False [0]
Possible values:
  • False [0] = End session with C12.22 Logoff service
  • True [1] = End session with C12.22 Terminate service
void MProtocolC1222::SetMaximumApduSize ( unsigned  size)

Maximum size of the outgoing application protocol data unit (APDU).

Prior to the introduction of GetMaximumApduSizeIncoming, this property set the maximum size of both the incoming and outgoing APDU. If GetMaximumApduSizeIncoming is zero, this property still sets the maximum limit for both the incoming and outgoing APDU size.

For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.43.
Default value:
Possible values:
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability. MeteringSDK versions prior to 6.4.0.4830 had 0x400 as the minimum value. MeteringSDK versions prior to 6.2.0.4200 had 0x800 as the minimum value.
See also
GetMaximumApduSizeIncoming - incoming APDU size that can be the same as outgoing, or different.
void MProtocolC1222::SetMaximumApduSizeIncoming ( unsigned  size)

Maximum size of the incoming application protocol data unit (APDU).

The property was introduced in MeteringSDK 6.1 with compatibility in mind. When this property is zero, GetMaximumApduSize sets both the incoming and outgoing maximum APDU size, as it did before the introduction of this property. When this property is not zero, it sets the maximum size of the incoming APDU.

For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 6.1.0.3833.
Default value:
Possible values:
  • 0 - use the value of GetMaximumApduSize as the maximum incoming APDU size.
  • 0x200 .. 0x1000000, which is 512 .. 16,777,216 (16 megabytes), though it can be limited further by the device capability. MeteringSDK versions prior to 6.4.0.4830 had 0x400 as the minimum value. MeteringSDK versions prior to 6.2.0.4200 had 0x800 as the minimum value.
See also
GetMaximumApduSize - outgoing or common APDU size (if maximum incoming APDU size is zero).
void MProtocolC1222::SetOneServicePerApdu ( bool  yes)
inline

When OneServicePerApdu is true the behavior differs.

Whether the protocol should transmit services one at a time (only one service per APDU).

When OneServicePerApdu is false the protocol will attempt to place as many C12 services as possible into the packet.on whether the protocol is sessionless:

  • If GetSessionless=false each C12 service will be sent in a separate packet resulting in a very long start and end session sequence. Each packet will always have only one C12 service.
  • If GetSessionless=true each packet will consist of Security service followed by the payload service such as table read or write. The name 'one service per APDU' is somewhat misleading as there will be a pair of services sent in each packet.
Since
MeteringSDK Version 5.0.0.980.
Default value:
False [0]
Possible values:
  • True [1] = One payload service per APDU mode is in effect.
  • False [0] = Multiple services packed into a single APDU.
void MProtocolC1222::SetResponseControl ( ResponseControlEnum  c)

Whether the protocol EPSEM request is going to be one-way. One way requests cannot pass information back from devices, therefore table reads and function executions with response cannot be handled.

Response control of the outgoing EPSEM packet, as defined by the ANSI Standard C12.22 documentation. When ResponseControl <> 0, GetSessionless = False is not supported and an error is thrown. When ResponseControl <> 0, an error is thrown for any request that requires application- level information to be returned from the peer. Examples are: full/partial table read, and executing a function that has RESPONSE data.

Since
MeteringSDK Version 4.0.46.
Default value:
0 = always respond
Possible values:
  • 0 = always respond
  • 1 = only respond on error
  • 2 = never respond
  • An error is thrown for any other value.
void MProtocolC1222::SetResponseTimeout ( unsigned  timeout)

The number of seconds to wait after sending a packet to get a response.

Should this timeout be exceeded, a timeout error is raised.

Since
MeteringSDK Version 4.0.43.
Default value:
  • 300 seconds for MProtocolC1222 and MeteringSDK Versions 5.0.0 and later. Prior to MeteringSDK Version 5.0.0, the default was 60 seconds. Note that the standard specifies a default of 300 seconds.
Possible values:
0 .. MAX_INT in seconds, while having it at zero is not practical. Very large values will represent practically infinite timeout, while due to the implementation constraint, values bigger than 2147483 will have the same effect as 2147483 seconds, which is about 24 days.
void MProtocolC1222::SetSecurityKey ( const MStdString )

The security key used for encryption and authentication.

The security key is a hex string of exactly 32 characters (representing 16 bytes). The property is only used when GetSecurityMode <> 0. For more information regarding the security key, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • "00000000000000000000000000000000"
Possible values:
  • Any 32 character string that uses hex characters, 0 .. 9, A .. F.
void MProtocolC1222::SetSecurityKeyId ( int  )

Security key ID identifies the key used to encrypt and decrypt the information.

The SecurityKeyID is matched with an entry in the KEY_ENTRIES array located in the Security Table (Table 45, KEY_TBL or Table 46, EXTENDED_KEY_TBL) of the target C12.22 Node. This element is optional, and when not provided in a sessionless message, the SecurityKeyId shall be 0, otherwise the previous SecurityKeyId of the session shall be used.

The SecurityKeyId may be different in each C12.22 Message transmitted. The SecurityKeyId used in a request may be different from the SecurityKeyId used in the response message. For more information regarding the security key ID, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
0
Possible values:
  • 0 .. 255, though it can be limited further by the device capability.
void MProtocolC1222::SetSecurityKeyList ( const MByteStringVector )

Security key list for the protocol.

The security key lists overwrite the security key property, when given. These are used to try multiple keys through a single connection, which is, no doubt, a too nice security invention.

void MProtocolC1222::SetSecurityMode ( SecurityModeEnum  mode)

Protocol security mode.

Determines whether or not the request and response messages are encrypted. For more information regarding the security mode, refer to the ANSI Standard C12.22 documentation.

Since
MeteringSDK Version 4.0.35.
Default value:
  • 0 (clear text)
Possible values:
  • 0 = clear text
  • 1 = clear text with authentication
  • 2 = cipher text with authentication
  • -1 = Undefined security mode, special value used by applications. Communication attempts with this value will fail.
  • Any other value results in an error
void MProtocolC1222::SetSessionIdleTimeout ( unsigned  timeout)

Session idle timeout, value to use in C12 Logon service.

The maximum number of seconds a session may be idle on the C12.22 Server side before the C12.22 Server may terminate the session. There is also a special value, zero, that means the session will never time out.

Since
MeteringSDK Version 4.0.11.
Default value:
60 seconds
Possible values:
  • 0 : Special value, session will never time out.
  • 1 .. MAX_INT : Number of seconds to allow the session to be idle. Very large values will represent practically infinite timeout, while due to the implementation constraint, values bigger than 2147483 will have the same effect as 2147483 seconds, which is about 24 days.
void MProtocolC1222::SetSessionless ( bool  )

Whether the protocol mode is sessionless.

When Sessionless = true, communications are done in the sessionless mode, and start and end session requires are ignored. Sessionless mode is more efficient for connections with high latency, as it puts many services into one request. There is no guarantee that the whole queue will be done in one trip in sessionless mode.

For more information regarding the sessionless behavior, refer to the ANSI Standard C12.22-200x documentation.

Since
MeteringSDK Version 4.0.11.
Default value:
True [1]
Possible values:
  • True [1] = Sessionless mode
  • False [0] = Session mode
void MProtocolC1222::WriteApdu ( const MByteString buffer)

Write raw incoming APDU.

Serial variant of the protocol processes the necessary link layer wrapping.