Added checks for disconnecting 23/190823/2
authorKrzysztof Wieclaw <k.wieclaw@samsung.com>
Fri, 5 Oct 2018 13:45:03 +0000 (15:45 +0200)
committerKrzysztof Wieclaw <k.wieclaw@samsung.com>
Tue, 23 Oct 2018 12:09:47 +0000 (14:09 +0200)
Change-Id: I13014d4064347551a846159dc7078cb28a540e59
Signed-off-by: Krzysztof Wieclaw <k.wieclaw@samsung.com>
.cproject
inc/model/model_car_connection.h
src/controller/controller_connection_successed.c
src/controller/controller_help.c
src/controller/controller_name_input.c
src/controller/controller_racing.c
src/controller/controller_reset.c
src/model/model_car_connection.c

index 18ba695..b11f130 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1847471508" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.328737878" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                        <builder autoBuildTarget="all" buildPath="${workspace_loc:/gear-racing-controller}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.227410736" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
-                                                       <tool command="arm-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1679874459" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+                                                       <tool command="i586-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1679874459" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
                                                        <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1354257060" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.796007872" 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.1472200190" 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.1659893418" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.912899474" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm40.armel"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.395715001" 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="${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.1203848534" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1140874669" 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.1096056089" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.1123455384" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm40.armel"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-emulator.core_llvm40.i386"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1389731891" 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/lib/glib-2.0/include&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.398744298" 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="${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"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.321037953" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.544193418" 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.1152050479" 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.2074193141" 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="${TC_LINKER_MISC}"/>
+                                                                       <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="-pie -lpthread "/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;$(PROJ_PATH)/.exportMap&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-L&quot;$(SBI_SYSROOT)/usr/lib&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
                                                                </option>
                                                                <option id="gnu.cpp.link.option.paths.83999257" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
index 648ceef..26ccc22 100644 (file)
@@ -40,5 +40,6 @@ void model_car_connection_ready_to_drive(bool is_ready);
 void model_car_connection_set_stop(bool stop);
 void model_car_connection_send_cam_elevation(float cam_elevation);
 void model_car_connection_send_cam_azimuth(float cam_azimuth);
+bool model_car_connection_is_connected();
 
 #endif /* MODEL_MODEL_CAR_CONNECTION_H_ */
index f843feb..8dad3b3 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "gear-racing-controller.h"
 #include "model/model_cloud_connection.h"
+#include "model/model_car_connection.h"
 #include "controller/controller_connection_successed.h"
 #include "view_manager/view_manager.h"
 
@@ -38,6 +39,10 @@ void controller_connection_successed_back(void)
 
 void controller_connection_successed_next()
 {
+       if(!model_car_connection_is_connected()) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+               return;
+       }
        view_manager_set_view(VIEW_NAME_INPUT);
 }
 
index 749f6f5..0add5a0 100644 (file)
@@ -17,7 +17,7 @@
 
 
 #include "gear-racing-controller.h"
-#include "model/model_cloud_connection.h"
+#include "model/model_car_connection.h"
 #include "controller/controller_help.h"
 #include "view_manager/view_manager.h"
 
@@ -40,6 +40,10 @@ void controller_help_back(void)
 
 void controller_help_next()
 {
+       if(!model_car_connection_is_connected()) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+               return;
+       }
        view_manager_set_view(VIEW_RACING);
 }
 
index 9b4339d..da3e3b6 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "gear-racing-controller.h"
 #include "model/model_cloud_connection.h"
+#include "model/model_car_connection.h"
 #include "controller/controller_name_input.h"
 #include "view_manager/view_manager.h"
 
@@ -41,6 +42,10 @@ void controller_name_input_back(void)
 
 void controller_name_input_next()
 {
+       if(!model_car_connection_is_connected()) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+               return;
+       }
        view_manager_set_view(VIEW_HELP);
 }
 
index 714f0b3..6b2a70a 100644 (file)
@@ -31,6 +31,7 @@ static s_racing_controller s_info = { { 0, } };
 
 void controller_racing_destroy(void)
 {
+       model_car_connection_ready_to_drive(false);
        model_sensors_unsubscirbe_event();
        model_car_connection_unsubscirbe_event();
        model_hw_unsubscirbe_event();
@@ -39,7 +40,9 @@ void controller_racing_destroy(void)
 
 static void _model_connected_cb(s_model_car_connection_cb_data *model_data)
 {
-       view_manager_set_view(VIEW_RESET);
+       if(model_data->type == MODEL_TYPE_FAIL) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+       }
 }
 
 void _map_device_to_view(e_device device, float value)
@@ -114,6 +117,6 @@ void controller_racing_back(void)
 
 void controller_racing_next()
 {
-       model_car_connection_ready_to_drive(false);
+       view_manager_set_view(VIEW_RESET);
 }
 
index fd524a5..2bdb72f 100644 (file)
@@ -47,10 +47,18 @@ void controller_reset_next()
 
 void controller_reset_reset()
 {
+       if(!model_car_connection_is_connected()) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+               return;
+       }
        view_manager_set_view(VIEW_NAME_INPUT);
 }
 
 void controller_reset_discard()
 {
+       if(!model_car_connection_is_connected()) {
+               view_manager_set_view(VIEW_NETWORK_FAILURE);
+               return;
+       }
        view_manager_set_view(VIEW_RACING);
 }
index f37aa6f..a0d7d31 100644 (file)
@@ -163,6 +163,10 @@ void model_car_connection_set_stop(bool stop)
        }
 }
 
+bool model_car_connection_is_connected() {
+       return CAR_CONNECTION_STATE_CONNECTED == car_connection_manager_get_state();
+}
+
 void _connection_state_cb(car_connection_state_e previous, car_connection_state_e current) {
        static s_model_car_connection_cb_data model_data;
        if(current == CAR_CONNECTION_STATE_CONNECTING) {