return FN_ERROR_NONE;
}
+char * __get_type_from_resource_type(fn_resource_type_e resource_type)
+{
+ return NULL;
+}
+char * __get_uri_from_resource_type(fn_resource_type_e resource_type, int index)
+{
+ return NULL;
+}
+
+uint8_t __get_resource_properties_from_resource_type(fn_resource_type_e resource_type)
+{
+ return 0;
+}
+
+OCEntityHandlerResult OCEntityHandlerCb (OCEntityHandlerFlag flag,
+ OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam)
+{
+ LOG_DEBUG("Inside entity handler - flags: 0x%x", flag);
+ OCEntityHandlerResult ehResult = OC_EH_ERROR;
+ OCEntityHandlerResponse response;
+ memset(&response, 0, sizeof(response));
+
+ // Validate pointer
+ if (!entityHandlerRequest) {
+ LOG_DEBUG("Invalid request pointer");
+ return OC_EH_ERROR;
+ }
+
+ OCRepPayload* payload = NULL;
+
+ if (flag & OC_REQUEST_FLAG) {
+ LOG_DEBUG("Flag includes OC_REQUEST_FLAG");
+ if (entityHandlerRequest) {
+ if (OC_REST_GET == entityHandlerRequest->method) {
+ LOG_DEBUG("Received OC_REST_GET from client");
+ //ehResult = ProcessGetRequest (entityHandlerRequest, &payload);
+ } else if (OC_REST_PUT == entityHandlerRequest->method) {
+ LOG_DEBUG("Received OC_REST_PUT from client");
+ //ehResult = ProcessPutRequest (entityHandlerRequest, &payload);
+ } else if (OC_REST_POST == entityHandlerRequest->method) {
+ LOG_DEBUG("Received OC_REST_POST from client");
+ //ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload);
+ } else {
+ LOG_DEBUG("Received unsupported method %d from client %d", entityHandlerRequest->method);
+ ehResult = OC_EH_ERROR;
+ }
+
+ if (ehResult == OC_EH_OK && ehResult != OC_EH_FORBIDDEN) {
+ // Format the response. Note this requires some info about the request
+ response.requestHandle = entityHandlerRequest->requestHandle;
+ response.resourceHandle = entityHandlerRequest->resource;
+ response.ehResult = ehResult;
+ response.payload = (OCPayload*)(payload);
+ response.numSendVendorSpecificHeaderOptions = 0;
+ memset(response.sendVendorSpecificHeaderOptions, 0,
+ sizeof(response.sendVendorSpecificHeaderOptions));
+ memset(response.resourceUri, 0, sizeof(response.resourceUri));
+ // Indicate that response is NOT in a persistent buffer
+ response.persistentBufferFlag = 0;
+
+ // Send the response
+ if (OCDoResponse(&response) != OC_STACK_OK) {
+ LOG_DEBUG("Error sending response");
+ ehResult = OC_EH_ERROR;
+ }
+ }
+ }
+ }
+
+ OCPayloadDestroy(response.payload);
+ return ehResult;
+}
+
+int fn_iotivity_add_resource(fn_resource_type_e resource_type, int index)
+{
+ OCResourceHandle handle;
+ fn_context *fn_ctx = fn_context_get_context();
+ void *callbackParam = NULL;
+ //get resource list of resource type
+ //GList *list = fn_ctx->resource_list[resource_type];
+
+ //type generation and uri generation and resourceProperties generation
+ char *type = __get_type_from_resource_type(resource_type);
+ char *uri = __get_uri_from_resource_type(resource_type, index);
+ uint8_t resource_properties = __get_resource_properties_from_resource_type(resource_type);
+
+ //create callback parameter - insert resource type and index and...?
+ callbackParam = NULL;
+
+ OCStackResult result = OCCreateResource(&handle,
+ type,
+ OC_RSRVD_INTERFACE_DEFAULT,
+ uri,
+ OCEntityHandlerCb,
+ callbackParam,
+ resource_properties);
+
+ return 0;
+}
+
+int fn_iotivity_delete_resource(fn_resource_type_e resource_type, int index)
+{
+ //delete resource from resource list using resource_type and index
+}
+