Attach "coap://" automatically. & Divide "notify"(all and list)
[platform/core/iot/iotcon.git] / lib / icl-device.c
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <stdlib.h>
17 #include <string.h>
18 #include <errno.h>
19 #include <glib.h>
20
21 #include "iotcon.h"
22 #include "icl.h"
23 #include "icl-ioty.h"
24
25 /* The length of manufacturer_name should be less than and equal to 16.
26  * The length of manufacturer_url should be less than and equal to 32. */
27 API int iotcon_register_device_info(iotcon_device_info_s device_info)
28 {
29         int ret;
30
31         if (device_info.manuf_name
32                         && (IOTCON_MANUFACTURER_NAME_LENGTH_MAX < strlen(device_info.manuf_name))) {
33                 ERR("The length of manufacturer_name(%s) is invalid.", device_info.manuf_name);
34                 return IOTCON_ERROR_INVALID_PARAMETER;
35         }
36
37         if (device_info.manuf_url
38                         && (IOTCON_MANUFACTURER_URL_LENGTH_MAX < strlen(device_info.manuf_url))) {
39                 ERR("The length of manufacturer_url(%s) is invalid.", device_info.manuf_url);
40                 return IOTCON_ERROR_INVALID_PARAMETER;
41         }
42
43
44         ret = ic_ioty_register_device_info(device_info);
45         if (IOTCON_ERROR_NONE != ret)
46                 ERR("ic_ioty_register_device_info() Fail(%d)", ret);
47
48         return ret;
49 }
50
51
52 API int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb cb,
53                 void *user_data)
54 {
55         FN_CALL;
56         int ret = IOTCON_ERROR_NONE;
57
58         RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
59         RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
60
61         ret = ic_ioty_get_device_info(host_address, cb, user_data);
62         if (IOTCON_ERROR_NONE != ret) {
63                 ERR("ic_ioty_get_device_info() Fail(%d)", ret);
64                 return ret;
65         }
66
67         return IOTCON_ERROR_NONE;
68 }