Eric Jung / GMMP_mbed_Ethernet_Reinit

Dependents:   ThingPlug_Ethernet_Example

Fork of GMMP_mbed by Eric Jung

Embed: (wiki syntax)

« Back to documentation index

M2M GW/Device 제어 결과 보고

M2M GW/Device 제어 결과 보고

전송 패킷 : Struct_Notification.h 참조 제어 결과를 플랫폼으로 통보하고 그에 대한 결과를 수신한다. More...

int GO_Notifi (const char *pszGWID, const char *pszDeviceID, const char cControlType, const char cResultCode, const char *pszMessageBody, const int nMessageBodySize)

Detailed Description

전송 패킷 : Struct_Notification.h 참조 제어 결과를 플랫폼으로 통보하고 그에 대한 결과를 수신한다.


Function Documentation

int GO_Notifi ( const char *  pszGWID,
const char *  pszDeviceID,
const char  cControlType,
const char  cResultCode,
const char *  pszMessageBody,
const int  nMessageBodySize 
)
Parameters:
pszGWIDOMP로 제공 받은 GW ID값.
pszDeviceIDOMP로 제공 받은 Device ID값.
cControlType단말 제어 메시지에 수신한 값과 동일한 값을 사용한다
cResultCodeResult Code (0x00 : Success, other : Fail Reason)
pszMessageBodyData[2048 Byte]
nMessageBodySizepszMessageBody의 크기
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;


            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;

}

Definition at line 350 of file GMMP.cpp.