#include "connectivity.h"
#define ULTRASONIC_RESOURCE_TYPE "org.tizen.door"
-#define CBOR_FILE_IN_RES "/home/owner/apps_rw/org.tizen.position-finder-server/res/iotcon-test-svr-db-server.dat"
-#define CBOR_FILE_IN_DATA "/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat"
#define BUFSIZE 1024
+#define URI_PATH_LEN 64
static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
ret = iotcon_representation_set_uri_path(representation, uri_path);
goto_if(IOTCON_ERROR_NONE != ret, error);
- ret = iotcon_attributes_add_bool(attributes, "opened", value);
+ ret = iotcon_attributes_add_bool(attributes, key, value);
goto_if(IOTCON_ERROR_NONE != ret, error);
ret = iotcon_representation_set_attributes(representation, attributes);
free(resource_info);
}
+static int _get_default_uri_path_in_conf(char *buf, int size)
+{
+ FILE *in = NULL;
+ size_t nread = 0;
+
+ in = fopen(CONF_FILE, "r");
+ retv_if(!in, -1);
+
+ nread = fread(buf, 1, size, in);
+ if (nread <= 0) {
+ _I("No contents in the conf.");
+ return -1;
+ }
+
+ if (buf[nread - 1] == '\n')
+ buf[nread - 1] = '\0';
+
+ fclose(in);
+
+ return 0;
+}
+
int connectivity_set_resource(const char *uri_path, const char *type, connectivity_resource_s **out_resource_info)
{
iotcon_resource_types_h resource_types = NULL;
connectivity_resource_s *resource_info = NULL;
uint8_t policies;
int ret = -1;
+ const char *final_uri_path = NULL;
+ char default_uri_path[URI_PATH_LEN] = { 0, };
+
+ if (uri_path) {
+ final_uri_path = uri_path;
+ } else {
+ ret = _get_default_uri_path_in_conf(default_uri_path, URI_PATH_LEN);
+ retv_if(ret < 0, -1);
+ final_uri_path = default_uri_path;
+ }
+
+ _D("uri path : [%s]", final_uri_path);
resource_info = calloc(1, sizeof(connectivity_resource_s));
retv_if(!resource_info, -1);
IOTCON_RESOURCE_OBSERVABLE |
IOTCON_RESOURCE_SECURE;
- ret = iotcon_resource_create(uri_path,
+ ret = iotcon_resource_create(final_uri_path,
resource_types,
ifaces,
policies,