Modified for W5500 Ethernet initialize
Fork of GMMP_mbed by
Operation/Delivery/GMMP_Delivery.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 | #include "GMMP_Delivery.h" |
lesmin | 0:7e575e5f88ec | 2 | |
lesmin | 0:7e575e5f88ec | 3 | int GMMP_Delivery_Req(Delivery_Req* pDelivery_Req, int nPacketSize) |
lesmin | 0:7e575e5f88ec | 4 | { |
lesmin | 0:7e575e5f88ec | 5 | if(pDelivery_Req == NULL) |
lesmin | 0:7e575e5f88ec | 6 | { |
lesmin | 0:7e575e5f88ec | 7 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 8 | } |
lesmin | 0:7e575e5f88ec | 9 | |
lesmin | 0:7e575e5f88ec | 10 | if(CheckSocket() != 0) |
lesmin | 0:7e575e5f88ec | 11 | { |
lesmin | 0:7e575e5f88ec | 12 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 13 | } |
lesmin | 0:7e575e5f88ec | 14 | |
lesmin | 0:7e575e5f88ec | 15 | return WriteTCP((char*)pDelivery_Req, nPacketSize); |
lesmin | 0:7e575e5f88ec | 16 | } |
lesmin | 0:7e575e5f88ec | 17 | |
lesmin | 0:7e575e5f88ec | 18 | int GMMP_Delivery_Rsp(Delivery_Rsp* pDelivery_Rsp) |
lesmin | 0:7e575e5f88ec | 19 | { |
lesmin | 0:7e575e5f88ec | 20 | if(pDelivery_Rsp == NULL) |
lesmin | 0:7e575e5f88ec | 21 | { |
lesmin | 0:7e575e5f88ec | 22 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 23 | } |
lesmin | 0:7e575e5f88ec | 24 | |
lesmin | 0:7e575e5f88ec | 25 | if(CheckSocket() != 0) |
lesmin | 0:7e575e5f88ec | 26 | { |
lesmin | 0:7e575e5f88ec | 27 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:7e575e5f88ec | 28 | } |
lesmin | 0:7e575e5f88ec | 29 | |
lesmin | 0:7e575e5f88ec | 30 | int nRet = ReadTCP((char*)&pDelivery_Rsp->header, sizeof(pDelivery_Rsp->header)); |
lesmin | 0:7e575e5f88ec | 31 | if(nRet != GMMP_SUCCESS) |
lesmin | 0:7e575e5f88ec | 32 | { |
lesmin | 0:7e575e5f88ec | 33 | return nRet; |
lesmin | 0:7e575e5f88ec | 34 | } |
lesmin | 0:7e575e5f88ec | 35 | |
lesmin | 0:7e575e5f88ec | 36 | ConvertShort cvtshort; |
lesmin | 0:7e575e5f88ec | 37 | cvtshort.sU8 = 0; |
lesmin | 0:7e575e5f88ec | 38 | memcpy(cvtshort.usShort, pDelivery_Rsp->header.usMessageLength, sizeof(pDelivery_Rsp->header.usMessageLength)); |
lesmin | 0:7e575e5f88ec | 39 | |
lesmin | 0:7e575e5f88ec | 40 | int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDelivery_Rsp->header); |
lesmin | 0:7e575e5f88ec | 41 | |
lesmin | 0:7e575e5f88ec | 42 | return ReadTCP((char*)&pDelivery_Rsp->body, nReadSize); |
lesmin | 0:7e575e5f88ec | 43 | } |
lesmin | 0:7e575e5f88ec | 44 |