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_Ethernet_Example
Fork of GMMP_mbed by
GMMP_Reg.cpp
00001 #include "GMMP_Reg.h" 00002 00003 //Request 00004 int GMMP_GW_Reg_Req(GwRegist_Req* pRegist_Req) 00005 { 00006 debugln("GMMP_GW_Reg_Req()"); 00007 if(pRegist_Req == NULL) 00008 { 00009 return SERVER_INFO_NOT_FOUND; 00010 } 00011 00012 if(CheckSocket() != 0) 00013 { 00014 return SERVER_INFO_NOT_FOUND; 00015 } 00016 00017 return WriteTCP( (char*)pRegist_Req, sizeof(GwRegist_Req) ); 00018 } 00019 00020 int GMMP_GW_Reg_Rsp(GwRegist_Rsp* pRegist_Rsp) 00021 { 00022 if(pRegist_Rsp == NULL) 00023 { 00024 return SERVER_INFO_NOT_FOUND; 00025 } 00026 00027 if(CheckSocket() != 0) 00028 { 00029 return SERVER_INFO_NOT_FOUND; 00030 } 00031 00032 int nRet = ReadTCP( (char*)&pRegist_Rsp->header , sizeof(pRegist_Rsp->header) ); 00033 if(nRet != GMMP_SUCCESS) 00034 { 00035 return nRet; 00036 } 00037 00038 ConvertShort cvtshort; 00039 cvtshort.sU8 = 0; 00040 memcpy(cvtshort.usShort, pRegist_Rsp->header.usMessageLength, sizeof(pRegist_Rsp->header.usMessageLength) ); 00041 00042 int nReadSize = ltobs(cvtshort.sU8)- sizeof(pRegist_Rsp->header); 00043 00044 return ReadTCP( (char*)&pRegist_Rsp->body, nReadSize); 00045 } 00046 00047 int GMMP_Device_Reg_Req(DeviceRegist_Req* pRegist_Req) 00048 { 00049 if(pRegist_Req == NULL) 00050 { 00051 return SERVER_INFO_NOT_FOUND; 00052 } 00053 00054 if(CheckSocket() != 0) 00055 { 00056 return SERVER_INFO_NOT_FOUND; 00057 } 00058 00059 return WriteTCP( (char*)pRegist_Req, sizeof(DeviceRegist_Req) ); 00060 } 00061 00062 int GMMP_Device_Reg_Rsp(DeviceRegist_Rsp* pRegist_Rsp) 00063 { 00064 if(pRegist_Rsp == NULL) 00065 { 00066 return SERVER_INFO_NOT_FOUND; 00067 } 00068 00069 if(CheckSocket() != 0) 00070 { 00071 return SERVER_INFO_NOT_FOUND; 00072 } 00073 00074 int nRet = ReadTCP( (char*)&pRegist_Rsp->header , sizeof(pRegist_Rsp->header) ); 00075 if(nRet != GMMP_SUCCESS) 00076 { 00077 return nRet; 00078 } 00079 00080 ConvertShort cvtshort; 00081 cvtshort.sU8 = 0; 00082 memcpy(cvtshort.usShort, pRegist_Rsp->header.usMessageLength, sizeof(pRegist_Rsp->header.usMessageLength) ); 00083 00084 int nReadSize = ltobs(cvtshort.sU8)- sizeof(pRegist_Rsp->header); 00085 00086 return ReadTCP( (char*)&pRegist_Rsp->body, nReadSize); 00087 } 00088 00089 00090 int GMMP_GW_DeReg_Req(GwDeRegist_Req* pDeRegist_Req) 00091 { 00092 if(pDeRegist_Req == NULL) 00093 { 00094 return SERVER_INFO_NOT_FOUND; 00095 } 00096 00097 if(CheckSocket() != 0) 00098 { 00099 return SERVER_INFO_NOT_FOUND; 00100 } 00101 00102 return WriteTCP( (char*)pDeRegist_Req, sizeof(GwDeRegist_Req) ); 00103 } 00104 00105 int GMMP_GW_DeReg_Rsp(GwDeRegist_Rsp* pDeRegist_Rsp) 00106 { 00107 if(pDeRegist_Rsp == NULL) 00108 { 00109 return SERVER_INFO_NOT_FOUND; 00110 } 00111 00112 if(CheckSocket() != 0) 00113 { 00114 return SERVER_INFO_NOT_FOUND; 00115 } 00116 00117 int nRet = ReadTCP( (char*)&pDeRegist_Rsp->header , sizeof(pDeRegist_Rsp->header) ); 00118 if(nRet != GMMP_SUCCESS) 00119 { 00120 return nRet; 00121 } 00122 00123 ConvertShort cvtshort; 00124 cvtshort.sU8 = 0; 00125 memcpy(cvtshort.usShort, pDeRegist_Rsp->header.usMessageLength, sizeof(pDeRegist_Rsp->header.usMessageLength) ); 00126 00127 int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDeRegist_Rsp->header); 00128 00129 return ReadTCP( (char*)&pDeRegist_Rsp->body, nReadSize); 00130 } 00131 00132 int GMMP_Device_DeReg_Req(DeviceDeRegist_Req* pDeRegist_Req) 00133 { 00134 if(pDeRegist_Req == NULL) 00135 { 00136 return SERVER_INFO_NOT_FOUND; 00137 } 00138 00139 if(CheckSocket() != 0) 00140 { 00141 return SERVER_INFO_NOT_FOUND; 00142 } 00143 00144 return WriteTCP( (char*)pDeRegist_Req, sizeof(DeviceDeRegist_Req) ); 00145 } 00146 00147 int GMMP_Device_DeReg_Rsp(DeviceDeRegist_Rsp* pDeRegist_Req) 00148 { 00149 if(pDeRegist_Req == NULL) 00150 { 00151 return SERVER_INFO_NOT_FOUND; 00152 } 00153 00154 if(CheckSocket() != 0) 00155 { 00156 return SERVER_INFO_NOT_FOUND; 00157 } 00158 00159 int nRet = ReadTCP( (char*)&pDeRegist_Req->header , sizeof(pDeRegist_Req->header) ); 00160 if(nRet != GMMP_SUCCESS) 00161 { 00162 return nRet; 00163 } 00164 00165 ConvertShort cvtshort; 00166 cvtshort.sU8 = 0; 00167 memcpy(cvtshort.usShort, pDeRegist_Req->header.usMessageLength, sizeof(pDeRegist_Req->header.usMessageLength) ); 00168 00169 int nReadSize = ltobs(cvtshort.sU8)- sizeof(pDeRegist_Req->header); 00170 00171 return ReadTCP( (char*)&pDeRegist_Req->body, nReadSize); 00172 }
Generated on Tue Jul 12 2022 21:35:52 by
