summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/model_car_connection.c20
-rw-r--r--src/model/model_cloud_connection.c13
2 files changed, 17 insertions, 16 deletions
diff --git a/src/model/model_car_connection.c b/src/model/model_car_connection.c
index 5c7378e..1174a9a 100644
--- a/src/model/model_car_connection.c
+++ b/src/model/model_car_connection.c
@@ -29,7 +29,7 @@
#include "gear-racing-controller.h"
#include "log.h"
-#define SEND_TIMEOUT 20
+#define SEND_TIMEOUT 30
#define DIRECTION_BASE_VALUE 10000
#define THROTTLE_BASE_VALUE 10000
#define HELLO_TIMER_WAIT 3.0
@@ -37,7 +37,7 @@
typedef struct _s_car_model_connection {
t_model_car_connection_update_cb controller_update_cb;
bool ready_to_drive;
-
+ char player_name[PLAYER_NAME_MAX_LEN + 1];
float direction;
float throttle;
float cam_elevation;
@@ -162,10 +162,24 @@ void model_car_connection_set_stop(bool stop)
}
}
-bool model_car_connection_is_connected() {
+bool model_car_connection_is_connected()
+{
return CAR_CONNECTION_STATE_CONNECTED == car_connection_manager_get_state();
}
+bool model_car_connection_player_name_set(const char *player_name)
+{
+ if(!model_car_connection_is_connected()) {
+ _E("Connection hasn't been established");
+ return false;
+ }
+
+ strncpy(s_info.player_name, player_name, PLAYER_NAME_MAX_LEN);
+
+ car_connection_manager_send_user_name(s_info.player_name);
+ return true;
+}
+
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) {
diff --git a/src/model/model_cloud_connection.c b/src/model/model_cloud_connection.c
index 4493633..16fcfbf 100644
--- a/src/model/model_cloud_connection.c
+++ b/src/model/model_cloud_connection.c
@@ -24,7 +24,6 @@
typedef struct _s_cloud_model_connection {
t_model_cloud_connection_update_cb controller_update_cb;
t_model_cloud_connection_update_cb reconnect_cb;
- char player_name[PLAYER_NAME_MAX_LEN + 1];
car_info_t **cars;
int cars_size;
gboolean is_initialized;
@@ -78,18 +77,6 @@ void model_cloud_connection_unsubscirbe_event(void)
model_cloud_connection.reconnect_cb = NULL;
}
-bool model_cloud_connection_player_name_set(const char *player_name)
-{
- if(!model_cloud_connection.is_initialized) {
- _E("Model cloud connection hasn't been initialized");
- return false;
- }
-
- strncpy(model_cloud_connection.player_name, player_name, PLAYER_NAME_MAX_LEN);
- //In case of failure, return 0
- return true;
-}
-
void model_cloud_connection_subscribe_reconnect(t_model_cloud_connection_update_cb model_update_cb)
{
if(!model_cloud_connection.is_initialized) {