#include "ocstackinternal.h"
#include "ocserverrequest.h"
-/**
- * Attributes used to form a proper OIC conforming JSON message.
- */
-#define OC_RSRVD_OC "oc"
-#define OC_RSRVD_PAYLOAD "payload"
-#define OC_RSRVD_HREF "href"
-#define OC_RSRVD_PROPERTY "prop"
-#define OC_RSRVD_REPRESENTATION "rep"
-#define OC_RSRVD_CONTENT_TYPE "ct"
-#define OC_RSRVD_RESOURCE_TYPE "rt"
-#define OC_RSRVD_RESOURCE_TYPE_PRESENCE "core.presence"
-#define OC_RSRVD_INTERFACE "if"
-#define OC_RSRVD_DEVICE_ID "di"
-#define OC_RSRVD_DEVICE_NAME "dn"
-#define OC_RSRVD_INTERFACE_DEFAULT "oc.mi.def"
-#define OC_RSRVD_INTERFACE_LL "oc.mi.ll"
-#define OC_RSRVD_INTERFACE_BATCH "oc.mi.b"
-#define OC_RSRVD_INTERFACE_GROUP "oc.mi.grp"
-#define OC_RSRVD_MFG_DATE "mndt"
-#define OC_RSRVD_FW_VERSION "mnfv"
-#define OC_RSRVD_HOST_NAME "hn"
-#define OC_RSRVD_MFG_NAME "mnmn"
-#define OC_RSRVD_MFG_URL "mnml"
-#define OC_RSRVD_MODEL_NUM "mnmo"
-#define OC_RSRVD_PLATFORM_VERSION "mnpv"
-#define OC_RSRVD_SUPPORT_URL "mnsl"
-#define OC_RSRVD_VERSION "icv"
-#define OC_RSRVD_OBSERVABLE "obs"
-#define OC_RSRVD_SECURE "sec"
-#define OC_RSRVD_HOSTING_PORT "port"
-#define OC_RSRVD_SERVER_INSTANCE_ID "sid"
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
/**
* Common JSON string components used by the stack to build JSON strings.
* These details are exposed in ocstackconfig.h file in the form of documentation.
* Remember to update the documentation there if these are changed.
*/
-#define OC_JSON_PREFIX "{\"oc\":["
+#define OC_JSON_PREFIX "{\"oic\":["
#define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
#define OC_JSON_SUFFIX "]}"
#define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1)
#define OC_JSON_SEPARATOR ','
#define OC_JSON_SEPARATOR_STR ","
+#define OC_KEY_VALUE_DELIMITER "="
/**
* Static values for various JSON attributes.
#define OC_RESOURCE_SECURE 1
/**
+ * OIC Virtual resources supported by every OIC device.
+ */
+typedef enum
+{
+ /** unknown URI.*/
+ OC_UNKNOWN_URI =0,
+
+ /** "/oic/res".*/
+ OC_WELL_KNOWN_URI,
+
+ /** "/oic/d" .*/
+ OC_DEVICE_URI,
+
+ /** "/oic/p" .*/
+ OC_PLATFORM_URI,
+
+ /** "/oic/res/d/type" .*/
+ OC_RESOURCE_TYPES_URI,
+#ifdef ROUTING_GATEWAY
+ /** "/oic/gateway" .*/
+ OC_GATEWAY_URI,
+#endif
+#ifdef WITH_PRESENCE
+ /** "/oic/ad" .*/
+ OC_PRESENCE,
+#endif
+
+#ifdef MQ_BROKER
+ /** "/oic/ps" .*/
+ OC_MQ_BROKER_URI,
+#endif
+
+#ifdef TCP_ADAPTER
+ /** "/oic/ping" .*/
+ OC_KEEPALIVE_RESOURCE_URI,
+#endif
+
+ /** Max items in the list */
+ OC_MAX_VIRTUAL_RESOURCES //<s Max items in the list
+
+} OCVirtualResources;
+
+/**
* The type of query a request/response message is.
*/
typedef enum
* no entity handler.
*/
OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag,
- OCEntityHandlerRequest * request);
-
-/**
- * Get string value associated with a virtual resource type.
- */
-const char * GetVirtualResourceUri(OCVirtualResources resource);
+ OCEntityHandlerRequest * request, void* callbackParam);
/**
* Find and retrieve pointer to a resource associated with a specific resource
* URI.
+ * @return pointer to found resource
*/
OCResource *FindResourceByUri(const char* resourceUri);
/**
- * Returns true if the specificed resource URI aligns with a pre-existing
+ * This function checks whether the specified resource URI aligns with a pre-existing
* virtual resource; returns false otherwise.
+ * @return true or false.
*/
bool IsVirtualResource(const char* resourceUri);
/**
* Parameter @ref handling returns by-reference the type of resource handling
* required by the internal stack based on the specified @ref request.
+ * @return ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult DetermineResourceHandling (const OCServerRequest *request,
ResourceHandling *handling,
/**
* Processes the specified @ref request based on the type of resource handling
* @ref resHandling.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult ProcessRequest(ResourceHandling resHandling,
OCResource *resource,
OCServerRequest *request);
/**
- * Internal API used to save all of the device's information for use in device
+ * Internal API used to save all of the platform's information for use in platform
+ * discovery requests.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
+ */
+OCStackResult SavePlatformInfo(OCPlatformInfo info);
+
+/**
+ * Internal API used to save all of the device's information for use in platform
* discovery requests.
+ * @param info Device name is received from the application.
+ * DeviceID, spec version and data model version are initialized by the stack.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
+ */
+OCStackResult SaveDeviceInfo(OCDeviceInfo info);
+
+/**
+ * Internal API used to clear the platform information.
*/
-OCStackResult SaveDeviceInfo(OCDeviceInfo deviceInfo);
+void DeletePlatformInfo();
/**
* Internal API used to clear the device information.
*/
void DeleteDeviceInfo();
-/**
- * Prepares a JSON string for response.
+/*
+ * Prepare payload for resource representation.
*/
-OCStackResult BuildVirtualResourceResponse(const OCResource *resourcePtr,
- uint8_t filterOn,
- const char *filterValue,
- char * out,
- uint16_t *remaining,
- CAConnectivityType_t connType);
+OCStackResult BuildResponseRepresentation(const OCResource *resourcePtr,
+ OCRepPayload** payload);
/**
* A helper function that Maps an @ref OCEntityHandlerResult type to an
*/
OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
+#ifdef __cplusplus
+}
+#endif // __cplusplus
#endif //OC_RESOURCEHANDLER_H