Modified for W5500 Ethernet initialize
Fork of GMMP_mbed by
Operation/Notification/GMMP_Notification.cpp@0:7e575e5f88ec, 2015-08-09 (annotated)
- Committer:
- lesmin
- Date:
- Sun Aug 09 14:11:35 2015 +0000
- Revision:
- 0:7e575e5f88ec
forked from GMMP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lesmin | 0:7e575e5f88ec | 1 | /* |
lesmin | 0:7e575e5f88ec | 2 | * GMMP_Notification.c |
lesmin | 0:7e575e5f88ec | 3 | * |
lesmin | 0:7e575e5f88ec | 4 | * Created on: 2013. 11. 18. |
lesmin | 0:7e575e5f88ec | 5 | * Author: root |
lesmin | 0:7e575e5f88ec | 6 | */ |
lesmin | 0:7e575e5f88ec | 7 | |
lesmin | 0:7e575e5f88ec | 8 | #include "GMMP_Notification.h" |
lesmin | 0:7e575e5f88ec | 9 | |
lesmin | 0:7e575e5f88ec | 10 | int GMMP_Notifi_Req(Notifi_Req* pNotifi_Req, int nPacketSize) |
lesmin | 0:7e575e5f88ec | 11 | { |
lesmin | 0:7e575e5f88ec | 12 | if(pNotifi_Req == NULL) |
lesmin | 0:7e575e5f88ec | 13 | { |
lesmin | 0:7e575e5f88ec | 14 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 15 | } |
lesmin | 0:7e575e5f88ec | 16 | |
lesmin | 0:7e575e5f88ec | 17 | if(CheckSocket() != 0) |
lesmin | 0:7e575e5f88ec | 18 | { |
lesmin | 0:7e575e5f88ec | 19 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 20 | } |
lesmin | 0:7e575e5f88ec | 21 | |
lesmin | 0:7e575e5f88ec | 22 | return WriteTCP( (char*)pNotifi_Req, nPacketSize ); |
lesmin | 0:7e575e5f88ec | 23 | } |
lesmin | 0:7e575e5f88ec | 24 | |
lesmin | 0:7e575e5f88ec | 25 | int GMMP_Notifi_Rsp(Notifi_Rsp* pNotifi_Rsp) |
lesmin | 0:7e575e5f88ec | 26 | { |
lesmin | 0:7e575e5f88ec | 27 | if(pNotifi_Rsp == NULL) |
lesmin | 0:7e575e5f88ec | 28 | { |
lesmin | 0:7e575e5f88ec | 29 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 30 | } |
lesmin | 0:7e575e5f88ec | 31 | |
lesmin | 0:7e575e5f88ec | 32 | if(CheckSocket() != 0) |
lesmin | 0:7e575e5f88ec | 33 | { |
lesmin | 0:7e575e5f88ec | 34 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 35 | } |
lesmin | 0:7e575e5f88ec | 36 | |
lesmin | 0:7e575e5f88ec | 37 | int nRet = ReadTCP( (char*)&pNotifi_Rsp->header , sizeof(pNotifi_Rsp->header) ); |
lesmin | 0:7e575e5f88ec | 38 | if(nRet != GMMP_SUCCESS) |
lesmin | 0:7e575e5f88ec | 39 | { |
lesmin | 0:7e575e5f88ec | 40 | return nRet; |
lesmin | 0:7e575e5f88ec | 41 | } |
lesmin | 0:7e575e5f88ec | 42 | |
lesmin | 0:7e575e5f88ec | 43 | ConvertShort cvtshort; |
lesmin | 0:7e575e5f88ec | 44 | cvtshort.sU8 = 0; |
lesmin | 0:7e575e5f88ec | 45 | memcpy(cvtshort.usShort, pNotifi_Rsp->header.usMessageLength, sizeof(pNotifi_Rsp->header.usMessageLength) ); |
lesmin | 0:7e575e5f88ec | 46 | |
lesmin | 0:7e575e5f88ec | 47 | int nReadSize = ltobs(cvtshort.sU8)- sizeof(pNotifi_Rsp->header); |
lesmin | 0:7e575e5f88ec | 48 | |
lesmin | 0:7e575e5f88ec | 49 | return ReadTCP( (char*)&pNotifi_Rsp->body, nReadSize); |
lesmin | 0:7e575e5f88ec | 50 | } |
lesmin | 0:7e575e5f88ec | 51 |