123

Dependencies:   MQTTSN

Committer:
m_ahsan
Date:
Tue Aug 06 05:32:43 2019 +0000
Revision:
15:8c473836feba
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m_ahsan 15:8c473836feba 1 #include <string>
m_ahsan 15:8c473836feba 2
m_ahsan 15:8c473836feba 3 int ty, op, cst, rsc;
m_ahsan 15:8c473836feba 4 std::string resourceType, cseType, operation, content, response;
m_ahsan 15:8c473836feba 5 bool RequestReachability;
m_ahsan 15:8c473836feba 6 bool rr, local;
m_ahsan 15:8c473836feba 7 std::string From, csi, api, poa,to, rqi, aei, rn;
m_ahsan 15:8c473836feba 8 char URI[40];
m_ahsan 15:8c473836feba 9 char* c_aei;
m_ahsan 15:8c473836feba 10 std::string con, cnf;
m_ahsan 15:8c473836feba 11 std::string nu;
m_ahsan 15:8c473836feba 12 std::string sur;
m_ahsan 15:8c473836feba 13 int net, nct;
m_ahsan 15:8c473836feba 14
m_ahsan 15:8c473836feba 15 extern struct Resource RES;
m_ahsan 15:8c473836feba 16 extern struct regularResource regRES;
m_ahsan 15:8c473836feba 17 extern struct announceableResource ancRES;
m_ahsan 15:8c473836feba 18 extern struct announcedResource ancdRES;
m_ahsan 15:8c473836feba 19 extern struct subordinateResource subRES;
m_ahsan 15:8c473836feba 20 extern struct announceableSubordinateResource ancsubRES;
m_ahsan 15:8c473836feba 21 extern struct announcedSubordinateResource ancdsubRES;
m_ahsan 15:8c473836feba 22
m_ahsan 15:8c473836feba 23 extern struct CreateAE CAE;
m_ahsan 15:8c473836feba 24 extern struct CreateCIN CIN;
m_ahsan 15:8c473836feba 25 extern struct CreateSub CSub;
m_ahsan 15:8c473836feba 26 extern struct respAE RAE;
m_ahsan 15:8c473836feba 27 extern struct respCnt RCnt;
m_ahsan 15:8c473836feba 28 extern struct respCin RCin;
m_ahsan 15:8c473836feba 29 extern struct respSub RSub;
m_ahsan 15:8c473836feba 30
m_ahsan 15:8c473836feba 31 char* CSE_ID = "cse01";
m_ahsan 15:8c473836feba 32 char* AE_ID;
m_ahsan 15:8c473836feba 33 bool lcl;
m_ahsan 15:8c473836feba 34
m_ahsan 15:8c473836feba 35 bool CreateAE;
m_ahsan 15:8c473836feba 36
m_ahsan 15:8c473836feba 37 void resource_type();
m_ahsan 15:8c473836feba 38 void Operation_Type();
m_ahsan 15:8c473836feba 39 void CSE_Type();
m_ahsan 15:8c473836feba 40
m_ahsan 15:8c473836feba 41 void resource_type()
m_ahsan 15:8c473836feba 42 {
m_ahsan 15:8c473836feba 43 switch (ty)
m_ahsan 15:8c473836feba 44 {
m_ahsan 15:8c473836feba 45 case 1:
m_ahsan 15:8c473836feba 46 resourceType = "accessControlPolicy";
m_ahsan 15:8c473836feba 47 content = "m2m:acp";
m_ahsan 15:8c473836feba 48 break;
m_ahsan 15:8c473836feba 49 case 2:
m_ahsan 15:8c473836feba 50 resourceType = "AE";
m_ahsan 15:8c473836feba 51 content = "m2m:ae";
m_ahsan 15:8c473836feba 52 break;
m_ahsan 15:8c473836feba 53 case 3:
m_ahsan 15:8c473836feba 54 resourceType = "container";
m_ahsan 15:8c473836feba 55 content = "m2m:cnt";
m_ahsan 15:8c473836feba 56 break;
m_ahsan 15:8c473836feba 57 case 4:
m_ahsan 15:8c473836feba 58 resourceType = "contentInstance";
m_ahsan 15:8c473836feba 59 content = "m2m:cin";
m_ahsan 15:8c473836feba 60 break;
m_ahsan 15:8c473836feba 61 case 5:
m_ahsan 15:8c473836feba 62 resourceType = "CSEBase";
m_ahsan 15:8c473836feba 63 content = "m2m:cb";
m_ahsan 15:8c473836feba 64 break;
m_ahsan 15:8c473836feba 65 case 6:
m_ahsan 15:8c473836feba 66 resourceType = "delivery";
m_ahsan 15:8c473836feba 67 content = "m2m:dlv";
m_ahsan 15:8c473836feba 68 break;
m_ahsan 15:8c473836feba 69 case 7:
m_ahsan 15:8c473836feba 70 resourceType = "eventConfig";
m_ahsan 15:8c473836feba 71 content = "m2m:evcg";
m_ahsan 15:8c473836feba 72 break;
m_ahsan 15:8c473836feba 73 case 8:
m_ahsan 15:8c473836feba 74 resourceType = "execInstance";
m_ahsan 15:8c473836feba 75 content = "m2m:exin";
m_ahsan 15:8c473836feba 76 break;
m_ahsan 15:8c473836feba 77 case 9:
m_ahsan 15:8c473836feba 78 resourceType = "group";
m_ahsan 15:8c473836feba 79 content = "m2m:grp";
m_ahsan 15:8c473836feba 80 break;
m_ahsan 15:8c473836feba 81 case 10:
m_ahsan 15:8c473836feba 82 resourceType = "locationPolicy";
m_ahsan 15:8c473836feba 83 content = "m2m:lcp";
m_ahsan 15:8c473836feba 84 break;
m_ahsan 15:8c473836feba 85 case 11:
m_ahsan 15:8c473836feba 86 resourceType = "m2mServiceSubscriptionProfile";
m_ahsan 15:8c473836feba 87 content = "m2m:mssp";
m_ahsan 15:8c473836feba 88 break;
m_ahsan 15:8c473836feba 89 case 12:
m_ahsan 15:8c473836feba 90 resourceType = "mgmtCmd";
m_ahsan 15:8c473836feba 91 content = "m2m:mgc";
m_ahsan 15:8c473836feba 92 break;
m_ahsan 15:8c473836feba 93 case 13:
m_ahsan 15:8c473836feba 94 resourceType = "mgmtObj";
m_ahsan 15:8c473836feba 95 //content = "m2m:cnt";
m_ahsan 15:8c473836feba 96 break;
m_ahsan 15:8c473836feba 97 case 14:
m_ahsan 15:8c473836feba 98 resourceType = "node";
m_ahsan 15:8c473836feba 99 content = "m2m:nod";
m_ahsan 15:8c473836feba 100 break;
m_ahsan 15:8c473836feba 101 case 15:
m_ahsan 15:8c473836feba 102 resourceType = "pollingChannel";
m_ahsan 15:8c473836feba 103 content = "m2m:contenth";
m_ahsan 15:8c473836feba 104 break;
m_ahsan 15:8c473836feba 105 case 16:
m_ahsan 15:8c473836feba 106 resourceType = "remoteCSE";
m_ahsan 15:8c473836feba 107 content = "m2m:csr";
m_ahsan 15:8c473836feba 108 break;
m_ahsan 15:8c473836feba 109 case 17:
m_ahsan 15:8c473836feba 110 resourceType = "request";
m_ahsan 15:8c473836feba 111 content = "m2m:req";
m_ahsan 15:8c473836feba 112 break;
m_ahsan 15:8c473836feba 113 case 18:
m_ahsan 15:8c473836feba 114 resourceType = "schedule";
m_ahsan 15:8c473836feba 115 content = "m2m:sch";
m_ahsan 15:8c473836feba 116 break;
m_ahsan 15:8c473836feba 117 case 19:
m_ahsan 15:8c473836feba 118 resourceType = "serviceSubscribedAppRule";
m_ahsan 15:8c473836feba 119 content = "m2m:asar";
m_ahsan 15:8c473836feba 120 break;
m_ahsan 15:8c473836feba 121 case 20:
m_ahsan 15:8c473836feba 122 resourceType = "serviceSubscribedNode";
m_ahsan 15:8c473836feba 123 content = "m2m:svsn";
m_ahsan 15:8c473836feba 124 break;
m_ahsan 15:8c473836feba 125 case 21:
m_ahsan 15:8c473836feba 126 resourceType = "statsCollect";
m_ahsan 15:8c473836feba 127 content = "m2m:stcl";
m_ahsan 15:8c473836feba 128 break;
m_ahsan 15:8c473836feba 129 case 22:
m_ahsan 15:8c473836feba 130 resourceType = "statsConfig";
m_ahsan 15:8c473836feba 131 content = "m2m:stcg";
m_ahsan 15:8c473836feba 132 break;
m_ahsan 15:8c473836feba 133 case 23:
m_ahsan 15:8c473836feba 134 resourceType = "subscription";
m_ahsan 15:8c473836feba 135 content = "m2m:sub";
m_ahsan 15:8c473836feba 136 break;
m_ahsan 15:8c473836feba 137 case 10001:
m_ahsan 15:8c473836feba 138 resourceType = "accessControlPolicyAnnc";
m_ahsan 15:8c473836feba 139 content = "m2m:acpA";
m_ahsan 15:8c473836feba 140 break;
m_ahsan 15:8c473836feba 141 case 10002:
m_ahsan 15:8c473836feba 142 resourceType = "AEAnnc";
m_ahsan 15:8c473836feba 143 content = "m2m:aeA";
m_ahsan 15:8c473836feba 144 break;
m_ahsan 15:8c473836feba 145 case 10003:
m_ahsan 15:8c473836feba 146 resourceType = "containerAnnc";
m_ahsan 15:8c473836feba 147 content = "m2m:cntA";
m_ahsan 15:8c473836feba 148 break;
m_ahsan 15:8c473836feba 149 case 10004:
m_ahsan 15:8c473836feba 150 resourceType = "contentInstanceAnnc";
m_ahsan 15:8c473836feba 151 content = "m2m:cinA";
m_ahsan 15:8c473836feba 152 break;
m_ahsan 15:8c473836feba 153 case 10009:
m_ahsan 15:8c473836feba 154 resourceType = "groupAnnc";
m_ahsan 15:8c473836feba 155 content = "m2m:grpA";
m_ahsan 15:8c473836feba 156 break;
m_ahsan 15:8c473836feba 157 case 10010:
m_ahsan 15:8c473836feba 158 resourceType = "locationPolicyAnnc";
m_ahsan 15:8c473836feba 159 content = "m2m:lcpA";
m_ahsan 15:8c473836feba 160 break;
m_ahsan 15:8c473836feba 161 case 10013:
m_ahsan 15:8c473836feba 162 resourceType = "mgmtObjAnnc";
m_ahsan 15:8c473836feba 163 //content = "m2m:cnt";
m_ahsan 15:8c473836feba 164 break;
m_ahsan 15:8c473836feba 165 case 10014:
m_ahsan 15:8c473836feba 166 resourceType = "nodeAnnc";
m_ahsan 15:8c473836feba 167 content = "m2m:nodA";
m_ahsan 15:8c473836feba 168 break;
m_ahsan 15:8c473836feba 169 case 10016:
m_ahsan 15:8c473836feba 170 resourceType = "remoteCSEAnnc";
m_ahsan 15:8c473836feba 171 content = "m2m:csrA";
m_ahsan 15:8c473836feba 172 break;
m_ahsan 15:8c473836feba 173 case 10018:
m_ahsan 15:8c473836feba 174 resourceType = "scheduleAnnc";
m_ahsan 15:8c473836feba 175 content = "m2m:schA";
m_ahsan 15:8c473836feba 176 break;
m_ahsan 15:8c473836feba 177 }
m_ahsan 15:8c473836feba 178 }
m_ahsan 15:8c473836feba 179 void CSE_Type()
m_ahsan 15:8c473836feba 180 {
m_ahsan 15:8c473836feba 181 switch (cst)
m_ahsan 15:8c473836feba 182 {
m_ahsan 15:8c473836feba 183 case 1:
m_ahsan 15:8c473836feba 184 cseType = "IN_CSE";
m_ahsan 15:8c473836feba 185 break;
m_ahsan 15:8c473836feba 186 case 2:
m_ahsan 15:8c473836feba 187 cseType = "MN_CSE";
m_ahsan 15:8c473836feba 188 break;
m_ahsan 15:8c473836feba 189 case 3:
m_ahsan 15:8c473836feba 190 cseType = "ASN_CSE";
m_ahsan 15:8c473836feba 191 break;
m_ahsan 15:8c473836feba 192 }
m_ahsan 15:8c473836feba 193 }
m_ahsan 15:8c473836feba 194 void Operation_Type() //CRUD+N
m_ahsan 15:8c473836feba 195 {
m_ahsan 15:8c473836feba 196 switch (op)
m_ahsan 15:8c473836feba 197 {
m_ahsan 15:8c473836feba 198 case 1:
m_ahsan 15:8c473836feba 199 operation = "Create";
m_ahsan 15:8c473836feba 200 break;
m_ahsan 15:8c473836feba 201 case 2:
m_ahsan 15:8c473836feba 202 operation = "Retrieve";
m_ahsan 15:8c473836feba 203 break;
m_ahsan 15:8c473836feba 204 case 3:
m_ahsan 15:8c473836feba 205 operation = "Update";
m_ahsan 15:8c473836feba 206 break;
m_ahsan 15:8c473836feba 207 case 4:
m_ahsan 15:8c473836feba 208 operation = "Delete";
m_ahsan 15:8c473836feba 209 break;
m_ahsan 15:8c473836feba 210 case 5:
m_ahsan 15:8c473836feba 211 operation = "Notify";
m_ahsan 15:8c473836feba 212 break;
m_ahsan 15:8c473836feba 213 }
m_ahsan 15:8c473836feba 214 }
m_ahsan 15:8c473836feba 215 void Response_Type()
m_ahsan 15:8c473836feba 216 {
m_ahsan 15:8c473836feba 217 switch (rsc)
m_ahsan 15:8c473836feba 218 {
m_ahsan 15:8c473836feba 219 //Informational response class
m_ahsan 15:8c473836feba 220 case 1000:
m_ahsan 15:8c473836feba 221 response = "ACCEPTED";
m_ahsan 15:8c473836feba 222 break;
m_ahsan 15:8c473836feba 223 case 1001:
m_ahsan 15:8c473836feba 224 response = "ACCEPTED for nonBlockingRequestSynch";
m_ahsan 15:8c473836feba 225 break;
m_ahsan 15:8c473836feba 226 case 1002:
m_ahsan 15:8c473836feba 227 response = "ACCEPTED for nonBlockingRequestAsynch";
m_ahsan 15:8c473836feba 228 break;
m_ahsan 15:8c473836feba 229 //specifies the RSCs for successful responses.
m_ahsan 15:8c473836feba 230 case 2000:
m_ahsan 15:8c473836feba 231 response = "OK";
m_ahsan 15:8c473836feba 232 break;
m_ahsan 15:8c473836feba 233 case 2001:
m_ahsan 15:8c473836feba 234 response = "CREATED";
m_ahsan 15:8c473836feba 235 break;
m_ahsan 15:8c473836feba 236 case 2002:
m_ahsan 15:8c473836feba 237 response = "DELETED";
m_ahsan 15:8c473836feba 238 break;
m_ahsan 15:8c473836feba 239 case 2004:
m_ahsan 15:8c473836feba 240 response = "UPDATED";
m_ahsan 15:8c473836feba 241 break;
m_ahsan 15:8c473836feba 242 //RSCs for Originator error response class
m_ahsan 15:8c473836feba 243 case 4000:
m_ahsan 15:8c473836feba 244 response = "BAD_REQUEST";
m_ahsan 15:8c473836feba 245 break;
m_ahsan 15:8c473836feba 246 case 4001:
m_ahsan 15:8c473836feba 247 response = "RELEASE_VERSION_NOT_SUPPORTED";
m_ahsan 15:8c473836feba 248 break;
m_ahsan 15:8c473836feba 249 case 4004:
m_ahsan 15:8c473836feba 250 response = "NOT_FOUND";
m_ahsan 15:8c473836feba 251 break;
m_ahsan 15:8c473836feba 252 case 4005:
m_ahsan 15:8c473836feba 253 response = "OPERATION_NOT_ALLOWED";
m_ahsan 15:8c473836feba 254 break;
m_ahsan 15:8c473836feba 255 case 4008:
m_ahsan 15:8c473836feba 256 response = "REQUEST_TIMEOUT";
m_ahsan 15:8c473836feba 257 break;
m_ahsan 15:8c473836feba 258 case 4101:
m_ahsan 15:8c473836feba 259 response = "SUBSCRIPTION_CREATOR_HAS_NO_PRIVILEGE";
m_ahsan 15:8c473836feba 260 break;
m_ahsan 15:8c473836feba 261 case 4102:
m_ahsan 15:8c473836feba 262 response = "CONTENTS_UNACCEPTABLE";
m_ahsan 15:8c473836feba 263 break;
m_ahsan 15:8c473836feba 264 case 4103:
m_ahsan 15:8c473836feba 265 response = "ORIGINATOR_HAS_NO_PRIVILEGE";
m_ahsan 15:8c473836feba 266 break;
m_ahsan 15:8c473836feba 267 case 4104:
m_ahsan 15:8c473836feba 268 response = "GROUP_REQUEST_IDENTIFIER_EXISTS";
m_ahsan 15:8c473836feba 269 break;
m_ahsan 15:8c473836feba 270 case 4105:
m_ahsan 15:8c473836feba 271 response = "CONFLICT";
m_ahsan 15:8c473836feba 272 break;
m_ahsan 15:8c473836feba 273 case 4106:
m_ahsan 15:8c473836feba 274 response = "ORIGINATOR_HAS_NOT_REGISTERED";
m_ahsan 15:8c473836feba 275 break;
m_ahsan 15:8c473836feba 276 case 4107:
m_ahsan 15:8c473836feba 277 response = "SECURITY_ASSOCIATION_REQUIRED";
m_ahsan 15:8c473836feba 278 break;
m_ahsan 15:8c473836feba 279 case 4108:
m_ahsan 15:8c473836feba 280 response = "INVALID_CHILD_RESOURCE_TYPE";
m_ahsan 15:8c473836feba 281 break;
m_ahsan 15:8c473836feba 282 case 4109:
m_ahsan 15:8c473836feba 283 response = "NO_MEMBERS";
m_ahsan 15:8c473836feba 284 break;
m_ahsan 15:8c473836feba 285 case 4110:
m_ahsan 15:8c473836feba 286 response = "GROUP_MEMBER_TYPE_INCONSISTENT";
m_ahsan 15:8c473836feba 287 break;
m_ahsan 15:8c473836feba 288 case 4111:
m_ahsan 15:8c473836feba 289 response = "ESPRIM_UNSUPPORTED_OPTION";
m_ahsan 15:8c473836feba 290 break;
m_ahsan 15:8c473836feba 291 case 4112:
m_ahsan 15:8c473836feba 292 response = "ESPRIM_UNKNOWN_KEY_ID";
m_ahsan 15:8c473836feba 293 break;
m_ahsan 15:8c473836feba 294 case 4113:
m_ahsan 15:8c473836feba 295 response = "ESPRIM_UNKNOWN_ORIG_RAND_ID";
m_ahsan 15:8c473836feba 296 break;
m_ahsan 15:8c473836feba 297 case 4114:
m_ahsan 15:8c473836feba 298 response = "ESPRIM_UNKNOWN_RECV_RAND_ID";
m_ahsan 15:8c473836feba 299 break;
m_ahsan 15:8c473836feba 300 case 4115:
m_ahsan 15:8c473836feba 301 response = "ESPRIM_BAD_MAC";
m_ahsan 15:8c473836feba 302 break;
m_ahsan 15:8c473836feba 303 case 4116:
m_ahsan 15:8c473836feba 304 response = "ESPRIM_IMPERSONATION_ERROR";
m_ahsan 15:8c473836feba 305 break;
m_ahsan 15:8c473836feba 306 case 4117:
m_ahsan 15:8c473836feba 307 response = "ORIGINATOR_HAS_ALREADY_REGISTERED";
m_ahsan 15:8c473836feba 308 break;
m_ahsan 15:8c473836feba 309 case 4118:
m_ahsan 15:8c473836feba 310 response = "ONTOLOGY_NOT_AVAILABLE";
m_ahsan 15:8c473836feba 311 break;
m_ahsan 15:8c473836feba 312 case 4119:
m_ahsan 15:8c473836feba 313 response = "LINKED_SEMANTICS_NOT_AVAILABLE";
m_ahsan 15:8c473836feba 314 break;
m_ahsan 15:8c473836feba 315 case 4120:
m_ahsan 15:8c473836feba 316 response = "INVALID_SEMANTICS";
m_ahsan 15:8c473836feba 317 break;
m_ahsan 15:8c473836feba 318 case 4121:
m_ahsan 15:8c473836feba 319 response = "MASHUP_MEMBER_NOT_FOUND";
m_ahsan 15:8c473836feba 320 break;
m_ahsan 15:8c473836feba 321 case 4122:
m_ahsan 15:8c473836feba 322 response = "INVALID_TRIGGER_PURPOSE";
m_ahsan 15:8c473836feba 323 break;
m_ahsan 15:8c473836feba 324 }
m_ahsan 15:8c473836feba 325 }