return;
}
- ret = iotcon_representation_set_uri_path(resp_repr, "core.door");
+ ret = iotcon_representation_set_uri_path(resp_repr, "org.tizen.door");
if (IOTCON_ERROR_NONE != ret) {
iotcon_representation_destroy(resp_repr);
iotcon_response_destroy(response);
int ret;
int interfaces = IOTCON_INTERFACE_DEFAULT;
int properties = (IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE);
- const char *uri_path = "/a/door1";
- const char *type = "core.door";
+ const char *uri_path = "/door/1";
+ const char *type = "org.tizen.door";
iotcon_resource_types_h resource_types;
ret = iotcon_resource_types_create(&resource_types);
...
{
int ret;
- const char *type = "core.door";
+ const char *type = "org.tizen.door";
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, type,
&_found_resource, NULL);
int interfaces = IOTCON_INTERFACE_DEFAULT;
int properties = (IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE);
iotcon_resource_h door_handle;
- const char *uri_path = "/a/door1";
- const char *type = "core.door";
+ const char *uri_path = "/door/1";
+ const char *type = "org.tizen.door";
iotcon_resource_types_h resource_types;
ret = iotcon_resource_types_create(&resource_types);
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
if (0 == resource->sub_id) {
ERR("Invalid Resource handle");
static char *door_resource_device_id;
static GList *device_id_list;
-static const char* const door_uri_path = "/a/door";
+#define DOOR_RESOURCE_URI_PREFIX "/door"
+#define DOOR_RESOURCE_TYPE "org.tizen.door"
static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err,
iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare);
- if (node && TEST_STR_EQUAL == strcmp(door_uri_path, resource_uri_path)) {
+ if (node && TEST_STR_EQUAL == strncmp(DOOR_RESOURCE_URI_PREFIX, resource_uri_path,
+ strlen(DOOR_RESOURCE_URI_PREFIX))) {
DBG("uri_path \"%s\" already found. skip !", resource_uri_path);
return;
}
return;
}
- ret = iotcon_add_presence_cb(resource_host, connectivity_type, "core.door",
+ ret = iotcon_add_presence_cb(resource_host, connectivity_type, DOOR_RESOURCE_TYPE,
_presence_handler, NULL, &presence_handle);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_add_presence_cb() Fail(%d)", ret);
return;
}
- if (TEST_STR_EQUAL == strcmp(door_uri_path, resource_uri_path)) {
+ if (TEST_STR_EQUAL == strncmp(DOOR_RESOURCE_URI_PREFIX, resource_uri_path,
+ strlen(DOOR_RESOURCE_URI_PREFIX))) {
iotcon_query_h query;
ret = iotcon_query_create(&query);
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- "core.door", &_found_resource, NULL);
+ DOOR_RESOURCE_TYPE, &_found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();
static bool resource_created;
+#define DOOR_RESOURCE_URI "/door/1"
+#define DOOR_RESOURCE_URI2 "/door/2"
+#define DOOR_RESOURCE_TYPE "org.tizen.door"
+
static void _request_handler(iotcon_resource_h resource, iotcon_request_h request,
void *user_data);
door->state = false;
- door->uri_path = strdup("/a/door");
+ door->uri_path = strdup(DOOR_RESOURCE_URI);
if (NULL == door->uri_path) {
- ERR("strdup(/a/door) Fail");
+ ERR("strdup(%s) Fail", DOOR_RESOURCE_URI);
return -1;
}
- door->type = strdup("core.door");
+ door->type = strdup(DOOR_RESOURCE_TYPE);
if (NULL == door->type) {
- ERR("strdup(core.door) Fail");
+ ERR("strdup(%s) Fail", DOOR_RESOURCE_TYPE);
free(door->uri_path);
return -1;
}
return;
}
- new_door_handle = _create_door_resource("/a/door1", door->type,
+ new_door_handle = _create_door_resource(DOOR_RESOURCE_URI2, door->type,
IOTCON_INTERFACE_DEFAULT, (IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE), NULL);
if (NULL == new_door_handle) {
ERR("_create_door_resource() Fail");
return;
}
- ret = iotcon_state_set_str(resp_state, "createduripath", "/a/door1");
+ ret = iotcon_state_set_str(resp_state, "createduripath", DOOR_RESOURCE_URI2);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_state_set_str() Fail(%d)", ret);
iotcon_state_destroy(resp_state);
static char *door_resource_device_id;
static GList *device_id_list;
+#define DOOR_RESOURCE_TYPE "org.tizen.door"
+
static bool _get_res_type_cb(const char *string, void *user_data)
{
char *resource_uri_path = user_data;
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- "core.door", &_found_resource, &resource);
+ DOOR_RESOURCE_TYPE, &_found_resource, &resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();
#include <iotcon-internal.h>
#include "test.h"
+#define DOOR_RESOURCE_URI "/door/1"
+#define DOOR_RESOURCE_TYPE "org.tizen.door"
+
/* Door Resource */
typedef struct _door_resource_s {
bool state;
{
door->state = false;
- door->uri_path = strdup("/a/door");
+ door->uri_path = strdup(DOOR_RESOURCE_URI);
if (NULL == door->uri_path) {
- ERR("strdup(/a/door) Fail");
+ ERR("strdup(%s) Fail", DOOR_RESOURCE_URI);
return -1;
}
- door->type = strdup("core.door");
+ door->type = strdup(DOOR_RESOURCE_TYPE);
if (NULL == door->type) {
- ERR("strdup(core.door) Fail");
+ ERR("strdup(%s) Fail", DOOR_RESOURCE_TYPE);
free(door->uri_path);
return -1;
}
static char *room_resource_device_id;
static GList *device_id_list;
-static const char* const room_uri_path = "/a/room";
+#define ROOM_RESOURCE_TYPE "org.tizen.room"
+#define ROOM_RESOURCE_URI_PREFIX "/room"
+#define LIGHT_RESOURCE_URI_PREFIX "/light"
+#define SWITCH_RESOURCE_URI_PREFIX "/switch"
static bool _get_int_list_cb(int pos, const int value, void *user_data)
{
continue;
}
- if (TEST_STR_EQUAL == strcmp("/a/light", uri_path)) {
+ if (TEST_STR_EQUAL == strncmp(LIGHT_RESOURCE_URI_PREFIX, uri_path,
+ strlen(LIGHT_RESOURCE_URI_PREFIX))) {
ret = iotcon_state_get_keys_count(child_state, &key_count);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_state_get_keys_count() Fail(%d)", ret);
}
DBG("brightness : %d", int_val);
}
- } else if (TEST_STR_EQUAL == strcmp("/a/switch", uri_path)) {
+ } else if (TEST_STR_EQUAL == strncmp(SWITCH_RESOURCE_URI_PREFIX, uri_path,
+ strlen(SWITCH_RESOURCE_URI_PREFIX))) {
ret = iotcon_state_get_keys_count(child_state, &key_count);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_state_get_keys_count() Fail(%d)", ret);
node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare);
- if (node && TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) {
+ if (node && TEST_STR_EQUAL == strncmp(ROOM_RESOURCE_URI_PREFIX, resource_uri_path,
+ strlen(ROOM_RESOURCE_URI_PREFIX))) {
DBG("uri_path \"%s\" already found. skip !", resource_uri_path);
return;
}
return;
}
- if (TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) {
+ if (TEST_STR_EQUAL == strncmp(ROOM_RESOURCE_URI_PREFIX, resource_uri_path,
+ strlen(ROOM_RESOURCE_URI_PREFIX))) {
ret = iotcon_remote_resource_clone(resource, &cloned_resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_remote_resource_clone() Fail(%d)", ret);
/* find room typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
- "core.room", &_found_resource, NULL);
+ ROOM_RESOURCE_TYPE, &_found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_disconnect();
#include <iotcon.h>
#include "test.h"
+#define LIGHT_RESOURCE_URI "/light/1"
+#define LIGHT_RESOURCE_TYPE "org.tizen.light"
+
+#define ROOM_RESOURCE_URI "/room/1"
+#define ROOM_RESOURCE_TYPE "org.tizen.room"
+
+#define SWITCH_RESOURCE_URI "/switch/1"
+
static int _send_response(iotcon_response_h response, iotcon_representation_h repr,
iotcon_interface_e iface)
{
return;
}
- ret = iotcon_representation_set_uri_path(room_repr, "/a/room");
+ ret = iotcon_representation_set_uri_path(room_repr, ROOM_RESOURCE_URI);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_representation_set_uri_path() Fail(%d)", ret);
iotcon_state_destroy(room_state);
return;
}
- ret = iotcon_representation_set_uri_path(light_repr, "/a/light");
+ ret = iotcon_representation_set_uri_path(light_repr, LIGHT_RESOURCE_URI);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_representation_set_uri_path() Fail(%d)", ret);
iotcon_representation_destroy(light_repr);
return;
}
- ret = iotcon_representation_set_uri_path(switch_repr, "/a/switch");
+ ret = iotcon_representation_set_uri_path(switch_repr, SWITCH_RESOURCE_URI);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_representation_set_uri_path() Fail(%d)", ret);
iotcon_representation_destroy(switch_repr);
iotcon_disconnect();
return -1;
}
- ret = iotcon_resource_types_add(room_rtypes, "core.room");
+ ret = iotcon_resource_types_add(room_rtypes, ROOM_RESOURCE_TYPE);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_resource_types_add(%s) Fail(%d)", "core.room", ret);
+ ERR("iotcon_resource_types_add(%s) Fail(%d)", ROOM_RESOURCE_TYPE, ret);
iotcon_resource_types_destroy(room_rtypes);
iotcon_disconnect();
return -1;
}
- ret = iotcon_resource_create("/a/room", room_rtypes,
+ ret = iotcon_resource_create(ROOM_RESOURCE_URI, room_rtypes,
(IOTCON_INTERFACE_DEFAULT | IOTCON_INTERFACE_BATCH),
(IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE), _room_request_handler,
NULL, &room_handle);
iotcon_disconnect();
return -1;
}
- ret = iotcon_resource_types_add(light_rtypes, "core.light");
+ ret = iotcon_resource_types_add(light_rtypes, LIGHT_RESOURCE_TYPE);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_resource_types_add(%s) Fail(%d)", "core.light", ret);
+ ERR("iotcon_resource_types_add(%s) Fail(%d)", LIGHT_RESOURCE_TYPE, ret);
iotcon_resource_types_destroy(light_rtypes);
iotcon_resource_destroy(room_handle);
iotcon_disconnect();
return -1;
}
- ret = iotcon_resource_create("/a/light", light_rtypes,
+ ret = iotcon_resource_create(LIGHT_RESOURCE_URI, light_rtypes,
(IOTCON_INTERFACE_DEFAULT | IOTCON_INTERFACE_BATCH),
(IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE), _light_request_handler,
NULL, &light_handle);