Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ThingPlug_WiFi_Example
M2M GW/Device 단말 제어
M2M 단말에 대한 특정 제어 명령을 전달하기 위한 절차로서 GMMP에서는 2가지 제어 방식을 지원한다. More...
Functions | |
| int | GO_Control (const char *pszGWID, const char *pszDeviceID, long nTID, const char cControlType, const char cResultCode) |
Detailed Description
M2M 단말에 대한 특정 제어 명령을 전달하기 위한 절차로서 GMMP에서는 2가지 제어 방식을 지원한다.
방식 1) TCP Always On 세션을 가지고 있는 M2M 단말인 경우 해당 세션을 통해 직접 제어 메시지를 전달하는 방식이다.
방식 2) SMS 메시지를 통해 제어 명령을 전송하는 방식이다.
※ Always ON 단말도 TCP 세션이 끊어져 있는 경우에는 SMS 메시지를 통한 제어 명령을 수신할 수 있다.
일반적으로 단말 제어 절차는 3단계로 이루어져 있다.
1단계는 단말 제어 메시지를 통해 단말에게 제어 명령을 전달하고 응답하는 절차이다.
2단계는 Control Type 에 따른 부가적인(Optional) 절차로서 Profile 정보, 큰 제어 데이터, FTP 정보, Remote Access 정보등을 획득하는 절차이다.
3단계는 제어 결과를 플랫폼으로 통보하는 절차로서 단말 제어 결과 보고 메시지를 통해 제어 결과를 플랫폼으로 통보하고 그에 대한 결과를 수신한다.
제어절차시 Control Type 에 따라 M2M GW의 Reboot 절차가 수행될 수 있다.
단말 제어 메시지의 Control Type은 Define_Control::h의 메시지 타입이 존재하며, 아래의 Control Type인 경우 부가 절차를 따른다.
1. CONTROL_Profile_Reset인 경우 GMMP_ProfileInfo_Operation의 기능을 연계
2. CONTROL_FW_Download, CONTROL_App_Download인 경우 GMMP_FTP_Operation의 기능을 연계
3. CONTROL_Remote_Access인 경우 GMMP_Remote_Operation의 기능을 연계
4. CONTROL_Multimedia_Control_Start인 경우 GMMP_Multimedia_Operation의 기능을 연계
전송 패킷 : Struct_Control.h Struct_Control_Opt::h참조
Function Documentation
| int GO_Control | ( | const char * | pszGWID, |
| const char * | pszDeviceID, | ||
| long | nTID, | ||
| const char | cControlType, | ||
| const char | cResultCode | ||
| ) |
- Parameters:
-
pszGWID OMP로 제공 받은 GW ID값. pszDeviceID OMP로 제공 받은 Device ID값. nTID T-ID는 M2M GW와 OMP 간의 트랜잭션을 구분하기 위한 값으로서 Request 요청하는 곳에서 할당하며 Response 받은 곳에서는 해당 T-ID 값을 그대로 반환한다.
M2M GW와 OMP에서 T-ID 사용 범위는 다음과 같다.
※ M2M GW T-ID : 0 ~ 99,999 (10만개)
※ OMP T-ID : M2M GW가 사용 이외의 값
cControlType Data Collect Period & Time Setting , Reboot, Configuration, Time Sync, Change Server IP/Port(OMP), HB Period, etc
Define_Operation.h 참조cResultCode Result Code (0x00 : Success, other : Fail Reason)
OMPErrorCode.h 참조
- Returns:
- 성공 : GMMMP_SUCCESS, 실패 : ErrorCode.h 참조
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; }
Generated on Tue Jul 12 2022 14:17:05 by
1.7.2