ThingPlug GMMP library for mbed
Dependents: ThingPlug_WiFi_Example
Operation/ProfileInfo/GMMP_ProfileInfo.cpp@0:32c20cfb2b30, 2015-07-23 (annotated)
- Committer:
- lesmin
- Date:
- Thu Jul 23 00:55:15 2015 +0000
- Revision:
- 0:32c20cfb2b30
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lesmin | 0:32c20cfb2b30 | 1 | /* |
lesmin | 0:32c20cfb2b30 | 2 | * GMMP_ProfileInfo.c |
lesmin | 0:32c20cfb2b30 | 3 | * |
lesmin | 0:32c20cfb2b30 | 4 | * Created on: 2013. 11. 18. |
lesmin | 0:32c20cfb2b30 | 5 | * Author: root |
lesmin | 0:32c20cfb2b30 | 6 | */ |
lesmin | 0:32c20cfb2b30 | 7 | |
lesmin | 0:32c20cfb2b30 | 8 | #include "GMMP_ProfileInfo.h" |
lesmin | 0:32c20cfb2b30 | 9 | |
lesmin | 0:32c20cfb2b30 | 10 | int GMMP_Profile_Req(Profile_Req* pstProfile_Req) |
lesmin | 0:32c20cfb2b30 | 11 | { |
lesmin | 0:32c20cfb2b30 | 12 | if(pstProfile_Req == NULL) |
lesmin | 0:32c20cfb2b30 | 13 | { |
lesmin | 0:32c20cfb2b30 | 14 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:32c20cfb2b30 | 15 | } |
lesmin | 0:32c20cfb2b30 | 16 | |
lesmin | 0:32c20cfb2b30 | 17 | if(CheckSocket() != 0) |
lesmin | 0:32c20cfb2b30 | 18 | { |
lesmin | 0:32c20cfb2b30 | 19 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:32c20cfb2b30 | 20 | } |
lesmin | 0:32c20cfb2b30 | 21 | |
lesmin | 0:32c20cfb2b30 | 22 | return WriteTCP( (char*)pstProfile_Req, sizeof(Profile_Req) ); |
lesmin | 0:32c20cfb2b30 | 23 | } |
lesmin | 0:32c20cfb2b30 | 24 | |
lesmin | 0:32c20cfb2b30 | 25 | int GMMP_Profile_Rsp(Profile_Rsp* pstProfile_Rsp) |
lesmin | 0:32c20cfb2b30 | 26 | { |
lesmin | 0:32c20cfb2b30 | 27 | if(pstProfile_Rsp == NULL) |
lesmin | 0:32c20cfb2b30 | 28 | { |
lesmin | 0:32c20cfb2b30 | 29 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:32c20cfb2b30 | 30 | } |
lesmin | 0:32c20cfb2b30 | 31 | |
lesmin | 0:32c20cfb2b30 | 32 | if(CheckSocket() != 0) |
lesmin | 0:32c20cfb2b30 | 33 | { |
lesmin | 0:32c20cfb2b30 | 34 | return SERVER_INFO_NOT_FOUND; |
lesmin | 0:32c20cfb2b30 | 35 | } |
lesmin | 0:32c20cfb2b30 | 36 | |
lesmin | 0:32c20cfb2b30 | 37 | int nRet = ReadTCP( (char*)&pstProfile_Rsp->header , sizeof(pstProfile_Rsp->header) ); |
lesmin | 0:32c20cfb2b30 | 38 | if(nRet != GMMP_SUCCESS) |
lesmin | 0:32c20cfb2b30 | 39 | { |
lesmin | 0:32c20cfb2b30 | 40 | return nRet; |
lesmin | 0:32c20cfb2b30 | 41 | } |
lesmin | 0:32c20cfb2b30 | 42 | |
lesmin | 0:32c20cfb2b30 | 43 | ConvertShort cvtshort; |
lesmin | 0:32c20cfb2b30 | 44 | cvtshort.sU8 = 0; |
lesmin | 0:32c20cfb2b30 | 45 | memcpy(cvtshort.usShort, pstProfile_Rsp->header.usMessageLength, sizeof(pstProfile_Rsp->header.usMessageLength) ); |
lesmin | 0:32c20cfb2b30 | 46 | |
lesmin | 0:32c20cfb2b30 | 47 | int nReadSize = ltobs(cvtshort.sU8)- sizeof(pstProfile_Rsp->header); |
lesmin | 0:32c20cfb2b30 | 48 | |
lesmin | 0:32c20cfb2b30 | 49 | return ReadTCP( (char*)&pstProfile_Rsp->body, nReadSize); |
lesmin | 0:32c20cfb2b30 | 50 | } |