2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 static void _request_device_info(iotcon_device_info_h info, iotcon_error_e result, void *user_data)
24 char *device_name = NULL;
25 char *spec_ver = NULL;
26 char *device_id = NULL;
27 char *data_model_ver = NULL;
29 RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result (%d)", result);
31 ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_NAME, &device_name);
32 if (IOTCON_ERROR_NONE != ret) {
33 ERR("iotcon_device_info_get_property() Fail(%d)", ret);
37 ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_SPEC_VER, &spec_ver);
38 if (IOTCON_ERROR_NONE != ret) {
39 ERR("iotcon_device_info_get_property() Fail(%d)", ret);
43 ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_ID, &device_id);
44 if (IOTCON_ERROR_NONE != ret) {
45 ERR("iotcon_device_info_get_property() Fail(%d)", ret);
49 ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_DATA_MODEL_VER,
51 if (IOTCON_ERROR_NONE != ret) {
52 ERR("iotcon_device_info_get_property() Fail(%d)", ret);
56 INFO("Get Device Info");
57 INFO("device_name : %s", device_name);
58 INFO("spec_version : %s", spec_ver);
59 INFO("device_id : %s", device_id);
60 INFO("data_model_version : %s", data_model_ver);
63 static void _request_platform_info(iotcon_platform_info_h info, iotcon_error_e result, void *user_data)
66 char *platform_id = NULL;
67 char *manuf_name = NULL;
68 char *manuf_url = NULL;
69 char *model_number = NULL;
70 char *date_of_manuf = NULL;
71 char *platform_ver = NULL;
73 char *hardware_ver = NULL;
74 char *firmware_ver = NULL;
75 char *support_url = NULL;
76 char *system_time = NULL;
78 RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result (%d)", result);
80 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_ID, &platform_id);
81 if (IOTCON_ERROR_NONE != ret) {
82 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
86 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_MANUF_NAME,
88 if (IOTCON_ERROR_NONE != ret) {
89 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
93 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_MANUF_URL,
95 if (IOTCON_ERROR_NONE != ret) {
96 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
100 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_MODEL_NUMBER,
102 if (IOTCON_ERROR_NONE != ret) {
103 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
107 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_DATE_OF_MANUF,
109 if (IOTCON_ERROR_NONE != ret) {
110 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
114 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_PLATFORM_VER,
116 if (IOTCON_ERROR_NONE != ret) {
117 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
121 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_OS_VER, &os_ver);
122 if (IOTCON_ERROR_NONE != ret) {
123 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
127 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_HARDWARE_VER,
129 if (IOTCON_ERROR_NONE != ret) {
130 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
134 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_FIRMWARE_VER,
136 if (IOTCON_ERROR_NONE != ret) {
137 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
141 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_SUPPORT_URL,
143 if (IOTCON_ERROR_NONE != ret) {
144 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
148 ret = iotcon_platform_info_get_property(info, IOTCON_PLATFORM_INFO_SYSTEM_TIME,
150 if (IOTCON_ERROR_NONE != ret) {
151 ERR("iotcon_platform_info_get_property() Fail(%d)", ret);
155 INFO("Get Platform Info");
156 INFO("platform_id : %s", platform_id);
157 INFO("manuf_name : %s", manuf_name);
158 INFO("manuf_url : %s", manuf_url);
159 INFO("model_number : %s", model_number);
160 INFO("date_of_manufacture : %s", date_of_manuf);
161 INFO("platform_ver : %s", platform_ver);
162 INFO("os_ver : %s", os_ver);
163 INFO("hardware_ver : %s", hardware_ver);
164 INFO("firmware_ver : %s", firmware_ver);
165 INFO("support_url : %s", support_url);
166 INFO("system_time : %s", system_time);
174 loop = g_main_loop_new(NULL, FALSE);
177 ret = iotcon_connect();
178 if (IOTCON_ERROR_NONE != ret) {
179 ERR("iotcon_connect() Fail(%d)", ret);
183 ret = iotcon_get_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
184 _request_device_info, NULL);
185 if (IOTCON_ERROR_NONE != ret) {
186 ERR("iotcon_get_device_info() Fail(%d)", ret);
191 ret = iotcon_get_platform_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
192 _request_platform_info, NULL);
193 if (IOTCON_ERROR_NONE != ret) {
194 ERR("iotcon_get_platform_info() Fail(%d)", ret);
199 g_main_loop_run(loop);
201 g_main_loop_unref(loop);
203 /* disconnect iotcon */