1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "resourcehandler.h"
25 #include "ocpayload.h"
26 #include "oic_string.h"
30 * @brief Logging tag for module name.
32 #define ES_RH_TAG "ES_RH"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
39 * @brief Structure for holding the Provisioning status and target information required to
40 * connect to the target network
42 static ProvResource gProvResource;
43 static WiFiResource gWiFiResource;
44 static CloudResource gCloudResource;
45 static DevConfResource gDevConfResource;
47 //-----------------------------------------------------------------------------
48 // Private internal function prototypes
49 //-----------------------------------------------------------------------------
50 OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *ehRequest,
52 const char *getResult(OCStackResult result);
53 OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
54 OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
55 OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload);
56 OCRepPayload* constructResponse(OCEntityHandlerRequest *ehRequest);
58 ESEnrolleeResourceEventCallback gNetworkInfoProvEventCb = NULL;
60 void RegisterResourceEventCallBack(ESEnrolleeResourceEventCallback cb)
62 gNetworkInfoProvEventCb = cb;
65 void UnRegisterResourceEventCallBack()
67 if (gNetworkInfoProvEventCb)
69 gNetworkInfoProvEventCb = NULL;
73 void GetTargetNetworkInfoFromProvResource(char *name, char *pass)
75 if (name != NULL && pass != NULL)
77 OICStrcpy(name, MAXSSIDLEN, gWiFiResource.ssid);
78 OICStrcpy(pass, MAXNETCREDLEN, gWiFiResource.cred);
82 OCStackResult initProvResource(bool isSecured)
84 gProvResource.status = NO_PROVISION;
85 gProvResource.trigger = false;
87 OCStackResult res = OC_STACK_ERROR;
90 res = OCCreateResource(&gProvResource.handle, OC_RSRVD_ES_RES_TYPE_PROV,
91 OC_RSRVD_INTERFACE_DEFAULT,
92 OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,
93 NULL, OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
96 res = OCCreateResource(&gProvResource.handle, OC_RSRVD_ES_RES_TYPE_PROV,
97 OC_RSRVD_INTERFACE_DEFAULT,
98 OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,
99 NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
103 OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
107 res = OCBindResourceInterfaceToResource(gProvResource.handle, OC_RSRVD_INTERFACE_LL);
110 OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
113 res = OCBindResourceInterfaceToResource(gProvResource.handle, OC_RSRVD_INTERFACE_BATCH);
116 OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
120 OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
124 OCStackResult initWiFiResource(bool isSecured)
126 OCStackResult res = OC_STACK_ERROR;
128 gWiFiResource.supportedFreq = WiFi_BOTH;
129 gWiFiResource.supportedMode[0] = WiFi_11A;
130 gWiFiResource.supportedMode[1] = WiFi_11B;
131 gWiFiResource.supportedMode[2] = WiFi_11G;
132 gWiFiResource.supportedMode[3] = WiFi_11N;
133 gWiFiResource.numMode = 4;
134 gWiFiResource.authType = NONE_AUTH;
135 gWiFiResource.encType = NONE_ENC;
136 OICStrcpy(gWiFiResource.ssid, sizeof(gWiFiResource.ssid), "");
137 OICStrcpy(gWiFiResource.cred, sizeof(gWiFiResource.cred), "");
141 res = OCCreateResource(&gWiFiResource.handle, OC_RSRVD_ES_RES_TYPE_WIFI,
142 OC_RSRVD_INTERFACE_DEFAULT,
143 OC_RSRVD_ES_URI_WIFI, OCEntityHandlerCb,
144 NULL, OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
147 res = OCCreateResource(&gWiFiResource.handle, OC_RSRVD_ES_RES_TYPE_WIFI,
148 OC_RSRVD_INTERFACE_DEFAULT,
149 OC_RSRVD_ES_URI_WIFI, OCEntityHandlerCb,
150 NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
153 OIC_LOG_V(INFO, ES_RH_TAG, "Created WiFi resource with result: %s", getResult(res));
158 OCStackResult initCloudServerResource(bool isSecured)
160 OCStackResult res = OC_STACK_ERROR;
162 OICStrcpy(gCloudResource.authCode, sizeof(gCloudResource.authCode), "");
163 OICStrcpy(gCloudResource.authProvider, sizeof(gCloudResource.authProvider), "");
164 OICStrcpy(gCloudResource.ciServer, sizeof(gCloudResource.ciServer), "");
168 res = OCCreateResource(&gCloudResource.handle, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER,
169 OC_RSRVD_INTERFACE_DEFAULT,
170 OC_RSRVD_ES_URI_CLOUDSERVER, OCEntityHandlerCb,
171 NULL, OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
174 res = OCCreateResource(&gCloudResource.handle, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER,
175 OC_RSRVD_INTERFACE_DEFAULT,
176 OC_RSRVD_ES_URI_CLOUDSERVER, OCEntityHandlerCb,
177 NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
180 OIC_LOG_V(INFO, ES_RH_TAG, "Created CloudServer resource with result: %s", getResult(res));
185 OCStackResult initDevConfResource(bool isSecured)
187 OCStackResult res = OC_STACK_ERROR;
189 OICStrcpy(gDevConfResource.devName, sizeof(gDevConfResource.devName), "");
190 OICStrcpy(gDevConfResource.country, sizeof(gDevConfResource.country), "");
191 OICStrcpy(gDevConfResource.language, sizeof(gDevConfResource.language), "");
195 res = OCCreateResource(&gDevConfResource.handle, OC_RSRVD_ES_RES_TYPE_DEVCONF,
196 OC_RSRVD_INTERFACE_DEFAULT,
197 OC_RSRVD_ES_URI_DEVCONF, OCEntityHandlerCb,
198 NULL, OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE);
201 res = OCCreateResource(&gDevConfResource.handle, OC_RSRVD_ES_RES_TYPE_DEVCONF,
202 OC_RSRVD_INTERFACE_DEFAULT,
203 OC_RSRVD_ES_URI_DEVCONF, OCEntityHandlerCb,
204 NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
207 OIC_LOG_V(INFO, ES_RH_TAG, "Created DevConf resource with result: %s", getResult(res));
212 void updateProvResource(OCRepPayload* input)
214 OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.status %lld", gProvResource.status);
216 if (OCRepPayloadGetPropBool(input, OC_RSRVD_ES_TRIGGER, &trigger))
219 gProvResource.trigger = trigger;
223 void updateWiFiResource(OCRepPayload* input)
226 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_SSID, &ssid))
228 OICStrcpy(gWiFiResource.ssid, sizeof(gWiFiResource.ssid), ssid);
229 OIC_LOG(INFO, ES_RH_TAG, "got ssid");
233 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CRED, &cred))
235 OICStrcpy(gWiFiResource.cred, sizeof(gWiFiResource.cred), cred);
236 OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.cred %s", gWiFiResource.cred);
240 if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_AUTHTYPE, &authType))
242 gWiFiResource.authType = authType;
243 OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.authType %u", gWiFiResource.authType);
247 if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_ENCTYPE, &encType))
249 gWiFiResource.encType = encType;
250 OIC_LOG_V(INFO, ES_RH_TAG, "gWiFiResource.encType %u", gWiFiResource.encType);
253 void updateCloudResource(OCRepPayload* input)
256 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHCODE, &authCode))
258 OICStrcpy(gCloudResource.authCode, sizeof(gCloudResource.authCode), authCode);
259 OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authCode %s", gCloudResource.authCode);
263 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHPROVIDER, &authProvider))
265 OICStrcpy(gCloudResource.authProvider, sizeof(gCloudResource.authProvider), authProvider);
266 OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.authServerUrl %s", gCloudResource.authProvider);
270 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CISERVER, &ciServer))
272 OICStrcpy(gCloudResource.ciServer, sizeof(gCloudResource.ciServer), ciServer);
273 OIC_LOG_V(INFO, ES_RH_TAG, "gCloudResource.ciServer %s", gCloudResource.ciServer);
277 void updateDevConfResource(OCRepPayload* input)
280 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHCODE, &country))
282 OICStrcpy(gDevConfResource.country, sizeof(gDevConfResource.country), country);
283 OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.country %s", gDevConfResource.country);
287 if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHPROVIDER, &language))
289 OICStrcpy(gDevConfResource.language, sizeof(gDevConfResource.language), language);
290 OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.language %s", gDevConfResource.language);
294 OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
296 OCRepPayload* payload = OCRepPayloadCreate();
299 OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
303 OIC_LOG(INFO, ES_RH_TAG, "constructResponse wifi res");
304 OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI);
306 size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0};
307 OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, gWiFiResource.supportedMode, dimensions);
309 OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_SUPPORTEDWIFIFREQ, gWiFiResource.supportedFreq);
310 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_SSID, gWiFiResource.ssid);
311 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CRED, gWiFiResource.cred);
312 OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, gWiFiResource.authType);
313 OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, gWiFiResource.encType);
315 printf("%s\n", gWiFiResource.ssid);
320 OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
322 OCRepPayload* payload = OCRepPayloadCreate();
325 OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
329 OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
330 OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_CLOUDSERVER);
331 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHCODE, gCloudResource.authCode);
332 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHPROVIDER, gCloudResource.authProvider);
333 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CISERVER, gCloudResource.ciServer);
338 OCRepPayload* constructResponseOfDevConf(OCEntityHandlerRequest *ehRequest)
340 OCRepPayload* payload = OCRepPayloadCreate();
343 OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
347 OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
348 OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_DEVCONF);
349 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, gDevConfResource.devName);
350 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, gDevConfResource.language);
351 OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, gDevConfResource.country);
356 OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
358 OCRepPayload* payload = OCRepPayloadCreate();
361 OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
365 OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
366 OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
367 OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, gProvResource.status);
368 OCRepPayloadSetPropBool(payload, OC_RSRVD_ES_TRIGGER, gProvResource.trigger);
372 if(strstr(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
373 {// When Provisioning resource has a GET with BatchInterface
374 payload->next = constructResponseOfWiFi(ehRequest);
377 payload->next->next = constructResponseOfCloud(ehRequest);
381 if(payload->next->next)
382 payload->next->next->next = constructResponseOfDevConf(ehRequest);
392 OCStackResult CreateEasySetupResources(bool isSecured)
394 OCStackResult res = OC_STACK_ERROR;
396 res = initProvResource(isSecured);
399 // TODO: destroy logic will be added
403 res = initWiFiResource(isSecured);
406 // TODO: destroy logic will be added
410 res = initCloudServerResource(isSecured);
413 // TODO: destroy logic will be added
417 res = initDevConfResource(isSecured);
420 // TODO: destroy logic will be added
424 OCBindResource(gProvResource.handle, gWiFiResource.handle);
425 OCBindResource(gProvResource.handle, gCloudResource.handle);
426 OCBindResource(gProvResource.handle, gDevConfResource.handle);
428 OIC_LOG_V(INFO, ES_RH_TAG, "Created all resources with result: %s", getResult(res));
432 OCStackResult DeleteProvisioningResource()
434 OCStackResult res = OCDeleteResource(gProvResource.handle);
435 if (res != OC_STACK_OK)
437 OIC_LOG_V(INFO, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res));
443 OCStackResult DeleteEasySetupResources()
445 OCStackResult res = OCDeleteResource(gProvResource.handle);
446 if (res != OC_STACK_OK)
448 OIC_LOG_V(INFO, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res));
450 res = OCDeleteResource(gWiFiResource.handle);
451 if (res != OC_STACK_OK)
453 OIC_LOG_V(INFO, ES_RH_TAG, "Deleting WiFi resource error with result: %s", getResult(res));
455 res = OCDeleteResource(gCloudResource.handle);
456 if (res != OC_STACK_OK)
458 OIC_LOG_V(INFO, ES_RH_TAG, "Deleting CloudServer resource error with result: %s", getResult(res));
460 res = OCDeleteResource(gDevConfResource.handle);
461 if (res != OC_STACK_OK)
463 OIC_LOG_V(INFO, ES_RH_TAG, "Deleting DevConf resource error with result: %s", getResult(res));
469 OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload **payload)
471 OCEntityHandlerResult ehResult = OC_EH_ERROR;
474 OIC_LOG(ERROR, ES_RH_TAG, "Request is Null");
477 if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
479 OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
483 OCRepPayload *getResp = NULL;
485 if(ehRequest->resource == gProvResource.handle)
486 getResp = constructResponseOfProv(ehRequest);
487 else if(ehRequest->resource == gWiFiResource.handle)
488 getResp = constructResponseOfWiFi(ehRequest);
489 else if(ehRequest->resource == gCloudResource.handle)
490 getResp = constructResponseOfCloud(ehRequest);
491 else if(ehRequest->resource == gDevConfResource.handle)
492 getResp = constructResponseOfDevConf(ehRequest);
496 OIC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
506 OCEntityHandlerResult ProcessPostRequest(OCEntityHandlerRequest *ehRequest, OCRepPayload** payload)
508 OIC_LOG(INFO, ES_RH_TAG, "ProcessPostRequest enter");
509 OCEntityHandlerResult ehResult = OC_EH_ERROR;
510 if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
512 OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
516 OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
519 OIC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
523 if(ehRequest->resource == gProvResource.handle)
524 updateProvResource(input);
525 else if(ehRequest->resource == gWiFiResource.handle)
526 updateWiFiResource(input);
527 else if(ehRequest->resource == gCloudResource.handle)
528 updateCloudResource(input);
529 else if(ehRequest->resource == gDevConfResource.handle)
530 updateDevConfResource(input);
532 //ES_PS_PROVISIONING_COMPLETED state indicates that already provisioning is completed.
533 // A new request for provisioning means overriding existing network provisioning information.
534 if (gProvResource.trigger)
536 OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning already completed."
537 "Tiggering the network connection");
539 if (gNetworkInfoProvEventCb)
541 gNetworkInfoProvEventCb(ES_RECVTRIGGEROFPROVRES);
546 OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
547 "Network handler not registered. Failed to connect to the network");
548 ehResult = OC_EH_ERROR;
554 OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
557 OCRepPayload *getResp = NULL;
558 if(ehRequest->resource == gProvResource.handle)
559 getResp = constructResponseOfProv(ehRequest);
560 else if(ehRequest->resource == gWiFiResource.handle)
561 getResp = constructResponseOfWiFi(ehRequest);
562 else if(ehRequest->resource == gCloudResource.handle)
563 getResp = constructResponseOfCloud(ehRequest);
564 else if(ehRequest->resource == gDevConfResource.handle)
565 getResp = constructResponseOfDevConf(ehRequest);
567 if (gProvResource.trigger)// Trigger false should be restored after executed
568 gProvResource.trigger = false;
572 OIC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
582 OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest * ehRequest,
583 OCRepPayload** payload)
585 OCEntityHandlerResult ehResult = OC_EH_ERROR;
590 * This is the entity handler for the registered resource.
591 * This is invoked by OCStack whenever it recevies a request for this resource.
593 OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
594 OCEntityHandlerRequest* entityHandlerRequest, void *callback)
597 OCEntityHandlerResult ehRet = OC_EH_OK;
598 OCEntityHandlerResponse response =
599 { 0, 0, OC_EH_ERROR, 0, 0,
602 OCRepPayload* payload = NULL;
604 if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
606 if (OC_REST_GET == entityHandlerRequest->method)
608 OIC_LOG(INFO, ES_RH_TAG, "Received GET request");
609 ehRet = ProcessGetRequest(entityHandlerRequest, &payload);
611 else if (OC_REST_PUT == entityHandlerRequest->method)
613 OIC_LOG(INFO, ES_RH_TAG, "Received PUT request");
615 //PUT request will be handled in the internal implementation
616 if (gProvResource.handle != NULL)
618 ehRet = ProcessPutRequest(entityHandlerRequest, &payload);
622 OIC_LOG(ERROR, ES_RH_TAG, "Cannot process put");
626 else if (OC_REST_POST == entityHandlerRequest->method)
628 OIC_LOG(INFO, ES_RH_TAG, "Received OC_REST_POST from client");
629 if (gProvResource.handle != NULL)
631 ehRet = ProcessPostRequest(entityHandlerRequest, &payload);
635 OIC_LOG(ERROR, ES_RH_TAG, "Cannot process put");
640 if (ehRet == OC_EH_OK)
642 // Format the response. Note this requires some info about the request
643 response.requestHandle = entityHandlerRequest->requestHandle;
644 response.resourceHandle = entityHandlerRequest->resource;
645 response.ehResult = ehRet;
646 //response uses OCPaylod while all get,put methodes use OCRepPayload
647 response.payload = (OCPayload*) (payload);
648 response.numSendVendorSpecificHeaderOptions = 0;
649 memset(response.sendVendorSpecificHeaderOptions, 0,
650 sizeof(response.sendVendorSpecificHeaderOptions));
651 memset(response.resourceUri, 0, sizeof(response.resourceUri));
652 // Indicate that response is NOT in a persistent buffer
653 response.persistentBufferFlag = 0;
656 if (OCDoResponse(&response) != OC_STACK_OK)
658 OIC_LOG(ERROR, ES_RH_TAG, "Error sending response");
667 const char *getResult(OCStackResult result)
672 return "OC_STACK_OK";
673 case OC_STACK_INVALID_URI:
674 return "OC_STACK_INVALID_URI";
675 case OC_STACK_INVALID_QUERY:
676 return "OC_STACK_INVALID_QUERY";
677 case OC_STACK_INVALID_IP:
678 return "OC_STACK_INVALID_IP";
679 case OC_STACK_INVALID_PORT:
680 return "OC_STACK_INVALID_PORT";
681 case OC_STACK_INVALID_CALLBACK:
682 return "OC_STACK_INVALID_CALLBACK";
683 case OC_STACK_INVALID_METHOD:
684 return "OC_STACK_INVALID_METHOD";
685 case OC_STACK_NO_MEMORY:
686 return "OC_STACK_NO_MEMORY";
687 case OC_STACK_COMM_ERROR:
688 return "OC_STACK_COMM_ERROR";
689 case OC_STACK_INVALID_PARAM:
690 return "OC_STACK_INVALID_PARAM";
691 case OC_STACK_NOTIMPL:
692 return "OC_STACK_NOTIMPL";
693 case OC_STACK_NO_RESOURCE:
694 return "OC_STACK_NO_RESOURCE";
695 case OC_STACK_RESOURCE_ERROR:
696 return "OC_STACK_RESOURCE_ERROR";
697 case OC_STACK_SLOW_RESOURCE:
698 return "OC_STACK_SLOW_RESOURCE";
699 case OC_STACK_NO_OBSERVERS:
700 return "OC_STACK_NO_OBSERVERS";
702 return "OC_STACK_ERROR";