<arg type="a(qs)" name="options" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
- <method name="registerDeviceInfo">
- <arg type="(s)" name="device_info" direction="in"/>
- <arg type="i" name="ret" direction="out"/>
- </method>
<method name="getDeviceInfo">
<arg type="s" name="host_address" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
- <method name="registerPlatformInfo">
- <arg type="(sssssssssss)" name="platform_info" direction="in"/>
- <arg type="i" name="ret" direction="out"/>
- </method>
<method name="getPlatformInfo">
<arg type="s" name="host_address" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
return TRUE;
}
-
-static gboolean _dbus_handle_register_device_info(icDbus *object,
- GDBusMethodInvocation *invocation, GVariant *device_info)
-{
- int ret;
-
- ret = icd_ioty_register_device_info(device_info);
- if (IOTCON_ERROR_NONE != ret)
- ERR("icd_ioty_register_device_info() Fail(%d)", ret);
-
- ic_dbus_complete_register_device_info(object, invocation, ret);
-
- return TRUE;
-}
-
-
static gboolean _dbus_handle_get_device_info(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
return TRUE;
}
-
-static gboolean _dbus_handle_register_platform_info(icDbus *object,
- GDBusMethodInvocation *invocation, GVariant *platform_info)
-{
- int ret;
-
- ret = icd_ioty_register_platform_info(platform_info);
- if (IOTCON_ERROR_NONE != ret)
- ERR("icd_ioty_register_platform_info() Fail(%d)", ret);
-
- ic_dbus_complete_register_platform_info(object, invocation, ret);
-
- return TRUE;
-}
-
-
static gboolean _dbus_handle_get_platform_info(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
G_CALLBACK(_dbus_handle_notify), NULL);
g_signal_connect(icd_dbus_object, "handle-send-response",
G_CALLBACK(_dbus_handle_send_response), NULL);
- g_signal_connect(icd_dbus_object, "handle-register-device-info",
- G_CALLBACK(_dbus_handle_register_device_info), NULL);
g_signal_connect(icd_dbus_object, "handle-get-device-info",
G_CALLBACK(_dbus_handle_get_device_info), NULL);
- g_signal_connect(icd_dbus_object, "handle-register-platform-info",
- G_CALLBACK(_dbus_handle_register_platform_info), NULL);
g_signal_connect(icd_dbus_object, "handle-get-platform-info",
G_CALLBACK(_dbus_handle_get_platform_info), NULL);
g_signal_connect(icd_dbus_object, "handle-get-tizen-info",
}
-int icd_ioty_register_device_info(GVariant *value)
+int icd_ioty_register_device_info(char *device_name)
{
- char *device_name;
OCStackResult result;
OCDeviceInfo device_info = {0};
- g_variant_get(value, "(&s)", &device_info.deviceName);
+ RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
- device_name = strdup(device_info.deviceName);
- if (NULL == device_name) {
- ERR("strdup() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
+ device_info.deviceName = device_name;
icd_ioty_csdk_lock();
result = OCSetDeviceInfo(device_info);
if (OC_STACK_OK != result) {
ERR("OCSetDeviceInfo() Fail(%d)", result);
- free(device_name);
return icd_ioty_convert_error(result);
}
- icd_tizen_info.device_name = device_name;
+ icd_tizen_info.device_name = strdup(device_name);
return IOTCON_ERROR_NONE;
}
-int icd_ioty_register_platform_info(GVariant *value)
+int icd_ioty_register_platform_info(char *platform_id,
+ char *manufacturer_name,
+ char *manufacturer_url,
+ char *model_number,
+ char *date_of_manufacture,
+ char *platform_version,
+ char *os_version,
+ char *hw_version,
+ char *firmware_version,
+ char *support_url,
+ char *system_time)
{
OCStackResult result;
OCPlatformInfo platform_info = {0};
- g_variant_get(value, "(&s&s&s&s&s&s&s&s&s&s&s)",
- &platform_info.platformID,
- &platform_info.manufacturerName,
- &platform_info.manufacturerUrl,
- &platform_info.modelNumber,
- &platform_info.dateOfManufacture,
- &platform_info.platformVersion,
- &platform_info.operatingSystemVersion,
- &platform_info.hardwareVersion,
- &platform_info.firmwareVersion,
- &platform_info.supportUrl,
- &platform_info.systemTime);
+ platform_info.platformID = platform_id;
+ platform_info.manufacturerName = manufacturer_name;
+ platform_info.manufacturerUrl = manufacturer_url;
+ platform_info.modelNumber = model_number;
+ platform_info.dateOfManufacture = date_of_manufacture;
+ platform_info.platformVersion = platform_version;
+ platform_info.operatingSystemVersion = os_version;
+ platform_info.hardwareVersion = hw_version;
+ platform_info.firmwareVersion = firmware_version;
+ platform_info.supportUrl = support_url;
+ platform_info.systemTime = system_time;
icd_ioty_csdk_lock();
result = OCSetPlatformInfo(platform_info);
int icd_ioty_observer_stop(OCDoHandle handle, GVariant *options);
-int icd_ioty_register_device_info(GVariant *value);
-
-int icd_ioty_register_platform_info(GVariant *value);
+int icd_ioty_register_device_info(char *device_name);
+
+int icd_ioty_register_platform_info(char *platform_id,
+ char *manufacturer_name,
+ char *manufacturer_url,
+ char *model_number,
+ char *date_of_manufacture,
+ char *platform_version,
+ char *os_version,
+ char *hw_version,
+ char *firmware_version,
+ char *support_url,
+ char *system_time);
int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
const char *bus_name);
* <td>iotcon_remote_resource_get</td>
* </tr>
* <tr>
- * <td>iotcon_register_device_info</td>
- * <td>iotcon_remote_resource_put</td>
- * </tr>
- * <tr>
- * <td>iotcon_start_presence</td>
- * <td>iotcon_remote_resource_post</td>
- * </tr>
- * <tr>
- * <td>iotcon_stop_presence</td>
- * <td>iotcon_remote_resource_delete</td>
- * </tr>
- * <tr>
* <td>iotcon_response_send</td>
- * <td></td>
+ * <td>iotcon_remote_resource_put</td>
* </tr>
* <tr>
* <td>iotcon_resource_notify</td>
- * <td></td>
+ * <td>iotcon_remote_resource_post</td>
* </tr>
* <tr>
- * <td>iotcon_register_device_info</td>
* <td></td>
+ * <td>iotcon_remote_resource_delete</td>
* </tr>
* </table></div>
*
} icl_tizen_info_s;
-API int iotcon_device_info_create(iotcon_device_info_h *device_info)
-{
- iotcon_device_info_h info = NULL;
-
- RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER);
-
- info = calloc(1, sizeof(struct icl_device_info));
- if (NULL == info) {
- ERR("calloc() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
-
- *device_info = info;
-
- return IOTCON_ERROR_NONE;
-}
-
-
-API void iotcon_device_info_destroy(iotcon_device_info_h device_info)
-{
- RET_IF(NULL == device_info);
-
- free(device_info->device_name);
- free(device_info->spec_ver);
- free(device_info->device_id);
- free(device_info->data_model_ver);
- free(device_info);
-}
-
-
-API int iotcon_device_info_set_property(iotcon_device_info_h device_info,
- iotcon_device_info_e property, const char *value)
-{
- char *dup_value;
-
- RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER);
-
- if (value) {
- dup_value = strdup(value);
- if (NULL == dup_value) {
- ERR("strdup() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
- } else {
- dup_value = NULL;
- }
-
- switch (property) {
- case IOTCON_DEVICE_INFO_NAME:
- if (device_info->device_name)
- free(device_info->device_name);
- device_info->device_name = dup_value;
- break;
- case IOTCON_DEVICE_INFO_SPEC_VER:
- if (device_info->spec_ver)
- free(device_info->spec_ver);
- device_info->spec_ver = dup_value;
- break;
- case IOTCON_DEVICE_INFO_ID:
- if (device_info->device_id)
- free(device_info->device_id);
- device_info->device_id = dup_value;
- break;
- case IOTCON_DEVICE_INFO_DATA_MODEL_VER:
- if (device_info->data_model_ver)
- free(device_info->data_model_ver);
- device_info->data_model_ver = dup_value;
- break;
- default:
- ERR("Invalid property(%d)", property);
- free(dup_value);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
-
-
API int iotcon_device_info_get_property(iotcon_device_info_h device_info,
iotcon_device_info_e property, char **value)
{
return IOTCON_ERROR_NONE;
}
-
-API int iotcon_set_device_info(iotcon_device_info_h device_info)
-{
- int ret;
- GError *error = NULL;
- GVariant *arg_info;
-
- RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
- RETV_IF(NULL == device_info, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == device_info->device_name, IOTCON_ERROR_INVALID_PARAMETER);
-
- arg_info = icl_dbus_device_info_to_gvariant(device_info);
- ic_dbus_call_register_device_info_sync(icl_dbus_get_object(), arg_info, &ret,
- NULL, &error);
- if (error) {
- ERR("ic_dbus_call_register_device_info_sync() Fail(%s)", error->message);
- ret = icl_dbus_convert_dbus_error(error->code);
- g_error_free(error);
- g_variant_unref(arg_info);
- return ret;
- }
-
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon-daemon Fail(%d)", ret);
- return icl_dbus_convert_daemon_error(ret);
- }
-
- return ret;
-}
-
-
static void _icl_device_info_cb(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
return ret;
}
-
-API int iotcon_platform_info_create(iotcon_platform_info_h *platform_info)
-{
- iotcon_platform_info_h info = NULL;
-
- RETV_IF(NULL == platform_info, IOTCON_ERROR_INVALID_PARAMETER);
-
- info = calloc(1, sizeof(struct icl_platform_info));
- if (NULL == info) {
- ERR("calloc() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
-
- *platform_info = info;
-
- return IOTCON_ERROR_NONE;
-}
-
-
-API void iotcon_platform_info_destroy(iotcon_platform_info_h platform_info)
-{
- RET_IF(NULL == platform_info);
-
- free(platform_info->platform_id);
- free(platform_info->manuf_name);
- free(platform_info->manuf_url);
- free(platform_info->model_number);
- free(platform_info->date_of_manuf);
- free(platform_info->platform_ver);
- free(platform_info->os_ver);
- free(platform_info->hardware_ver);
- free(platform_info->firmware_ver);
- free(platform_info->support_url);
- free(platform_info->system_time);
- free(platform_info);
-}
-
-
-API int iotcon_platform_info_set_property(iotcon_platform_info_h platform_info,
- iotcon_platform_info_e property, const char *value)
-{
- char *dup_value;
-
- RETV_IF(NULL == platform_info, IOTCON_ERROR_INVALID_PARAMETER);
-
- if (value) {
- dup_value = strdup(value);
- if (NULL == dup_value) {
- ERR("strdup() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
- } else {
- dup_value = NULL;
- }
-
- switch (property) {
- case IOTCON_PLATFORM_INFO_ID:
- if (platform_info->platform_id)
- free(platform_info->platform_id);
- platform_info->platform_id = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_MANUF_NAME:
- if (platform_info->manuf_name)
- free(platform_info->manuf_name);
- platform_info->manuf_name = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_MANUF_URL:
- if (platform_info->manuf_url)
- free(platform_info->manuf_url);
- platform_info->manuf_url = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_MODEL_NUMBER:
- if (platform_info->model_number)
- free(platform_info->model_number);
- platform_info->model_number = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_DATE_OF_MANUF:
- if (platform_info->date_of_manuf)
- free(platform_info->date_of_manuf);
- platform_info->date_of_manuf = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_PLATFORM_VER:
- if (platform_info->platform_ver)
- free(platform_info->platform_ver);
- platform_info->platform_ver = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_OS_VER:
- if (platform_info->os_ver)
- free(platform_info->os_ver);
- platform_info->os_ver = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_HARDWARE_VER:
- if (platform_info->hardware_ver)
- free(platform_info->hardware_ver);
- platform_info->hardware_ver = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_FIRMWARE_VER:
- if (platform_info->firmware_ver)
- free(platform_info->firmware_ver);
- platform_info->firmware_ver = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_SUPPORT_URL:
- if (platform_info->support_url)
- free(platform_info->support_url);
- platform_info->support_url = dup_value;
- break;
- case IOTCON_PLATFORM_INFO_SYSTEM_TIME:
- if (platform_info->system_time)
- free(platform_info->system_time);
- platform_info->system_time = dup_value;
- break;
- default:
- ERR("Invalid property(%d)", property);
- free(dup_value);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
-
-
API int iotcon_platform_info_get_property(iotcon_platform_info_h platform_info,
iotcon_platform_info_e property, char **value)
{
}
-/* The length of manufacturer_name should be less than and equal to 16.
- * The length of manufacturer_url should be less than and equal to 32. */
-API int iotcon_set_platform_info(iotcon_platform_info_h platform_info)
-{
- int ret;
- GError *error = NULL;
- GVariant *arg_info;
-
- RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
- RETV_IF(NULL == platform_info, IOTCON_ERROR_INVALID_PARAMETER);
-
- if (NULL == platform_info->platform_id
- || NULL == platform_info->manuf_name
- || NULL == platform_info->manuf_url
- || NULL == platform_info->model_number
- || NULL == platform_info->date_of_manuf
- || NULL == platform_info->platform_ver
- || NULL == platform_info->os_ver
- || NULL == platform_info->hardware_ver
- || NULL == platform_info->firmware_ver
- || NULL == platform_info->support_url
- || NULL == platform_info->system_time) {
- ERR("one of parameter is NULL");
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- if (platform_info->manuf_name
- && (ICL_MANUFACTURER_NAME_LENGTH_MAX < strlen(platform_info->manuf_name))) {
- ERR("The length of manufacturer_name(%s) is invalid.", platform_info->manuf_name);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- if (platform_info->manuf_url
- && (ICL_MANUFACTURER_URL_LENGTH_MAX < strlen(platform_info->manuf_url))) {
- ERR("The length of manufacturer_url(%s) is invalid.", platform_info->manuf_url);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- arg_info = icl_dbus_platform_info_to_gvariant(platform_info);
- ic_dbus_call_register_platform_info_sync(icl_dbus_get_object(), arg_info, &ret,
- NULL, &error);
- if (error) {
- ERR("ic_dbus_call_register_platform_info_sync() Fail(%s)", error->message);
- ret = icl_dbus_convert_dbus_error(error->code);
- g_error_free(error);
- g_variant_unref(arg_info);
- return ret;
- }
-
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon-daemon Fail(%d)", ret);
- return icl_dbus_convert_daemon_error(ret);
- }
-
- return ret;
-}
-
-
static void _icl_platform_info_cb(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
#include <glib.h>
#include "iotcon.h"
+#include "iotcon-internal.h"
#include "ic-utils.h"
#include "icl.h"
#include "icl-resource-types.h"
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__
+#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file iotcon-internal.h
+ */
+
+/**
+ * @brief Starts presence of a server.
+ * @details Use this function to send server's announcements to clients.\n
+ * Server can call this function when online for the first time or come back from offline to online.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
+ *
+ * @remarks If @a time_to_live is 0, server will set default value as 60 seconds.\n
+ * If @a time_to_live is very big, server will set maximum value as (60 * 60 * 24) seconds.
+ * (24 hours)
+ *
+ * @param[in] time_to_live The interval of announcing presence in seconds.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_DBUS Dbus error
+ * @retval #IOTCON_ERROR_SYSTEM System error
+ * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see iotcon_stop_presence()
+ * @see iotcon_subscribe_presence()
+ * @see iotcon_unsubscribe_presence()
+ */
+int iotcon_start_presence(unsigned int time_to_live);
+
+/**
+ * @brief Stop presence of a server.
+ * @details Use this function to stop sending server's announcements to clients.
+ * Server can call this function when terminating, entering to offline or out of network.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_DBUS Dbus error
+ * @retval #IOTCON_ERROR_SYSTEM System error
+ * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see iotcon_start_presence()
+ * @see iotcon_subscribe_presence()
+ * @see iotcon_unsubscribe_presence()
+ */
+int iotcon_stop_presence(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__ */
typedef struct icl_device_info* iotcon_device_info_h;
/**
- * @brief Sets device properties into the device information handle
- *
- * @since_tizen 3.0
- *
- * @param[in] device_info The handle of the device information
- * @param[in] property The properties of the device information
- * @param[in] value The value of the property
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see iotcon_device_info_create()
- * @see iotcon_device_info_destroy()
- * @see iotcon_set_device_info()
- */
-int iotcon_device_info_set_property(iotcon_device_info_h device_info,
- iotcon_device_info_e property, const char *value);
-
-/**
* @brief Get device properties from the device information handle
*
* @since_tizen 3.0
typedef struct icl_platform_info* iotcon_platform_info_h;
/**
- * @brief Sets platform properties into the platform information handle
- *
- * @since_tizen 3.0
- *
- * @param[in] platform_info The handle of the platform information
- * @param[in] property The properties of the platform information
- * @param[in] value The value of the property
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see iotcon_platform_info_create()
- * @see iotcon_platform_info_destroy()
- * @see iotcon_set_platform_info()
- */
-int iotcon_platform_info_set_property(iotcon_platform_info_h platform_info,
- iotcon_platform_info_e property, const char *value);
-
-/**
* @brief Get platform properties from the platform information handle
*
* @since_tizen 3.0
iotcon_resource_h child);
/**
- * @brief Creates a new device information handle.
- *
- * @since_tizen 3.0
- *
- * @param[out] device_info The handle of the device information
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see iotcon_device_info_destroy()
- * @see iotcon_set_device_info()
- * @see iotcon_device_info_set_property()
- */
-int iotcon_device_info_create(iotcon_device_info_h *device_info);
-
-/**
- * @brief Releases a device information handle.
- *
- * @since_tizen 3.0
- *
- * @param[in] device_info The handle of the device information
- *
- * @return void
- *
- * @see iotcon_device_info_create()
- * @see iotcon_set_device_info()
- * @see iotcon_device_info_set_property()
- */
-void iotcon_device_info_destroy(iotcon_device_info_h device_info);
-
-/**
- * @brief Set the device information in a server.
- *
- * @since_tizen 3.0
- *
- * @param[in] device_info The device information to set
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_DBUS Dbus error
- * @retval #IOTCON_ERROR_SYSTEM System error
- *
- * @see iotcon_device_info_create()
- * @see iotcon_device_info_destroy()
- * @see iotcon_device_info_set_property()
- */
-int iotcon_set_device_info(iotcon_device_info_h device_info);
-
-/**
* @brief Specifies the type of function passed to iotcon_get_device_info().
*
* @since_tizen 3.0
void *user_data);
/**
- * @brief Creates a new platform information handle.
- *
- * @since_tizen 3.0
- *
- * @param[out] platform_info The handle of the platform information
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see iotcon_platform_info_destroy()
- * @see iotcon_set_platform_info()
- * @see iotcon_platform_info_set_property()
- */
-int iotcon_platform_info_create(iotcon_platform_info_h *platform_info);
-
-/**
- * @brief Releases a platform information handle.
- *
- * @since_tizen 3.0
- *
- * @param[in] platform_info The handle of the platform information
- *
- * @return void
- *
- * @see iotcon_platform_info_create()
- * @see iotcon_set_platform_info()
- * @see iotcon_platform_info_set_property()
- */
-void iotcon_platform_info_destroy(iotcon_platform_info_h platform_info);
-
-/**
- * @brief Set platform information in a server.
- *
- * @since_tizen 3.0
- *
- * @param[in] platform_info The platform information to set
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_DBUS Dbus error
- * @retval #IOTCON_ERROR_SYSTEM System error
- *
- * @see iotcon_platform_info_create()
- * @see iotcon_platform_info_destroy()
- * @see iotcon_platform_info_set_property()
- */
-int iotcon_set_platform_info(iotcon_platform_info_h platform_info);
-
-/**
* @brief Specifies the type of function passed to iotcon_get_platform_info().
*
* @since_tizen 3.0
void *user_data);
/**
- * @brief Starts presence of a server.
- * @details Use this function to send server's announcements to clients.\n
- * Server can call this function when online for the first time or come back from offline to online.
- *
- * @since_tizen 3.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/internet
- *
- * @remarks If @a time_to_live is 0, server will set default value as 60 seconds.\n
- * If @a time_to_live is very big, server will set maximum value as (60 * 60 * 24) seconds.
- * (24 hours)
- *
- * @param[in] time_to_live The interval of announcing presence in seconds.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_DBUS Dbus error
- * @retval #IOTCON_ERROR_SYSTEM System error
- * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
- *
- * @see iotcon_stop_presence()
- * @see iotcon_subscribe_presence()
- * @see iotcon_unsubscribe_presence()
- */
-int iotcon_start_presence(unsigned int time_to_live);
-
-/**
- * @brief Stop presence of a server.
- * @details Use this function to stop sending server's announcements to clients.
- * Server can call this function when terminating, entering to offline or out of network.
- *
- * @since_tizen 3.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/internet
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_DBUS Dbus error
- * @retval #IOTCON_ERROR_SYSTEM System error
- * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
- *
- * @see iotcon_start_presence()
- * @see iotcon_subscribe_presence()
- * @see iotcon_unsubscribe_presence()
- */
-int iotcon_stop_presence(void);
-
-/**
* @brief Specifies the type of function passed to iotcon_subscribe_presence().
* @details Called when client receive presence events from the server.
*
%{_bindir}/crud-test-client
%{_bindir}/crud-test-server
%{_bindir}/device-test-client
-%{_bindir}/device-test-server
%{_bindir}/repr-test-client
%{_bindir}/repr-test-server
SET(CRUD_TEST_SERVER_SRCS "crud-test-server.c")
SET(DEVICE_TEST_CLIENT "device-test-client")
-SET(DEVICE_TEST_SERVER "device-test-server")
SET(DEVICE_TEST_CLIENT_SRCS "device-test-client.c")
-SET(DEVICE_TEST_SERVER_SRCS "device-test-server.c")
SET(REPR_TEST_CLIENT "repr-test-client")
SET(REPR_TEST_SERVER "repr-test-server")
TARGET_LINK_LIBRARIES(${DEVICE_TEST_CLIENT} ${test_pkgs_LIBRARIES} ${CLIENT})
INSTALL(TARGETS ${DEVICE_TEST_CLIENT} DESTINATION ${BIN_INSTALL_DIR})
-ADD_EXECUTABLE(${DEVICE_TEST_SERVER} ${DEVICE_TEST_SERVER_SRCS})
-TARGET_LINK_LIBRARIES(${DEVICE_TEST_SERVER} ${test_pkgs_LIBRARIES} ${CLIENT})
-INSTALL(TARGETS ${DEVICE_TEST_SERVER} DESTINATION ${BIN_INSTALL_DIR})
-
ADD_EXECUTABLE(${REPR_TEST_CLIENT} ${REPR_TEST_CLIENT_SRCS})
TARGET_LINK_LIBRARIES(${REPR_TEST_CLIENT} ${test_pkgs_LIBRARIES} ${CLIENT})
INSTALL(TARGETS ${REPR_TEST_CLIENT} DESTINATION ${BIN_INSTALL_DIR})
#include <glib.h>
#include <iotcon.h>
+#include <iotcon-internal.h>
#include "test.h"
/* Door Resource */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <glib.h>
-#include <iotcon.h>
-#include "test.h"
-
-static int _set_device_info()
-{
- int ret;
- char *device_name = "device name";
- iotcon_device_info_h device_info;
-
- ret = iotcon_device_info_create(&device_info);
- if (NULL == device_info) {
- ERR("iotcon_device_info_create() Fail(%d)", ret);
- return -1;
- }
-
- ret = iotcon_device_info_set_property(device_info, IOTCON_DEVICE_INFO_NAME,
- device_name);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_device_info_set_property() Fail(%d)", ret);
- iotcon_device_info_destroy(device_info);
- return -1;
- }
-
- ret = iotcon_set_device_info(device_info);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_set_device_info() Fail(%d)", ret);
- iotcon_device_info_destroy(device_info);
- return -1;
- }
-
- iotcon_device_info_destroy(device_info);
-
- return 0;
-}
-
-static int _set_platform_info()
-{
- int ret;
- char *platform_id = "platform_id";
- char *manuf_name = "manuf_name";
- char *manuf_url = "manuf_url";
- char *model_number = "model_number";
- char *date_of_manuf = "date_of_manuf";
- char *platform_ver = "platform_ver";
- char *os_ver = "os_ver";
- char *hardware_ver = "hardware_ver";
- char *firmware_ver = "firmware_ver";
- char *support_url = "support_url";
- char *system_time = "system_time";
- iotcon_platform_info_h platform_info;
-
- ret = iotcon_platform_info_create(&platform_info);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_create() Fail(%d)", ret);
- return -1;
- }
-
- ret = iotcon_platform_info_set_property(platform_info, IOTCON_PLATFORM_INFO_ID,
- platform_id);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_MANUF_NAME, manuf_name);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info, IOTCON_PLATFORM_INFO_MANUF_URL,
- manuf_url);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_MODEL_NUMBER, model_number);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_DATE_OF_MANUF, date_of_manuf);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_PLATFORM_VER, platform_ver);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info, IOTCON_PLATFORM_INFO_OS_VER,
- os_ver);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_HARDWARE_VER, hardware_ver);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_FIRMWARE_VER, firmware_ver);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_SUPPORT_URL, support_url);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
- ret = iotcon_platform_info_set_property(platform_info,
- IOTCON_PLATFORM_INFO_SYSTEM_TIME, system_time);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_platform_info_set_property() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
-
- ret = iotcon_set_platform_info(platform_info);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_set_platform_info() Fail(%d)", ret);
- iotcon_platform_info_destroy(platform_info);
- return -1;
- }
-
- return 0;
-}
-
-int main()
-{
- FN_CALL;
- int ret;
- GMainLoop *loop;
-
- loop = g_main_loop_new(NULL, FALSE);
-
- /* iotcon open */
- ret = iotcon_open();
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_open() Fail(%d)", ret);
- return -1;
- }
-
- ret = _set_device_info();
- if (0 != ret) {
- ERR("_set_device_info() Fail");
- iotcon_close();
- return -1;
- }
- ret = _set_platform_info();
- if (0 != ret) {
- ERR("_set_platform_info() Fail");
- iotcon_close();
- return -1;
- }
-
- g_main_loop_run(loop);
-
- g_main_loop_unref(loop);
-
- /* iotcon close */
- iotcon_close();
-
- return 0;
-}
-