/**
@brief Register sensor client with SLIM CORE

Function sends message to slim daemon to initiate client
registration with SLIM CORE

@param  z_Txn: Parameters for sensor client registration
*/
int SocketClientWrapper::ClientRegister(slim_OpenTxnStructType &z_Txn)
{
    LOC_LOGD("%s:%d] Received client register", __func__, __LINE__);

    SocketClientOpenReq openRequest;
    memset(&openRequest, 0, sizeof(openRequest));

    openRequest.msgHeader.msgId = eSLIM_SOCKET_CLIENT_MSG_ID_OPEN_REQ;
    openRequest.msgHeader.msgSize = sizeof(SocketClientOpenReq);
    openRequest.msgPayload = z_Txn;

    LOC_LOGD("%s:%d] sizeof(SocketClientOpenReq) is %d, sizeof(openRequest.msgHeader) is %d",
             __func__, __LINE__, sizeof(SocketClientOpenReq), sizeof(openRequest.msgHeader));

    SocketClientWrapper::mCallbackFunction = openRequest.msgPayload.fn_Callback;
    LOC_LOGD("%s:%d] Received client register, p_Handle is %08X", __func__, __LINE__, z_Txn.p_Handle);
    LOC_LOGD("%s:%d] Received fn_Callback is %08X", __func__, __LINE__, openRequest.msgPayload.fn_Callback);
    // If socket_not_present or socket_not_connected, then error/warning
    if ( (SocketClientWrapper::mSocketFd < 0)
        )
    {
        LOC_LOGE("%s[%d]: socket not present/connected\n",
                        __func__, __LINE__);
        return -1;
    }

    if (write(SocketClientWrapper::mSocketFd, &openRequest, sizeof(openRequest)) < 0)
    {
        LOC_LOGE("%s[%d]: error writing on socket\n", __func__, __LINE__);
        return -1;
    }
    return 0;
}
/*This function obtains the list of supported profiles*/
static ds_client_status_enum_type ds_client_get_profile_list(
    qmi_client_type *ds_client_handle,
    ds_client_resp_union_type *profile_list_resp_msg,
    wds_profile_type_enum_v01 profile_type)
{
    ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
    ds_client_req_union_type req_union;
    LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);

    req_union.p_get_profile_list_req = NULL;
    req_union.p_get_profile_list_req = (wds_get_profile_list_req_msg_v01 *)
        calloc(1, sizeof(wds_get_profile_list_req_msg_v01));
    if(req_union.p_get_profile_list_req == NULL) {
        LOC_LOGE("%s:%d]: Could not allocate memory for"
                 "wds_get_profile_list_req_msg_v01\n", __func__, __LINE__);
        goto err;
    }
    //Populate required members of the request structure
    req_union.p_get_profile_list_req->profile_type_valid = 1;
    req_union.p_get_profile_list_req->profile_type = profile_type;
    ret = ds_client_send_qmi_sync_req(ds_client_handle,
                                       QMI_WDS_GET_PROFILE_LIST_REQ_V01,
                                       profile_list_resp_msg, &req_union);
    if(ret != E_DS_CLIENT_SUCCESS) {
        LOC_LOGE("%s:%d]: ds_client_send_qmi_req failed. ret: %d\n",
                 __func__, __LINE__, ret);
        goto err;
    }
err:
    LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
    if(req_union.p_get_profile_list_req)
        free(req_union.p_get_profile_list_req);
    return ret;
}
/*This function obtains settings for the profile specified by
 the profile_identifier*/
static ds_client_status_enum_type ds_client_get_profile_settings(
    qmi_client_type *ds_client_handle,
    ds_client_resp_union_type *profile_settings_resp_msg,
    wds_profile_identifier_type_v01 *profile_identifier)
{
    ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
    ds_client_req_union_type req_union;

    LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
    //Since it's a union containing a pointer to a structure,
    //following entities have the same address
    //- req_union
    //- req_union.p_get_profile_settings_req
    //- req_union.p_get_profile_settings_req->profile
    //so we can very well assign req_union = profile_identifier
    req_union.p_get_profile_settings_req =
        (wds_get_profile_settings_req_msg_v01 *)profile_identifier;
    ret = ds_client_send_qmi_sync_req(ds_client_handle,
                                       QMI_WDS_GET_PROFILE_SETTINGS_REQ_V01,
                                       profile_settings_resp_msg, &req_union);
    if(ret != E_DS_CLIENT_SUCCESS) {
        LOC_LOGE("%s:%d]: ds_client_send_qmi_req failed. ret: %d\n",
                 __func__, __LINE__, ret);
        goto err;
    }
err:
    LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
    return ret;
}
Example #4
0
void* loc_timer_start(unsigned int msec, loc_timer_callback cb_func,
                      void* caller_data)
{
    timer_data *t=NULL;
    pthread_attr_t tattr;
    pthread_t id;
    LOC_LOGD("%s:%d]: Enter\n", __func__, __LINE__);
    if(cb_func == NULL || msec == 0) {
        LOC_LOGE("%s:%d]: Error: Wrong parameters\n", __func__, __LINE__);
        goto _err;
    }
    t = (timer_data *)calloc(1, sizeof(timer_data));
    if(t == NULL) {
        LOC_LOGE("%s:%d]: Could not allocate memory. Failing.\n",
                 __func__, __LINE__);
        goto _err;
    }

    if(pthread_cond_init(&(t->timer_cond), NULL)) {
        LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__);
        goto t_err;
    }
    if(pthread_mutex_init(&(t->timer_mutex), NULL)) {
        LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
        goto cond_err;
    }

    t->callback_func = cb_func;
    t->user_data = caller_data;
    t->time_msec = msec;
    t->state = READY;

    if (pthread_attr_init(&tattr)) {
        LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
        goto mutex_err;
    }
    pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);

    if(pthread_create(&(id), &tattr, timer_thread, (void *)t)) {
        LOC_LOGE("%s:%d]: Could not create thread\n", __func__, __LINE__);
        goto attr_err;
    }

    LOC_LOGD("%s:%d]: Created thread with id: %d\n",
             __func__, __LINE__, (int)id);
    goto _err;

attr_err:
    pthread_attr_destroy(&tattr);
mutex_err:
    pthread_mutex_destroy(&t->timer_mutex);
cond_err:
    pthread_cond_destroy(&t->timer_cond);
t_err:
    free(t);
    t = NULL;
_err:
    LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
    return t;
}
/**
@brief Enabling or disabling of sensor data streaming for sensor client

Function sends enabling or disabling of sensor data
streaming for sensor client to slim daemon

@param  z_Txn: Request parameters for sensor streaming
*/
int SocketClientWrapper::requestSensorData(slim_EnableSensorDataTxnStructType &z_Txn)
{
    LOC_LOGD("%s:%d] Received sensor data request", __func__, __LINE__);

    SocketClientSensorDataReq sensorDataRequest;
    memset(&sensorDataRequest, 0, sizeof(sensorDataRequest));

    sensorDataRequest.msgHeader.msgId = eSLIM_SOCKET_CLIENT_MSG_ID_SENSOR_DATA_REQ;
    sensorDataRequest.msgHeader.msgSize = sizeof(SocketClientSensorDataReq);
    sensorDataRequest.msgPayload = z_Txn;
    LOC_LOGD("%s:%d] Received sensor request, p_Handle is %08X", __func__, __LINE__, z_Txn.z_TxnData.p_Handle);
    // If socket_not_present or socket_not_connected, then error/warning
    if ( (SocketClientWrapper::mSocketFd < 0)
        )
    {
        LOC_LOGE("%s[%d]: socket not present/connected\n",
                        __func__, __LINE__);
        return -1;
    }

    if (write(SocketClientWrapper::mSocketFd, &sensorDataRequest, sizeof(sensorDataRequest)) < 0)
    {
        LOC_LOGE("%s[%d]: error writing on socket\n", __func__, __LINE__);
        return -1;
    }
    return 0;
}
/*===========================================================================
FUNCTION    loc_eng_dmn_conn_glue_pipeget

DESCRIPTION
   create a named pipe.

   pipe_name - pipe name path
   mode - mode

DEPENDENCIES
   None

RETURN VALUE
   0: success or negative value for failure

SIDE EFFECTS
   N/A

===========================================================================*/
int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode)
{
    int fd;
    int result;

    LOC_LOGD("%s, mode = %d\n", pipe_name, mode);
    result = mkfifo(pipe_name, 0660);

    if ((result == -1) && (errno != EEXIST)) {
        LOC_LOGE("failed: %s\n", strerror(errno));
        return result;
    }

    // The mode in mkfifo is not honoured and does not provide the
    // group permissions. Doing chmod to add group permissions.
    result = chmod (pipe_name, 0660);
    if (result != 0){
        LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__,
              pipe_name, strerror(errno));
    }

    fd = open(pipe_name, mode);
    if (fd <= 0)
    {
        LOC_LOGE("failed: %s\n", strerror(errno));
    }
    LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
    return fd;
}
Example #7
0
/*===========================================================================

  FUNCTION:   msg_q_unblock

  ===========================================================================*/
msq_q_err_type msg_q_unblock(void* msg_q_data)
{
   if ( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;
   pthread_mutex_lock(&p_msg_q->list_mutex);

   if( p_msg_q->unblocked )
   {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   LOC_LOGD("%s: Unblocking Message Queue\n", __FUNCTION__);
   /* Unblocking message queue */
   p_msg_q->unblocked = 1;

   /* Allow all the waiters to wake up */
   pthread_cond_broadcast(&p_msg_q->list_cond);

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGD("%s: Message Queue unblocked\n", __FUNCTION__);

   return eMSG_Q_SUCCESS;
}
/**
 * @brief Stops a data call associated with the handle
 *
 * @param[in] client_handle Client handle
 *
 * @return Operation result
 * @retval E_DS_CLIENT_SUCCESS    On success.
 * @retval E_DS_CLIENT_FAILURE... On error.
 */
static ds_client_status_enum_type ds_client_stop_call(dsClientHandleType client_handle)
{
    ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
    ds_client_session_data *p_ds_global_data = (ds_client_session_data *)client_handle;
    LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);

    if(client_handle == NULL) {
        LOC_LOGE("%s:%d]: Null argument received. Failing\n", __func__, __LINE__);
        ret = E_DS_CLIENT_FAILURE_GENERAL;
        goto err;
    }

    if(dsi_stop_data_call(p_ds_global_data->dsi_net_handle) == DSI_SUCCESS) {
        LOC_LOGD("%s:%d]: Sent request to stop data call\n", __func__, __LINE__);
    }
    else {
        LOC_LOGE("%s:%d]: Could not send request to stop data call\n",
                 __func__, __LINE__);
        ret = E_DS_CLIENT_FAILURE_GENERAL;
        goto err;
    }

err:
    LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
    return ret;
}
int ExtServicer :: requestRsrc(void *cb_data)
{
    int ret=-1;
    LOC_LOGD("Enter ExtServicer :: requestRsrc\n");
    ret = callbackExt(cb_data);
    LOC_LOGD("Exit ExtServicer :: requestRsrc\n");
    return(ret);
}
/*===========================================================================
FUNCTION loc_set_config_entry

DESCRIPTION
   Potentially sets a given configuration table entry based on the passed in
   configuration value. This is done by using a string comparison of the
   parameter names and those found in the configuration file.

PARAMETERS:
   config_entry: configuration entry in the table to possibly set
   config_value: value to store in the entry if the parameter names match

DEPENDENCIES
   N/A

RETURN VALUE
   None

SIDE EFFECTS
   N/A
===========================================================================*/
void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
{
   if(NULL == config_entry || NULL == config_value)
   {
      LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
      return;
   }

   if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
               config_entry->param_ptr)
   {
      switch (config_entry->param_type)
      {
      case 's':
         if (strcmp(config_value->param_str_value, "NULL") == 0)
         {
            *((char*)config_entry->param_ptr) = '\0';
         }
         else {
            strlcpy((char*) config_entry->param_ptr,
                  config_value->param_str_value,
                  LOC_MAX_PARAM_STRING + 1);
         }
         /* Log INI values */
         LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);

         if(NULL != config_entry->param_set)
         {
            *(config_entry->param_set) = 1;
         }
         break;
      case 'n':
         *((int *)config_entry->param_ptr) = config_value->param_int_value;
         /* Log INI values */
         LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);

         if(NULL != config_entry->param_set)
         {
            *(config_entry->param_set) = 1;
         }
         break;
      case 'f':
         *((double *)config_entry->param_ptr) = config_value->param_double_value;
         /* Log INI values */
         LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);

         if(NULL != config_entry->param_set)
         {
            *(config_entry->param_set) = 1;
         }
         break;
      default:
         LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
      }
   }
}
/**
 * @brief Initialize the DS client service
 *
 * This function is to be called as a first step by each process that
 * needs to use data services. This call internally calls dsi_init()
 * and prepares the module for making data calls.
 * Needs to be called once for every process
 *
 * @return Operation result
 * @retval E_DS_CLIENT_SUCCESS    On success.
 * @retval E_DS_CLIENT_FAILURE... On error.
 */
static ds_client_status_enum_type ds_client_init()
{
  ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
  LOC_LOGD("%s:%d]:Enter", __func__, __LINE__);
  if(DSI_SUCCESS != dsi_init(DSI_MODE_GENERAL))
  {
    LOC_LOGE("%s:%d]:dsi_init failed", __func__, __LINE__);
    ret = E_DS_CLIENT_FAILURE_GENERAL;
  }
  LOC_LOGD("%s:%d]:Exit", __func__, __LINE__);
  return ret;
}
/* Logs parsed report */
static void log_parsed_report(const rpc_loc_parsed_position_s_type *parsed_report)
{
   rpc_loc_session_status_e_type status = parsed_report->session_status;
   LOC_LOGD("Session status: %s   Valid mask: 0x%X\n",
         loc_get_sess_status_name(status),
         (uint) parsed_report->valid_mask);
   LOC_LOGD("Latitude:  %.7f (%s)\n", parsed_report->latitude,
         log_final_interm_string(
               (parsed_report->valid_mask & RPC_LOC_POS_VALID_LATITUDE) &&
               parsed_report->session_status == RPC_LOC_SESS_STATUS_SUCCESS));
   LOC_LOGD("Longitude: %.7f\n", parsed_report->longitude);
   LOC_LOGD("Accuracy: %.7f\n", parsed_report->hor_unc_circular);
}
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
    LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
    if (mStateMachine->hasSubscribers()) {
        LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
        // I don't know how to recover from it.  I am adding this rather
        // for debugging purpose.
    }

    AgpsState* nextState = this;
    switch (event)
    {
    case RSRC_SUBSCRIBE:
    {
        // no notification until we get RSRC_GRANTED
        // but we need to add subscriber to the list
        mStateMachine->addSubscriber((Subscriber*)data);
        // request from connecivity service for NIF
        //The if condition is added so that if the data call setup fails
        //for DS State Machine, we want to retry in released state.
        //for AGps State Machine, sendRsrcRequest() will always return success
        if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {
            // move the state to PENDING
            nextState = mPendingState;
        }
    }
    break;

    case RSRC_UNSUBSCRIBE:
    {
        // the list should really be empty, nothing to remove.
        // but we might as well just tell the client it is
        // unsubscribed.  False tolerance, right?
        Subscriber* subscriber = (Subscriber*) data;
        Notification notification(subscriber, event, false);
        subscriber->notifyRsrcStatus(notification);
    }
        // break;
    case RSRC_GRANTED:
    case RSRC_RELEASED:
    case RSRC_DENIED:
    default:
        LOC_LOGW("%s: unrecognized event %d", whoami(), event);
        // no state change.
        break;
    }

    LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
             whoami(), nextState->whoami(), event);
    return nextState;
}
static int loc_api_server_proc(void *context)
{
    int length, sz;
    int result = 0;
    static int cnt = 0;
    struct ctrl_msgbuf * p_cmsgbuf;
    struct ctrl_msgbuf cmsg_resp;

    sz = sizeof(struct ctrl_msgbuf) + 256;
    p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz);

    if (!p_cmsgbuf) {
        LOC_LOGE("%s:%d] Out of memory\n", __func__, __LINE__);
        return -1;
    }

    cnt ++;
    LOC_LOGD("%s:%d] %d listening on %s...\n", __func__, __LINE__, cnt, (char *) context);
    length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz);
    if (length <= 0) {
        free(p_cmsgbuf);
        LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
        usleep(1000);
        return 0;
    }

    LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);
    switch(p_cmsgbuf->ctrl_type) {
        case GPSONE_LOC_API_IF_REQUEST:
            result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length);
            break;

        case GPSONE_LOC_API_IF_RELEASE:
            result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length);
            break;

        case GPSONE_UNBLOCK:
            LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__);
            break;

        default:
            LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n",
                __func__, __LINE__, p_cmsgbuf->ctrl_type);
            break;
    }

    free(p_cmsgbuf);
    return 0;
}
/*===========================================================================
FUNCTION    loc_eng_dmn_conn_join_thelper

    thelper - pointer to thelper instance

DESCRIPTION
   This function will wait for the thread of thelper_main to finish

DEPENDENCIES
   None

RETURN VALUE
   0: success or negative value for failure

SIDE EFFECTS
   N/A

===========================================================================*/
int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper)
{
    int result;

    LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
    result = pthread_join(thelper->thread_id, NULL);
    if (result != 0) {
        LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
    }
    LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);

    thelper_signal_destroy(thelper);

    return result;
}
Example #16
0
/*===========================================================================
FUNCTION    loc_init

DESCRIPTION
   Initialize the location engine, this include setting up global datas
   and registers location engien with loc api service.

DEPENDENCIES
   None

RETURN VALUE
   0: success

SIDE EFFECTS
   N/Ax

===========================================================================*/
static int loc_init(GpsCallbacks* callbacks)
{
    ENTRY_LOG();
    LOC_API_ADAPTER_EVENT_MASK_T event =
        LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
        LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
        LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
        LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
        LOC_API_ADAPTER_BIT_IOCTL_REPORT |
        LOC_API_ADAPTER_BIT_STATUS_REPORT |
        LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
        LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
    LocCallbacks clientCallbacks = {loc_cb, /* location_cb */
                                    callbacks->status_cb, /* status_cb */
                                    sv_cb, /* sv_status_cb */
                                    callbacks->nmea_cb, /* nmea_cb */
                                    callbacks->set_capabilities_cb, /* set_capabilities_cb */
                                    callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */
                                    callbacks->release_wakelock_cb, /* release_wakelock_cb */
                                    callbacks->create_thread_cb, /* create_thread_cb */
                                    NULL, /* location_ext_parser */
                                    NULL  /* sv_ext_parser */};
    gps_loc_cb = callbacks->location_cb;
    gps_sv_cb = callbacks->sv_status_cb;

    if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE)
    {
        gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
        gss_fd = open("/dev/gss", O_RDONLY);
        if (gss_fd < 0) {
            LOC_LOGE("GSS open failed: %s\n", strerror(errno));
            return NULL;
        }
        LOC_LOGD("GSS open success! CAPABILITIES %0x\n", gps_conf.CAPABILITIES);
    }

    int retVal = -1;
    if (loc_eng_ulp_inf == NULL)
        retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
                              NULL);
    else
        retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
                              loc_ulp_msg_sender);
    int ret_val1 = loc_eng_ulp_init(loc_afw_data, loc_eng_ulp_inf);
    LOC_LOGD("loc_eng_ulp_init returned %d\n",ret_val1);
    EXIT_LOG(%d, retVal);
    return retVal;
}
/**
 * @brief Starts a data call using the profile number provided
 *
 * The function uses parameters provided from @a ds_client_open_call_type
 * call result.
 *
 * @param[in] client_handle Client handle
 * @param[in] profile_index Profile index
 * @param[in] pdp_type      PDP type
 *
 * @return Operation result
 * @retval E_DS_CLIENT_SUCCESS    On success.
 * @retval E_DS_CLIENT_FAILURE... On error.
 */
static ds_client_status_enum_type ds_client_start_call
(
  dsClientHandleType client_handle,
  int profile_index,
  int pdp_type
)
{
    ds_client_status_enum_type ret = E_DS_CLIENT_FAILURE_GENERAL;
    dsi_call_param_value_t param_info;
    dsi_hndl_t dsi_handle;
    ds_client_session_data *ds_global_data = (ds_client_session_data *)client_handle;
    LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
    if(ds_global_data == NULL) {
        LOC_LOGE("%s:%d]: Null callback parameter\n", __func__, __LINE__);
        goto err;
    }
    dsi_handle = ds_global_data->dsi_net_handle;
    //Set profile index as call parameter
    param_info.buf_val = NULL;
    param_info.num_val = profile_index;
    dsi_set_data_call_param(dsi_handle,
                            DSI_CALL_INFO_UMTS_PROFILE_IDX,
                            &param_info);

    //Set IP Version as call parameter
    param_info.buf_val = NULL;
    param_info.num_val = pdp_type;
    dsi_set_data_call_param(dsi_handle,
                            DSI_CALL_INFO_IP_VERSION,
                            &param_info);
    LOC_LOGD("%s:%d]: Starting emergency call with profile index %d; pdp_type:%d\n",
             __func__, __LINE__, profile_index, pdp_type);
    if(dsi_start_data_call(dsi_handle) == DSI_SUCCESS) {
        LOC_LOGD("%s:%d]: Sent request to start data call\n",
                 __func__, __LINE__);
        ret = E_DS_CLIENT_SUCCESS;
    }
    else {
        LOC_LOGE("%s:%d]: Could not send req to start data call \n", __func__, __LINE__);
        ret = E_DS_CLIENT_FAILURE_GENERAL;
        goto err;
    }

err:
    LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
    return ret;

}
Example #18
0
bool GnssAPIClient::gnssStart()
{
    LOC_LOGD("%s]: ()", __FUNCTION__);
    bool retVal = true;
    locAPIStartTracking(mLocationOptions);
    return retVal;
}
/**
@brief Deregister sensor client with SLIM CORE

Function sends message to slim daemon to initiate client
de-registration with SLIM CORE

@param  z_Txn: Parameters for sensor client de-registration
*/
int SocketClientWrapper::ClientDeRegister(slim_GenericTxnStructType &z_Txn)
{
    LOC_LOGD("%s:%d] Received client deregister", __func__, __LINE__);

    SocketClientCloseReq closeRequest;
    memset(&closeRequest, 0, sizeof(closeRequest));

    closeRequest.msgHeader.msgId = eSLIM_SOCKET_CLIENT_MSG_ID_CLOSE_REQ;
    closeRequest.msgHeader.msgSize = sizeof(SocketClientCloseReq);
    closeRequest.msgPayload = z_Txn;

    // If socket_not_present or socket_not_connected, then error/warning
    if ( (SocketClientWrapper::mSocketFd < 0)
        )
    {
        LOC_LOGE("%s[%d]: socket not present/connected\n",
                        __func__, __LINE__);
        return -1;
    }

    if (write(SocketClientWrapper::mSocketFd, &closeRequest, sizeof(closeRequest)) < 0)
    {
        LOC_LOGE("%s[%d]: error writing on socket\n", __func__, __LINE__);
        return -1;
    }
    return 0;
}
Example #20
0
bool GnssAPIClient::gnssStop()
{
    LOC_LOGD("%s]: ()", __FUNCTION__);
    bool retVal = true;
    locAPIStopTracking();
    return retVal;
}
/**
@brief Constructor

Function class initialization

@param  pMsgQ: msg q data
*/
ClientListener::ClientListener(void* pMsgQ)
{
    LOC_LOGD("%s:%d]: ClientListener created. ClientListener: %p\n",
             __func__, __LINE__, this);
    mMsgQ = pMsgQ;

}
void LocApiAdapter::requestXtraData()
{
    LOC_LOGD("XTRA download request");

    loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_XTRA_DATA));
    locEngHandle.sendMsge(locEngHandle.owner, msg);
}
/*===========================================================================
FUNCTION    loc_eng_dmn_conn_glue_piperemove

DESCRIPTION
   remove a pipe

    pipe_name - pipe name path
    fd - fd for the pipe

DEPENDENCIES
   None

RETURN VALUE
   0: success

SIDE EFFECTS
   N/A

===========================================================================*/
int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd)
{
    close(fd);
    if (pipe_name) unlink(pipe_name);
    LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
    return 0;
}
/*===========================================================================
FUNCTION    ulp_msg_process_geofence_position_report

DESCRIPTION
   This function is called when libulp module receives a message from
   Geofence Adapter after a geofence breach event

DEPENDENCIES
   None

RETURN VALUE
   0: success
   -1: failure

SIDE EFFECTS
   N/A

===========================================================================*/
int ulp_msg_process_geofence_position_report (const UlpLocation* locationPtr)
{
   int ret_val = -1;
   LOC_LOGD("%s:%d]: Enter", __func__, __LINE__);
   do
   {
      if (locationPtr == NULL)
      {
         break;
      }

      ret_val = ulp_brain_process_geofence_position_report (locationPtr);
   } while (0);
   LOC_LOGD("%s:%d]: Exit", __func__, __LINE__);
   return ret_val;
}
/*===========================================================================
FUNCTION loc_udpate_conf

DESCRIPTION
   Parses the passed in buffer for configuration items, and update the table
   that is also passed in.

Reads the specified configuration file and sets defined values based on
   the passed in configuration table. This table maps strings to values to
   set along with the type of each of these values.

PARAMETERS:
   conf_data: configuration items in bufferas a string
   length: strlen(conf_data)
   config_table: table definition of strings to places to store information
   table_length: length of the configuration table

DEPENDENCIES
   N/A

RETURN VALUE
   number of the records in the table that is updated at time of return.

SIDE EFFECTS
   N/A
===========================================================================*/
int loc_update_conf(const char* conf_data, int32_t length,
                    const loc_param_s_type* config_table, uint32_t table_length)
{
    int ret = -1;

    if (conf_data && length && config_table && table_length) {
        // make a copy, so we do not tokenize the original data
        char* conf_copy = (char*)malloc(length+1);

        if (conf_copy != NULL)
        {
            memcpy(conf_copy, conf_data, length);
            // we hard NULL the end of string to be safe
            conf_copy[length] = 0;

            // start with one record off
            uint32_t num_params = table_length - 1;
            char* saveptr = NULL;
            char* input_buf = strtok_r(conf_copy, "\n", &saveptr);
            ret = 0;

            LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
            while(num_params && input_buf) {
                ret++;
                num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
                input_buf = strtok_r(NULL, "\n", &saveptr);
            }
            free(conf_copy);
        }
    }

    return ret;
}
/*===========================================================================
FUNCTION    ulp_msg_process_network_position_report

DESCRIPTION
   This function is called when libulp module receives a message regarding
   network position report.

   libulp will translate the network position report to generic GpsPosition
   and sent it to GPS HAL layer. GPS HAL layer will then send the position
   to Android location framework.

DEPENDENCIES
   None

RETURN VALUE
   0: success
   -1: failure

SIDE EFFECTS
   N/A

===========================================================================*/
int ulp_msg_process_network_position_report (const UlpNetworkPositionReport* networkPositionPtr)
{
   int ret_val = -1;
   UlpLocation ulpLocation;

   ENTRY_LOG_CALLFLOW();
   do
   {
      if (networkPositionPtr == NULL)
      {
         break;
      }

      if (ulp_data.ulp_started == false)
      {
         // Disgard position report if ulp is not started
         break;
      }

      LOC_LOGD ("%s, network position valid flag = 0x%x, lat = %f, lon = %f, hepe = %f \n",
                __func__,
                networkPositionPtr->valid_flag,
                networkPositionPtr->position.latitude,
                networkPositionPtr->position.longitude,
                networkPositionPtr->position.HEPE);

      if ((networkPositionPtr->valid_flag & ULP_NETWORK_POSITION_REPORT_HAS_POSITION) == 0)
      {
         // No position info, break
         break;
      }

      memset (&ulpLocation, 0, sizeof (UlpLocation));
      ulpLocation.gpsLocation.size = sizeof (GpsLocation);
      ulpLocation.gpsLocation.flags |= GPS_LOCATION_HAS_LAT_LONG |
                           GPS_LOCATION_HAS_ACCURACY |
                           LOCATION_HAS_SOURCE_INFO;
      ulpLocation.gpsLocation.latitude = networkPositionPtr->position.latitude;
      ulpLocation.gpsLocation.longitude = networkPositionPtr->position.longitude;
      ulpLocation.gpsLocation.accuracy  = networkPositionPtr->position.HEPE;
      ulpLocation.position_source = ULP_LOCATION_IS_FROM_HYBRID;
      ulpLocation.rawDataSize     = 0;
      ulpLocation.rawData         = NULL;

      if (networkPositionPtr->valid_flag & ULP_NETWORK_POSITION_REPORT_HAS_FIX_TIME)
      {
         ulpLocation.gpsLocation.timestamp = networkPositionPtr->fix_time;
      }

      ret_val = ulp_brain_process_gnp_position_report (&ulpLocation);

      if (ulp_data.run_provider_selection_logic == true)
      {
         ret_val = ulp_brain_select_providers ();
      }
   } while (0);

   EXIT_LOG(%d, ret_val);
   return ret_val;
}
Example #27
0
/*===========================================================================

FUNCTION loc_ni_process_user_response

DESCRIPTION
   Handles user input from the UI

RETURN VALUE
   error code (0 for successful, -1 for error)

===========================================================================*/
int loc_ni_process_user_response(GpsUserResponseType userResponse)
{
   int rc=0;
   LOC_LOGD("NI response from UI: %d", userResponse);

   rpc_loc_ni_user_resp_e_type resp;
   switch (userResponse)
   {
   case GPS_NI_RESPONSE_ACCEPT:
      resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_ACCEPT;
      break;
   case GPS_NI_RESPONSE_DENY:
      resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_DENY;
      break;
   case GPS_NI_RESPONSE_NORESP:
      resp = RPC_LOC_NI_LCS_NOTIFY_VERIFY_NORESP;
      break;
   default:
      return -1;
   }
   /* Turn of the timeout*/
   pthread_mutex_lock(&user_cb_data_mutex);
   loc_eng_ni_data.resp = resp;
   loc_eng_ni_data.user_response_received = TRUE;
   rc = pthread_cond_signal(&user_cb_arrived_cond);
   pthread_mutex_unlock(&user_cb_data_mutex);
   return 0;
}
BatchingAPIClient::BatchingAPIClient(const sp<IGnssBatchingCallback>& callback) :
    LocationAPIClientBase(),
    mGnssBatchingCbIface(callback),
    mDefaultId(42),
    mLocationCapabilitiesMask(0)
{
    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);

    LocationCallbacks locationCallbacks;
    locationCallbacks.size = sizeof(LocationCallbacks);

    locationCallbacks.trackingCb = nullptr;
    locationCallbacks.batchingCb = nullptr;
    if (mGnssBatchingCbIface != nullptr) {
        locationCallbacks.batchingCb = [this](size_t count, Location* location) {
            onBatchingCb(count, location);
        };
    }
    locationCallbacks.geofenceBreachCb = nullptr;
    locationCallbacks.geofenceStatusCb = nullptr;
    locationCallbacks.gnssLocationInfoCb = nullptr;
    locationCallbacks.gnssNiCb = nullptr;
    locationCallbacks.gnssSvCb = nullptr;
    locationCallbacks.gnssNmeaCb = nullptr;
    locationCallbacks.gnssMeasurementsCb = nullptr;

    locAPISetCallbacks(locationCallbacks);
}
Example #29
0
/*===========================================================================

FUNCTION   loc_sync_req_init

DESCRIPTION
   Initialize this module

DEPENDENCIES
   N/A

RETURN VALUE
   none

SIDE EFFECTS
   N/A

===========================================================================*/
void loc_sync_req_init()
{
   LOC_LOGV(" %s:%d]:\n", __func__, __LINE__);
   pthread_mutex_lock(&loc_sync_call_mutex);
   if(true == loc_sync_call_initialized)
   {
      LOC_LOGD("%s:%d]:already initialized\n", __func__, __LINE__);
      pthread_mutex_unlock(&loc_sync_call_mutex);
      return;
   }

   loc_sync_array.in_use = false;

   memset(loc_sync_array.slot_in_use, 0, sizeof(loc_sync_array.slot_in_use));

   int i;
   for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE; i++)
   {
      loc_sync_req_data_s_type *slot = &loc_sync_array.slots[i];

      pthread_mutex_init(&slot->sync_req_lock, NULL);
      pthread_cond_init(&slot->ind_arrived_cond, NULL);

      slot->client_handle = LOC_CLIENT_INVALID_HANDLE_VALUE;
      slot->ind_is_selected = false;       /* is ind selected? */
      slot->ind_is_waiting  = false;       /* is waiting?     */
      slot->ind_has_arrived = false;       /* callback has arrived */
      slot->recv_ind_id = 0;       /* ind to wait for   */
      slot->recv_ind_payload_ptr = NULL;
      slot->req_id =  0;   /* req id   */
   }

   loc_sync_call_initialized = true;
   pthread_mutex_unlock(&loc_sync_call_mutex);
}
Example #30
0
/*===========================================================================

FUNCTION    loc_free_slot

DESCRIPTION
   Frees a buffer slot after the synchronous API call

DEPENDENCIES
   N/A

RETURN VALUE
   None

SIDE EFFECTS
   N/A

===========================================================================*/
static void loc_free_slot(int select_id)
{
   int i;
   loc_sync_req_data_s_type *slot;

   pthread_mutex_lock(&loc_sync_call_mutex);

   LOC_LOGD("%s:%d]: freeing slot %d\n", __func__, __LINE__, select_id);

   loc_sync_array.slot_in_use[select_id] = 0;

   slot = &loc_sync_array.slots[select_id];

   slot->client_handle = LOC_CLIENT_INVALID_HANDLE_VALUE;
   slot->ind_is_selected = false;       /* is ind selected? */
   slot->ind_is_waiting  = false;       /* is waiting?     */
   slot->ind_has_arrived = false;       /* callback has arrived */
   slot->recv_ind_id = 0;       /* ind to wait for   */
   slot->recv_ind_payload_ptr = NULL;
   slot->req_id =  0;

   // check if all slots are now free
   for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE; i++)
   {
      if (loc_sync_array.slot_in_use[i]) break;
   }

   if (i >= LOC_SYNC_REQ_BUFFER_SIZE)
   {
      loc_sync_array.in_use = false;
   }

   pthread_mutex_unlock(&loc_sync_call_mutex);
}