안 병학 / GMMP

Fork of GMMP by SKTelecom_ThingPlug

Files at this revision

API Documentation at this revision

Comitter:
lesmin
Date:
Thu Jul 23 00:55:15 2015 +0000
Child:
1:272f2e355446
Commit message:
initial commit

Changed in this revision

Define/Define.h Show annotated file Show diff for this revision Revisions of this file
Define/Define_Control.h Show annotated file Show diff for this revision Revisions of this file
Define/Define_Delivery.h Show annotated file Show diff for this revision Revisions of this file
Define/Define_Operation.h Show annotated file Show diff for this revision Revisions of this file
ErrorCode/ErrorCode.h Show annotated file Show diff for this revision Revisions of this file
ErrorCode/OMPErrorCode.h Show annotated file Show diff for this revision Revisions of this file
GMMP.cpp Show annotated file Show diff for this revision Revisions of this file
GMMP.h Show annotated file Show diff for this revision Revisions of this file
Network/Network.cpp Show annotated file Show diff for this revision Revisions of this file
Network/Network.h Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Client.cpp Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Client.h Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Print.cpp Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Print.h Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Utility.cpp Show annotated file Show diff for this revision Revisions of this file
Network/TCPclient/Utility.h Show annotated file Show diff for this revision Revisions of this file
Operation/Control/GMMP_Control.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/Control/GMMP_Control.h Show annotated file Show diff for this revision Revisions of this file
Operation/Control/Struct_Control.h Show annotated file Show diff for this revision Revisions of this file
Operation/Control/Struct_Control_Opt.h Show annotated file Show diff for this revision Revisions of this file
Operation/Delivery/GMMP_Delivery.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/Delivery/GMMP_Delivery.h Show annotated file Show diff for this revision Revisions of this file
Operation/Delivery/Struct_Delivery.h Show annotated file Show diff for this revision Revisions of this file
Operation/GMMP_Operation.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/GMMP_Operation.h Show annotated file Show diff for this revision Revisions of this file
Operation/Heartbeat/GMMP_Heartbeat.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/Heartbeat/GMMP_Heartbeat.h Show annotated file Show diff for this revision Revisions of this file
Operation/Heartbeat/Struct_Heartbeat.h Show annotated file Show diff for this revision Revisions of this file
Operation/Notification/GMMP_Notification.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/Notification/GMMP_Notification.h Show annotated file Show diff for this revision Revisions of this file
Operation/Notification/Struct_Notification.h Show annotated file Show diff for this revision Revisions of this file
Operation/ProfileInfo/GMMP_ProfileInfo.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/ProfileInfo/GMMP_ProfileInfo.h Show annotated file Show diff for this revision Revisions of this file
Operation/ProfileInfo/Struct_ProfileInfo.h Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/GMMP_Reg.cpp Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/GMMP_Reg.h Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/Struct_DeReg_Device.h Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/Struct_DeReg_GW.h Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/Struct_Reg_Device.h Show annotated file Show diff for this revision Revisions of this file
Operation/Reg/Struct_Reg_GW.h Show annotated file Show diff for this revision Revisions of this file
Operation/Struct_Common.h Show annotated file Show diff for this revision Revisions of this file
Util/GMMP_Util.cpp Show annotated file Show diff for this revision Revisions of this file
Util/GMMP_Util.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Define/Define.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,160 @@
+/** GMMP 공통 정의
+ * @file Define.h
+ * @date 2015/07/20
+ * @version 0.0.1.0
+ **/
+
+/*
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+*/
+
+#ifndef DEFINE_H_
+#define DEFINE_H_
+
+#include "mbed.h"
+#define byte unsigned char
+
+#include "Define_Operation.h"
+#include "ErrorCode.h"
+
+#define true										1
+#define false									0
+
+#define MAX_MSG_BODY					256
+#define MAX_SMS_MSG_BODY			38
+
+#define LEN_DOMAIN_CODE				10
+#define LEN_GW_ID							16
+#define LEN_DEVICE_ID						16
+#define LEN_AUTH_KEY					16
+#define LEN_AUTH_ID						16
+#define LEN_MANUFACTURE_ID			16
+#define LEN_ENCRYTION_KEY			32
+#define LEN_MULTIMEDIA_URL			256
+#define LEN_MULTIMEDIA_ID				16
+#define LEN_MULTIMEDIA_PW			16
+#define LEN_LOB_ACCESS_KEY			20
+#define LEN_LOB_SECRET_KEY			16
+#define LEN_LOB_DIRECTORY_PATH	16
+#define LEN_LOB_PATH						64
+#define LEN_TID								4
+#define LEN_IP									4
+#define LEN_FILE_NAME					32
+
+#define TID_TANGE_MIN 					0
+#define TID_TANGE_MAX 					99999
+
+#define GMMP_ON_LOG					true
+#define GMMP_OFF_LOG					false
+
+#define GMMP_ERROR_LEVEL_ERROR				0
+#define GMMP_ERROR_LEVEL_DEBUG				1
+#define GMMP_ERROR_LEVEL_DEBUG_DATA		2
+
+#define GMMP_LOG_MARKET_OPS			0
+#define GMMP_LOG_MARKET_REQ			1
+#define GMMP_LOG_MARKET_RSP			2
+#define GMMP_LOG_MARKET_OPE			3
+#define GMMP_LOG_MARKET_ERR			4
+#define GMMP_LOG_MARKET_NOT			5
+
+#define GMMP_LOG_KEY_KEY0							"<Well>"
+#define GMMP_LOG_KEY_KEY1							"<ID:%s_%d>"
+#define GMMP_LOG_KEY_KEY2							"<Marker:OPS>"
+#define GMMP_LOG_KEY_KEY3							"<Marker:REQ>"
+#define GMMP_LOG_KEY_KEY4							"<Marker:RSP>"
+#define GMMP_LOG_KEY_KEY5							"<Marker:OPE>"
+#define GMMP_LOG_KEY_KEY6							"<Marker:ERR>"
+
+
+#define GMMP_MARKET_LEN							15
+
+
+#define GMMP_NETWORK_ALYWAYS_OFF 	0
+#define GMMP_NETWORK_ALYWAYS_ON 	1
+
+#define GMMP_GW							0x01
+#define GMMP_Device  					0x02
+
+#define GMMP_REG							0x01
+#define GMMP_DEREG						0x02
+#define GMMP_PROFILE					0x03
+#define GMMP_DELIVERY					0x04
+#define GMMP_CONTROL					0x05
+#define GMMP_LSENTENCE 				0x06
+#define GMMP_FTP							0x07
+#define GMMP_REMOTE					0x08
+#define GMMP_HEARTBEAT				0x09
+#define GMMP_NOTIFICATION			0x0a
+#define GMMP_MULTIMEDIA				0x0b
+#define GMMP_LOB							0x0c
+
+#define GMMP_REG_ENCRYPTION_INFO 	0x01
+#define GMMP_REG_ENCRYPTION_KEY 	0x02
+
+#define GMMP_ENCRYPTION_USE		0x01
+#define GMMP_ENCRYPTION_NOT		0x02
+
+#define GMMP_LOB_CLOUD				0x01
+#define GMMP_LOB_FTP					0x02
+#define GMMP_LOB_NOTIFICATION	0x03
+
+#define U8						unsigned char
+
+#define GMMP_VERSION			0x21
+
+extern byte g_serverIp[LEN_IP];
+extern int g_nServerPort;
+extern char g_szAuthID[LEN_AUTH_ID];
+extern char g_szAuthKey[LEN_AUTH_KEY];
+extern char g_szDomainCode[LEN_DOMAIN_CODE];
+extern char g_szGWID[LEN_GW_ID];
+extern char g_szDeviceID[LEN_DEVICE_ID];
+
+#define LOG_LEVEL 2
+#define LOG_LEVEL_NONE 6
+#define LOG_LEVEL_FATAL 5
+#define LOG_LEVEL_ERROR 4
+#define LOG_LEVEL_WARN 3
+#define LOG_LEVEL_INFO 2
+#define LOG_LEVEL_DEBUG 1
+#define LOG_LEVEL_ALL 0
+
+#include <cstdio>
+#define INFO(x, ...) if (LOG_LEVEL <= LOG_LEVEL_INFO) std::printf("[INFO]"x"\r\n", ##__VA_ARGS__);
+#define DBG(x, ...) if (LOG_LEVEL <= LOG_LEVEL_DEBUG) std::printf("[DBG]"x"\r\n", ##__VA_ARGS__);
+#define WARN(x, ...) if (LOG_LEVEL <= LOG_LEVEL_WARN) std::printf("[WARN]"x"\r\n", ##__VA_ARGS__);
+#define ERR(x, ...) if (LOG_LEVEL <= LOG_LEVEL_ERROR) std::printf("[ERR]"x"\r\n", ##__VA_ARGS__);
+
+#define fatal(x) if (LOG_LEVEL <= LOG_LEVEL_FATAL) std::printf((x))
+#define fatalln(x) if (LOG_LEVEL <= LOG_LEVEL_FATAL) {std::printf(((x)); std::printf("\r\n");}
+#define fatal2(x, y) if (LOG_LEVEL <= LOG_LEVEL_FATAL) std::printf((x), (y))
+#define fatalln2(x, y) if (LOG_LEVEL <= LOG_LEVEL_FATAL) {std::printf((x), (y)); std::printf("\r\n");}
+
+#define error(x) if (LOG_LEVEL <= LOG_LEVEL_ERROR) std::printf((x))
+#define errorln(x) if (LOG_LEVEL <= LOG_LEVEL_ERROR) {std::printf((x)); std::printf("\r\n");}
+#define error2(x, y) if (LOG_LEVEL <= LOG_LEVEL_ERROR) std::printf((x), (y))
+#define errorln2(x, y) if (LOG_LEVEL <= LOG_LEVEL_ERROR) {std::printf((x), (y)); std::printf("\r\n");}
+
+#define warn(x) if (LOG_LEVEL <= LOG_LEVEL_WARN) std::printf((x))
+#define warnln(x) if (LOG_LEVEL <= LOG_LEVEL_WARN) {std::printf((x)); std::printf("\r\n");}
+#define warn2(x, y) if (LOG_LEVEL <= LOG_LEVEL_WARN) std::printf((x), (y))
+#define warnln2(x, y) if (LOG_LEVEL <= LOG_LEVEL_WARN) {std::printf((x), (y)); std::printf("\r\n");}
+
+#define info(x) if (LOG_LEVEL <= LOG_LEVEL_INFO) std::printf((x))
+#define infoln(x) if (LOG_LEVEL <= LOG_LEVEL_INFO) {std::printf((x)); std::printf("\r\n");}
+#define info2(x, y) if (LOG_LEVEL <= LOG_LEVEL_INFO) std::printf((x), (y))
+#define infoln2(x, y) if (LOG_LEVEL <= LOG_LEVEL_INFO) {std::printf((x), (y)); std::printf("\r\n");}
+
+#define debug(x) if (LOG_LEVEL <= LOG_LEVEL_DEBUG) std::printf((x))
+#define debugln(x) if (LOG_LEVEL <= LOG_LEVEL_DEBUG) {std::printf((x)); std::printf("\r\n");}
+#define debug2(x, y) if (LOG_LEVEL <= LOG_LEVEL_DEBUG) std::printf((x), (y))
+#define debugln2(x, y) if (LOG_LEVEL <= LOG_LEVEL_DEBUG) {std::printf((x), (y)); std::printf("\r\n");}
+
+#endif /* DEFINE_H_ */
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Define/Define_Control.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,40 @@
+/** GMMP Operation 중 제어 명령 리스트 정의
+ * @file Define_Control.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+#ifndef DEFINE_CONTROL_H_
+#define DEFINE_CONTROL_H_
+
+//Control Command define using ControlReqHdr
+#define CONTROL_Reset									0x01		///<단말 리셋
+#define CONTROL_Turn_Off								0x02		///<단말 Turn off
+#define CONTROL_Report_On							0x03		///<단말 보고 데이터 전송 On
+#define CONTROL_Report_Off							0x04		///<단말 보고 데이터 전송 Off
+#define CONTROL_Time_Sync							0x05		///<단말 시각 동기화 설정
+#define CONTROL_Pause									0x06		///<단말 동작 일시중지
+#define CONTROL_Restart								0x07		///<단말 동작 재시작
+#define CONTROL_Signal_Power_Check				0x08		///<단말 전파 강도 조회
+#define CONTROL_Diagnostic							0x09		///<단말 상태 진단
+#define CONTROL_Reserved								0x0a		///<Reserved
+#define CONTROL_Profile_Reset						0x0b		///<단말 Profile 정보 재설정
+#define CONTROL_Status_Check						0x0c		///<단말 동작 상태 조회
+#define CONTROL_FW_Download						0x0d		///<단말 펌웨어 다운로드
+#define CONTROL_FW_Update							0x0e		///<단말 펌웨어 업그레이드
+#define CONTROL_App_Download						0x0f		///<단말 App 다운로드
+#define CONTROL_App_Update							0x10		///<단말 App 업그레이드
+#define CONTROL_Remote_Access					0x11		///<단말 원격 터미널 접속
+#define CONTROL_Multimedia_Control_Start		0x12		///<멀티미디어 통신 제어 시작
+#define CONTROL_Multimedia_Control_Pause		0x13		///<멀티미디어 통신 제어 멈춤
+#define CONTROL_Multimedia_Control_Stop		0x14		///<멀티미디어 통신 제어 종료
+#define CONTROL_Multimedia_Control_Restart	0x15		///<멀티미디어 통신 제어 재시작
+#define Industrial_Reserved_Min						0x20		///<산업별 Reserved
+#define Industrial_Reserved_Max						0x7f		///<산업별 Reserved
+#define User_defined_Control_Min						0x80		///<사용자 정의 제어 타입
+#define User_defined_Control_Max					0x9f		///<사용자 정의 제어 타입
+#define Reserved_Min										0xa0		///<Reserved
+#define Reserved_Max										0xff		///<Reserved
+
+#endif /* DEFINE_CONTROL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Define/Define_Delivery.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,15 @@
+/** GMMP Operation 중 주기보고 명령 리스트 정의
+ * @file Define_Delivery.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+#ifndef DEFINE_DELIVERY_H_
+#define DEFINE_DELIVERY_H_
+
+#define DELIVERY_COLLECT_DATA			0x01 ///<OMP에 수집 데이터 보고 한다.
+#define DELIVERY_ALARM_DATA			0x02 ///<OMP에 장애 데이터 보고 한다.
+#define DELIVERY_EVENT_DATA				0x03 ///<OMP에 이벤트 데이터 보고 한다.
+#define DELIVERY_ALARM_CLEAR			0x04 ///<OMP에 장애 해제 데이터 보고 한다.
+
+#endif /* DEFINE_DELIVERY_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Define/Define_Operation.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,70 @@
+/** GMMP Operation 절차 리스트 정의
+ * @file Define_Operation.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+#ifndef DEFINE_OPERATION_H_
+#define DEFINE_OPERATION_H_
+
+
+#include "Define_Delivery.h"
+#include "Define_Control.h"
+
+#define OPERATION_GW_REG_REQ					0x01 ///<OMP에 GW 등록 Request
+#define OPERATION_GW_REG_RSP						0x02 ///<OMP에 GW 등록 Response
+
+#define OPERATION_GW_DEREG_REQ				0x03 ///<OMP에 GW 등록 Request
+#define OPERATION_GW_DEREG_RSP					0x04 ///<OMP에 GW 등록 Response
+
+#define OPERATION_PROFILE_REQ					0x05 ///<OMP에 GW 등록 Request
+#define OPERATION_PROFILE_RSP					0x06 ///<OMP에 GW 등록 Response
+
+#define OPERATION_DEVICE_REG_REQ			0x07 ///<OMP에 GW 등록 Request
+#define OPERATION_DEVICE_REG_RSP			0x08 ///<OMP에 GW 등록 Response
+
+#define OPERATION_DEVICE_DEREG_REQ 	0x09 ///<OMP에 GW 등록 Request
+#define OPERATION_DEVICE_DEREG_RSP 	0x0a ///<OMP에 GW 등록 Response
+
+#define OPERATION_DELIVERY_REQ				0x0b ///<OMP에 GW 등록 Request
+#define OPERATION_DELIVERY_RSP				0x0c ///<OMP에 GW 등록 Response
+
+#define OPERATION_CONTROL_REQ				0x0d ///<OMP에 GW 등록 Request
+#define OPERATION_CONTROL_RSP				0x0e ///<OMP에 GW 등록 Response
+
+#define OPERATION_HEARTBEAT_REQ			0x0f ///<OMP에 GW 등록 Request
+#define OPERATION_HEARTBEAT_RSP			0x10 ///<OMP에 GW 등록 Response
+
+#define OPERATION_LSENTENCE_REQ			0x11 ///<OMP에 GW 등록 Request
+#define OPERATION_LSENTENCE_RSP			0x12 ///<OMP에 GW 등록 Response
+
+#define OPERATION_FTP_INFO_REQ				0x13 ///<OMP에 GW 등록 Request
+#define OPERATION_FTP_INFO_RSP				0x14 ///<OMP에 GW 등록 Response
+
+#define OPERATION_REMOTE_INFO_REQ		0x15 ///<OMP에 GW 등록 Request
+#define OPERATION_REMOTE_INFO_RSP			0x16 ///<OMP에 GW 등록 Response
+
+#define OPERATION_NOTIFICATION_REQ		0x17 ///<OMP에 GW 등록 Request
+#define OPERATION_NOTIFICATION_RSP			0x18 ///<OMP에 GW 등록 Response
+
+#define OPERATION_ENCRYPTION_INFO_REQ		0x19 ///<OMP에 GW 등록 Request
+#define OPERATION_ENCRYPTION_INFO_RSP		0x1a ///<OMP에 GW 등록 Response
+
+#define OPERATION_ENCRYPTION_KEY_REQ		0x1b ///<OMP에 GW 등록 Request
+#define OPERATION_ENCRYPTION_KEY_RSP		0x1c ///<OMP에 GW 등록 Response
+
+#define OPERATION_MULTIMEDIA_URL_INFO_REQ	0x1d ///<OMP에 GW 등록 Request
+#define OPERATION_MULTIMEDIA_URL_INFO_RSP	0x1e ///<OMP에 GW 등록 Response
+
+#define OPERATION_LOB_CLOUD_INFO_REQ		0x1f ///<OMP에 GW 등록 Request
+#define OPERATION_LOB_CLOUD_INFO_RSP		0x20 ///<OMP에 GW 등록 Response
+
+#define OPERATION_LOB_FTP_INFO_REQ			0x21 ///<OMP에 GW 등록 Request
+#define OPERATION_LOB_FTP_INFO_RSP				0x22 ///<OMP에 GW 등록 Response
+
+#define OPERATION_LOB_UPLOAD_NOTIFICATION_REQ		0x23 ///<OMP에 GW 등록 Request
+#define OPERATION_LOB_UPLOAD_NOTIFICATION_RSP		0x24 ///<OMP에 GW 등록 Response
+
+
+#endif /* DEFINE_OPERATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ErrorCode/ErrorCode.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,31 @@
+/** GMMP 라이브러리 에러코드
+ * @file ErrorCode.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ **/
+
+#ifndef ERRORCODE_H_
+#define ERRORCODE_H_
+
+//error type define
+#define GMMP_SUCCESS										0
+
+#define GMMP_ERROR_DEFAULT						10000
+#define GMMP_ERROR_UNKWOUN					10001
+#define GMMP_LOG_ERROR_OPEN						10002
+#define GMMP_LOG_ERROR_WRITE					10003
+#define GMMP_LOG_ERROR_CLOSE					10004
+#define GMMP_LOG_NO_WRITE_DATA				10005
+#define GMMP_LOG_LONG_STRING					10006
+#define SERVER_INFO_NOT_FOUND					10007
+#define SERVER_REQUEST_TIMEOUT					10008
+#define SERVER_SOCKET_ERROR						10009
+#define SERVER_CONNECT_ERROR					10010
+#define SERVER_DISCONNECT							10011
+#define LIB_PARAM_ERROR								10012
+#define GMMP_MALLOC_ERROR						10013
+#define GMMP_HEADER_SIZE_ERROR					10014
+
+#define E_WOULDBLOCK                  20000
+
+#endif /* ERRORCODE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ErrorCode/OMPErrorCode.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,41 @@
+/** OMP에서 제공하는 에러코드
+ * @file OMPErrorCode.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ **/
+
+
+#ifndef OMPERRORCODE_H_
+#define OMPERRORCODE_H_
+
+#define STATUS_OK															0x00
+#define STATUS_CREATED													0x01
+#define STATUS_ACCEPTED												0x02
+#define STATUS_BAD_REQUEST											0x03
+#define STATUS_PERMISSION_DENIED								0x04
+#define STATUS_FORBIDDEN												0x05
+#define STATUS_NOT_FOUND											0x06
+#define STATUS_METHOD_NOT_ALLOWED							0x07
+#define STATUS_NOT_ACCEPTABLE									0x08
+#define STATUS_REQUEST_TIMEOUT									0x09
+#define STATUS_CONFLICT												0x0a
+#define STATUS_UNSUPPORTED_MEDIA_TYPE						0x0b
+#define STATUS_INTERNAL_SERVER_ERROR						0x0c
+#define STATUS_NOT_IMPLEMENTED									0x0d
+#define STATUS_BAD_GATEWAY											0x0e
+#define STATUS_SERVICE_UNAVAILABLE								0x0f
+#define STATUS_GATEWAY_TIMEOUT									0x10
+#define STATUS_DELETED													0x11
+#define STATUS_EXPIRED													0x12
+#define STATUS_SMS_SEND_FAIL										0x13
+
+#define User_Defined_Result_Code_Min								0x80
+#define User_Defined_Result_Code_Max							0xff
+
+#define STATUS_DB_TIMEOUT											0x81	///<과부하에 의한 DB Access time out의 경우
+#define STATUS_MSPTCP_DISCONNECTED							0x82	///<MNP와 MSP간의 TCP 소켓이 끊어 졌을 경우
+#define STATUS_GMMPTCP_PORT_CLOSED							0x83	///<단말과 GMMP Listen Port의 TCP연결이 끊어진 경우
+#define STAUS_AO_CONTROL_SEND_FAIL							0x84	///<TCP Always On 제어 전송 실패인 경우
+
+
+#endif /* OMPERRORCODE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GMMP.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,493 @@
+/** GMMP 공통 정의
+ * @file GMMP.cpp
+ * @date 2015/07/20
+ * @version 0.0.1.0
+ **/
+
+#ifndef GMMP_h
+#define GMMP_h
+
+/*
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <stdarg.h>
+*/
+
+//#include <inttypes.h>
+//#include <Time.h>
+//#include <Arduino.h>
+
+#define USE_SNIC_WIFI //Murata Type YD Wi-Fi
+//#define USE_WIZNET_W5500
+
+#if defined(TARGET_LPC1768)
+#include "EthernetInterface.h"
+#elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
+
+	#ifdef USE_SNIC_WIFI
+	#include "SNIC_WifiInterface.h"
+	#endif//USE_SNIC_WIFI
+	
+	#ifdef USE_WIZNET_W5500
+	#include "WIZnetInterface.h"
+	#endif//USE_WIZNET_W5500
+#endif
+
+#include "NTPClient.h"
+
+#include "GMMP.h"
+
+byte g_serverIp[LEN_IP] ; ///< 서버 IP 정보를 저장한다.
+int  g_nServerPort = 0; ///<  서버 Port 정보를 저장한다.
+
+char g_szAuthID[LEN_AUTH_ID];///< OMP Portal을 통해 사전에 등록된 M2M GW 의 Serial Number 저장 변수, 자동화를 위해 사용된다.
+
+char g_szAuthKey[LEN_AUTH_KEY]; ///< 등록 절차 시 OMP에서 할당 받은 AuthKey 저장 변수, 자동화를 위해 사용된다.
+
+char g_szDomainCode[LEN_DOMAIN_CODE]; ///< OMP Portal을 통해 사전에 등록된 서비스 영역별 구분 코드 저장 변수, 자동화를 위해 사용된다.
+
+char g_szGWID[LEN_GW_ID]; ///< OMP에서 할당 받은 Gateway의 ID 문자열 저장 변수, 자동화를 위해 사용된다.
+
+/**
+ * @brief OMP서버로 부터 수신한 패킷을 제공할 콜백함수 포인트 구조체
+ * @param pstGMMPHeader GMMP Header의 구조체 포인트
+ * @param pstBody GMMP Body의 구조체 포인트
+ * @return 성공:0, 실패: 1이상 , 에러코드 참조
+ */
+typedef int (*callback_Reg)(GMMPHeader* pstGMMPHeader, void* pstBody);
+
+callback_Reg g_CallFunctionRegRecv = NULL; ///< OMP서버로 부터 수신한 패킷을 제공할 콜백함수 포인트 변수.
+//callback_Reg g_CallHeartbeatRegRecv = NULL; ///< OMP서버로 부터 수신한 패킷 중 Heartbeat 패킷을 제공할 콜백함수 포인트 변수. (TCP Always On mode에서만 사용된다.)
+
+void Uninitialize()
+{
+	InitMemory();
+	CloseSocket();
+}
+
+
+
+int Initialize(byte* serverIp,
+		const int nPort,
+		const char* pszDomainCode,
+		const char* pszGWAuthID,
+		byte* mac)
+{
+  debugln("Initialize()");
+
+	InitMemory();
+
+  //delay(2000);
+#if defined(TARGET_LPC1768)
+EthernetInterface eth;
+#elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
+
+	#ifdef USE_SNIC_WIFI
+	C_SNIC_WifiInterface     wifi( D8, D2, NC, NC, D3);
+	
+	#define MBED_AP_SSID                  "T-Smart"
+	/** Securiry Options
+    e_SEC_OPEN       = 0x00, //Open
+    e_SEC_WEP        = 0x01, // WEP
+    e_SEC_WPA_TKIP   = 0x02, // WPA-PSK(TKIP)
+    e_SEC_WPA2_AES   = 0x04, // WPA2-PSK(AES)
+    e_SEC_WPA2_MIXED = 0x06, // WPA2-PSK(TKIP/AES)
+    e_SEC_WPA_AES    = 0x07  // WPA-PSK(AES) **/
+	#define MBED_AP_SECURITY_TYPE         e_SEC_OPEN
+	#define MBED_AP_SECUTIRY_KEY          ""
+	
+	#endif//USE_SNIC_WIFI
+
+	#ifdef USE_WIZNET_W5500
+	//unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56};
+	SPI spi(PA_7, PA_6, PA_5); // mosi, miso, sclk
+    WIZnetInterface ethernet(&spi, PB_6, PA_9);//scs(PB_6), nRESET(PA_9); // reset pin is dummy, don't affect any pin of WIZ550io
+	#endif//USE_WIZNET_W5500
+
+#endif
+//NTPClient ntp;
+
+  infoln("Getting IP...");
+
+	#if defined(TARGET_LPC1768)
+    eth.init(); //Use DHCP
+    eth.connect();
+    wait(0.5);
+    printf("IP Address is %s\r\n", eth.getIPAddress());
+	#elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
+
+	#ifdef USE_SNIC_WIFI
+	wifi.init();
+
+    wait(0.5);
+    int s = wifi.disconnect();
+    if( s != 0 ) {
+        return -1;
+    }
+
+    wait(0.3);
+    // Connect AP
+    wifi.connect( MBED_AP_SSID
+                  , strlen(MBED_AP_SSID)
+                  , MBED_AP_SECURITY_TYPE
+                  , MBED_AP_SECUTIRY_KEY
+                  , strlen(MBED_AP_SECUTIRY_KEY) );
+    wait(0.5);
+    wifi.setIPConfig( true );     //Use DHCP
+    wait(0.5);
+    
+    tagWIFI_STATUS_T wifi_status;
+    if( wifi.getWifiStatus(&wifi_status) ) printf("wifi_status error!\r\n");
+
+    printf("MAC Address is %s\r\n", wifi_status.mac_address);
+    printf("IP Address is %s\r\n", wifi.getIPAddress());
+    #endif//USE_SNIC_WIFI
+
+	#ifdef USE_WIZNET_W5500
+	//mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres
+	
+	int ret = ethernet.init(mac);
+    printf("SPI Initialized \r\n");
+    wait(1); // 1 second for stable state
+    
+    printf("W5500 Networking Started \r\n");
+    wait(1); // 1 second for stable state
+
+    if (!ret) {
+        printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
+        ret = ethernet.connect();
+        if (!ret) {
+            printf("IP: %s, MASK: %s, GW: %s\r\n",
+                      ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
+        } else {
+            printf("Error ethernet.connect() - ret = %d\r\n", ret);
+            //exit(0);
+        }
+    } else {
+        printf("Error ethernet.init() - ret = %d\r\n", ret);
+        //exit(0);
+    }
+
+	#endif//USE_WIZNET_W5500
+	#endif
+    
+
+	NTPClient ntp;
+	printf("Trying to update time...\r\n");
+	//if (ntp.setTime("0.pool.ntp.org") == 0)
+//	if (ntp.setTime("time-a.timefreq.bldrdoc.gov") == 0)
+//	if (ntp.setTime("kr.pool.ntp.org") == 0)
+	if (ntp.setTime("211.233.40.78") == 0) //MURATA UDP does not support DNS resolver...
+	{
+	  printf("Set time successfully\r\n");
+	  time_t ctTime;
+	  ctTime = time(NULL);
+//	  printf("Time is set to (UTC): %s\r\n", ctime(&ctTime));
+      ctTime += 32400; // GMT+9/Seoul
+	  printf("Time is set to (GMT+9): %s\r\n", ctime(&ctTime));
+	}
+	else
+	{
+	  printf("Error\r\n");
+	} 
+
+
+	if(SetServerInfo(serverIp, nPort, pszGWAuthID, pszDomainCode) != 0)
+	{
+		return LIB_PARAM_ERROR;
+	}
+	SetTID(0);
+
+	return GMMP_SUCCESS;
+}
+
+void SetAuthKey(const char* pszAuthKey)
+{
+	memcpy(g_szAuthKey, pszAuthKey, strlen(pszAuthKey));
+}
+
+void SetGWID(const char* pszGWID)
+{
+	if(pszGWID != NULL)
+	{
+		memcpy(g_szGWID, pszGWID, strlen(pszGWID));
+	}
+}
+
+char* GetGWID()
+{
+	return g_szGWID;
+}
+
+int SetServerInfo(byte* serverIp, int nPort, const char* pszAuthID, const char* pszDoamainCode)
+{
+  /*
+	if(pszAuthID == NULL || strlen(pszAuthID) > LEN_AUTH_ID
+			|| pszDoamainCode == NULL || strlen(pszDoamainCode) > LEN_DOMAIN_CODE)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	memcpy(g_serverIp, serverIp, LEN_IP);
+	memcpy(g_szAuthID, pszAuthID, strlen(pszAuthID));
+	memcpy(g_szDomainCode, pszDoamainCode, strlen(pszDoamainCode));
+
+	g_nServerPort = nPort;
+
+	int nRet = SetIntiSocket();
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	return GMMP_SUCCESS;
+}
+
+void SetCallFunction(int (* pCallFunctionName)(GMMPHeader* pstGMMPHeader, void* pstBody))
+{
+	g_CallFunctionRegRecv = (callback_Reg)pCallFunctionName;
+}
+
+int GO_Reg(const char* pszGWID,
+		const char* pszManufactureID)
+{
+  debugln("GO_Reg()");
+	SetTID(GetTID()+1);
+
+	int nRet = GMMP_SetReg(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszManufactureID);
+  debugln("GO_SetReg() Done");
+
+	return nRet;
+}
+
+int GO_DeReg(const char* pszGWID, const char* pszDeviceID)
+{
+	SetTID(GetTID()+1);
+
+	int nRet = GMMP_SetDeReg(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszDeviceID);
+
+	return nRet;
+}
+
+int GO_Profile(const char* pszGWID,
+		const char* pszDeviceID,
+		const long nTID /*=0*/)
+{
+	if(nTID == 0) {
+		SetTID(GetTID()+1);
+	} else {
+		SetTID(nTID);
+	}
+
+	int nRet = GMMP_SetProfile(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszDeviceID);
+
+  return nRet;
+}
+
+int GO_Delivery(const char* pszGWID,
+		const char* pszDeviceID,
+		const char cReportType,
+		const char cMediaType,
+		const char* pszMessageBody)
+{
+	SetTID(GetTID()+1);
+
+	int nRet = GMMP_SetDelivery(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszDeviceID, cReportType, cMediaType, pszMessageBody, 1, 1);
+
+	return nRet;
+}
+
+int GO_Control(const char* pszGWID,
+		const char* pszDeviceID,
+		long nTID,
+		const char cControlType,
+		const char cResultCode)
+{
+	SetTID(nTID);
+
+	return GMMP_SetControl(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszDeviceID, cControlType, cResultCode);
+}
+
+int GO_Notifi(const char* pszGWID,
+		const char* pszDeviceID,
+		const char cControlType,
+		const char cResultCode,
+		const char* pszMessageBody,
+		const int nMessageBodySize)
+{
+	int nRet =	GMMP_SetNotifi(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID, pszDeviceID, cControlType, cResultCode, pszMessageBody, nMessageBodySize);
+
+	return nRet;
+}
+
+int GO_HB(const char* pszGWID)
+{
+	int nRet =	GMMP_SetHB(g_szAuthID, g_szAuthKey, g_szDomainCode, pszGWID);
+
+	return nRet;
+}
+
+int OG_Reg_Recv(GMMPHeader* pstGMMPHeader, stGwRegistrationRspHdr* pstGWBody, stDeviceRegistrationRspHdr* pstDeviceBody)
+{
+	int nRet = 0;
+
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		if(pstGWBody != NULL)
+		{
+			nRet= (*g_CallFunctionRegRecv)(pstGMMPHeader, pstGWBody);
+
+			if(nRet != GMMP_SUCCESS)
+			{
+				return nRet;
+			}
+		}
+		else
+		{
+			nRet = (*g_CallFunctionRegRecv)(pstGMMPHeader, pstDeviceBody);
+
+			if(nRet != GMMP_SUCCESS)
+			{
+				return nRet;
+			}
+		}
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_DeReg_Recv(GMMPHeader* pstGMMPHeader, stGwDeRegistrationRspHdr* pstGWBody, stDeviceDeRegistrationRspHdr* pstDeviceBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		if(pstGWBody != NULL)
+		{
+			return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstGWBody);
+		}
+		else
+		{
+			return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstDeviceBody);
+		}
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_Profile_Recv(GMMPHeader* pstGMMPHeader, stProfileRspHdr* pstBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstBody);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_Delivery_Recv(GMMPHeader* pstGMMPHeader, stPacketDeliveryRspHdr* pstBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstBody);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_Ctrl_Recv(GMMPHeader* pstGMMPHeader, stControlReqHdr* pstBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstBody);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_HB_Recv(GMMPHeader* pstGMMPHeader, stHeartBeatMsgRspHdr* pstBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstBody);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int OG_Notifi_Recv(GMMPHeader* pstGMMPHeader, stNotificationRspHdr* pstBody)
+{
+	if(g_CallFunctionRegRecv != NULL)
+	{
+		return (*g_CallFunctionRegRecv)(pstGMMPHeader, pstBody);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int GetReadData(GMMPHeader* pstGMMPHeader, void** pBody)
+{
+	int nHeaderCound = 0;
+	int nRet = 0;
+  
+	while(true)
+	{
+		nRet = GMMP_Read(pstGMMPHeader, pBody);
+		if(nRet == GMMP_HEADER_SIZE_ERROR) {
+			if(nHeaderCound > 3) {
+				break;
+			}
+			nHeaderCound++;
+			continue;
+		}
+		else if(nRet == GMMP_SUCCESS) {
+			break;
+		}
+		else {
+			return nRet;
+		}
+	}
+
+	GMMP_Recv(pstGMMPHeader, *pBody);
+
+	return nRet;
+}
+
+long Char2int(void* pBuffer, int nSize)
+{
+	if(nSize != sizeof(long)) {
+		return 0;
+	}
+
+	long nInt = 0;
+	memcpy(&nInt, pBuffer, sizeof(long));
+	return btoli(nInt);
+}
+
+int Char2short(void* pBuffer, short nSize)
+{
+	if(nSize != sizeof(short)) {
+		return 0;
+	}
+
+	short nShort = 0;
+	memcpy(&nShort, pBuffer, sizeof(short));
+	return btols(nShort);
+}
+
+void InitMemory()
+{
+	memset(g_szDomainCode, 0 , sizeof(g_szAuthID));
+	memset(g_szAuthID, 0 , sizeof(g_szAuthID));
+	memset(g_szAuthKey, 0 , sizeof(g_szAuthKey));
+	memset(g_szGWID, 0 , sizeof(g_szGWID));
+
+	g_nServerPort = 0;
+
+	g_CallFunctionRegRecv = NULL;
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GMMP.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,1020 @@
+/**
+ * @mainpage GMMP (Global M2M Protocol) 개요
+  * @brief GMMP는 M2M 단말과 개방형 M2M 플랫폼(OMP)사이의 TCP 기반 연동 규격으로서, 단말 등록/해지, 주기보고, 단말 제어 등의 기능을 수행하는 SKTelecom 내부 규격이다.
+ * @brief M2M Portal Site : <a href="https://www.m2mportal.co.kr"> Mobius Portal </a>
+ * @date 2015/07/20
+ * @version 1.0
+ * @file GMMP.h
+ **/
+
+
+#ifndef GMMP_H_
+#define GMMP_H_
+
+#include "GMMP_Operation.h"
+
+/**
+ * @defgroup GMMP_Registration_Operation M2M GW/Device 등록
+ *등록 절차는 현장에 설치된 M2M GW가 서비스 수행을 시작하기 위해서 최초로 수행해야 하는 절차이다.\n
+ *1. GW 등록 절차\n
+(1) M2M GW는 M2M Portal을 통해 사전에 등록된 자기 자신의 AUTH_ID(MSISDN or MAC Address), Domain Code, Manufacture ID를 전송한다.\n
+(2) OMP는 M2M GW가 전송한 AUTH_ID(MSISDN or MAC Address), Manufacture ID 값이 정상인지 확인하고 이상이 없으면 M2M GW로 Auth Key, GW ID를 부여하여 응답 메시지를 전송한다.\n
+(3) OMP에서 M2M GW의 등록이 정상적으로 이루어지지 않으면 응답 메시지의 Result Code에 Fail Code 값을 포함하여 M2M GW로 전송한다.\n
+(4) 3회 이상 M2M GW의 등록이 정상적이지 않은 경우 M2M GW는 더 이상 등록 요청을 수행하지 않고 GW 장애 절차를 수행한다.(GMMP 규격 논외)\n
+(5) M2M GW의 등록이 정상적으로 수행되었으나 Profile 정보(주기보고의 주기정보 및 Heartbeat 주기정보 등)가 없는 경우에는 @ref GO_Profile을 수행한다.\n
+
+	NOTE :\n
+	[사전 등록] M2M GW 등록 절차 수행을 위해서는 사전에 M2M 포털을 통해 등록 되어야 한다.\n
+	[ID 등록] M2M GW의 Auth ID(MSISDN, MAC) 또는 Manufacture ID가 변경되었으나 M2M 포털을 통해 갱신 등록되지 않으면 M2M 단말 등록 절차는 Fail 처리 된다.\n
+	[정상 등록] 등록 요청이 정상적으로 수행된 경우 더 이상 등록 절차를 수행 하지 않는다.\n
+	[재 등록 요청] OMP 에 등록 과정을 수행한 단말에 대해서 전원을 껐다(Off) 켜(On)는 경우에는 재 등록을 수행할 필요가 없다. 단, 할당 받은 GW ID, Auth Key, Domain Code 등의 값이 유실되거나 삭제된 경우에는 재 등록 요청을 수행 할 수 있다.\n
+	[할당 Field 사용] Auth Key 값은 GMMP Common Header의 Auth_key 필드에 설정되며, Domain Code, GW ID 값은 Message Type별 Field 정의영역 부분에 설정되어 반환 된다. 이후 모든 메시지에는 반드시 OMP에서 할당된 Auth Key, GW ID 값을 해당 메시지에 이용되어야 한다.\n
+	[중복 등록 허용] 이미 등록되어 있는 M2M GW에 대해 재 등록 요청을 하는 경우에는 중복 등록이 허용이 된다. 이때 전달되는 Auth Key, GW ID 값은 이전의 등록절차에서 할당 되었던 동일한 값이 전달된다.\n
+	[M2M GW Timeout] M2M GW에서 OMP로 Request 명령을 전송한 뒤 응답이 없는 경우 Timeout 처리를 수행한다. 이 값은 Profile 정보에 포함 되어 있으며, OMP의 제어 명령에 의해서 변경 될 수 있다. (Timeout은 default로 최소 30sec 이상으로 설정되어야 한다)\n
+
+전송 패킷 : @ref Struct_Reg_GW.h, @ref Struct_Reg_Device.h 참조
+
+ * @ingroup GMMP_Registration_Operation
+ * @{
+ */
+
+/**
+ *
+ *@brief GW,Device 등록 절차 진행 명령 함수, 옵션으로 암호화 진행 유무 Flag가 있다.\n
+ 등록 절차는 현장에 설치된 M2M GW가 서비스 수행을 시작하기 위해서 최초로 수행해야 하는 절차이다.\n
+ 등록 절차를 통해 GW ID, Device ID를 OMP로 부터 제공 받는다.\n
+ *@warning GW 등록 절차가 진행되어야만 Device 등록 절차를 진행 할 수 있다.\n
+ * @param pszGWID OMP에서 제공받은 GW ID, NULL이면 GW 등록, 아니면 Device 등록 절차를 진행한다.\n
+ * @param pszManufactureID M2M GW,Device의 Manufacture ID이다.\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+Ex) 공장 제조 Serial No. : “AVB12132SET23DT”, “SKTSerial“\n
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ *
+ * @code GW/Device 등록 샘플 코드 (Sample_Registration 샘플 참조)
+
+int GW_Reg()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_Reg(NULL, pszGWMFID, false);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Reg Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Device_Reg()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_Reg(GetGWID(), pszDeviceMFID, false);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Reg Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Init()
+{
+	if(Initialize(szServerIP, nServerPort, pszDomainCode , pszGWAuthID, GMMP_ON_LOG, nErrorLevel, GMMP_NETWORK_ALYWAYS_OFF, "Log") != 0)
+	{
+		printf("Server Connect Error\n");
+
+		return 1;
+	}
+
+	SetCallFunction( (void*)Recv);
+
+	return 0;
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	if(GW_Reg() != 0)
+	{
+		printf("GW_Reg Error");
+		return -1;
+	}
+
+	if(Device_Reg() != 0)
+	{
+		printf("Device_Reg Error");
+		return -1;
+	}
+
+	return 0;
+
+}
+ @endcode
+ */
+
+int GO_Reg(const char* pszGWID,
+const char* pszManufactureID);
+/**
+ * @}
+ */
+
+/**
+ * @defgroup GMMP_DeRegistration_Operation M2M GW/Device 등록 해지
+ *해지 절차는 M2M Device가 더 이상 서비스를 수행하지 않음을 OMP에 알리는 절차로서 Device ID값이 OMP에 반납된다.\n
+ * GMMP_Device_DeRegistration_Request 메시지를 이용하여 해지 요청을 수행하고, \n
+ * GMMP_Device_DeRegistration_Response 메시지를 통해 해지 결과를 받는다.\n
+ * 현장에서 문제가 생기거나 또는 철거하는 경우 M2M 포털을 통해서 해지(DeRegistration)할 수 있다.\n
+ * 이때 M2M GW가 DeRegistration 하는 경우 하위 Device 정보도 모두 해제 된다.
+
+전송 패킷 : @ref Struct_DeReg_GW.h, @ref Struct_DeReg_Device.h 참조
+
+ * @ingroup GMMP_DeRegistration_Operation
+ * @{
+ */
+
+/**
+ *@brief GW,Device 해지 절차 진행 명령 함수
+ *@brief 해지 절차는 등록 절차를 통해 OMP로 부터 제공 받은 GW ID, Device ID를 해지 한다.
+ *@warning GW 등록 절차가 진행되어야만 Device 등록 절차를 진행 할 수 있다. GW 등록 해제 절차를 진행할 경우 하위 Device에 대해 자동 해지가 된다.
+ *@warning OMP 연동을 통해 서비스를 재개하기 위해서는 다시 OMP를 통해 Auth Key, GW ID를 할당 받아야 한다.
+ * @param pszGWID OMP로 제공 받은 GW ID값.
+ * @param pszDeviceID OMP로 제공 받은 Device ID값.
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ *
+ * @code GW/Device 등록 해지 샘플 코드 (Sample_DeRegistration 샘플 참조)  샘플코드 참조
+ *
+int GW_DeReg()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_DeReg(pszGWID, NULL);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Reg Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Device_DeReg()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_DeReg(GetGWID(), pszDeviceID);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Reg Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Init()
+{
+	if(Initialize(szServerIP, nServerPort, pszDomainCode , pszGWAuthID, GMMP_ON_LOG, nErrorLevel, GMMP_NETWORK_ALYWAYS_OFF, "Log") != 0)
+	{
+		printf("Server Connect Error\n");
+
+		return 1;
+	}
+
+	SetCallFunction( (void*)Recv);
+	SetAuthKey(pszAuthKey);
+	SetGWID(pszGWID);
+
+	return 0;
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	if(GW_DeReg() != 0)
+	{
+		printf("GW_Reg Error");
+		return -1;
+	}
+
+	if(Device_DeReg() != 0)
+	{
+		printf("Device_Reg Error");
+		return -1;
+	}
+
+	return 0;
+
+}
+ @endcode
+ */
+int GO_DeReg(const char* pszGWID,
+		const char* pszDeviceID);
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup GMMP_ProfileInfo_Operation M2M GW/Device Profile Info
+ *
+M2M GW에 Profile 정보가 없는 경우에 또는 일부 존재 하지 않는 경우 OMP에 Profile 정보를 요청한다.\n
+Profile 정보가 미리 설정되어 있는 경우에는 Profile 요청 절차를 수행하지 않는다.\n
+M2M GW의 등록 절차 또는 M2M Device 등록 절차 이후에 수행될 수 있다. \n
+또한 OMP로부터 제어 명령(@ref GMMP_Control_Operation, Control Type @ref CONTROL_Profile_Reset)을 수신한 경우 Profile 정보 Operation을 수행한다.
+
+전송 패킷 : @ref Struct_ProfileInfo.h 참조
+
+ * @ingroup GMMP_ProfileInfo_Operation
+ * @{
+ */
+/**
+ * @param pszGWID OMP로 제공 받은 GW ID값.
+ * @param pszDeviceID OMP로 제공 받은 Device ID값.
+ * @param nTID T-ID는 M2M GW와 OMP 간의 트랜잭션을 구분하기 위한 값으로서 Request 요청하는 곳에서 할당하며 Response 받은 곳에서는 해당 T-ID 값을 그대로 반환한다.\n
+				M2M GW와 OMP에서 T-ID 사용 범위는 다음과 같다.\n
+				※ M2M GW T-ID : 0 ~ 99,999 (10만개)\n
+				※ OMP T-ID : M2M GW가 사용 이외의 값\n
+ *
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ * @code GW/Device Profile Info 요청 샘플 코드 (Sample_Profile 샘플 참조)
+
+int GW_Profile()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_Profile(pszGWID, NULL, nTID);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Profile Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Device_Profile()
+{
+	int nRet = GMMP_SUCCESS;
+
+	nRet = GO_Profile(pszGWID, pszDeviceID, nTID);
+
+	if(nRet < 0)
+	{
+		printf("GW GO_Profile Error : %d\n", nRet);
+
+		return 1;
+	}
+
+	return 0;
+}
+
+int Init()
+{
+	if(Initialize(szServerIP, nServerPort, pszDomainCode , pszGWAuthID, GMMP_ON_LOG, nErrorLevel, GMMP_NETWORK_ALYWAYS_OFF, "Log") != 0)
+	{
+		printf("Server Connect Error\n");
+
+		return 1;
+	}
+
+	SetCallFunction( (void*)Recv);
+	SetAuthKey(pszAuthKey);
+
+	return 0;
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	if(GW_Profile() != 0)
+	{
+		printf("GW_Profile Error");
+		return -1;
+	}
+
+	if(Device_Profile() != 0)
+	{
+		printf("Device_Profile Error");
+		return -1;
+	}
+
+	return 0;
+
+}
+ @endcode
+ */
+int GO_Profile(const char* pszGWID,
+		const char* pszDeviceID,
+		const long nTID);
+/**
+ * @}
+ */
+
+/**
+ * @defgroup GMMP_Delivery_Operation M2M GW/Device 주기 보고
+ *
+M2M 단말에서 수집된 데이터를 OMP로 전송하는 절차이다.\n
+수집된 데이터를 전송하는 M2M 단말은 반드시 등록 절차를 통해 OMP에 등록되어 있어야 한다.\n
+수집된 데이터는 타입에 따라서 수집 데이터(collect data), 장애 데이터(alarm data), 이벤트 데이터(event data), 장애 해제(alarm clear) 데이터 등으로 분류 된다.\n
+이 값에 대한 설정은 cReportType 변수의 Report Type에 따라 구분된다. @ref Define_Delivery.h 참조
+
+전송 패킷 : @ref Struct_Delivery.h 참조
+
+ * @ingroup GMMP_Delivery_Operation
+ * @{
+ */
+/**
+ *
+ * @param pszGWID OMP로 제공 받은 GW ID값.
+ * @param pszDeviceID OMP로 제공 받은 Device ID값.
+ * @param cReportType Report Type\n @ref Define_Delivery.h 참조
+ - 0x01 : collect data\n
+ - 0x02 : alarm data\n
+ - 0x03 : event data\n
+ - 0x04 : alarm clear\n
+ *
+ * @param cMediaType Message Body의 미디어 타입을 의미 @ref Struct_Delivery.h 참조
+ * @param pszMessageBody Data[2048 Byte]
+ * @param nTotalCount Message Body에 전달될 내용이 2048 Bytes를 초과할 경우 여러 개의 메시지로 전송하며 전체 메시지 개수를 표시 한다
+ * @param nCurrentCount 여러 개의 메시지로 전송되는 경우 현재 메시지의 순서로서 1에서 Total Count까지의 값이 기록 된다.
+  * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+
+ @code GW/Device 주기 보고 샘플 코드 (Sample_Delivery 샘플 참조)
+int GW_Delivery()
+{
+	int nRet = 0;
+	int nTotalCount = 0;
+	int nLoop = 0;
+	int nMessageBodyLen = strlen(pszMessage);
+
+	if(nMessageBodyLen < MAX_MSG_BODY)
+	{
+		nTotalCount = 1;
+	}
+	else
+	{
+		nTotalCount = nMessageBodyLen/MAX_MSG_BODY;
+
+		if(nMessageBodyLen%MAX_MSG_BODY > 0)
+		{
+			nTotalCount++;
+		}
+	}
+
+	int nMessagePos = 0;
+	int nSendLen = 0;
+	int nSendedLen = nMessageBodyLen;
+
+	char szMessage[MAX_MSG_BODY];
+
+	for(nLoop = 1 ; nLoop <= nTotalCount ; nLoop++)
+	{
+		memset(szMessage, 0, sizeof(szMessage) );
+
+		if(nSendedLen >= MAX_MSG_BODY)
+		{
+			nSendLen = MAX_MSG_BODY;
+		}
+		else
+		{
+			nSendLen = nSendedLen;
+		}
+
+		memcpy(szMessage, pszMessage+nMessagePos, nSendLen);
+
+		printf("Send Message Len = %d\n", strlen(szMessage) );
+
+		nRet = GO_Delivery(pszGWID, NULL, DELIVERY_COLLECT_DATA,  0x01, szMessage);
+
+		if(nRet < 0)
+		{
+			printf("GO_Delivery Error : %d\n", nRet);
+
+			return 1;
+		}
+
+		nSendedLen -= nSendLen;
+		nMessagePos+= nSendedLen;
+	}
+
+	return 0;
+}
+
+int Device_Delivery()
+{
+	int nRet = 0;
+	int nTotalCount = 0;
+	int nLoop = 0;
+	int nMessageBodyLen = strlen(pszMessage);
+
+	if(nMessageBodyLen < MAX_MSG_BODY)
+	{
+		nTotalCount = 1;
+	}
+	else
+	{
+		nTotalCount = nMessageBodyLen/MAX_MSG_BODY;
+
+		if(nMessageBodyLen%MAX_MSG_BODY > 0)
+		{
+			nTotalCount++;
+		}
+	}
+
+	int nMessagePos = 0;
+	int nSendLen = 0;
+	int nSendedLen = nMessageBodyLen;
+
+	char szMessage[MAX_MSG_BODY];
+
+	for(nLoop = 1 ; nLoop <= nTotalCount ; nLoop++)
+	{
+		memset(szMessage, 0, sizeof(szMessage) );
+
+		if(nSendedLen >= MAX_MSG_BODY)
+		{
+			nSendLen = MAX_MSG_BODY;
+		}
+		else
+		{
+			nSendLen = nSendedLen;
+		}
+
+		memcpy(szMessage, pszMessage+nMessagePos, nSendLen);
+
+		printf("Send Message Len = %d\n", strlen(szMessage) );
+
+		nRet = GO_Delivery(pszGWID, pszDeviceID, DELIVERY_COLLECT_DATA,  0x01, szMessage);
+
+		if(nRet < 0)
+		{
+			printf("GO_Delivery Error : %d\n", nRet);
+
+			return 1;
+		}
+
+		nSendedLen -= nSendLen;
+		nMessagePos+= nSendedLen;
+	}
+
+	return 0;
+}
+
+int Init()
+{
+	if(Initialize(szServerIP, nServerPort, pszDomainCode , pszGWAuthID, GMMP_ON_LOG, nErrorLevel, GMMP_NETWORK_ALYWAYS_OFF, "Log") != 0)
+	{
+		printf("Server Connect Error\n");
+
+		return 1;
+	}
+
+	SetCallFunction( (void*)Recv);
+	SetAuthKey(pszAuthKey);
+	SetGWID(pszGWID);
+
+
+	return 0;
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	if(GW_Delivery() != 0)
+	{
+		printf("GW_Delivery Error");
+		return -1;
+	}
+
+	if(Device_Delivery() != 0)
+	{
+		printf("Device_Delivery Error");
+		return -1;
+	}
+
+	return 0;
+
+}
+ @endcode
+ */
+int GO_Delivery(const char* pszGWID,
+		const char* pszDeviceID,
+		const char cReportType,
+		const char cMediaType,
+		const char* pszMessageBody);
+/**
+ * @}
+ */
+/**
+ * @defgroup GMMP_Control_Operation M2M GW/Device 단말 제어
+ * M2M 단말에 대한 특정 제어 명령을 전달하기 위한 절차로서 GMMP에서는 2가지 제어 방식을 지원한다.\n
+방식 1) TCP Always On 세션을 가지고 있는 M2M 단말인 경우 해당 세션을 통해 직접 제어 메시지를 전달하는 방식이다.\n
+방식 2) SMS 메시지를 통해 제어 명령을 전송하는 방식이다.\n
+
+※ Always ON 단말도 TCP 세션이 끊어져 있는 경우에는 SMS 메시지를 통한 제어 명령을 수신할 수 있다.\n
+
+일반적으로 단말 제어 절차는 3단계로 이루어져 있다.\n
+1단계는 단말 제어 메시지를 통해 단말에게 제어 명령을 전달하고 응답하는 절차이다.\n
+2단계는 Control Type 에 따른 부가적인(Optional) 절차로서 Profile 정보, 큰 제어 데이터, FTP 정보, Remote Access 정보등을 획득하는 절차이다.\n
+3단계는 제어 결과를 플랫폼으로 통보하는 절차로서 단말 제어 결과 보고 메시지를 통해 제어 결과를 플랫폼으로 통보하고 그에 대한 결과를 수신한다.\n
+
+제어절차시 Control Type 에 따라 M2M GW의 Reboot 절차가 수행될 수 있다.\n
+
+단말 제어 메시지의 Control Type은 @ref Define_Control.h의 메시지 타입이 존재하며, 아래의 Control Type인 경우 부가 절차를 따른다.\n
+1. @ref CONTROL_Profile_Reset인 경우 @ref GMMP_ProfileInfo_Operation의 기능을 연계\n
+2. @ref CONTROL_FW_Download, @ref  CONTROL_App_Download인 경우 @ref GMMP_FTP_Operation의 기능을 연계\n
+3. @ref CONTROL_Remote_Access인 경우 @ref GMMP_Remote_Operation의 기능을 연계\n
+4. @ref CONTROL_Multimedia_Control_Start인 경우 @ref GMMP_Multimedia_Operation의 기능을 연계
+
+전송 패킷 : @ref Struct_Control.h @ref Struct_Control_Opt.h참조
+
+ * @ingroup GMMP_Control_Operation
+ * @{
+ */
+/**
+ *
+ * @param pszGWID OMP로 제공 받은 GW ID값.
+ * @param pszDeviceID OMP로 제공 받은 Device ID값.
+ * @param nTID T-ID는 M2M GW와 OMP 간의 트랜잭션을 구분하기 위한 값으로서 Request 요청하는 곳에서 할당하며 Response 받은 곳에서는 해당 T-ID 값을 그대로 반환한다.\n
+				M2M GW와 OMP에서 T-ID 사용 범위는 다음과 같다.\n
+				※ M2M GW T-ID : 0 ~ 99,999 (10만개)\n
+				※ OMP T-ID : M2M GW가 사용 이외의 값\n
+ * @param cControlType Data Collect Period & Time Setting , Reboot, Configuration, Time Sync, Change Server IP/Port(OMP), HB Period, etc\n
+ * 				@ref Define_Operation.h 참조
+ * @param cResultCode Result Code (0x00 : Success, other : Fail Reason)\n
+			@ref OMPErrorCode.h 참조
+ *
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ @code GW/Device 제어 샘플 코드 (Sample_Control_TCP_AlwaysOn 샘플 참조)
+
+int Recv(GMMPHeader* pstGMMPHeader, void* pBody)
+{
+	U8 cMessageType = pstGMMPHeader->ucMessageType;
+
+	if(cMessageType  == OPERATION_PROFILE_RSP)
+	{
+		stProfileRspHdr* pstRspHdr =(stProfileRspHdr*) pBody;
+
+		if(pstRspHdr->ucResultCode != 0x00)
+		{
+			printf("ResultCode  : %x - %s\n", pstRspHdr->ucResultCode, GetStringtoOMPErrorCode(pstRspHdr->ucResultCode));
+
+			return 1;
+		}
+
+		if(strlen((char*)pstRspHdr->usDeviceID) <= 0) //GW Profile 조회
+		{
+			//주기값 재설정
+			//pstRspHdr->unHeartbeatPeriod;
+			//pstRspHdr->unReportOffset;
+			//pstRspHdr->unReportPeriod;
+			//pstRspHdr->unResponseTimeout;
+
+
+			ConvertInt cvtInt;
+			memcpy(&cvtInt.usInt, pstRspHdr->unHeartbeatPeriod, sizeof(pstRspHdr->unHeartbeatPeriod) );
+
+			cvtInt.sU8 = ltobi(cvtInt.sU8);
+
+			//Profile 요청 수신 값에 Heartbeat 주기 값으로 변경
+			if(cvtInt.sU8 > 0)
+			{
+				nTimerSec = cvtInt.sU8;
+			}
+		}
+		else  //Device Profile 조회
+		{
+			//주기값 재설정
+			//pstRspHdr->unReportOffset;
+			//pstRspHdr->unReportPeriod;
+			//pstRspHdr->unResponseTimeout;
+
+		}
+	}
+	else if(pstGMMPHeader->ucMessageType == OPERATION_HEARTBEAT_RSP)
+	{
+		stHeartBeatMsgReqHdr* pstRspHdr =(stHeartBeatMsgReqHdr*) pBody;
+
+
+		return 0;
+	}
+
+	return 0;
+}
+
+void* TimerThread()
+{
+	//생략
+}
+
+void* TCPReadThread(void *data)
+{
+	//생략
+}
+
+
+int Init()
+{
+	//생략
+}
+
+int GW_Profile()
+{
+	//생략
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	pthread_t thread_id = 0;
+	pthread_t timer_id = 0;
+
+	pthread_create(&thread_id, NULL, TCPReadThread, NULL);
+	pthread_create(&timer_id, NULL, TimerThread, NULL);
+
+	pthread_join(thread_id, NULL);
+	pthread_join(timer_id, NULL);
+	return 0;
+
+}
+ @endcode
+ */
+ int GO_Control(const char* pszGWID,
+ 		const char* pszDeviceID,
+ 		long nTID,
+ 		const char cControlType,
+ 		const char cResultCode);
+/**
+ * @}
+ */
+/**
+ * @defgroup GMMP_Notification_Operation M2M GW/Device 제어 결과 보고
+ 전송 패킷 : @ref Struct_Notification.h 참조
+ * 제어 결과를 플랫폼으로 통보하고 그에 대한 결과를 수신한다.
+ */
+/**
+* @ingroup GMMP_Notification_Operation
+* @{
+*/
+/**
+ *
+  * @param pszGWID OMP로 제공 받은 GW ID값.
+ * @param pszDeviceID OMP로 제공 받은 Device ID값.
+ * @param cControlType 단말 제어 메시지에 수신한 값과 동일한 값을 사용한다
+ * @param cResultCode Result Code (0x00 : Success, other : Fail Reason)
+ * @param pszMessageBody Data[2048 Byte]
+ * @param nMessageBodySize pszMessageBody의 크기
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ *
+ @code GW/Device 제어 결과 보고 샘플 코드 (Sample_Control_TCP_AlwaysOn 샘플 참조)
+
+int Recv(GMMPHeader* pstGMMPHeader, void* pBody)
+{
+	U8 cMessageType = pstGMMPHeader->ucMessageType;
+
+	if(cMessageType  == OPERATION_PROFILE_RSP)
+	{
+		stProfileRspHdr* pstRspHdr =(stProfileRspHdr*) pBody;
+
+		if(pstRspHdr->ucResultCode != 0x00)
+		{
+			printf("ResultCode  : %x - %s\n", pstRspHdr->ucResultCode, GetStringtoOMPErrorCode(pstRspHdr->ucResultCode));
+
+			return 1;
+		}
+
+		if(strlen((char*)pstRspHdr->usDeviceID) <= 0) //GW Profile 조회
+		{
+			//주기값 재설정
+			//pstRspHdr->unHeartbeatPeriod;
+			//pstRspHdr->unReportOffset;
+			//pstRspHdr->unReportPeriod;
+			//pstRspHdr->unResponseTimeout;
+
+
+			int nHeartBeat = Char2int((char*)pstRspHdr->unHeartbeatPeriod); //수신받은 Heartbeat 주기 값을 확인.
+
+			//Profile 요청 수신 값에 Heartbeat 주기 값으로 변경
+			if(nHeartBeat > 0)
+			{
+				nTimerSec = nHeartBeat;
+			}
+		}
+		else  //Device Profile 조회
+		{
+			//주기값 재설정
+			//pstRspHdr->unReportOffset;
+			//pstRspHdr->unReportPeriod;
+			//pstRspHdr->unResponseTimeout;
+
+		}
+	}
+	else if(pstGMMPHeader->ucMessageType == OPERATION_HEARTBEAT_RSP)
+	{
+		stHeartBeatMsgReqHdr* pstRspHdr =(stHeartBeatMsgReqHdr*) pBody;
+
+
+		return 0;
+	}
+
+	return 0;
+}
+
+void* TimerThread()
+{
+	//생략
+}
+
+void* TCPReadThread(void *data)
+{
+	//생략
+}
+
+
+int Init()
+{
+	//생략
+}
+
+int GW_Profile()
+{
+	//생략
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	pthread_t thread_id = 0;
+	pthread_t timer_id = 0;
+
+	pthread_create(&thread_id, NULL, TCPReadThread, NULL);
+	pthread_create(&timer_id, NULL, TimerThread, NULL);
+
+	pthread_join(thread_id, NULL);
+	pthread_join(timer_id, NULL);
+	return 0;
+
+}
+ @endcode
+ */
+int GO_Notifi(const char* pszGWID,
+		const char* pszDeviceID,
+		const char cControlType,
+		const char cResultCode,
+		const char* pszMessageBody,
+		const int nMessageBodySize);
+/**
+ * @}
+ */
+
+/**
+ * @defgroup GMMP_Heartbeat_Operation M2M GW/Device Heartbeat
+ TCP Always On 단말인 경우 해당 세션을 감시하기 위해 주기적으로 Heartbeat 메시지를 전송한다.\n
+ M2M 단말은 Profile 정보의 Heartbeat Period 값을 주기로 전송하며, 0인 경우에는 세션을 유지하지 않는다.
+
+ 전송 패킷 : @ref Struct_Heartbeat.h 참조
+
+ * @ingroup GMMP_Heartbeat_Operation
+ * @{
+ */
+
+/**
+ *
+ * @param pszGWID GW ID
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ @code GW/Device Heartbeat 보고 샘플 코드 (Sample_Control_TCP_AlwaysOn 샘플 참조)
+
+int Recv(GMMPHeader* pstGMMPHeader, void* pBody)
+{
+	U8 cMessageType = pstGMMPHeader->ucMessageType;
+
+	if(cMessageType  == OPERATION_PROFILE_RSP)
+	{
+		//생략
+	}
+	else if(pstGMMPHeader->ucMessageType == OPERATION_HEARTBEAT_RSP)
+	{
+		stHeartBeatMsgReqHdr* pstRspHdr =(stHeartBeatMsgReqHdr*) pBody;
+
+
+		return 0;
+	}
+
+	return 0;
+}
+
+void* TimerThread()
+{
+	int nCount = 0;
+	while(bTimer == true)
+	{
+		if(strlen(pszGWAuthID) > 0 && strlen(pszAuthKey) > 0  )
+		{
+			SetTID(GetTID()+1);
+
+			int nRet = GMMP_SetHB(pszGWAuthID, pszAuthKey, pszDomainCode, pszGWID);
+			if(nRet != GMMP_SUCCESS)
+			{
+				if(nCount > 2)
+				{
+					break;
+				}
+				nCount++;
+			}
+		}
+
+		sleep(nTimerSec);
+	}
+
+	return NULL;
+}
+
+void* TCPReadThread(void *data)
+{
+	//생략
+}
+
+
+int Init()
+{
+	//생략
+}
+
+int GW_Profile()
+{
+	//생략
+}
+
+int main()
+{
+	if(Init() != 0)
+	{
+		printf("Init Error");
+		return -1;
+	}
+
+	pthread_t thread_id = 0;
+	pthread_t timer_id = 0;
+
+	pthread_create(&thread_id, NULL, TCPReadThread, NULL);
+	pthread_create(&timer_id, NULL, TimerThread, NULL);
+
+	pthread_join(thread_id, NULL);
+	pthread_join(timer_id, NULL);
+	return 0;
+
+}
+
+ @endcode
+ */
+int GO_HB(const char* pszGWID);
+/**
+ * @}
+ */
+
+int OG_Reg_Recv(GMMPHeader* pstGMMPHeader, stGwRegistrationRspHdr* pstGWBody, stDeviceRegistrationRspHdr* pstDeviceBody);
+int OG_DeReg_Recv(GMMPHeader* pstGMMPHeader, stGwDeRegistrationRspHdr* pstGWBody, stDeviceDeRegistrationRspHdr* pstDeviceBody);
+int OG_Profile_Recv(GMMPHeader* pstGMMPHeader, stProfileRspHdr* pstBody);
+int OG_Delivery_Recv(GMMPHeader* pstGMMPHeader, stPacketDeliveryRspHdr* pstBody);
+int OG_Ctrl_Recv(GMMPHeader* pstGMMPHeader, stControlReqHdr* pstBody);
+int OG_HB_Recv(GMMPHeader* pstGMMPHeader, stHeartBeatMsgRspHdr* pstBody);
+int OG_Notifi_Recv(GMMPHeader* pstGMMPHeader, stNotificationRspHdr* pstBody);
+
+/**
+ * @brief GMMP 라이브러리 초기화 및 기본 정보 입력
+ * @param serverIp 접속할 서버 IP, 4 byte array. @ref g_serverIp에 저장된다,
+ * @param nPort 접속할 서버 port, @ref g_nServerPort에 저장된다.
+ * @param pszDomainCode OMP Portal을 통해 등록된 서비스 코드, @ref g_szDomainCode에 저장된다,
+ * @param pszGWAuthID M2M GW 의 Serial Number 값이며, MSISDN 또는 MAC Address값을 사용할 수도 있다. @ref g_szAuthID에 저장된다.
+ * @param nGMMPMode 로그 저장 유무, GMMP_OFF_LOG, GMMP_ON_LOG
+ * @param nErrorLevel	로그 출력 레벨
+ * @param nNetwrokType 통신 타입
+ * @param mac MAC Address. 6 byte array.
+ * @return 성공 : GMMP_SUCCESS, 실패: 1이상 , 에러코드 참조
+ */
+int Initialize(byte* serverIp,
+		const int nPort,
+		const char* pszDomainCode,
+		const char* pszGWAuthID,
+		byte* mac);
+
+/**
+* @brief GMMP 라이브러리 Uninitialize
+*/
+void Uninitialize();
+
+/**
+ * @brief TCP Always On 에서 사용하는 함수\n
+ * Thread를 생성 하고 이 함수를 연결하여 사용한다.
+ * @param pstGMMPHeader @ref GMMPHeader 구조체 포인트
+ * @param pBody Body 메시지 구조체 포인트
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GetReadData(GMMPHeader* pstGMMPHeader, void** pBody);
+
+/**
+ *char 타입의 데이터를  int로 변환한다.
+ * @param pBuffer in
+ * @param nSize in pBuffer size
+ * @return int
+ */
+long Char2int(void* pBuffer, int nSize);
+
+/**
+ *char 타입의 데이터를  short로 변환한다.
+ * @param pBuffer
+ * @param nSize
+ * @return
+ */
+int Char2short(void* pBuffer, int nSize);
+
+/**
+ *@fn void InitMemory();
+ *@brief 내부 변수 초기화
+ */
+void InitMemory();
+
+/**
+ * @brief OMP로 제공 받은 AuthKey값을 저장하는 함수
+ * @param pszAuthKey OMP로 부터 제공 받은 Auth Key 값
+ */
+void SetAuthKey(const char* pszAuthKey);
+/**
+ @brief 저장된  AuthKey
+ * @return 저장된 Auth Key
+ */
+char* GetAuthKey();
+
+
+/**
+ * @brief OMP로 제공 받은 GW ID값을 저장하는 함수
+ * @param pszGWID OMP로 부터 제공 받은 GW ID 값
+ */
+void SetGWID(const char* pszGWID);
+
+/**
+ *
+ * @return 저장된 GW ID
+ */
+char* GetGWID();
+
+/**
+ *@brief 서버 정보 및 GW Auth ID, DomainCode를 저장한다.
+ * @param serverIp Server IP
+ * @param nPort Server Port
+ * @param pszAuthID Auth ID
+ * @param pszDomainCode DomainCode
+ * @return 성공 : GMMP_SUCCESS, 실패 : LIB_PARAM_ERROR
+ */
+int SetServerInfo(byte* serverIp, int nPort, const char* pszAuthID, const char* pszDomainCode);
+
+/**
+ *@brief OMP서버로 부터 수신한 패킷을 제공할 콜백함수 저장 함수
+ * @param pCallFunctionName 콜백을 제공 받을 함수 포인트
+ */
+void SetCallFunction(int (* pCallFunctionName)(GMMPHeader* pstGMMPHeader, void* pstBody));
+
+#endif /* GMMP_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/Network.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,135 @@
+/** TCP Socket 통신을 위한 모듈
+ * @file Network.cpp
+ * @date 2015/07/20
+ * @version 0.0.1.0
+ **/
+
+#include "Client.h"
+
+#include "Network.h"
+#include "GMMP_Operation.h"
+
+int g_socket = -1;
+
+//Client client;
+Client *pClient = NULL;
+
+void CloseSocket()
+{
+	if (g_socket <= 0) return;
+
+	g_socket = -1;
+	
+	delete pClient;
+	pClient = NULL;
+
+	return;
+}
+
+int CheckSocket()
+{
+	return 0;
+}
+
+int Connect()
+{
+  int ret = GMMP_SUCCESS;
+
+  if(pClient == NULL)
+  	pClient = new Client;
+
+  //delay(2000);
+  infoln("Connecting...");
+  INFO("server ip: %d.%d.%d.%d:%d", g_serverIp[0], g_serverIp[1], g_serverIp[2], g_serverIp[3], g_nServerPort);
+
+  char szServerIp[24];
+  sprintf(szServerIp, "%d.%d.%d.%d", g_serverIp[0], g_serverIp[1], g_serverIp[2], g_serverIp[3]);
+
+  if (/*client.)*/pClient->connect((char *)szServerIp, g_nServerPort)) {
+    infoln("Connected!!");
+  } else {
+    infoln("connection failed!");
+    ret = SERVER_CONNECT_ERROR;
+  }
+
+	return ret;
+}
+
+int WriteTCP(char* pBuf, int nLen)
+{
+	DBG("WriteTCP(): %d", nLen);
+
+	if (pBuf == NULL || nLen <= 0) return LIB_PARAM_ERROR;
+
+  /*client.*/pClient->write(pBuf, nLen);
+
+	return GMMP_SUCCESS;
+}
+
+int ReadTCP(char* pBuf, const int nMaxlen)
+{
+  return ReadTCP2(pBuf, nMaxlen, 1);
+}
+
+int ReadTCPAsync(char* pBuf, const int nMaxlen);
+
+int ReadTCP2(char* pBuf, const int nMaxlen, byte blocking)
+{
+  //blocking = 0;
+
+  if (!blocking) {
+    return ReadTCPAsync(pBuf, nMaxlen);
+  }
+
+	if (pBuf == NULL || nMaxlen <= 0) return LIB_PARAM_ERROR;
+
+	int idx = 0;
+
+	memset(pBuf,  0, nMaxlen);
+
+	while(idx < nMaxlen)
+	{
+    if (/*client.*/pClient->available()) {
+		  pBuf[idx] = /*client.*/pClient->read();
+      DBG("%d", idx);
+      DBG(" %c",(byte)pBuf[idx]);
+      idx++;
+    } else {
+      debugln("E_WOULDBLOCK");
+      return E_WOULDBLOCK;
+    }
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int ReadTCPAsync(char* pBuf, const int nMaxlen)
+{
+	if (pBuf == NULL || nMaxlen <= 0) return LIB_PARAM_ERROR;
+
+	int idx = 0;
+  char val = -1;
+
+	memset(pBuf,  0, nMaxlen);
+
+	while(idx < nMaxlen)
+	{
+    val = /*client.*/pClient->read();
+
+    if (val != -1) {
+		  pBuf[idx++] = (byte)val;
+      
+      /*
+		  pBuf[idx] = (byte)val;
+      debug(idx);
+      debug(" ");
+      debugln((byte)pBuf[idx]);
+      idx++;
+      */
+    } else {
+      return E_WOULDBLOCK;
+    }
+	}
+
+	return GMMP_SUCCESS;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/Network.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,54 @@
+/** TCP Socket 통신을 위한 모듈
+ * @file Network.h
+ * @date 2015/07/20
+ * @version 0.0.1.0
+ **/
+
+#ifndef NETWORK_H_
+#define NETWORK_H_
+
+#include "Define.h"
+#include "GMMP_Util.h"
+
+/**
+ *@brief 서버와 연결된 TCP Socket을 닫는다.
+ */
+void CloseSocket();
+
+/**
+ * @brief TCP Socket을 연결한다.
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int Connect();
+
+/**
+ * @brief TCP Socket에 Write한다.
+ * @param pBuf Write 버퍼 포인트.
+ * @param nLen Write 버퍼 크기.
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int WriteTCP(char* pBuf, int nLen);
+
+/**
+ * @brief TCP Socket을 Read한다.
+ * @param _pBuf Read 버퍼 포인트.
+ * @param _nMaxlen Read 버퍼 최대 크기
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int ReadTCP(char* _pBuf, const int _nMaxlen);
+
+/**
+ * @brief TCP Socket을 Read한다. (Blocking/Non-blocking 지원)
+ * @param _pBuf Read 버퍼 포인트.
+ * @param _nMaxlen Read 버퍼 최대 크기
+ * @param blocking blocking: 1, non-blocking: 0
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int ReadTCP2(char* _pBuf, const int _nMaxlen, byte blocking);
+
+/**
+ * @brief TCP Socket 세션 유지를 확인한다. 세션이 연결이 되어 있지 않다면 연결을 시도한다.
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int CheckSocket();
+#endif /* NETWORK_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Client.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,63 @@
+#include "Client.h"
+#include "mbed.h"
+
+#include <stdint.h>
+
+Client::Client() : _len(0), _sock() {
+}
+
+Client::~Client() {
+}
+
+int Client::connect(const char *host, uint16_t port) {
+  return _sock.connect(host, port) == 0;
+}
+
+size_t Client::write(uint8_t b) {
+  //return write(&b, 1);
+  return write((char*)&b, 1); //lesmin
+}
+
+//size_t Client::write(const uint8_t *buf, size_t size) {
+size_t Client::write(char *buf, size_t size) {
+  _sock.set_blocking(false, 15000);
+  // NOTE: we know it's dangerous to cast from (const uint8_t *) to (char *),
+  // but we are trying to maintain a stable interface between the Arduino
+  // one and the mbed one. What's more, while TCPSocketConnection has no
+  // intention of modifying the data here, it requires us to send a (char *)
+  // typed data. So we belive it's safe to do the cast here.
+  //return _sock.send_all(const_cast<char*>((const char*) buf), size);
+  return _sock.send_all(buf, size);
+}
+
+int Client::available() {
+  if (_len > 0) { return 1; }
+  int ret = read(_buf, 1);
+  if (ret <= 0) { return 0; }
+  _len = ret;
+  return 1;
+}
+
+int Client::read() {
+  if (_len > 0) {
+    _len = 0;
+    return _buf[0];
+  }
+  return -1;
+}
+
+int Client::read(uint8_t *buf, size_t size) {
+  return _sock.receive_all((char*) buf, size);
+}
+
+void Client::flush() {
+  // does nothing, TCP stack takes care of this
+}
+
+void Client::stop() {
+  _sock.close();
+}
+
+uint8_t Client::connected() {
+  return _sock.is_connected();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Client.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,33 @@
+#ifndef Client_h
+#define Client_h
+
+#include "TCPSocketConnection.h"
+
+#include "Print.h"
+#include "Utility.h"
+
+/*
+ * TCP Client
+ */
+class Client : public Print {
+public:
+  Client();
+  ~Client();
+
+  virtual int connect(const char *host, uint16_t port);
+  virtual size_t write(uint8_t);
+  //virtual size_t write(const uint8_t *buf, size_t size);
+  virtual size_t write(char *buf, size_t size); //lesmin
+  virtual int available();
+  virtual int read();
+  virtual void flush();
+  virtual void stop();
+  virtual uint8_t connected();
+private:
+  virtual int read(uint8_t *buf, size_t size);
+  uint8_t _buf[1];
+  uint8_t _len;
+  TCPSocketConnection _sock;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Print.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,62 @@
+#include "Print.h"
+#include "mbed.h"
+
+#include <stdio.h>
+#include <string.h>
+
+size_t Print::write(const uint8_t* buf, size_t size) {
+  size_t ret = 0;
+  while (size--) {
+    ret += write(*buf++);
+  }
+  return ret;
+}
+
+size_t Print::print(const char* s) {
+  return write((const uint8_t*)s, strlen(s));
+}
+
+size_t Print::print(char c) {
+  return write(c);
+}
+
+size_t Print::print(int n) {
+  return print((long) n);
+}
+
+size_t Print::print(long n) {
+  char buf[8 * sizeof(long) + 1];
+  snprintf(buf, sizeof(buf), "%ld", n);
+  return print(buf);
+}
+
+// Digits are ignored for now
+size_t Print::print(double n, int digits) {
+  char buf[65];
+  snprintf(buf, sizeof(buf), "%g", n);
+  return print(buf);
+}
+
+size_t Print::println(const char* s) {
+  return print(s) + println();
+}
+
+size_t Print::println(char c) {
+  return print(c) + println();
+}
+
+size_t Print::println(int n) {
+  return print(n) + println();
+}
+
+size_t Print::println(long n) {
+  return print(n) + println();
+}
+
+size_t Print::println(double n, int digits) {
+  return print(n, digits) + println();
+}
+
+size_t Print::println() {
+  return print('\r') + print('\n');
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Print.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,26 @@
+#ifndef Print_h
+#define Print_h
+
+#include <stddef.h>
+#include <stdint.h>
+
+class Print {
+public:
+  size_t print(const char* s);
+  size_t print(char c);
+  size_t print(int n);
+  size_t print(long n);
+  size_t print(double n, int digits = 2);
+
+  size_t println(const char* s);
+  size_t println(char c);
+  size_t println(int n);
+  size_t println(long n);
+  size_t println(double n, int digits = 2);
+  size_t println();
+
+  virtual size_t write(uint8_t c) = 0;
+  virtual size_t write(const uint8_t* buf, size_t size);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Utility.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,11 @@
+#include "Utility.h"
+
+void delay(int ms) {
+  wait_ms(ms);
+}
+
+char* strdup(const char* s) {
+  char* ret = (char*) malloc(strlen(s) + 1);
+  if (ret == NULL) { return ret;}
+  return strcpy(ret, s);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Network/TCPclient/Utility.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,18 @@
+#ifndef UTILITY_H_
+#define UTILITY_H_
+
+#include "mbed.h"
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void delay(int ms);
+char* strdup(const char* s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Control/GMMP_Control.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,45 @@
+#include "GMMP_Control.h"
+
+int GMMP_Control_Req(Control_Req*  pControl_Req)
+{
+	if(pControl_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pControl_Req->header  , sizeof(pControl_Req->header) );
+	if(nRet == GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pControl_Req->header.usMessageLength, sizeof(pControl_Req->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8) - sizeof(pControl_Req->header) ;
+
+	return ReadTCP( (char*)&pControl_Req->body, nReadSize);
+}
+
+int GMMP_Control_Rsp(Control_Rsp*  pControl_Rsp)
+{
+	if(pControl_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pControl_Rsp, sizeof(Control_Rsp) );
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Control/GMMP_Control.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,30 @@
+ /** GMMP Operation 중 제어 명령 함수
+ * @file GMMP_Control.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+#ifndef GMMP_CONTROL_H_
+#define GMMP_CONTROL_H_
+
+#include "Network.h"
+#include "Struct_Control.h"
+
+
+
+/**
+ *@brief 제어 명령 수신 구조체
+ * @param pControl_Req @ref Control_Req참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Control_Req(Control_Req*  pControl_Req);
+
+/**
+ * @brief 제어 명령 확인 전송 구조체
+ * @param pControl_Req @ref Control_Rsp참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Control_Rsp(Control_Rsp*  pControl_Req);
+
+#endif /* GMMP_CONTROL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Control/Struct_Control.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,131 @@
+ /** GMMP Operation 중 제어 명령에 사용되는 구조체
+ * @file Struct_Control.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+#ifndef STRUCT_CONTROL_H_
+#define STRUCT_CONTROL_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+#include "Struct_Control_Opt.h"
+
+#pragma pack(1)
+
+/**
+ * @struct stControlReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에서 제어 명령 메시지를 전송하여 GMMP Lib에서 해당 메시지를 수신한다.
+  */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucControlType
+*@brief 제어 명령 구분자
+**아래 표 참조\n
+*@image html ControlDefine.png Control Type 표
+*@ref Define_Control.h 참조
+*/
+/**
+*@var usMessageBody
+*@brief Data [2048byte]
+*@ref Struct_Control_Opt.h 참조
+*/
+
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucControlType;
+	U8  usMessageBody[MAX_MSG_BODY];
+}stControlReqHdr; //Control Request
+
+/**
+* @struct stControlRspHdr
+* @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+* OMP에서 전송한 제어 메시지에 대한 응답을 전송한다.
+*/
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucControlType
+*@brief 제어 명령 구분자\n
+*@ref Define_Control.h 참조
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucControlType;
+	U8  ucResultCode;
+}stControlRspHdr; //Control Response
+
+
+/**
+* @struct Control_Req
+* @brief GMMP TCP Packet  구조 중 Request Control 제어 구조
+*  OMP에서 메시지를 전송하여 GMMP Lib에서 해당 메시지를 수신한다.
+*/
+typedef struct {
+/**
+*@var header
+*@brief
+*@ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stControlReqHdr 참조
+*/
+	GMMPHeader			header;
+	stControlReqHdr	body;
+}Control_Req;
+
+/**
+ * @struct Control_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Control 제어 구조
+ * OMP에서 전송한 제어 메시지에 대한 응답을 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stControlRspHdr 참조
+*/
+	GMMPHeader			header;
+	stControlRspHdr	body;
+}Control_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_CONTROL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Control/Struct_Control_Opt.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,128 @@
+ /** GMMP 제어 명령 중 Message Body의 값이 필요한 경우 사용되는 구조체
+ * @file Struct_Control_Opt.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+
+#ifndef STRUCT_CONTROL_OPT_H_
+#define STRUCT_CONTROL_OPT_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct TimeStamp
+ * @brief 제어 명령 중 CONTROL_Time_Sync 일 경우 usMessageBody의 값\n
+ * @ref stControlReqHdr 참조
+ * 제어 메시지 수신 데이터에 포함되어 있다.
+ */
+typedef struct {
+/**
+*@var unTimeStamp
+*@brief Unix Time
+*/
+	U8 unTimeStamp[4];
+}TimeStamp;
+
+/**
+ * @struct SignalPowerCheck
+ * @brief 제어 명령 중 CONTROL_Signal_Power_Check 일 경우 usMessageBody의 값\n
+ * @ref stNotificationReqHdr 참조
+ * 제어 메시지 수행 후 제어 메시지 결과 전송 시 포함한다.
+ */
+typedef struct {
+/**
+*@var unSignalPower
+*@brief RSSI(dBm), Ec/Lo(dB)
+*/
+	U8 unSignalPower[4];
+}SignalPowerCheck;
+
+/**
+ * @struct Diagnostic
+ * @brief 제어 명령 중 CONTROL_Diagnostic 일 경우 usMessageBody의 값\n
+ * @ref stNotificationReqHdr 참조
+ * 제어 메시지 수행 후 제어 메시지 결과 전송 시 포함한다.
+ */
+typedef struct {
+/**
+*@var ucStatusValue
+*@brief OK = 0, NOK = 1
+*/
+	U8 ucStatusValue;
+}Diagnostic;
+
+/**
+ * @struct StatusCheck
+ * @brief 제어 명령 중 CONTROL_Status_Check 일 경우 usMessageBody의 값\n
+ * @ref stNotificationReqHdr 참조
+ * 제어 메시지 수행 후 제어 메시지 결과 전송 시 포함한다.
+ */
+typedef struct {
+/**
+*@var ucOnOffValue
+*@brief OK = 0, OFF = 1
+*/
+/**
+*@var RunPauseValue
+*@brief Run = 0, Pause = 1
+*/
+
+	U8 ucOnOffValue;
+	U8 RunPauseValue;
+}StatusCheck;
+
+/**
+ * @struct FW_APP_Download_Update_Remote
+ * @brief 제어 명령 중 CONTROL_FW_Download, CONTROL_FW_Update, CONTROL_App_Download, CONTROL_App_Update, CONTROL_Remote_Access 일 경우 usMessageBody의 값\n
+ * @ref stNotificationReqHdr 참조
+ * 제어 메시지 수행 후 제어 메시지 결과 전송 시 포함한다.
+ */
+typedef struct {
+/**
+*@var unStartTime
+*@brief 다운로드 시작 시각, Unix Time(=POSIX time, 1970년 1월1일부터 경과된 초)을 사용한다.
+
+*/
+/**
+*@var unEndTime
+*@brief 다운로드 종료 시각, Unix Time(=POSIX time, 1970년 1월1일부터 경과된 초)을 사용한다.
+
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason)
+*@ref OMPErrorCode.h 참조
+*/
+
+	U8 unStartTime[4];
+	U8 unEndTime[4];
+	U8 ucResultCode;
+}FW_APP_Download_Update_Remote;
+
+
+/**
+ * @struct APP_Update
+ * @brief 제어 명령 중 CONTROL_App_Update 일 경우 usMessageBody의 값\n
+ * @ref stControlReqHdr 참조
+ * OMP에서 제어 명령 메시지를 전송하여 GMMP Lib에서 해당 메시지를 수신한다.
+ */
+typedef struct {
+/**
+*@var usFileName
+*@brief Application 파일 이름, App Name과 버전 정보를 합친 unique 이름  (예, AppName_1.0.0).
+*/
+/**
+*@var ucAppUpdateCommand
+*@brief App Activation = 0, App Deactivation = 1
+*/
+
+	U8 usFileName[LEN_FILE_NAME];
+	U8 ucAppUpdateCommand;
+}APP_Update;
+#pragma pack(0)
+
+#endif /* STRUCT_CONTROL_OPT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Delivery/GMMP_Delivery.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,44 @@
+#include "GMMP_Delivery.h"
+
+int GMMP_Delivery_Req(Delivery_Req* pDelivery_Req, int nPacketSize)
+{
+	if(pDelivery_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP((char*)pDelivery_Req, nPacketSize);
+}
+
+int GMMP_Delivery_Rsp(Delivery_Rsp* pDelivery_Rsp)
+{
+	if(pDelivery_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP((char*)&pDelivery_Rsp->header, sizeof(pDelivery_Rsp->header));
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pDelivery_Rsp->header.usMessageLength, sizeof(pDelivery_Rsp->header.usMessageLength));
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDelivery_Rsp->header);
+
+	return ReadTCP((char*)&pDelivery_Rsp->body, nReadSize);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Delivery/GMMP_Delivery.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,27 @@
+  /** GMMP Operation 중 주기보고 명령 함수
+ * @file GMMP_Delivery.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+#ifndef GMMP_DELIVERY_H_
+#define GMMP_DELIVERY_H_
+
+#include "Network.h"
+#include "Struct_Delivery.h"
+
+
+/**
+ * @param pControl_Req @ref Delivery_Req참조
+ *  @param nPacketSize 패킷 크기
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Delivery_Req(Delivery_Req*  pControl_Req, int nPacketSize);
+
+/**
+ * @param pControl_Rsp @ref Delivery_Rsp참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Delivery_Rsp(Delivery_Rsp*  pControl_Rsp);
+
+#endif /* GMMP_DELIVERY_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Delivery/Struct_Delivery.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,132 @@
+  /** GMMP Operation 중 주기보고 명령에 사용되는 구조체
+ * @file Struct_Delivery.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @ref GMMPHeader참조
+ **/
+
+#ifndef STRUCT_DELIVERY_H_
+#define STRUCT_DELIVERY_H_
+
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+
+/**
+ * @struct stPacketDeliveryReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에 주기 보고 명령을 전송 시 사용된다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucReportType
+*@brief 주기 보고 명령 구분자
+*@ref Define_Delivery.h 참조
+*/
+/**
+*@var ucMediaType
+*@brief 주기 보고 하는 데이터의 타입\n
+*아래 표 참조\n
+*@image html mediatype.JPG Media Type 표
+*/
+/**
+*@var usMessageBody
+*@brief Data [2048byte]
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucReportType;
+	U8  ucMediaType;
+	U8  usMessageBody[MAX_MSG_BODY];
+}stPacketDeliveryReqHdr; //Delivery Request
+
+/**
+ * @struct stPacketDeliveryRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 주기 보고 명령 응답 완료 수신 시 사용된다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+/**
+*@var unBackOffTime
+*@brief Result Code가 STATUS_NOT_ACCEPTABLE(OMP 과부하) 인 경우 해당 시간 값 만큼 이후 시간에 주기보고를 재시도 해야 한다.\n
+* Optional (선택적인 필드임을 의미한다)
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucResultCode;
+	U8  unBackOffTime[4];
+}stPacketDeliveryRspHdr; //Delivery Response
+
+/**
+ * @struct Delivery_Req
+ * @brief GMMP TCP Packet  구조 중 Request Delivery 구조체
+ *  OMP에 주기보고 데이터를 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stPacketDeliveryReqHdr 참조
+*/
+	GMMPHeader				header;
+	stPacketDeliveryReqHdr	body;
+}Delivery_Req;
+
+/**
+ * @struct Delivery_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Delivery 구조체
+ * OMP에 주기보고 데이터 전송 응답을 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stPacketDeliveryRspHdr 참조
+*/
+	GMMPHeader				header;
+	stPacketDeliveryRspHdr	body;
+}Delivery_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_DELIVERY_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/GMMP_Operation.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,957 @@
+/**
+ * @file GMMP_Operation.cpp
+ * @date 2015/07/20
+ * @version 0.0.1.0
+ **/
+
+/*
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <signal.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <stdarg.h>
+*/
+#include <time.h>
+
+#include "GMMP_Operation.h"
+
+long g_nTID = 0;
+int g_bLog = false;
+
+int g_nErrorLevel = GMMP_ERROR_LEVEL_ERROR;
+
+
+//GW/Device 등록/해지 Request
+int GMMP_SetReg(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszManufactureID)
+{
+  debugln("GMMP_SetReg()");
+
+	int nRet = GMMP_SUCCESS;
+
+	if(pszGWID == NULL) {
+		GwRegist_Req stRegist_Req;
+		memset(&stRegist_Req, 0 ,sizeof(stRegist_Req));
+
+		nRet = SetHeader((void*)&stRegist_Req, sizeof(stRegist_Req), 1,  1, OPERATION_GW_REG_REQ, pszAuthID, NULL);
+		if(nRet != GMMP_SUCCESS) {
+			return nRet;
+		}
+
+		memcpy(stRegist_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+		memcpy(stRegist_Req.body.usManufactureID, pszManufactureID, strlen(pszManufactureID));
+
+		GMMP_Trace(&stRegist_Req.header, &stRegist_Req.body);
+
+		nRet = GMMP_GW_Reg_Req((GwRegist_Req*)&stRegist_Req);
+
+	}
+	else
+	{
+    /*
+		if(pszAuthKey == NULL || strlen(pszAuthKey) > LEN_AUTH_KEY || strlen(pszGWID) > LEN_GW_ID)
+		{
+			return LIB_PARAM_ERROR;
+		}
+    */
+
+		DeviceRegist_Req stRegist_Req;
+
+		memset(&stRegist_Req, 0 ,sizeof(stRegist_Req));
+
+		nRet = SetHeader((void*)&stRegist_Req, sizeof(stRegist_Req), 1,  1, OPERATION_DEVICE_REG_REQ, pszAuthID, pszAuthKey);
+		if(nRet != GMMP_SUCCESS)
+		{
+			return nRet;
+		}
+
+		memcpy(stRegist_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+		memcpy(stRegist_Req.body.usGWID, pszGWID, strlen(pszGWID));
+		memcpy(stRegist_Req.body.usManufactureID, pszManufactureID, strlen(pszManufactureID));
+
+		GMMP_Trace(&stRegist_Req.header, &stRegist_Req.body);
+
+		nRet =  GMMP_Device_Reg_Req((DeviceRegist_Req*)&stRegist_Req);
+	}
+
+	return nRet;
+}
+
+int GMMP_SetDeReg(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID == NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nRet = GMMP_SUCCESS;
+
+	if(pszDeviceID == NULL) //GW DeReg
+	{
+		GwDeRegist_Req stDeRegist_Req;
+		memset(&stDeRegist_Req, 0 ,sizeof(stDeRegist_Req));
+
+		nRet = SetHeader((void*)&stDeRegist_Req,  sizeof(stDeRegist_Req), 1, 1,  OPERATION_GW_DEREG_REQ, pszAuthID, pszAuthKey);
+		if(nRet != GMMP_SUCCESS)
+		{
+			return nRet;
+		}
+
+		memcpy(stDeRegist_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+		memcpy(stDeRegist_Req.body.usGWID, pszGWID, strlen(pszGWID));
+
+		GMMP_Trace(&stDeRegist_Req.header, &stDeRegist_Req.body);
+
+		nRet  =  GMMP_GW_DeReg_Req((GwDeRegist_Req*)&stDeRegist_Req);
+	}
+	else
+	{
+		DeviceDeRegist_Req stDeviceDeRegist_Req;
+
+		memset(&stDeviceDeRegist_Req, 0 ,sizeof(stDeviceDeRegist_Req));
+
+		nRet = SetHeader((void*)&stDeviceDeRegist_Req, sizeof(stDeviceDeRegist_Req), 1,  1, OPERATION_DEVICE_DEREG_REQ, pszAuthID, pszAuthKey);
+		if(nRet != GMMP_SUCCESS)
+		{
+			return nRet;
+		}
+
+		memcpy(stDeviceDeRegist_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+		memcpy(stDeviceDeRegist_Req.body.usGWID, pszGWID, strlen(pszGWID));
+		memcpy(stDeviceDeRegist_Req.body.usDeviceID, pszDeviceID, strlen(pszDeviceID));
+
+		GMMP_Trace(&stDeviceDeRegist_Req.header, &stDeviceDeRegist_Req.body);
+
+		nRet =  GMMP_Device_DeReg_Req((DeviceDeRegist_Req*)&stDeviceDeRegist_Req);
+	}
+
+	return nRet;
+}
+
+//Profile Info Request
+int GMMP_SetProfile(const char* pszAuthID, const char* pszAuthKey, const char* pszDomainCode, const char* pszGWID, const char* pszDeviceID)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID ==NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nRet = GMMP_SUCCESS;
+
+	Profile_Req  stProfile_Req;
+
+	memset(&stProfile_Req, 0 ,sizeof(stProfile_Req));
+
+	nRet = SetHeader((void*)&stProfile_Req, sizeof(stProfile_Req), 1,  1, OPERATION_PROFILE_REQ, pszAuthID, pszAuthKey);
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(stProfile_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+	memcpy(stProfile_Req.body.usGWID, pszGWID, strlen(pszGWID));
+
+	if(pszDeviceID != NULL) //Device 판단
+	{
+		if(strlen(pszDeviceID) > LEN_DEVICE_ID) //Device ID 길이 확인
+		{
+		}
+		else
+		{
+			memcpy(stProfile_Req.body.usDeviceID, pszDeviceID, strlen(pszDeviceID));
+		}
+	}
+
+	GMMP_Trace(&stProfile_Req.header, &stProfile_Req.body);
+
+	nRet =  GMMP_Profile_Req(&stProfile_Req);
+
+	return nRet;
+}
+
+//수집 데이터 보고  Request
+int GMMP_SetDelivery(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID,
+		const char cReportType,
+		const char cMediaType,
+		const char* pszMessageBody,
+		const int nTotalCount,
+		const int nCurrentCount)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID == NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID
+			|| cReportType < 0x00
+			|| cReportType > 0x04
+			|| cMediaType < 0x01
+			|| pszMessageBody == NULL
+			|| strlen(pszMessageBody) > MAX_MSG_BODY)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nMessageBodyLen = strlen(pszMessageBody);
+
+  //debug("msgBodyLen = ");
+  //debugln(nMessageBodyLen);
+  DBG("msgBodyLen = %d", nMessageBodyLen);
+
+	int nRet = GMMP_SUCCESS;
+
+	Delivery_Req stDelivery_Req;
+
+  //debug(F("ReqSize = "));
+  //debugln(sizeof(stDelivery_Req));
+  DBG("ReqSize = %d", sizeof(stDelivery_Req));
+
+	memset(&stDelivery_Req, 0, sizeof(stDelivery_Req));
+
+	int PacketSize = sizeof(stDelivery_Req) - MAX_MSG_BODY + nMessageBodyLen ; //Message Body의 속성은 Optinal이다
+
+//  debug(F("pacektSize = "));
+//  debugln(PacketSize);
+	DBG("packetSize = %d", PacketSize);
+
+	nRet = SetHeader((void*)&stDelivery_Req, PacketSize, nTotalCount,  nCurrentCount, OPERATION_DELIVERY_REQ, pszAuthID, pszAuthKey);
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(stDelivery_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+	memcpy(stDelivery_Req.body.usGWID, pszGWID, strlen(pszGWID));
+
+	if(pszDeviceID != NULL) //Device 판단
+	{
+		if(strlen(pszDeviceID) > LEN_DEVICE_ID) //Device ID 길이 확인
+		{
+		}
+		else
+		{
+			memcpy(stDelivery_Req.body.usDeviceID, pszDeviceID, strlen(pszDeviceID));
+		}
+	}
+
+	stDelivery_Req.body.ucReportType = cReportType;
+	stDelivery_Req.body.ucMediaType = cMediaType;
+
+	if(nMessageBodyLen > 0)
+	{
+		memcpy(stDelivery_Req.body.usMessageBody, pszMessageBody, nMessageBodyLen);
+	}
+
+	GMMP_Trace(&stDelivery_Req.header, &stDelivery_Req.body);
+
+	nRet = GMMP_Delivery_Req(&stDelivery_Req, PacketSize);
+
+	return nRet;
+}
+
+//제어 수신 기능은 Thread에서 처리
+//제어 수신 보고  Response
+int GMMP_SetControl(const char* pszAuthID, const char* pszAuthKey, const char* pszDomainCode, const char* pszGWID, const char* pszDeviceID, const char cControlType, const char cResultCode)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID ==NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nRet = GMMP_SUCCESS;
+
+	Control_Rsp stControl_Rsp;
+
+	memset(&stControl_Rsp, 0 ,sizeof(stControl_Rsp));
+
+	nRet = SetHeader((void*)&stControl_Rsp, sizeof(stControl_Rsp), 1,  1, OPERATION_CONTROL_RSP, pszAuthID, pszAuthKey);
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(stControl_Rsp.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+	memcpy(stControl_Rsp.body.usGWID, pszGWID, strlen(pszGWID));
+
+	if(pszDeviceID != NULL) //Device 판단
+	{
+		if(strlen(pszDeviceID) > LEN_DEVICE_ID) //Device ID 길이 확인
+		{
+		}
+		else
+		{
+			memcpy(stControl_Rsp.body.usDeviceID, pszDeviceID, strlen(pszDeviceID));
+		}
+	}
+
+	stControl_Rsp.body.ucControlType = cControlType;
+	stControl_Rsp.body.ucResultCode = cResultCode;
+
+	GMMP_Trace(&stControl_Rsp.header, &stControl_Rsp.body);
+
+	nRet =  GMMP_Control_Rsp(&stControl_Rsp);
+
+	return nRet;
+}
+
+//제어 동작 완료 결과 보고 Request
+int GMMP_SetNotifi(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID,
+		const char cControlType,
+		const char cResultCode,
+		const char* pszMessageBody,
+		const int nMessageSize)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID ==NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nRet = GMMP_SUCCESS;
+
+	Notifi_Req stNotifi_Req;
+
+	memset(&stNotifi_Req, 0 ,sizeof(stNotifi_Req));
+
+	int PacketSize =sizeof(stNotifi_Req) - MAX_MSG_BODY + nMessageSize ; //Message Body의 속성은 Optinal이다
+
+	nRet = SetHeader((void*)&stNotifi_Req, PacketSize, 1,  1, OPERATION_NOTIFICATION_REQ, pszAuthID, pszAuthKey);
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(stNotifi_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+	memcpy(stNotifi_Req.body.usGWID, pszGWID, strlen(pszGWID));
+
+	if(pszDeviceID != NULL) //Device 판단
+	{
+		if(strlen(pszDeviceID) > LEN_DEVICE_ID) //Device ID 길이 확인
+		{
+		}
+		else
+		{
+			memcpy(stNotifi_Req.body.usDeviceID, pszDeviceID, strlen(pszDeviceID));
+		}
+	}
+
+	stNotifi_Req.body.ucControlType = cControlType;
+	stNotifi_Req.body.ucResultCode = cResultCode;
+
+	if(pszMessageBody != NULL) //Message 사용 판단
+	{
+		if(nMessageSize > MAX_MSG_BODY)
+		{
+		}
+		else
+		{
+			memcpy(stNotifi_Req.body.usMessageBody, pszMessageBody, nMessageSize);
+		}
+	}
+
+	GMMP_Trace(&stNotifi_Req.header, &stNotifi_Req.body);
+
+	nRet =  GMMP_Notifi_Req(&stNotifi_Req, PacketSize);
+
+	return nRet;
+}
+
+int GMMP_SetHB(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID)
+{
+  /*
+	if(pszAuthID == NULL
+			|| pszAuthKey == NULL
+			|| pszDomainCode == NULL
+			|| pszGWID ==NULL
+			|| strlen(pszAuthID) > LEN_AUTH_ID
+			|| strlen(pszAuthKey) > LEN_AUTH_KEY
+			|| strlen(pszDomainCode) > LEN_DOMAIN_CODE
+			|| strlen(pszGWID) > LEN_GW_ID)
+	{
+		return LIB_PARAM_ERROR;
+	}
+  */
+
+	int nRet = GMMP_SUCCESS;
+
+	HB_Req stHB_Req;
+
+	memset(&stHB_Req, 0 ,sizeof(stHB_Req));
+
+	nRet = SetHeader((void*)&stHB_Req, sizeof(stHB_Req), 1,  1, OPERATION_HEARTBEAT_REQ, pszAuthID, pszAuthKey);
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(stHB_Req.body.usDomainCode, pszDomainCode, strlen(pszDomainCode));
+	memcpy(stHB_Req.body.usGWID, pszGWID, strlen(pszGWID));
+
+	GMMP_Trace(&stHB_Req.header, &stHB_Req.body);
+
+	nRet =  GMMP_Heartbeat_Req(&stHB_Req);
+
+	return nRet;
+}
+
+//GW/Device 등록/해지 Response
+int GMMP_GetReg(GwRegist_Rsp* pstGwRegist_Rsp, DeviceRegist_Rsp* pstDeviceRegist_Rsp)
+{
+	int nRet = GMMP_SUCCESS;
+
+	if(pstGwRegist_Rsp != NULL)
+	{
+		nRet = GMMP_GW_Reg_Rsp(pstGwRegist_Rsp);
+		GMMP_Trace(&pstGwRegist_Rsp->header, &pstGwRegist_Rsp->body);
+	}
+	else
+	{
+		nRet = GMMP_Device_Reg_Rsp(pstDeviceRegist_Rsp);
+		GMMP_Trace(&pstDeviceRegist_Rsp->header, &pstDeviceRegist_Rsp->body);
+	}
+
+	CloseSocket();
+
+	return nRet;
+}
+
+int GMMP_GetDeReg(GwDeRegist_Rsp* pstGwRegist_Rsp, DeviceDeRegist_Rsp* pstDeviceDeRegist_Rsp)
+{
+	int nRet = GMMP_SUCCESS;
+
+	if(pstGwRegist_Rsp != NULL)
+	{
+		nRet = GMMP_GW_DeReg_Rsp(pstGwRegist_Rsp);
+		GMMP_Trace(&pstGwRegist_Rsp->header, &pstGwRegist_Rsp->body);
+	}
+	else
+	{
+		nRet = GMMP_Device_DeReg_Rsp(pstDeviceDeRegist_Rsp);
+		GMMP_Trace(&pstDeviceDeRegist_Rsp->header, &pstDeviceDeRegist_Rsp->body);
+	}
+
+	CloseSocket();
+
+	return nRet;
+}
+
+//Profile Info Response
+int GMMP_GetProfile(Profile_Rsp* pstProfile_Rsp)
+{
+	int nRet = GMMP_Profile_Rsp(pstProfile_Rsp);
+
+	GMMP_Trace(&pstProfile_Rsp->header, &pstProfile_Rsp->body);
+
+	CloseSocket();
+
+	return nRet;
+}
+
+//수집 데이터 보고  Response
+int GMMP_GetDelivery(Delivery_Rsp* pstDelivery_Rsp)
+{
+	int nRet = GMMP_Delivery_Rsp(pstDelivery_Rsp);
+
+	GMMP_Trace(&pstDelivery_Rsp->header, &pstDelivery_Rsp->body);
+
+	CloseSocket();
+
+	return nRet;
+}
+//제어 동작 완료 결과 보고 Response
+int GMMP_GetNotifi(Notifi_Rsp* pstNotifi_Rsp)
+{
+	int nRet = GMMP_Notifi_Rsp(pstNotifi_Rsp);
+
+	GMMP_Trace(&pstNotifi_Rsp->header, &pstNotifi_Rsp->body);
+
+	CloseSocket();
+
+	return nRet;
+}
+
+int GMMP_GetHB(HB_Rsp* pstHB_Rsp) //TCP Always ON 모드일 경우 (Thread 생성) 사용 TCP Disconnect하지 않음
+{
+	int nRet = GMMP_Heartbeat_Rsp(pstHB_Rsp);
+
+	GMMP_Trace(&pstHB_Rsp->header, &pstHB_Rsp->body);
+
+	return nRet;
+}
+
+int GMMP_Read(GMMPHeader* pstGMMPHeader, void** pBody)
+{
+  return GMMP_Read2(pstGMMPHeader, pBody, 1);
+}
+
+int GMMP_Read2(GMMPHeader* pstGMMPHeader, void** pBody, byte blocking)
+{
+	ConvertShort cvtShort;
+	//ConvertInt cvtint;
+
+	int nRet = 0;
+	int nHeaderSize = sizeof(GMMPHeader);
+
+	memset(pstGMMPHeader, 0, nHeaderSize);
+
+	cvtShort.sU8 = 0;
+	//cvtint.sU8 = 0;
+
+	nRet = 0;
+
+	nRet = ReadTCP2((char*)pstGMMPHeader, nHeaderSize, blocking);
+	if (nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	memcpy(cvtShort.usShort, pstGMMPHeader->usMessageLength, sizeof(pstGMMPHeader->usMessageLength));
+	cvtShort.sU8 = btols(cvtShort.sU8);
+
+	if (cvtShort.sU8 < nHeaderSize)
+	{
+		return GMMP_HEADER_SIZE_ERROR;
+	}
+
+	int nBodySize = 0;
+
+	if ((*pBody = MallocBody(pstGMMPHeader->ucMessageType, &nBodySize))== NULL || nBodySize <= 0)
+	{
+		return GMMP_MALLOC_ERROR;
+	}
+
+	memset(*pBody, 0, nBodySize);
+
+	int ReadPacketSize = cvtShort.sU8 -  nHeaderSize;
+
+	nRet = ReadTCP2((char*)(*pBody), ReadPacketSize, blocking);
+	if(nRet != GMMP_SUCCESS)
+	{
+		CloseSocket();
+
+		return nRet;
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int GMMP_Recv(GMMPHeader* pstGMMPHeader, void* pBody)
+{
+	GMMP_Trace(pstGMMPHeader, pBody);
+
+	char cMessageType =  pstGMMPHeader->ucMessageType ;
+
+	if(cMessageType == OPERATION_GW_REG_RSP)
+	{
+		stGwRegistrationRspHdr* pstRspHdr =(stGwRegistrationRspHdr*) pBody;
+		OG_Reg_Recv(pstGMMPHeader, pstRspHdr, NULL);
+	}
+	else if(cMessageType == OPERATION_GW_DEREG_RSP)
+	{
+		stGwDeRegistrationRspHdr* pstRspHdr =(stGwDeRegistrationRspHdr*) pBody;
+		OG_DeReg_Recv(pstGMMPHeader, pstRspHdr, NULL);
+	}
+	else if(cMessageType  == OPERATION_PROFILE_RSP)
+	{
+		stProfileRspHdr* pstRspHdr =(stProfileRspHdr*) pBody;
+		OG_Profile_Recv(pstGMMPHeader, pstRspHdr);
+	}
+	else if(cMessageType == OPERATION_DEVICE_REG_RSP)
+	{
+		stDeviceRegistrationRspHdr* pstRspHdr =(stDeviceRegistrationRspHdr*) pBody;
+		OG_Reg_Recv(pstGMMPHeader, NULL, pstRspHdr);
+	}
+	else if(cMessageType == OPERATION_DEVICE_DEREG_RSP)
+	{
+		stDeviceDeRegistrationRspHdr* pstRspHdr =(stDeviceDeRegistrationRspHdr*) pBody;
+		OG_DeReg_Recv(pstGMMPHeader, NULL,  pstRspHdr);
+	}
+	else if(cMessageType  == OPERATION_DELIVERY_RSP)
+	{
+		stPacketDeliveryRspHdr* pstRspHdr =(stPacketDeliveryRspHdr*) pBody;
+		OG_Delivery_Recv(pstGMMPHeader,  pstRspHdr);
+	}
+	else if(cMessageType  == OPERATION_CONTROL_REQ)
+	{
+		stControlReqHdr* pstReqHdr =(stControlReqHdr*) pBody;
+		GMMP_Ctrl_Recv(pstGMMPHeader,  pstReqHdr);
+	}
+	else if(cMessageType  == OPERATION_HEARTBEAT_RSP)
+	{
+		stHeartBeatMsgRspHdr* pstRspHdr =(stHeartBeatMsgRspHdr*) pBody;
+		OG_HB_Recv(pstGMMPHeader,  pstRspHdr);
+	}
+	else if(cMessageType  == OPERATION_NOTIFICATION_RSP)
+	{
+		stNotificationRspHdr* pstRspHdr =(stNotificationRspHdr*) pBody;
+		OG_Notifi_Recv(pstGMMPHeader,  pstRspHdr);
+	}
+
+	return GMMP_SUCCESS;
+}
+
+int GMMP_Ctrl_Recv(GMMPHeader* pstGMMPHeader,  stControlReqHdr* pstReqHdr)
+{
+	char cControlType = pstReqHdr->ucControlType;
+
+	//단순 제어 명령어인 경우
+	switch(cControlType)
+	{
+		case CONTROL_Reset:
+				break;
+		case CONTROL_Turn_Off:
+				break;
+		case CONTROL_Report_On:
+				break;
+		case CONTROL_Report_Off:
+				break;
+		case CONTROL_Time_Sync:
+				break;
+		case CONTROL_Pause:
+				break;
+		case CONTROL_Restart:
+				break;
+		case CONTROL_Signal_Power_Check:
+				break;
+		case CONTROL_Diagnostic:
+				break;
+		case CONTROL_Reserved:
+				break;
+		case CONTROL_Profile_Reset:
+				break;
+		case CONTROL_Status_Check:
+				break;
+		case CONTROL_FW_Download: //FTP 연결
+				break;
+		case CONTROL_FW_Update:
+				break;
+		case CONTROL_App_Download: //FTP 연결
+				break;
+		case CONTROL_App_Update:
+				break;
+		case CONTROL_Remote_Access: //Remote Info 연결
+				break;
+		case CONTROL_Multimedia_Control_Start: //Multimedia URL Info 연결
+				break;
+		case CONTROL_Multimedia_Control_Pause:
+				break;
+		case CONTROL_Multimedia_Control_Stop:
+				break;
+		case CONTROL_Multimedia_Control_Restart:
+				break;
+		default:
+			break;
+	}
+
+	OG_Ctrl_Recv(pstGMMPHeader, pstReqHdr);
+
+	return 1;
+}
+
+void SetTID(long nTid)
+{
+	g_nTID = nTid;
+}
+
+long GetTID()
+{
+	return g_nTID;
+}
+
+//protected
+int SetHeader(void* pData,
+		int nPacketSize,
+		int nTotalCount,
+		int nCurrentCount,
+		const char cMessageType,
+		const char* pszAuthID,
+		const char* pszAuthKey)
+{
+	GMMPHeader* pHeader = (GMMPHeader*)pData;
+	ConvertShort cvtShort;
+
+//  debug(F("authID len = "));
+//  debugln(strlen(pszAuthID));
+	DBG("authID len = %d", strlen(pszAuthID));
+
+	memset(pHeader, 0, sizeof(GMMPHeader));
+	memset(cvtShort.usShort, 0, sizeof(cvtShort.usShort));
+
+	pHeader->ucVersion = GMMP_VERSION;
+
+	ConvertInt cvtInt;
+
+	time_t t; time ( &t );
+
+//  debug(F("TIME = "));
+//  debugln(t);
+	DBG("TIME = %d", t);
+
+	memcpy(cvtInt.usInt, &t, sizeof(cvtInt.usInt));
+
+	cvtInt.sU8 = ltobi(cvtInt.sU8);
+
+	memcpy(&pHeader->unOriginTimeStamp, &cvtInt.usInt, sizeof(cvtInt.usInt));
+	memcpy(&pHeader->usAuthID, pszAuthID, strlen(pszAuthID));
+
+	if(pszAuthKey != NULL)
+	{
+		memcpy(&pHeader->usAuthKey, pszAuthKey, strlen(pszAuthKey));
+	}
+
+//  debug(F("TID = "));
+//  debugln(g_nTID);
+	DBG("TID = %ld", g_nTID);
+
+	memcpy(&cvtInt.usInt, &g_nTID, sizeof(g_nTID));
+	cvtInt.sU8 = ltobi(cvtInt.sU8);
+
+	memcpy(pHeader->usTID, &cvtInt.usInt, sizeof(pHeader->usTID));
+
+	cvtShort.sU8 = ltobs((short)nPacketSize);
+	memcpy(pHeader->usMessageLength, cvtShort.usShort, sizeof(cvtShort.usShort));
+
+	cvtShort.sU8 = ltobs((short)nTotalCount);
+	memcpy(pHeader->usTotalCount, cvtShort.usShort, sizeof(cvtShort.usShort));
+
+	cvtShort.sU8 = ltobs((short)nCurrentCount);
+	memcpy(pHeader->usCurrentCount, cvtShort.usShort, sizeof(cvtShort.usShort));
+
+	pHeader->ucMessageType = cMessageType;
+
+	return GMMP_SUCCESS;
+}
+
+int SetIntiSocket(void)
+{
+	return Connect();
+}
+
+char* MallocBody(const char Type, int* nBodySize)
+{
+	char* pBuffer = NULL;
+
+	switch(Type)
+	{
+		case OPERATION_GW_REG_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stGwRegistrationRspHdr));
+			*nBodySize = sizeof(stGwRegistrationRspHdr);
+			break;
+		}
+		case OPERATION_GW_DEREG_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stGwDeRegistrationRspHdr));
+			*nBodySize = sizeof(stGwDeRegistrationRspHdr);
+			break;
+		}
+		case OPERATION_PROFILE_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stProfileRspHdr));
+			*nBodySize = sizeof(stProfileRspHdr);
+			break;
+		}
+		case OPERATION_DEVICE_REG_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stDeviceRegistrationRspHdr));
+			*nBodySize = sizeof(stDeviceRegistrationRspHdr);
+			break;
+		}
+		case OPERATION_DEVICE_DEREG_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stDeviceDeRegistrationRspHdr));
+			*nBodySize = sizeof(stDeviceDeRegistrationRspHdr);
+			break;
+		}
+		case OPERATION_DELIVERY_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stPacketDeliveryRspHdr));
+			*nBodySize = sizeof(stPacketDeliveryRspHdr);
+			break;
+		}
+		case OPERATION_CONTROL_REQ:
+		{
+			pBuffer = (char*)malloc(sizeof(stControlReqHdr));
+			*nBodySize = sizeof(stControlReqHdr);
+			break;
+		}
+		case OPERATION_HEARTBEAT_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stHeartBeatMsgRspHdr));
+			*nBodySize = sizeof(stHeartBeatMsgRspHdr);
+			break;
+		}
+		case OPERATION_NOTIFICATION_RSP:
+		{
+			pBuffer = (char*)malloc(sizeof(stNotificationRspHdr));
+			*nBodySize = sizeof(stNotificationRspHdr);
+			break;
+		}
+		default:
+		{
+			nBodySize = 0;
+		}
+	}
+
+	return pBuffer;
+}
+
+int GMMP_Trace(GMMPHeader* pstGMMPHeader, void* pBody)
+{
+	ConvertInt cvtint;
+
+	char cMessageType =  pstGMMPHeader->ucMessageType ;
+
+	memcpy(cvtint.usInt, pstGMMPHeader->usTID, sizeof(pstGMMPHeader->usTID));
+	cvtint.sU8 = btoli(cvtint.sU8);
+
+	if(cMessageType == OPERATION_GW_REG_REQ)
+	{
+		stGwRegistrationReqHdr* pstRspHdr =(stGwRegistrationReqHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_GW_REG_RSP)
+	{
+		stGwRegistrationRspHdr* pstRspHdr =(stGwRegistrationRspHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_GW_DEREG_REQ)
+	{
+		stGwDeRegistrationReqHdr* pstRspHdr =(stGwDeRegistrationReqHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_GW_DEREG_RSP)
+	{
+		stGwDeRegistrationRspHdr* pstRspHdr =(stGwDeRegistrationRspHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_PROFILE_REQ)
+	{
+		stProfileReqHdr* pstRspHdr =(stProfileReqHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_PROFILE_RSP)
+	{
+		stProfileRspHdr* pstRspHdr =(stProfileRspHdr*) pBody;
+
+		memcpy(cvtint.usInt, pstRspHdr->unHeartbeatPeriod, sizeof(pstRspHdr->unHeartbeatPeriod));
+		cvtint.sU8 = btoli(cvtint.sU8);
+
+		memcpy(cvtint.usInt, pstRspHdr->unReportPeriod, sizeof(pstRspHdr->unReportPeriod));
+		cvtint.sU8 = btoli(cvtint.sU8);
+
+		memcpy(cvtint.usInt, pstRspHdr->unReportOffset, sizeof(pstRspHdr->unReportOffset));
+		cvtint.sU8 = btoli(cvtint.sU8);
+
+		memcpy(cvtint.usInt, pstRspHdr->unResponseTimeout, sizeof(pstRspHdr->unResponseTimeout));
+		cvtint.sU8 = btoli(cvtint.sU8);
+	}
+	else if(cMessageType == OPERATION_DEVICE_REG_REQ)
+	{
+		stDeviceRegistrationReqHdr* pstRspHdr =(stDeviceRegistrationReqHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_DEVICE_REG_RSP)
+	{
+		stDeviceRegistrationRspHdr* pstRspHdr =(stDeviceRegistrationRspHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_DEVICE_DEREG_REQ)
+	{
+		stDeviceDeRegistrationReqHdr* pstRspHdr =(stDeviceDeRegistrationReqHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_DEVICE_DEREG_RSP)
+	{
+		stDeviceDeRegistrationRspHdr* pstRspHdr =(stDeviceDeRegistrationRspHdr*) pBody;
+	}
+	else if(cMessageType == OPERATION_DELIVERY_REQ)
+	{
+		stPacketDeliveryReqHdr* pstRspHdr =(stPacketDeliveryReqHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_DELIVERY_RSP)
+	{
+		stPacketDeliveryRspHdr* pstRspHdr =(stPacketDeliveryRspHdr*) pBody;
+
+		memcpy(cvtint.usInt, pstRspHdr->unBackOffTime, sizeof(pstRspHdr->unBackOffTime));
+		cvtint.sU8 = btoli(cvtint.sU8);
+	}
+	else if(cMessageType  == OPERATION_CONTROL_REQ)
+	{
+		stControlReqHdr* pstReqHdr =(stControlReqHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_CONTROL_RSP)
+	{
+		stControlRspHdr* pstRspHdr =(stControlRspHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_HEARTBEAT_REQ)
+	{
+		stHeartBeatMsgRspHdr* pstRspHdr =(stHeartBeatMsgRspHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_HEARTBEAT_RSP)
+	{
+		stHeartBeatMsgRspHdr* pstRspHdr =(stHeartBeatMsgRspHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_NOTIFICATION_REQ)
+	{
+		stNotificationReqHdr* pstRspHdr =(stNotificationReqHdr*) pBody;
+	}
+	else if(cMessageType  == OPERATION_NOTIFICATION_RSP)
+	{
+		stNotificationRspHdr* pstRspHdr =(stNotificationRspHdr*) pBody;
+	}
+
+	return GMMP_SUCCESS;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/GMMP_Operation.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,285 @@
+/** GMMP 내부함수 및 변수 설명
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file GMMP_Operation.h
+ **/
+
+#ifndef GMMP_OPERATION_H_
+#define GMMP_OPERATION_H_
+
+#include "GMMP_Control.h"
+#include "GMMP_Delivery.h"
+#include "GMMP_Heartbeat.h"
+#include "GMMP_Notification.h"
+#include "GMMP_ProfileInfo.h"
+#include "GMMP_Reg.h"
+#include "Network.h"
+#include "GMMP.h"
+
+/**
+ * @brief GW/Device 등록/해지 Request 기능
+ * @param pszAuthID Auth ID 문자열 입력
+ * @param pszAuthKey Auth Key 문자열 입력
+ * @param pszDomainCode Domain Code
+ * @param pszGWID GW ID
+ * @param pszManufactureID
+ * @return
+ */
+int GMMP_SetReg(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszManufactureID);
+
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @return
+ */
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @return
+ */
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @return
+ */
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @return
+ */
+int GMMP_SetDeReg(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID);
+/**
+ *
+ * @param pstGwRegist_Rsp
+ * @param pstDeviceRegist_Rsp
+ * @return
+ */
+int GMMP_GetReg(GwRegist_Rsp* pstGwRegist_Rsp, DeviceRegist_Rsp* pstDeviceRegist_Rsp);
+
+/**
+ *
+ * @param pstGwRegist_Rsp
+ * @param pstDeviceDeRegist_Rsp
+ * @return
+ */
+int GMMP_GetDeReg(GwDeRegist_Rsp* pstGwRegist_Rsp, DeviceDeRegist_Rsp* pstDeviceDeRegist_Rsp);
+
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @return
+ */
+int GMMP_SetProfile(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID);
+/**
+ *
+ * @param pstProfile_Rsp
+ * @return
+ */
+int GMMP_GetProfile(Profile_Rsp* pstProfile_Rsp);
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @param cReportType
+ * @param cMediaType
+ * @param pszMessageBody
+ * @param nTotalCount
+ * @param nCurrentCount
+ * @return
+ */
+int GMMP_SetDelivery(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID,
+		const char cReportType,
+		const char cMediaType,
+		const char* pszMessageBody,
+		const int nTotalCount,
+		const int nCurrentCount);
+/**
+ *
+ * @param pstDelivery_Rsp
+ * @return
+ */
+int GMMP_GetDelivery(Delivery_Rsp* pstDelivery_Rsp);
+
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @param cControlType
+ * @param cResultCode
+ * @return
+ */
+int GMMP_SetControl(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID,
+		const char cControlType,
+		const char cResultCode);
+
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @param pszDeviceID
+ * @param cControlType
+ * @param cResultCode
+ * @param pszMessageBody
+ * @param nMessageSize
+ * @return
+ */
+int GMMP_SetNotifi(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID,
+		const char* pszDeviceID,
+		const char cControlType,
+		const char cResultCode,
+		const char* pszMessageBody,
+		const int nMessageSize);
+
+/**
+ *
+ * @param pstNotifi_Rsp
+ * @return
+ */
+int GMMP_GetNotifi(Notifi_Rsp* pstNotifi_Rsp);
+
+/**
+ *
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @param pszDomainCode
+ * @param pszGWID
+ * @return
+ */
+int GMMP_SetHB(const char* pszAuthID,
+		const char* pszAuthKey,
+		const char* pszDomainCode,
+		const char* pszGWID);
+
+/**
+ *
+ * @param pstHB_Rsp
+ * @return
+ */
+int GMMP_GetHB(HB_Rsp* pstHB_Rsp);
+
+/**
+ *
+ * @param pstGMMPHeader
+ * @param pBody
+ * @return
+ */
+int GMMP_Read(GMMPHeader* pstGMMPHeader, void** pBody);
+int GMMP_Read2(GMMPHeader* pstGMMPHeader, void** pBody, byte blocking);
+/**
+ *
+ * @param pstGMMPHeader
+ * @param pBody
+ * @return
+ */
+int GMMP_Recv(GMMPHeader* pstGMMPHeader, void* pBody);
+/**
+ *
+ * @param pstGMMPHeader
+ * @param pstRspHdr
+ * @return
+ */
+int GMMP_Ctrl_Recv(GMMPHeader* pstGMMPHeader,  stControlReqHdr* pstRspHdr);
+/**
+ *
+ * @param pstGMMPHeader
+ * @param pBody
+ * @return
+ */
+int GMMP_Trace(GMMPHeader* pstGMMPHeader, void* pBody);
+
+/**
+ *
+ * @param nTid
+ */
+void SetTID(long nTid);
+/**
+ *
+ * @return
+ */
+long GetTID();
+
+/**
+ *
+ * @param pData
+  * @param nPacketSize
+ * @param nTotalCount
+ * @param nCurrentCount
+ * @param cMessageType
+ * @param pszAuthID
+ * @param pszAuthKey
+ * @return
+ */
+int SetHeader(void* pData,
+		int nPacketSize,
+		int nTotalCount,
+		int nCurrentCount,
+		const char cMessageType,
+		const char* pszAuthID,
+		const char* pszAuthKey);
+
+/**
+ *
+ * @return
+ */
+int SetIntiSocket(void);
+
+/**
+ *
+ * @param Type
+ * @param nOutBufferSize
+ * @return
+ */
+char* MallocBody(const char Type, int* nOutBufferSize);
+
+#endif /* GMMP_OPERATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Heartbeat/GMMP_Heartbeat.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,50 @@
+/*
+ * GMMP_Hearbeat.c
+ *
+ *  Created on: 2013. 11. 18.
+ *      Author: root
+ */
+
+#include "GMMP_Heartbeat.h"
+
+int GMMP_Heartbeat_Req(HB_Req*  pHB_Req)
+{
+	if(pHB_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pHB_Req, sizeof(HB_Req) );
+}
+
+int GMMP_Heartbeat_Rsp(HB_Rsp*  pHB_Rsp)
+{
+	if(pHB_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pHB_Rsp->header  , sizeof(pHB_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pHB_Rsp->header.usMessageLength, sizeof(pHB_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pHB_Rsp->header);
+
+	return ReadTCP( (char*)&pHB_Rsp->body, nReadSize);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Heartbeat/GMMP_Heartbeat.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,29 @@
+/** GMMP Operation 중 Heartbeat 명령 힘수
+* @file GMMP_Heartbeat.h
+* @date 2013/11/21
+* @version 0.0.0.1
+* @ref GMMPHeader참조
+**/
+
+#ifndef GMMP_HEARBEAT_H_
+#define GMMP_HEARBEAT_H_
+
+#include "Network.h"
+#include "Struct_Heartbeat.h"
+
+
+/**
+ *
+ * @param pHB_Req @ref HB_Req 참조
+  * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Heartbeat_Req(HB_Req*  pHB_Req);
+
+/**
+ *
+ * @param pHB_Rsp @ref HB_Rsp 참조
+  * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Heartbeat_Rsp(HB_Rsp*  pHB_Rsp);
+
+#endif /* GMMP_HEARBEAT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Heartbeat/Struct_Heartbeat.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,92 @@
+/** GMMP Operation 중 Heartbeat 명령에 사용되는 구조체
+* @file Struct_Heartbeat.h
+* @date 2013/11/21
+* @version 0.0.0.1
+* @ref GMMPHeader참조
+**/
+
+#ifndef STRUCT_HEARTBEAT_H_
+#define STRUCT_HEARTBEAT_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stHeartBeatMsgReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에 Heartbeat 보고 명령을 전송 시 사용된다.
+ * @warning (TCP Always On mode에서만 동작한다.)
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+}stHeartBeatMsgReqHdr; //Heartbeat Request
+
+/**
+ * @struct stHeartBeatMsgRspHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에 Heartbeat 보고 응답 명령을 수신 시 사용된다.
+ * @warning (TCP Always On mode에서만 동작한다.)
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+}stHeartBeatMsgRspHdr; //Heartbeat Response
+
+/**
+ * @struct HB_Req
+ * @brief GMMP TCP Packet  구조 중 Request Heartbeat 구조체
+ * OMP에 Heartbeat 보고 명령을 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stHeartBeatMsgReqHdr 참조
+*/
+	GMMPHeader				header;
+	stHeartBeatMsgReqHdr	body;
+}HB_Req;
+
+/**
+ * @struct HB_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Heartbeat 구조체
+ * OMP에 Heartbeat 보고 응답 명령을 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stHeartBeatMsgRspHdr 참조
+*/
+	GMMPHeader				header;
+	stHeartBeatMsgRspHdr	body;
+}HB_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_HEARTBEAT_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Notification/GMMP_Notification.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,51 @@
+/*
+ * GMMP_Notification.c
+ *
+ *  Created on: 2013. 11. 18.
+ *      Author: root
+ */
+
+#include "GMMP_Notification.h"
+
+int GMMP_Notifi_Req(Notifi_Req*  pNotifi_Req, int nPacketSize)
+{
+	if(pNotifi_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pNotifi_Req, nPacketSize );
+}
+
+int GMMP_Notifi_Rsp(Notifi_Rsp*  pNotifi_Rsp)
+{
+	if(pNotifi_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pNotifi_Rsp->header  , sizeof(pNotifi_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pNotifi_Rsp->header.usMessageLength, sizeof(pNotifi_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pNotifi_Rsp->header);
+
+	return ReadTCP( (char*)&pNotifi_Rsp->body, nReadSize);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Notification/GMMP_Notification.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,28 @@
+ /** GMMP Operation 중 Notification 명령 함수
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file GMMP_Notification.h
+ **/
+
+#ifndef GMMP_NOTIFICATION_H_
+#define GMMP_NOTIFICATION_H_
+
+#include "Network.h"
+#include "Struct_Notification.h"
+
+/**
+ *
+ * @param pNotifi_Req @ref Notifi_Req참조
+ * @param nPacketSize 실제 전송해야하는 패킷 크기
+   * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Notifi_Req(Notifi_Req*  pNotifi_Req, int nPacketSize);
+
+/**
+ *
+ * @param pNotifi_Rsp @ref Notifi_Rsp참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Notifi_Rsp(Notifi_Rsp*  pNotifi_Rsp);
+
+#endif /* GMMP_NOTIFICATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Notification/Struct_Notification.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,129 @@
+/** GMMP Operation 중 제어 명령 수행 결과 보고 명령에 사용되는 구조체
+* @file Struct_Notification.h
+* @date 2013/11/21
+* @version 0.0.0.1
+* @ref GMMPHeader참조
+**/
+
+#ifndef STRUCT_NOTIFICATION_H_
+#define STRUCT_NOTIFICATION_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stNotificationReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에서 제어 메시지를 수행 후 제어 메시지 결과를 OMP에 보고한다.
+ */
+
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucControlType
+*@brief 제어 명령 수신 메시지에 수신한 값과 동일한 값을 사용한다. @ref Define_Control.h 참조
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+/**
+*@var usMessageBody
+*@brief Data [2048byte] ucControlType 정의에 의해 세부 내용이 변경 된다.
+*@brief  @ref Struct_Control_Opt.h 참조
+*@warning 옵션으로 사용하지 않을 수 있다.
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucControlType;
+	U8  ucResultCode;
+	U8  usMessageBody[MAX_MSG_BODY];
+}stNotificationReqHdr; //Notification Request
+
+/**
+ * @struct stNotificationRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+  * 제어 메시지 결과 응답을를 수신한다.
+ */
+typedef struct {
+ /**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucControlType
+*@brief 제어 명령 수신 메시지에 수신한 값과 동일한 값을 사용한다 @ref Define_Control.h 참조
+*@ref Define_Control.h 참조
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucControlType;
+	U8  ucResultCode;
+}stNotificationRspHdr; //Notification Response
+
+/**
+ * @struct Notifi_Req
+ * @brief GMMP TCP Packet  구조 중 Request Notification 구조체
+ * OMP에 Request Notification 데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stNotificationReqHdr 참조
+*/
+	GMMPHeader				header;
+	stNotificationReqHdr	body;
+}Notifi_Req;
+
+/**
+ * @struct Notifi_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Notification 구조체
+  * OMP에 Response Notification 데이터 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stNotificationRspHdr 참조
+*/
+	GMMPHeader				header;
+	stNotificationRspHdr	body;
+}Notifi_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_NOTIFICATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/ProfileInfo/GMMP_ProfileInfo.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,50 @@
+/*
+ * GMMP_ProfileInfo.c
+ *
+ *  Created on: 2013. 11. 18.
+ *      Author: root
+ */
+
+#include "GMMP_ProfileInfo.h"
+
+int GMMP_Profile_Req(Profile_Req*  pstProfile_Req)
+{
+	if(pstProfile_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pstProfile_Req, sizeof(Profile_Req) );
+}
+
+int GMMP_Profile_Rsp(Profile_Rsp* pstProfile_Rsp)
+{
+	if(pstProfile_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pstProfile_Rsp->header  , sizeof(pstProfile_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pstProfile_Rsp->header.usMessageLength, sizeof(pstProfile_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pstProfile_Rsp->header);
+
+	return ReadTCP( (char*)&pstProfile_Rsp->body, nReadSize);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/ProfileInfo/GMMP_ProfileInfo.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,27 @@
+ /** GMMP Operation 중 Profile Info 명령 함수
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file GMMP_ProfileInfo.h
+ **/
+
+#ifndef GMMP_PROFILEINFO_H_
+#define GMMP_PROFILEINFO_H_
+
+#include "Network.h"
+#include "Struct_ProfileInfo.h"
+
+/**
+ *
+ * @param pProfile_Req @ref Profile_Req참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Profile_Req(Profile_Req*  pProfile_Req);
+
+/**
+ *
+ * @param pstProfile_Rsp @ref Profile_Rsp참조
+ * @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Profile_Rsp(Profile_Rsp* pstProfile_Rsp);
+
+#endif /* GMMP_PROFILEINFO_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/ProfileInfo/Struct_ProfileInfo.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,153 @@
+/** GMMP Operation 중 제어 명령 수행 결과 보고 명령에 사용되는 구조체
+* @file Struct_ProfileInfo.h
+* @date 2013/11/21
+* @version 0.0.0.1
+* @ref GMMPHeader참조
+**/
+
+#ifndef STRUCT_PROFILEINFO_H_
+#define STRUCT_PROFILEINFO_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stProfileReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에서 Profile Info  메시지를 OMP에 전송한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+}stProfileReqHdr; //Profile Request
+
+/**
+ * @struct stProfileRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 Multimedia URL Info 제공 명령 수신 시 사용된다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+/**
+*@var unHeartbeatPeriod
+*@brief Heartbeat 주기로서 분(min)단위이다.\n
+*@brief 0x00 : Non Always On 단말\n
+*@brief other : TCP Always On 단말\n
+*@brief (Device Profile 조회시에는 해당 값이 0으로 전달)\n
+*/
+	/**
+	*@var unReportPeriod
+	*@brief 보고 주기로서 분(minute) 단위이다.\n
+	*@brief (Device Profile 조회시에는 해당 값이 0으로 전달)
+	*/
+/**
+*@var unReportOffset
+*@brief 보고 주기 Offset 시간으로서 초(sec) 단위이다.\n
+@brief 0이면 보고주기때 보고하고, 0이 아니면 보고 주기가 되었을때 단말은 Reporting OffSet Time 이후에 주기보고 동작을 해야한다.
+@brief (Device Profile 조회시에는 해당 값이 0으로 전달)
+*/
+/**
+*@var unResponseTimeout
+*@brief M2M 단말의 Request메시지에 대한 Response 메시지의 Timeout(최소 30sec 이상으로 설정한다.)\n
+*@brief (Device Profile 조회시에는 해당 값이 0으로 전달)\n
+*/
+/**
+*@var usModel
+*@brief 제조사에서 부여한 Device 의 이름
+*/
+/**
+*@var usFirmwareVersion
+*@brief Firmware Version
+*/
+/**
+*@var usSoftwareVersion
+*@brief Software Version
+*/
+/**
+*@var usHardwareVersion
+*@brief Hardware Version
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucResultCode;
+	U8  unHeartbeatPeriod[4];
+	U8  unReportPeriod[4];
+	U8  unReportOffset[4];
+	U8  unResponseTimeout[4];
+	U8  usModel[32];
+	U8  usFirmwareVersion[16];
+	U8  usSoftwareVersion[16];
+	U8  usHardwareVersion[16];
+}stProfileRspHdr; //Profile Response
+
+/**
+ * @struct Profile_Req
+ * @brief GMMP TCP Packet  구조 중 Request Profile Info 구조체
+ * OMP에 Request Profile Info  데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stProfileReqHdr 참조
+*/
+	GMMPHeader		header;
+	stProfileReqHdr	body;
+}Profile_Req;
+
+/**
+ * @struct Profile_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Profile Info 구조체
+  * OMP에 Response Profile Info 데이터 수신한다.
+ */
+
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stProfileRspHdr 참조
+*/
+	GMMPHeader		header;
+	stProfileRspHdr	body;
+}Profile_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_PROFILEINFO_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/GMMP_Reg.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,172 @@
+#include "GMMP_Reg.h"
+
+//Request
+int GMMP_GW_Reg_Req(GwRegist_Req* pRegist_Req)
+{
+  debugln("GMMP_GW_Reg_Req()");
+	if(pRegist_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pRegist_Req, sizeof(GwRegist_Req) );
+}
+
+int GMMP_GW_Reg_Rsp(GwRegist_Rsp* pRegist_Rsp)
+{
+	if(pRegist_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pRegist_Rsp->header  , sizeof(pRegist_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pRegist_Rsp->header.usMessageLength, sizeof(pRegist_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pRegist_Rsp->header);
+
+	return ReadTCP( (char*)&pRegist_Rsp->body, nReadSize);
+}
+
+int GMMP_Device_Reg_Req(DeviceRegist_Req* pRegist_Req)
+{
+	if(pRegist_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pRegist_Req, sizeof(DeviceRegist_Req) );
+}
+
+int GMMP_Device_Reg_Rsp(DeviceRegist_Rsp* pRegist_Rsp)
+{
+	if(pRegist_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pRegist_Rsp->header  , sizeof(pRegist_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pRegist_Rsp->header.usMessageLength, sizeof(pRegist_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pRegist_Rsp->header);
+
+	return ReadTCP( (char*)&pRegist_Rsp->body, nReadSize);
+}
+
+
+int GMMP_GW_DeReg_Req(GwDeRegist_Req* pDeRegist_Req)
+{
+	if(pDeRegist_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pDeRegist_Req, sizeof(GwDeRegist_Req) );
+}
+
+int GMMP_GW_DeReg_Rsp(GwDeRegist_Rsp* pDeRegist_Rsp)
+{
+	if(pDeRegist_Rsp == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pDeRegist_Rsp->header  , sizeof(pDeRegist_Rsp->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pDeRegist_Rsp->header.usMessageLength, sizeof(pDeRegist_Rsp->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDeRegist_Rsp->header);
+
+	return ReadTCP( (char*)&pDeRegist_Rsp->body, nReadSize);
+}
+
+int GMMP_Device_DeReg_Req(DeviceDeRegist_Req*  pDeRegist_Req)
+{
+	if(pDeRegist_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	return WriteTCP( (char*)pDeRegist_Req, sizeof(DeviceDeRegist_Req) );
+}
+
+int GMMP_Device_DeReg_Rsp(DeviceDeRegist_Rsp* pDeRegist_Req)
+{
+	if(pDeRegist_Req == NULL)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	if(CheckSocket() != 0)
+	{
+		return SERVER_INFO_NOT_FOUND;
+	}
+
+	int nRet = ReadTCP( (char*)&pDeRegist_Req->header  , sizeof(pDeRegist_Req->header) );
+	if(nRet != GMMP_SUCCESS)
+	{
+		return nRet;
+	}
+
+	ConvertShort cvtshort;
+	cvtshort.sU8 = 0;
+	memcpy(cvtshort.usShort, pDeRegist_Req->header.usMessageLength, sizeof(pDeRegist_Req->header.usMessageLength) );
+
+	int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDeRegist_Req->header);
+
+	return ReadTCP( (char*)&pDeRegist_Req->body, nReadSize);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/GMMP_Reg.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,80 @@
+ /** GMMP Operation 중 Registration 명령 함수
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file GMMP_Reg.h
+ **/
+
+#ifndef GMMP_REG_H_
+#define GMMP_REG_H_
+
+#include "Network.h"
+
+#include "Struct_Reg_GW.h"
+#include "Struct_Reg_Device.h"
+
+#include "Struct_DeReg_GW.h"
+#include "Struct_DeReg_Device.h"
+
+
+
+
+//public
+/**
+ *
+ * @param pGwRegist_Req @ref GwRegist_Req참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_GW_Reg_Req(GwRegist_Req*  pGwRegist_Req);
+
+/**
+ *
+ * @param pGwRegist_Rsp @ref GwRegist_Rsp참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_GW_Reg_Rsp(GwRegist_Rsp* pGwRegist_Rsp);
+
+/**
+ *
+ * @param pDeviceRegist_Req @ref DeviceRegist_Req참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Device_Reg_Req(DeviceRegist_Req*  pDeviceRegist_Req);
+
+/**
+ *
+ * @param pDeviceRegist_Rsp @ref DeviceRegist_Rsp참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Device_Reg_Rsp(DeviceRegist_Rsp*  pDeviceRegist_Rsp);
+
+/**
+ *
+ * @param pGwDeRegist_Req @ref GwDeRegist_Req참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_GW_DeReg_Req(GwDeRegist_Req* pGwDeRegist_Req);
+
+/**
+ *
+ * @param pGwDeRegist_Rsp @ref GwDeRegist_Rsp참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_GW_DeReg_Rsp(GwDeRegist_Rsp* pGwDeRegist_Rsp);
+
+/**
+ *
+ * @param pDeviceDeRegist_Req @ref DeviceDeRegist_Req참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Device_DeReg_Req(DeviceDeRegist_Req*  pDeviceDeRegist_Req);
+
+/**
+ *
+ * @param pDeviceDeRegist_Rsp @ref DeviceDeRegist_Rsp참조
+* @return 성공 : GMMMP_SUCCESS, 실패 : @ref ErrorCode.h 참조
+ */
+int GMMP_Device_DeReg_Rsp(DeviceDeRegist_Rsp*  pDeviceDeRegist_Rsp);
+
+
+#endif /* GMMP_REG_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/Struct_DeReg_Device.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,104 @@
+ /** GMMP Operation 중 Device DeRegistration 명령에 사용되는 구조체
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file Struct_DeReg_Device.h
+ **/
+
+#ifndef STRUCT_DEREG_DEVICE_H_
+#define STRUCT_DEREG_DEVICE_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stDeviceDeRegistrationReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+  * OMP에서 Device DeRegistration 메시지를 OMP에 전송한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+}stDeviceDeRegistrationReqHdr; //GW Registration Request
+
+/**
+ * @struct stDeviceDeRegistrationRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 Device DeRegistration 메시지를 OMP에 수신한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucResultCode;
+}stDeviceDeRegistrationRspHdr; //GW Registration Response
+
+/**
+ * @struct DeviceDeRegist_Req
+ * @brief GMMP TCP Packet  구조 중 Request Device DeRegist 구조체
+ * OMP에 Request  Device DeRegist 데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stDeviceDeRegistrationReqHdr 참조
+*/
+	GMMPHeader					header;
+	stDeviceDeRegistrationReqHdr	body;
+}DeviceDeRegist_Req;
+
+/**
+ * @struct DeviceDeRegist_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Device DeRegist 구조체
+  * OMP에 Response Device DeRegist 데이터 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stDeviceDeRegistrationRspHdr 참조
+*/
+	GMMPHeader					header;
+	stDeviceDeRegistrationRspHdr	body;
+}DeviceDeRegist_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_DEREG_DEVICE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/Struct_DeReg_GW.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,94 @@
+ /** GMMP Operation 중 GW DeRegistration 명령에 사용되는 구조체
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file Struct_DeReg_GW.h
+ **/
+
+#ifndef STRUCT_DEREG_GW_H_
+#define STRUCT_DEREG_GW_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stGwDeRegistrationReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에서 GW DeRegistration 메시지를 OMP에 전송한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+}stGwDeRegistrationReqHdr; //GW Registration Request
+
+/**
+ * @struct stGwDeRegistrationRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 GW DeRegistration 메시지를 OMP에 수신한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  ucResultCode;
+}stGwDeRegistrationRspHdr; //GW Registration Response
+
+/**
+ * @struct GwDeRegist_Req
+ * @brief GMMP TCP Packet  구조 중 Request GW DeRegist 구조체
+ * OMP에 Request GW DeRegist 데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stGwDeRegistrationReqHdr 참조
+*/
+	GMMPHeader					header;
+	stGwDeRegistrationReqHdr	body;
+}GwDeRegist_Req;
+
+/**
+ * @struct GwDeRegist_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response GW DeRegist 구조체
+  * OMP에 Response GW DeRegist 데이터 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stGwDeRegistrationRspHdr 참조
+*/
+	GMMPHeader					header;
+	stGwDeRegistrationRspHdr	body;
+}GwDeRegist_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_DEREG_GW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/Struct_Reg_Device.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,106 @@
+ /** GMMP Operation 중 Device Registration 명령에 사용되는 구조체
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file Struct_Reg_Device.h
+ **/
+
+#ifndef STRUCT_REG_DEVICE_H_
+#define STRUCT_REG_DEVICE_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stDeviceRegistrationReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+  * OMP에서 Device Registration 메시지를 OMP에 전송한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usManufactureID
+*@brief M2M GW의 Manufacture ID 이다.\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.
+Ex) 공장 제조 Serial No. : “AVB12132SET23DT”, “SKTSerial“
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usManufactureID[LEN_MANUFACTURE_ID];
+}stDeviceRegistrationReqHdr; //Device Registration Request
+
+/**
+ * @struct stDeviceRegistrationRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 Device Registration 메시지를 OMP에 수신한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var usDeviceID
+*@brief M2M Device ID, 값이 0x0이면 GW 명령이다.
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  usDeviceID[LEN_DEVICE_ID];
+	U8  ucResultCode;
+}stDeviceRegistrationRspHdr; //Device Registration Response
+
+/**
+ * @struct DeviceRegist_Req
+ * @brief GMMP TCP Packet  구조 중 Request Device Regist 구조체
+ * OMP에 Request Device Regist 데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stDeviceRegistrationReqHdr 참조
+*/
+	GMMPHeader				header;
+	stDeviceRegistrationReqHdr	body;
+}DeviceRegist_Req;
+
+/**
+ * @struct DeviceRegist_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Device Regist 구조체
+  * OMP에 Response Device Regist 데이터 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stDeviceRegistrationRspHdr 참조
+*/
+	GMMPHeader				header;
+	stDeviceRegistrationRspHdr	body;
+}DeviceRegist_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_REG_DEVICE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Reg/Struct_Reg_GW.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,96 @@
+ /** GMMP Operation 중 GW Registration 명령에 사용되는 구조체
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file Struct_Reg_GW.h
+ **/
+
+#ifndef STRUCT_REG_GW_H_
+#define STRUCT_REG_GW_H_
+
+#include "Define.h"
+#include "Struct_Common.h"
+
+#pragma pack(1)
+/**
+ * @struct stGwRegistrationReqHdr
+ * @brief GMMP TCP Packet  구조 중 Request 수행 시 Message Header와 Message Body 영역
+ * OMP에서 GW Registration 메시지를 OMP에 전송한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usManufactureID
+*@brief M2M GW의 Manufacture ID 이다.\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.
+Ex) 공장 제조 Serial No. : “AVB12132SET23DT”, “SKTSerial“
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usManufactureID[LEN_MANUFACTURE_ID];
+}stGwRegistrationReqHdr; //GW Registration Request
+
+/**
+ * @struct stGwRegistrationRspHdr
+ * @brief GMMP TCP Packet  구조 중 Response 수행 시 Message Header와 Message Body 영역
+ * OMP에서 GW Registration 메시지를 OMP에 수신한다.
+ */
+typedef struct {
+/**
+*@var usDomainCode
+*@brief 서비스 영역별 구분 코드\n
+- AlphaNumeric : 문자,숫자 조합, 특수문자제외, SPACE 허용 안하며 빈자리는 0x00(NULL)로 채운다.\n
+*/
+/**
+*@var usGWID
+*@brief M2M GW ID
+*/
+/**
+*@var ucResultCode
+*@brief Result Code (0x00 : Success, other : Fail Reason) @ref OMPErrorCode.h 참조
+*/
+	U8  usDomainCode[LEN_DOMAIN_CODE];
+	U8  usGWID[LEN_GW_ID];
+	U8  ucResultCode;
+}stGwRegistrationRspHdr; //GW Registration Response
+
+/**
+ * @struct GwRegist_Req
+ * @brief GMMP TCP Packet  구조 중 Request GW Regist 구조체
+ * OMP에 Request GW Regist 데이터 전송한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stGwRegistrationReqHdr 참조
+*/
+	GMMPHeader				header;
+	stGwRegistrationReqHdr	body;
+}GwRegist_Req;
+
+/**
+ * @struct GwRegist_Rsp
+ * @brief GMMP TCP Packet  구조 중 Response Gw Regist 구조체
+  * OMP에 Response Gw Regist 데이터 수신한다.
+ */
+typedef struct {
+/**
+*@var header
+*@brief @ref GMMPHeader 참조
+*/
+/**
+*@var body
+*@brief @ref stGwRegistrationRspHdr 참조
+*/
+	GMMPHeader				header;
+	stGwRegistrationRspHdr	body;
+}GwRegist_Rsp;
+#pragma pack(0)
+
+#endif /* STRUCT_REG_GW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Operation/Struct_Common.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,133 @@
+/** GMMP 공통 구조체
+  * @date 2013/11/21
+ * @version 0.0.0.1
+ * @file Struct_Common.h
+ **/
+
+#ifndef STRUCT_H_
+#define STRUCT_H_
+
+#include "Define.h"
+
+///////////////////////////////////////////////////////////////////////////
+//GMMP TCP Packet 공통
+
+#pragma pack(1)
+/**
+ *@struct GMMPHeader
+ *@brief GMMP TCP Packet Common Header
+ */
+typedef struct {
+/**@var ucVersion
+* @brief GMMP Version
+*/
+    U8  ucVersion;
+
+/**@var usMessageLength
+* @brief GMMP 통신 패킷의 전체 길이.
+*/
+/**@var ucMessageType
+* @brief 메시지의 유형으로서 단말등록, 주기보고, 단말제어 등 각각에 대해 요청과 응답을 구분한다.\n
+* *아래 표 참조\n
+*@image html OperationDefine.png Operation Type 표
+* @ref Define_Operation.h 참조
+*/
+/**@var unOriginTimeStamp
+* @brief Unix Time(=POSIX time, 1970년 1월1일부터 경과된 초)을 사용한다. 메시지를 전송하는 쪽에서 해당 값을 설정한다.
+*/
+/**@var usTotalCount
+* @brief Message Body에 전달될 내용이 2048 Bytes를 초과할 경우 여러 개의 메시지로 전송하며 전체 메시지 개수를 표시 한다.
+*/
+/**@var usCurrentCount
+* @brief 여러 개의 메시지로 전송되는 경우 현재 메시지의 순서로서 1에서 Total Count까지의 값이 기록 된다.
+*/
+/**@var usAuthID
+* @brief M2M GW 의 Serial Number 값이며, MSISDN 또는 MAC Address값을 사용할 수도 있다.
+*/
+/**@var usAuthKey
+* @brief GMMP Message를 인증하기 위해 사용되는 Key 값으로 등록 절차 시 OMP에서 할당한다.\n
+*  (등록 이전에 Default 로 16byte를 0x00으로 채운다.)
+*/
+/**@var usTID
+* @brief T-ID는 M2M GW와 OMP 간의 트랜잭션을 구분하기 위한 값으로서 Request 요청하는 곳에서 할당하며 Response 받은 곳에서는 해당 T-ID 값을 그대로 반환한다.
+M2M GW와 OMP에서 T-ID 사용 범위는 다음과 같다. (“6.4 T-ID 사용 범위”절 참조)\n
+※ M2M GW T-ID : 0 ~ 99,999 (10만개)\n
+※ OMP T-ID : M2M GW가 사용 이외의 값.
+*/
+/**@var ucReserved1
+* @brief Message Body를 암호화하여 전송시 0x01로 설정한다. 그렇지 않은 경우에는 0x00으로 설정한다.
+*/
+/**@var ucReserved2
+* @brief 현재 사용하지 않음 ( 0x00으로 설정한다.).
+*/
+    U8  usMessageLength[2];
+    U8  ucMessageType;
+    U8  unOriginTimeStamp[4];
+    U8  usTotalCount[2];
+    U8  usCurrentCount[2];
+    U8  usAuthID[LEN_AUTH_ID];
+    U8  usAuthKey[LEN_AUTH_KEY];
+    U8  usTID[LEN_TID];
+    U8  ucReserved1;
+    U8  ucReserved2;
+}GMMPHeader; //기본 구조체
+
+/**@union ConvertShort
+* @brief short형 변수를 endian 변환을 위해 사용된다.
+*/
+
+typedef union{
+	U8		usShort[2];
+	short	sU8;
+}ConvertShort;
+
+/**@union ConvertInt
+* @brief short형 변수를 endian 변환을 위해 사용된다.
+*/
+typedef union{
+	U8		usInt[4];
+	long sU8;
+}ConvertInt;
+
+
+/**
+ *@struct SMSMessage
+ *@brief GMMP SMS Packet
+ *@brief SMS 메시지는 Header Message와 최대 38byte를 갖는 Body Message로 구성된다. \n
+ *@brief Header 메시지는 제어 명령을 구분할 수 있는 T-ID(Transaction ID)와 제어의 종류를 나타내는 Control Type Code값을 포함한다.
+ *@ref Define_Operation.h 참조
+ */
+typedef struct {
+/**@var unTID
+* @brief T-ID는 M2M GW와 OMP 간의 트랜잭션을 구분하기 위한 값으로서 Request 요청하는 곳에서 할당하며 Response 받은 곳에서는 해당 T-ID 값을 그대로 반환한다.
+M2M GW와 OMP에서 T-ID 사용 범위는 다음과 같다. (“6.4 T-ID 사용 범위”절 참조)\n
+※ M2M GW T-ID : 0 ~ 99,999 (10만개)\n
+※ OMP T-ID : M2M GW가 사용 이외의 값.
+*/
+/**@var ucControlTypeCode
+* @brief M2M 단말로의 제어 명령 전달 시 제어 명령에 대한 Code값이다.
+* @ref Define_Operation.h 참조
+*/
+/**@var ucLongSentenceFlag
+* @brief 0x00 : 제어 데이터의 크기가 38 bytes 이하여서 SMS Control Message Body 에 제어 데이터가 포함되어 있으며, Long Sentence Operation을 수행할 필요 없다.
+* @brief 0x01 : 제어 데이터의 크기가 38 bytes 이상이므로 SMS Control Message Body 에 제어 데이터가 포함되어 있지않고, M2M GW/Device Long Sentence(@ref GMMP_LSentence_Operation 참조)을 수행하여 제어 데이터를 획득해야 한다.
+*/
+/**@var usDeviceID
+* @brief M2M Device ID
+* @warning 0x00이면 GW의 단말제어로 간주
+*/
+/**@var usSMSMessageBody
+* @brief 단말에게 전달될 제어 명령에 대한 내용이 포함된다.
+*/
+	U8 	unTID[4];
+	U8		ucControlTypeCode;
+	U8		ucLongSentenceFlag;
+	U8		usDeviceID[LEN_DEVICE_ID];
+	U8		usSMSMessageBody[38];
+}SMSMessage;
+
+#pragma pack(0)
+#endif /* STRUCT_H_ */
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Util/GMMP_Util.cpp	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,59 @@
+/*
+ * GMMP_Util.c
+ *
+ *  Created on: 2013. 11. 27.
+ *      Author: root
+ */
+
+#include "GMMP_Util.h"
+
+short ltobs(const short nShort)
+{
+	return _btols(nShort);
+}
+
+short btols(const short nShort)
+{
+	return _btols(nShort);
+}
+
+short _btols(const short nShort)
+{
+	short nValue = 0;
+
+	nValue = (unsigned short)nShort >> 8;
+	nValue |=(unsigned short) nShort << 8;
+
+	return  nValue;
+}
+
+long ltobi(const long nInt)
+{
+	return _ltobi(nInt);
+}
+
+long btoli(const long nInt)
+{
+	return _ltobi(nInt);
+}
+
+long _ltobi(const long nInt)
+{
+	long nVal0, nVal1, nVal2, nVal3;
+
+	nVal0 =  (unsigned long)nInt >> 24;
+	nVal1 =  (unsigned long)(nInt & 0x00FF0000) >> 8;
+	nVal2 =  (unsigned long)(nInt & 0x0000FF00) << 8;
+	nVal3 =  (unsigned long)nInt << 24;
+
+	return (nVal0 | nVal1 | nVal2 | nVal3);
+}
+
+int freeRam () {
+  // __brkval is the address of the top of the heap
+  // if memory has been allocated.
+  // If __brkval is zero then it means malloc has not used any memory yet, so
+  // we look at the address of __heap_start.
+  
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Util/GMMP_Util.h	Thu Jul 23 00:55:15 2015 +0000
@@ -0,0 +1,55 @@
+/** GMMP에 사용되는 Util 함수
+ * @file GMMP_Util.h
+ * @date 2013/11/21
+ * @version 0.0.0.1
+ **/
+#ifndef GMMP_UTIL_H_
+#define GMMP_UTIL_H_
+/**
+ *@brief 라이브러리를 사용중인 플랫폼 시스템이 big-endian, little-endian인지 확인한다.
+ * @return big-endian : 0, little-endian : 1
+ */
+int IsBigEndianSystem(void); //big endian system check
+
+/**
+ *  @brief short형 변수의 정보를 리틀엔디언 에서 빅엔디언으로 변경
+ * @param nShort
+ */
+short	ltobs(const short nShort); //little endian to big endian for short
+
+/**
+ *  @brief short형 변수의 정보를  빅엔디언에서 리틀엔디언으로 변경
+ * @param nShort
+ */
+short btols(const short nShort);
+
+/**
+ * @brief short형 변수의 정보 변환 내부 함수
+ * @param nShort
+ */
+short _btols(const short nShort);
+
+/**
+ * @brief int형 변수의 정보를 리틀엔디언 에서 빅엔디언으로 변경
+ * @param nInt
+ * @return
+ */
+long ltobi(const long nInt);
+
+/**
+ * @brief int형 변수의 정보를  빅엔디언에서 리틀엔디언으로 변경
+ * @param nInt
+ * @return
+ */
+long btoli(const long nInt);
+
+/**
+ * @brief int형 변수의 정보 변환 내부 함수
+ * @param nInt
+ * @return
+ */
+long _ltobi(const long nInt);
+
+int freeRam();
+
+#endif /* GMMP_UTIL_H_ */