diff options
Diffstat (limited to 'src/model/model_car_connection.c')
-rw-r--r-- | src/model/model_car_connection.c | 20 |
1 files changed, 17 insertions, 3 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) { |