Add code to use fmwup-api 83/156583/1
authorhhk86.heo <hhk86.heo@samsung.com>
Thu, 19 Oct 2017 04:32:32 +0000 (13:32 +0900)
committerhhk86.heo <hhk86.heo@samsung.com>
Thu, 19 Oct 2017 04:32:32 +0000 (13:32 +0900)
Change-Id: I1fb7c86cdba0a333f36affc0a734e5020daff6a9

.cproject
inc/fmwup_headless_thingsapp.h
src/fmwup_headless_thingsapp.c
src/thing.c
src/user.c
tizen-manifest.xml

index cf41b1666dd0cc18d7fd457eba611b29bac0adf1..8ad3d5c64dae3949176fa09593f95bcd3fc41f88 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                                <option id="gnu.cpp.compiler.option.optimization.level.1637530585" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1661973108" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.2136424710" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
-                                                               <option id="sbi.gnu.cpp.compiler.option.1372273028" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
+                                                               <option id="sbi.gnu.cpp.compiler.option.1372273028" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
                                                                </option>
-                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1031102311" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
+                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1031102311" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
                                                                </option>
-                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.334947479" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
+                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.334947479" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
-                                                               <option id="gnu.cpp.compiler.option.include.paths.1413926155" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+                                                               <option id="gnu.cpp.compiler.option.include.paths.1413926155" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                </option>
-                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks.core.575119607" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
+                                                               <option id="sbi.gnu.cpp.compiler.option.frameworks.core.575119607" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                        <listOptionValue builtIn="false" value="iot-things"/>
                                                                </option>
-                                                               <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.2032033056" superClass="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation" valueType="definedSymbols">
+                                                               <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.2032033056" name="Defined symbols (-D)" superClass="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation" valueType="definedSymbols">
                                                                        <listOptionValue builtIn="false" value="TIZEN_DEPRECATION"/>
                                                                        <listOptionValue builtIn="false" value="DEPRECATION_WARNING"/>
                                                                        <listOptionValue builtIn="false" value="_DEBUG"/>
                                                                <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1437493708" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.796097947" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1797171724" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
-                                                               <option id="sbi.gnu.c.compiler.option.1652032421" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
+                                                               <option id="sbi.gnu.c.compiler.option.1652032421" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
                                                                </option>
-                                                               <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.666689709" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
+                                                               <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.666689709" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
                                                                </option>
-                                                               <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.22022290" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
+                                                               <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.22022290" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
-                                                               <option id="gnu.c.compiler.option.include.paths.398634895" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+                                                               <option id="gnu.c.compiler.option.include.paths.398634895" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                </option>
-                                                               <option id="sbi.gnu.c.compiler.option.frameworks.core.722240420" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
+                                                               <option id="sbi.gnu.c.compiler.option.frameworks.core.722240420" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                        <listOptionValue builtIn="false" value="iot-things"/>
                                                                </option>
-                                                               <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.37702416" superClass="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation" valueType="definedSymbols">
+                                                               <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.37702416" name="Defined symbols (-D)" superClass="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation" valueType="definedSymbols">
                                                                        <listOptionValue builtIn="false" value="TIZEN_DEPRECATION"/>
                                                                        <listOptionValue builtIn="false" value="DEPRECATION_WARNING"/>
                                                                        <listOptionValue builtIn="false" value="_DEBUG"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.link.option.strip.2038855704" name="Omit all symbol information (-s)" superClass="sbi.gnu.cpp.link.option.strip" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1021906542" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1446685057" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
-                                                               <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1159324549" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
+                                                               <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1159324549" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="-pie -lpthread "/>
                                                                        <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/../iot-things-4.0-device.core/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
                                                                </option>
-                                                               <option id="gnu.cpp.link.option.paths.1940122343" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
+                                                               <option id="gnu.cpp.link.option.paths.1940122343" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
                                                                </option>
-                                                               <option id="gnu.cpp.link.option.libs.345292371" superClass="gnu.cpp.link.option.libs" valueType="libs">
+                                                               <option id="gnu.cpp.link.option.libs.345292371" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
                                                                        <listOptionValue builtIn="false" value="oicdastack"/>
                                                                        <listOptionValue builtIn="false" value="sdkapi"/>
                                                                </option>
                </scannerConfigBuildInfo>
        </storageModule>
        <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+       <storageModule moduleId="refreshScope"/>
 </cproject>
index f64bab9f07bd1bbb49d4cb164ee42204d662ffa9..b839880a1f1613ad287155471326ff16628e0c80 100644 (file)
@@ -6,7 +6,7 @@
 #ifdef  LOG_TAG
 #undef  LOG_TAG
 #endif
-#define LOG_TAG "fmwup-headless-thingsapp"
+#define LOG_TAG "FMWUP-HEADLESS-THINGSAPP"
 
 
 #endif /* __fmwup_headless_thingsapp_H__ */
index b781285425736003c7ddc2436a5dd94c943518de..e307b2a5af51a16adca13912a4b22d433d250f16 100644 (file)
@@ -6,6 +6,8 @@
 #include "log.h"
 #include "thing.h"
 
+#include "fmwup_api.h"
+
 bool service_app_create(void *data)
 {
     // Todo: add your code here.
@@ -49,20 +51,15 @@ void service_app_control(app_control_h app_control, void *data)
 
 
        if (g_strcmp0(operation, "http://samsung.com/appcontrol/operation/fmwup-headless-thingsapp/fmwup_get_newest_firmware_from_serve") == 0) {
-//             ret = fmwup_get_newest_firmware_from_server();
-//             if (ret != 0) {
-//                     /* error case */
-//             }
+               ret = fmwup_get_newest_firmware_from_server();
+               if (ret != 0) {
+                       /* error case */
+               }
        } else if (g_strcmp0(operation, "http://samsung.com/appcontrol/operation/fmwup-headless-thingsapp/fmwup_update") == 0) {
-//             ret = fmwup_update("3",NULL);
-//             if (ret != 0) {
-//                     /* error case */
-//             }
-       } else if (g_strcmp0(operation, "http://samsung.com/appcontrol/operation/fmwup-headless-thingsapp/fmwup_check_firmware_upgraded") == 0) {
-//             ret = fmwup_check_firmware_upgraded();
-//             if (ret != 0) {
-//                     /* error case */
-//             }
+               ret = fmwup_update(FMWUP_COMMAND_DOWNLOAD_IMAGE_AND_UPDATE, NULL);
+               if (ret != 0) {
+                       /* error case */
+               }
        }
 
 
index fe253e99f5a6d76fa274903a8d5c3413efb4fe2d..2a0f43955ddec4be30427baf1fa28e55581e1046 100644 (file)
 #include <string.h>
 #include <stdbool.h>
 #include <signal.h>
+#include <app_common.h>
+
 #include "st_things.h"
 #include "user.h"
 #include "fmwup_api.h"
-#include <ckmc/ckmc-manager.h>
 
 #define JSON_PATH "/usr/apps/org.tizen.st-things/res/device_def.json"
 static const char *RES_SWITCH = "/switch";
@@ -40,12 +41,12 @@ static bool handle_get_request(st_things_get_request_message_s *req_msg, st_thin
        if (0 == strcmp(req_msg->resource_uri, RES_SWITCH))
                return handle_get_request_on_switch(req_msg, resp_rep);
 
-//     int ret = fmwup_handle_get_request(req_msg, resp_rep);
-//     if (ret != 0) {
-//             DBG("fmwup_handle_get_request ret[%d]", ret);
-//     } else {
-//             return true;
-//     }
+       int ret = fmwup_handle_get_request(req_msg, resp_rep);
+       if (ret != 0) {
+               DBG("fmwup_handle_get_request ret[%d]", ret);
+       } else {
+               return true;
+       }
        ERR("not supported uri");
        return false;
 }
@@ -57,20 +58,20 @@ static bool handle_set_request(st_things_set_request_message_s *req_msg, st_thin
        if (0 == strcmp(req_msg->resource_uri, RES_SWITCH))
                return handle_set_request_on_switch(req_msg, resp_rep);
 
-//     int ret = fmwup_handle_set_request(req_msg, resp_rep);
-//     if (ret != 0) {
-//             DBG("fmwup_handle_get_request ret[%d]", ret);
-//     } else {
-//             return true;
-//     }
+       int ret = fmwup_handle_set_request(req_msg, resp_rep);
+       if (ret != 0) {
+               DBG("fmwup_handle_get_request ret[%d]", ret);
+       } else {
+               return true;
+       }
 
        ERR("not supported uri");
        return false;
 }
 
-static void state_changed_cb(fmwup_state_e value)
+static void state_changed_cb(fmwup_state_e value, fmwup_result_e result)
 {
-       DBG("state_changed_cb state[%d]\n", value);
+       DBG("state_changed_cb state[%d] result[%d]\n", value, result);
 
 
 }
@@ -96,7 +97,7 @@ void init_thing()
 {
        FN_CALL;
        static int initialized = 0;
-//     int ret = 0;
+       int ret = 0;
        if (initialized) {
                DBG("Already initialized!!");
                return;
@@ -104,14 +105,14 @@ void init_thing()
        initialized = 1;
        init_user();
 
-//     DBG("_set_firmware_download_path() is called\n");
-//     ret = fmwup_set_firmware_download_path(app_get_data_path());
-//     if (0 != ret)
-//             DBG("fmwup_set_firmware_download_path() is failed[%d]", ret);
+       DBG("_set_firmware_download_path() is called\n");
+       ret = fmwup_set_firmware_download_path(app_get_data_path());
+       if (0 != ret)
+               DBG("fmwup_set_firmware_download_path() is failed[%d]", ret);
 
-//     ret = fmwup_register_update_changed_cb(_state_changed_cb, is_new_firmware_cb));
-//     if (0 != ret)
-//             DBG("fmwup_register_update_changed_cb() is failed[%d]", ret);
+       ret = fmwup_register_update_changed_cb(state_changed_cb, is_new_firmware_cb);
+       if (0 != ret)
+               DBG("fmwup_register_update_changed_cb() is failed[%d]", ret);
 
 
        bool easysetup_complete = false;
index 8653e79a69dab6e7a6468b93a334644aafd9ca5e..79294b6048ee91756be253fa2ee7e60c17f17b23 100644 (file)
@@ -26,6 +26,8 @@
 #include "st_things.h"
 #include "user.h"
 
+#include "fmwup_api.h"
+
 static const char* PROPERTY_VALUE = "value";
 static bool g_switch_value = false;
 
@@ -56,6 +58,7 @@ bool handle_set_request_on_switch(st_things_set_request_message_s *req_msg, st_t
 
        g_switch_value = value;
        resp_rep->set_bool_value(resp_rep, PROPERTY_VALUE, g_switch_value);
+
        return true;
 }
 
@@ -77,7 +80,6 @@ bool handle_ownership_transfer_request()
 {
        FN_CALL;
        bool confirmed = true;
-
        return confirmed;
 }
 
@@ -87,9 +89,9 @@ void handle_things_status_change(st_things_status_e things_status)
        DBG("things_status : [%d]", things_status);
 
        if (things_status == ST_THINGS_STATUS_REGISTERED_TO_CLOUD) {
-//             int ret = fmwup_check_firmware_upgraded();
-//             if (ret  != 0) {
-//                     DBG("fmwup_check_firmware_upgraded : [%d]", ret);
-//             }
+               int ret = fmwup_check_firmware_upgraded();
+               if (ret  != 0) {
+                       DBG("fmwup_check_firmware_upgraded : [%d]", ret);
+               }
        }
 }
index 328d8d022682544cb353dee4254769df6d9d9f7a..83acf8dac7a4c5458046516344596da895f9ec9b 100644 (file)
@@ -3,7 +3,7 @@
     <profile name="iot-headless"/>
     <service-application appid="org.tizen.st-things" exec="st-things" multiple="false" nodisplay="true" on-boot="true" taskmanage="false" type="capp">
         <label>st-things</label>
-        <icon>st-things.png</icon>
+        <icon>fmwup-headless-thingsapp.png</icon>
         <background-category value="background-network"/>
     </service-application>
     <privileges>