1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25 #include "ocstackinternal.h"
27 #define OC_RSRVD_OC "oc"
28 #define OC_RSRVD_PAYLOAD "payload"
29 #define OC_RSRVD_HREF "href"
30 #define OC_RSRVD_SERVER_INSTANCE_ID "sid"
31 #define OC_RSRVD_RESOURCE_TYPE "rt"
32 #define OC_RSRVD_INTERFACE "if"
33 #define OC_RSRVD_INTERFACE_DEFAULT "oc.mi.def"
34 #define OC_RSRVD_INTERFACE_LL "oc.mi.ll"
35 #define OC_RSRVD_INTERFACE_BATCH "oc.mi.b"
36 #define OC_RSRVD_OBSERVABLE "obs"
37 #define OC_RSRVD_SECURE "sec"
38 #define OC_RSRVD_HOSTING_PORT "port"
40 #define OC_JSON_PREFIX "{\"oc\":["
41 #define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
42 #define OC_JSON_SUFFIX "]}"
43 #define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1)
44 #define OC_JSON_SEPARATOR ','
46 #define OC_RESOURCE_OBSERVABLE 1
47 #define OC_RESOURCE_SECURE 1
50 STACK_RES_DISCOVERY_NOFILTER = 0,
51 STACK_RES_DISCOVERY_IF_FILTER,
52 STACK_RES_DISCOVERY_RT_FILTER
56 OC_RESOURCE_VIRTUAL = 0,
57 OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER,
58 OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER,
59 OC_RESOURCE_COLLECTION_WITH_ENTITYHANDLER,
60 OC_RESOURCE_COLLECTION_DEFAULT_ENTITYHANDLER,
61 OC_RESOURCE_DEFAULT_DEVICE_ENTITYHANDLER,
62 OC_RESOURCE_NOT_SPECIFIED
65 OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag, OCEntityHandlerRequest * request);
67 const char * GetVirtualResourceUri( OCVirtualResources resource);
68 OCResource *FindResourceByUri(const char* resourceUri);
69 uint8_t IsVirtualResource(const char* resourceUri);
71 OCStackResult DetermineResourceHandling (OCRequest *request,
72 ResourceHandling *handling,
73 OCResource **resource);
76 BuildJSONResponse(ResourceHandling resHandling, OCResource *resource, OCRequest *request);
79 BuildObsJSONResponse(OCResource *resource, OCEntityHandlerRequest *ehRequest);
82 BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn,
83 char *filterValue, char * out, uint16_t *remaining);
85 OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
87 #endif //OC_RESOURCE_H