###### tags: `work` # GuruxDLMS.c Client ## client init ```cpp # GuruxDLMS.c/development/src/dlmsSettings.c void cl_init( dlmsSettings* settings, unsigned char useLogicalNameReferencing, uint16_t clientAddress, uint32_t serverAddress, DLMS_AUTHENTICATION authentication, const char* password, DLMS_INTERFACE_TYPE interfaceType) { # main.c cl_init(&con.settings, 1, 16, 1, DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC); # others settings->dlmsVersionNumber = 6; ``` ```cpp # GuruxDLMS.c/development/src/client.c if (settings->authentication != DLMS_AUTHENTICATION_HIGH_ECDSA && settings->authentication != DLMS_AUTHENTICATION_HIGH_GMAC && settings->password.size == 0) {} if (settings->authentication == DLMS_AUTHENTICATION_HIGH_GMAC) # 沒有 DLMS_AUTHENTICATION_HIGH_ECDSA) ``` ```cpp # GuruxDLMS.c/development/src/dlms.c if (settings->authentication == DLMS_AUTHENTICATION_HIGH_SHA256) {} ``` ```cpp # GuruxDLMS.c/development/src/gxaes.c # default AES128 #define BLOCKLEN 16 //Block length in bytes AES is 128b block only void gxaes_cbc_encrypt(unsigned char* output, unsigned char* input, uint32_t length, const unsigned char* key, const unsigned char* iv) {} void gxaes_ecb_encrypt(const unsigned char* input, const unsigned char* key, unsigned char* output, const size_t length) {} ``` ```cpp /*Read DLMS meter using serial port connection.*/ int readSerialPort( connection* connection, const char* port, unsigned char iec, char* readObjects, char* invocationCounter) { ret = com_open(connection, port, iec); ... } /*Read DLMS meter using TCP/IP connection.*/ int readTcpIpConnection( connection* connection, const char* address, const int port, char* readObjects, const char* invocationCounter) { //Make connection to the meter. ret = com_makeConnect(connection, address, port, 5000); } ```