QMI(Qualcomm Message Interface) 高通用来替代OneRPC/DM的协议,用来与modem通信。
本文是摸索高通QMI机制一点经验,重点解读了如果建立拨号连接,仅供参考。qmi详细使用参考:高通QMI协议

1. QMI协议常用组件

  • DMS(设备管理Device Management)
    提供查询设备信息功能
    参考: qmi/device_management_service_v01.h
  • NAS(网络访问Network Access)
    提供网络管理功能
    参考:qmi/network_access_service_v01.h
  • WDS(数据连接)
    参考:qmi/wireless_data_service_v01.h
  • UIM(管理User Identity Module)
    提供查询UIM卡信息
    参考:qmi/user_identity_module_v01.h
  • CTL(控制服务)
    用户发起其他服务请求前,必须先申请 ClientID, 这个ID就是由控制服务分配的, 这个服务永远在线
    参考:qmi/control_service_v01.h
  • 数据(拨号服务)
    建立数据连接
    参考:data/qualcomm_mobile_access_point_msgr_v01.h

每个服务模块都定义了 请求响应通知Indication, 请求分为同步和异步,其中异步请求的结果通过indication通知。

2. QMI举例

越来越多9X07模块被用于物联网,那么首要解决的问题即建立数据连接,所以本文使用QMI建立数据网络连接示意。

2.1 QMI初始化及释放

9X07模块提供了qcmap_msgr服务来进行拨号,通过与dsi_netctrl对比,qcmap_msgr接口更清晰,而且操作也简单。
AP侧使用QMI架构和modem通信初始化流程是固定的:

qcmap_msgr_get_service_object_v01查询服务对象 =>
qmi_client_notifier_init初始化client通知信息 =>
qmi_client_get_service_list查询支持的服务列表个数 =>
qmi_client_get_service_list查询支持的服务列表信息 =>
qmi_client_init使用其中一个服务信息初始化client
参考代码:

 void qcmap_ppp_init(qcmap_ppp_t *self,client_status_ind_t client_cb_ind) {
qmi_idl_service_object_type qcmap_msgr_qmi_idl_service_object;
uint32_t num_services = , num_entries = ;
qmi_service_info info[];
qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR; assert(self); self->qcmap_msgr_enable = FALSE;
self->qmi_qcmap_msgr_handle = ;
self->mobile_ap_handle = ; qcmap_msgr_qmi_idl_service_object = qcmap_msgr_get_service_object_v01;//when faild, add your trick for this~ if (qcmap_msgr_qmi_idl_service_object == NULL)
{
LOG("qcmap_msgr service object not available");
return;
} qmi_error = qmi_client_notifier_init(qcmap_msgr_qmi_idl_service_object,
&self->qmi_qcmap_msgr_os_params,
&self->qmi_qcmap_msgr_notifier);
if (qmi_error < )
{
LOG("qmi_client_notifier_init(qcmap_msgr) returned %d", qmi_error);
return;
} /* Check if the service is up, if not wait on a signal */
while()
{
qmi_error = qmi_client_get_service_list(qcmap_msgr_qmi_idl_service_object,
NULL,
NULL,
&num_services);
LOG("qmi_client_get_service_list: %d",qmi_error); if(qmi_error == QMI_NO_ERR)
break;
/* wait for server to come up */
QMI_CCI_OS_SIGNAL_WAIT(&self->qmi_qcmap_msgr_os_params, );
} num_entries = num_services; LOG("qmi_client_get_service_list: num_e %d num_s %d", num_entries, num_services);
/* The server has come up, store the information in info variable */
qmi_error = qmi_client_get_service_list(qcmap_msgr_qmi_idl_service_object,
info,
&num_entries,
&num_services); LOG("qmi_client_get_service_list: num_e %d num_s %d error %d", num_entries, num_services, qmi_error); if (qmi_error != QMI_NO_ERR)
{
qmi_client_release(self->qmi_qcmap_msgr_notifier);
self->qmi_qcmap_msgr_notifier = NULL;
LOG("Can not get qcmap_msgr service list %d",
qmi_error);
return;
} qmi_error = qmi_client_init(&info[],
qcmap_msgr_qmi_idl_service_object,
client_cb_ind,
NULL,
NULL,
&self->qmi_qcmap_msgr_handle); LOG("qmi_client_init: %d", qmi_error); if (qmi_error != QMI_NO_ERR)
{
qmi_client_release(self->qmi_qcmap_msgr_notifier);
self->qmi_qcmap_msgr_notifier = NULL;
LOG("Can not init qcmap_msgr client %d", qmi_error);
return;
}
}

对应释放过程比较简单,主要是释放client初始化信息:

 static void qcmap_ppp_uninit(qcmap_ppp_t *self) {
qmi_client_error_type qmi_error;
assert(self); qmi_error = qmi_client_release(self->qmi_qcmap_msgr_notifier);
self->qmi_qcmap_msgr_notifier = NULL; if (qmi_error != QMI_NO_ERR)
{
LOG("Can not release client qcmap notifier %d",qmi_error);
} qmi_error = qmi_client_release(self->qmi_qcmap_msgr_handle);
self->qmi_qcmap_msgr_handle = NULL; if (qmi_error != QMI_NO_ERR)
{
LOG("Can not release client qcmap handle %d",qmi_error);
}
}
2.2 建立/关闭拨号连接

建立拨号步骤:使能AP,连接服务

  • 使能ap
 /* Enable MobileAP */
static boolean qcmap_ppp_enable(qcmap_ppp_t *self) {
qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR;
qcmap_msgr_mobile_ap_enable_resp_msg_v01 qcmap_enable_resp_msg_v01;
qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01 qcmap_mobile_ap_status_ind_reg;
qcmap_msgr_wwan_status_ind_register_req_msg_v01 wwan_status_ind_reg;
qcmap_msgr_station_mode_status_ind_register_req_msg_v01 qcmap_station_mode_status_ind_reg;
qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01 qcmap_mobile_ap_status_ind_rsp;
qcmap_msgr_wwan_status_ind_register_resp_msg_v01 wwan_status_ind_rsp;
qcmap_msgr_station_mode_status_ind_register_resp_msg_v01 qcmap_station_mode_status_ind_rsp; memset(&qcmap_enable_resp_msg_v01, , sizeof(qcmap_msgr_mobile_ap_enable_resp_msg_v01));
memset(&wwan_status_ind_reg, , sizeof(qcmap_msgr_wwan_status_ind_register_req_msg_v01));
memset(&wwan_status_ind_rsp, , sizeof(qcmap_msgr_wwan_status_ind_register_resp_msg_v01));
wwan_status_ind_reg.register_indication = ; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_WWAN_STATUS_IND_REG_REQ_V01,
(void*)&wwan_status_ind_reg,
sizeof(qcmap_msgr_wwan_status_ind_register_req_msg_v01),
(void*)&wwan_status_ind_rsp,
sizeof(qcmap_msgr_wwan_status_ind_register_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); LOG("qmi_client_send_msg_sync: error %d result %d",
qmi_error, wwan_status_ind_rsp.resp.result); if (( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( wwan_status_ind_rsp.resp.result != QMI_NO_ERR ))
{
LOG("Can not register for wwan status %d : %d",
qmi_error, wwan_status_ind_rsp.resp.error);
return FALSE;
}
LOG("Registered for wwan status"); memset(&qcmap_mobile_ap_status_ind_reg, , sizeof(qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01));
memset(&qcmap_mobile_ap_status_ind_rsp, , sizeof(qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01));
qcmap_mobile_ap_status_ind_reg.register_indication = ; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_MOBILE_AP_STATUS_IND_REG_REQ_V01,
(void*)&qcmap_mobile_ap_status_ind_reg,
sizeof(qcmap_msgr_mobile_ap_status_ind_register_req_msg_v01),
(void*)&qcmap_mobile_ap_status_ind_rsp,
sizeof(qcmap_msgr_mobile_ap_status_ind_register_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); LOG("qmi_client_send_msg_sync: error %d result %d",
qmi_error, qcmap_mobile_ap_status_ind_rsp.resp.result);
if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( qcmap_mobile_ap_status_ind_rsp.resp.result != QMI_NO_ERR ))
{
LOG("Can not register for mobile ap status %d : %d",
qmi_error, qcmap_mobile_ap_status_ind_rsp.resp.error);
return FALSE;
}
LOG("Registered for mobile ap status"); memset(&qcmap_station_mode_status_ind_reg, , sizeof(qcmap_msgr_station_mode_status_ind_register_req_msg_v01));
memset(&qcmap_station_mode_status_ind_rsp, , sizeof(qcmap_msgr_station_mode_status_ind_register_resp_msg_v01));
qcmap_station_mode_status_ind_reg.register_indication = ; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_STATION_MODE_STATUS_IND_REG_REQ_V01,
(void*)&qcmap_station_mode_status_ind_reg,
sizeof(qcmap_msgr_station_mode_status_ind_register_req_msg_v01),
(void*)&qcmap_station_mode_status_ind_rsp,
sizeof(qcmap_msgr_station_mode_status_ind_register_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); LOG("qmi_client_send_msg_sync: error %d result %d",
qmi_error, qcmap_station_mode_status_ind_rsp.resp.result);
if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( qcmap_station_mode_status_ind_rsp.resp.result != QMI_NO_ERR ))
{
LOG("Can not register for station mode indications %d : %d",
qmi_error, qcmap_station_mode_status_ind_rsp.resp.error);
return FALSE;
}
LOG("Registered for station mode status"); qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_MOBILE_AP_ENABLE_REQ_V01,
NULL,
,
(void*)&qcmap_enable_resp_msg_v01,
sizeof(qcmap_msgr_mobile_ap_enable_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE);
LOG("qmi_client_send_msg_sync: error %d result %d valid %d",
qmi_error, qcmap_enable_resp_msg_v01.resp.result, qcmap_enable_resp_msg_v01.mobile_ap_handle_valid);
if (( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( qcmap_enable_resp_msg_v01.resp.result != QMI_NO_ERR) ||
( qcmap_enable_resp_msg_v01.mobile_ap_handle_valid != TRUE ))
{
LOG("Can not enable qcmap %d : %d",
qmi_error, qcmap_enable_resp_msg_v01.resp.error);
return FALSE;
} if( qcmap_enable_resp_msg_v01.mobile_ap_handle > )
{
self->mobile_ap_handle = qcmap_enable_resp_msg_v01.mobile_ap_handle;
self->qcmap_msgr_enable = TRUE;
LOG("QCMAP Enabled\n");
return TRUE;
}
else
{
LOG("QCMAP Enable Failure\n");
} return FALSE;
}
  • 去使能
/* Disable MobileAP */
static boolean qcmap_ppp_disable(qcmap_ppp_t *self) {
qcmap_msgr_mobile_ap_disable_req_msg_v01 qcmap_disable_req_msg_v01;
qcmap_msgr_mobile_ap_disable_resp_msg_v01 qcmap_disable_resp_msg_v01;
qmi_client_error_type qmi_error = QMI_NO_ERR; if (!self->qcmap_msgr_enable)
{
/* QCMAP is not enabled */
LOG("QCMAP not enabled\n");
return FALSE;
} qcmap_disable_req_msg_v01.mobile_ap_handle = self->mobile_ap_handle;
qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_MOBILE_AP_DISABLE_REQ_V01,
&qcmap_disable_req_msg_v01,
sizeof(qcmap_msgr_mobile_ap_disable_req_msg_v01),
&qcmap_disable_resp_msg_v01,
sizeof(qcmap_msgr_mobile_ap_disable_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( (qcmap_disable_resp_msg_v01.resp.error != QMI_ERR_NO_EFFECT_V01 &&
qcmap_disable_resp_msg_v01.resp.error != QMI_ERR_NONE_V01)) ||
( qcmap_disable_resp_msg_v01.resp.result != QMI_NO_ERR ))
{
LOG( "Can not disable qcmap %d : %d",
qmi_error, qcmap_disable_resp_msg_v01.resp.error);
return FALSE;
} /*.If backhaul is not connected, Mobileap will be disabled instantly. And since
call back function is being called much before the response pending flag is set to TRUE,
responses are not sent to the client.
Hence, we set qcmap_disable_resp_msg_v01.resp.error to QMI_ERR_NO_EFFECT_V01
So that the caller of this function sends a response back to the client. (Used for IoE 9x25)
*/
if (qcmap_disable_resp_msg_v01.resp.error == QMI_ERR_NO_EFFECT_V01)
LOG( "Already disable qcmap %d", qcmap_disable_resp_msg_v01.resp.error); self->mobile_ap_handle = ;
self->qcmap_msgr_enable = FALSE;
return TRUE;
}
  • 连接服务
/* ConnectBackHaul */
static boolean qcmap_ppp_connect(qcmap_ppp_t *self) {
int qcmap_msgr_errno;
int ret = ;
qcmap_msgr_wwan_call_type_v01 call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01; qcmap_msgr_bring_up_wwan_req_msg_v01 qcmap_bring_up_wwan_req_msg;
qcmap_msgr_bring_up_wwan_resp_msg_v01 qcmap_bring_up_wwan_resp_msg;
qmi_client_error_type qmi_error; /* Bring up the data call. */
LOG("Bring up wwan");
qcmap_bring_up_wwan_req_msg.mobile_ap_handle = self->mobile_ap_handle;
qcmap_bring_up_wwan_req_msg.call_type_valid = TRUE; qcmap_bring_up_wwan_req_msg.call_type = call_type; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_BRING_UP_WWAN_REQ_V01,
&qcmap_bring_up_wwan_req_msg,
sizeof(qcmap_msgr_bring_up_wwan_req_msg_v01),
&qcmap_bring_up_wwan_resp_msg,
sizeof(qcmap_msgr_bring_up_wwan_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( qcmap_bring_up_wwan_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not bring up wwan qcmap %d : %d",
qmi_error, qcmap_bring_up_wwan_resp_msg.resp.error);
return FALSE;
}
  /*
If WWAN is already enabled, and we are trying to enable again from a different client,
set error number to QMI_ERR_NO_EFFECT_V01, so that the correspondingclient can be
informed. We hit this scenario in the following case:
1. Start QCMAP_CLI and enable Backhaul.
2. Start MCM_MOBILEAP_CLI and try enabling backhaul again.
*/
if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01 &&
qcmap_bring_up_wwan_resp_msg.conn_status ==
QCMAP_MSGR_WWAN_STATUS_CONNECTED_V01)
{
LOG("WWAN is already enabled.");
}
else if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01 &&
qcmap_bring_up_wwan_resp_msg.conn_status ==
QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTED_V01)
{
LOG("IPv6 WWAN is already enabled.");
}
else
LOG("Bringing up wwan...");
return TRUE;
}
 
  • 断开服务
 /* DisconnectBackHual */
static boolean qcmap_ppp_disconnect(qcmap_ppp_t *self) {
qcmap_msgr_wwan_call_type_v01 call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01; qcmap_msgr_tear_down_wwan_req_msg_v01 qcmap_tear_down_wwan_req_msg;
qcmap_msgr_tear_down_wwan_resp_msg_v01 qcmap_tear_down_wwan_resp_msg;
qmi_client_error_type qmi_error; LOG("Bringing down wwan");
qcmap_tear_down_wwan_req_msg.mobile_ap_handle = self->mobile_ap_handle; qcmap_tear_down_wwan_req_msg.call_type_valid = TRUE; qcmap_tear_down_wwan_req_msg.call_type = call_type; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_TEAR_DOWN_WWAN_REQ_V01,
&qcmap_tear_down_wwan_req_msg,
sizeof(qcmap_msgr_tear_down_wwan_req_msg_v01),
&qcmap_tear_down_wwan_resp_msg,
sizeof(qcmap_msgr_tear_down_wwan_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR) ||
( qcmap_tear_down_wwan_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not tear down wwan qcmap %d : %d",
qmi_error, qcmap_tear_down_wwan_resp_msg.resp.error);
return FALSE;
} /*
If WWAN is already disabled, and we are trying to disable again from a different client,
set error number to QMI_ERR_NO_EFFECT_V01, so that the correspondingclient can be
informed. We hit this scenario in the following case:
1. Start QCMAP_CLI and enable Backhaul.
2. Start MCM_MOBILEAP_CLI and try enabling backhaul again.
3. Disable backhaul from the 1st client.
4. Now from the 2nd client.
*/
if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01 &&
qcmap_tear_down_wwan_resp_msg.conn_status ==
QCMAP_MSGR_WWAN_STATUS_DISCONNECTED_V01)
{
LOG("WWAN is already disabled.");
}
else if (call_type == QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01 &&
qcmap_tear_down_wwan_resp_msg.conn_status ==
QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTED_V01)
{
LOG("IPv6 WWAN is already disabled.");
}
else
LOG("Tearing down wwan...");
return TRUE;
} /* Get WWAN Statistics. */
static boolean qcmap_ppp_get_statistics(qcmap_ppp_t *self, qcmap_msgr_ip_family_enum_v01 ip_family, qcmap_msgr_wwan_statistics_type_v01 *wwan_stats) {
qcmap_msgr_get_wwan_stats_req_msg_v01 get_wwan_stats_req_msg;
qcmap_msgr_get_wwan_stats_resp_msg_v01 get_wwan_stats_resp_msg;
qmi_client_error_type qmi_error; get_wwan_stats_req_msg.mobile_ap_handle = self->mobile_ap_handle;
get_wwan_stats_req_msg.ip_family = ip_family; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_GET_WWAN_STATS_REQ_V01,
&get_wwan_stats_req_msg,
sizeof(qcmap_msgr_get_wwan_stats_req_msg_v01),
&get_wwan_stats_resp_msg,
sizeof(qcmap_msgr_get_wwan_stats_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( get_wwan_stats_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not get wwan stats %d : %d",
qmi_error, get_wwan_stats_resp_msg.resp.error);
return FALSE;
} wwan_stats->bytes_rx = get_wwan_stats_resp_msg.wwan_stats.bytes_rx;
wwan_stats->bytes_tx = get_wwan_stats_resp_msg.wwan_stats.bytes_tx;
wwan_stats->pkts_rx = get_wwan_stats_resp_msg.wwan_stats.pkts_rx;
wwan_stats->pkts_tx = get_wwan_stats_resp_msg.wwan_stats.pkts_tx;
wwan_stats->pkts_dropped_rx = get_wwan_stats_resp_msg.wwan_stats.pkts_dropped_rx;
wwan_stats->pkts_dropped_tx = get_wwan_stats_resp_msg.wwan_stats.pkts_dropped_tx;
LOG("Get WWAN Stats succeeded...");
return TRUE;
} /* Reset WWAN Statistics. */
static boolean qcmap_ppp_reset_statistics(qcmap_ppp_t *self, qcmap_msgr_ip_family_enum_v01 ip_family) {
qcmap_msgr_reset_wwan_stats_req_msg_v01 reset_wwan_stats_req_msg;
qcmap_msgr_reset_wwan_stats_resp_msg_v01 reset_wwan_stats_resp_msg;
qmi_client_error_type qmi_error; reset_wwan_stats_req_msg.mobile_ap_handle = self->mobile_ap_handle;
reset_wwan_stats_req_msg.ip_family = ip_family; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_RESET_WWAN_STATS_REQ_V01,
&reset_wwan_stats_req_msg,
sizeof(qcmap_msgr_reset_wwan_stats_req_msg_v01),
&reset_wwan_stats_resp_msg,
sizeof(qcmap_msgr_reset_wwan_stats_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( reset_wwan_stats_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not reset wwan stats %d : %d",
qmi_error, reset_wwan_stats_resp_msg.resp.error);
return FALSE;
} LOG("Reset WWAN Stats succeeded...");
return TRUE;
} /* Enable/Disable Autoconnect mode */
static boolean qcmap_ppp_set_auto_connect(qcmap_ppp_t *self, boolean enable) {
qcmap_msgr_set_auto_connect_req_msg_v01 set_auto_connect_req_msg;
qcmap_msgr_set_auto_connect_resp_msg_v01 set_auto_connect_resp_msg;
qmi_client_error_type qmi_error; set_auto_connect_req_msg.mobile_ap_handle = self->mobile_ap_handle;
set_auto_connect_req_msg.enable = enable; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_SET_AUTO_CONNECT_REQ_V01,
&set_auto_connect_req_msg,
sizeof(qcmap_msgr_set_auto_connect_req_msg_v01),
&set_auto_connect_resp_msg,
sizeof(qcmap_msgr_set_auto_connect_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE);
if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( set_auto_connect_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not set auto connect flag %d : %d",
qmi_error, set_auto_connect_resp_msg.resp.error);
return FALSE;
} LOG("Auto Connect Mode Set succeeded...");
return TRUE;
}

至此,就可以完成拨号的连接和断开。

2.3 PPP状态

如果关注状态通知,需要处理知函数client_cb_ind中状态通知。主要包含了建立拨号成功/失败,网络状态变化(切换网络模式)的断开通知等。

 static void qcmap_ppp_ind(
qmi_client_type user_handle,
unsigned int msg_id,
void *ind_buf,
unsigned int ind_buf_len,
void *ind_cb_data )
{
qmi_client_error_type qmi_error;
LOG("qcmap_msgr_qmi_qcmap_ind: user_handle %X msg_id %d ind_buf_len %d.", user_handle, msg_id, ind_buf_len);
}
2.4 建立连接可选项
  • 禁用ipv6
 static boolean qcmap_ppp_disable_ipv6(qcmap_ppp_t *self) {
int qcmap_msgr_errno;
int ret = ;
qcmap_msgr_disable_ipv6_req_msg_v01 qcmap_disable_ipv6_req_msg;
qcmap_msgr_disable_ipv6_resp_msg_v01 qcmap_disable_ipv6_resp_msg;
qmi_client_error_type qmi_error; /* Enable IPV6. */
LOG("Disable IPV6");
qcmap_disable_ipv6_req_msg.mobile_ap_handle = self->mobile_ap_handle; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_DISABLE_IPV6_REQ_V01,
&qcmap_disable_ipv6_req_msg,
sizeof(qcmap_msgr_disable_ipv6_req_msg_v01),
&qcmap_disable_ipv6_resp_msg,
sizeof(qcmap_msgr_disable_ipv6_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( qcmap_disable_ipv6_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not disable ipv6 %d : %d",
qmi_error, qcmap_disable_ipv6_resp_msg.resp.error);
return FALSE;
} LOG("Disabled IPV6...");
return TRUE;
}
  • 配置自动连接(没测试出效果)
 /* Enable/Disable Autoconnect mode */
static boolean qcmap_ppp_set_auto_connect(qcmap_ppp_t *self, boolean enable) {
qcmap_msgr_set_auto_connect_req_msg_v01 set_auto_connect_req_msg;
qcmap_msgr_set_auto_connect_resp_msg_v01 set_auto_connect_resp_msg;
qmi_client_error_type qmi_error; set_auto_connect_req_msg.mobile_ap_handle = self->mobile_ap_handle;
set_auto_connect_req_msg.enable = enable; qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_SET_AUTO_CONNECT_REQ_V01,
&set_auto_connect_req_msg,
sizeof(qcmap_msgr_set_auto_connect_req_msg_v01),
&set_auto_connect_resp_msg,
sizeof(qcmap_msgr_set_auto_connect_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE);
if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( set_auto_connect_resp_msg.resp.result != QMI_NO_ERR ) )
{
LOG("Can not set auto connect flag %d : %d",
qmi_error, set_auto_connect_resp_msg.resp.error);
return FALSE;
} LOG("Auto Connect Mode Set succeeded...");
return TRUE;
}
  • 查询wwan统计信息(流量)
 /* Get WWAN Status */
static boolean qcmap_ppp_get_status(qcmap_ppp_t *self, qcmap_msgr_wwan_status_enum_v01 *v4_status, qcmap_msgr_wwan_status_enum_v01 *v6_status) {
qmi_client_error_type qmi_error, qmi_err_code = QMI_NO_ERR;
qcmap_msgr_wwan_status_req_msg_v01 wan_status_req;
qcmap_msgr_wwan_status_resp_msg_v01 wan_status_resp; memset(&wan_status_resp, , sizeof(qcmap_msgr_wwan_status_resp_msg_v01));
wan_status_req.mobile_ap_handle = self->mobile_ap_handle;
wan_status_req.call_type_valid = ;
wan_status_req.call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V4_V01;
qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_WWAN_STATUS_REQ_V01,
&wan_status_req,
sizeof(qcmap_msgr_wwan_status_req_msg_v01),
(void*)&wan_status_resp,
sizeof(qcmap_msgr_wwan_status_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); LOG("qmi_client_send_msg_sync(enable): error %d result %d",
qmi_error, wan_status_resp.resp.result); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( wan_status_resp.resp.result != QMI_NO_ERR ) )
{
LOG("Can not get IPV4 WAN status %d : %d",
qmi_error, wan_status_resp.resp.error);
return FALSE;
}
if(wan_status_resp.conn_status_valid ==)
{
*v4_status=wan_status_resp.conn_status;
if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_CONNECTING_V01)
{
LOG(" IPV4 WWAN is Connecting \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_CONNECTED_V01)
{
LOG(" IPV4 WWAN is connected \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_DISCONNECTING_V01)
{
LOG(" IPV4 WWAN is Disconnecting \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_DISCONNECTED_V01)
{
LOG(" IPV4 WWAN is Disconnected \n");
}
} #ifdef ENABLE_IPV6
memset(&wan_status_resp, , sizeof(qcmap_msgr_wwan_status_resp_msg_v01));
wan_status_req.mobile_ap_handle = self->mobile_ap_handle;
wan_status_req.call_type_valid = ;
wan_status_req.call_type = QCMAP_MSGR_WWAN_CALL_TYPE_V6_V01;
qmi_error = qmi_client_send_msg_sync(self->qmi_qcmap_msgr_handle,
QMI_QCMAP_MSGR_WWAN_STATUS_REQ_V01,
&wan_status_req,
sizeof(qcmap_msgr_wwan_status_req_msg_v01),
(void*)&wan_status_resp,
sizeof(qcmap_msgr_wwan_status_resp_msg_v01),
QCMAP_MSGR_QMI_TIMEOUT_VALUE); LOG("qmi_client_send_msg_sync(enable): error %d result %d",
qmi_error, wan_status_resp.resp.result); if ( ( qmi_error == QMI_TIMEOUT_ERR ) ||
( qmi_error != QMI_NO_ERR ) ||
( wan_status_resp.resp.result != QMI_NO_ERR ) )
{
LOG("Can not get IPV6 WAN status %d : %d",
qmi_error, wan_status_resp.resp.error);
return FALSE;
}
if(wan_status_resp.conn_status_valid == )
{
*v6_status=wan_status_resp.conn_status;
if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTING_V01)
{
LOG(" IPV6 WWAN is Connecting \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_CONNECTED_V01)
{
LOG(" IPV6 WWAN is connected \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTING_V01)
{
LOG(" IPV6 WWAN is Disconnecting \n");
}
else if(wan_status_resp.conn_status == QCMAP_MSGR_WWAN_STATUS_IPV6_DISCONNECTED_V01)
{
LOG(" IPV6 WWAN is Disconnected \n");
}
}
#endif return TRUE;
}

综上,基本用到的就这些接口了,比起直接使用高通提供的QCMAP_Client类接口,本文实现更原生、灵活,经过验证可以在国内多家9X07模块上正确稳定的执行。

3 其他组件服务功能

请自行研究实现,不做赘述了。

作者:LittleFat
链接:https://www.jianshu.com/p/82a8177b8299
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

高通9X07模块QMI架构使用入门的更多相关文章

  1. 高通Android display架构分析

    目录(?)[-] Kernel Space Display架构介绍 函数和数据结构介绍 函数和数据结构介绍 函数和数据结构介绍 数据流分析 初始化过程分析 User Space display接口 K ...

  2. linux驱动由浅入深系列:高通sensor架构实例分析之二(驱动代码结构)【转】

    本文转载自:https://blog.csdn.net/radianceblau/article/details/73498303 本系列导航: linux驱动由浅入深系列:高通sensor架构实例分 ...

  3. 【转】高通平台android 环境配置编译及开发经验总结

    原文网址:http://blog.csdn.net/dongwuming/article/details/12784535 1.高通平台android开发总结 1.1 搭建高通平台环境开发环境 在高通 ...

  4. 高通Android display分析【转】

    本文转载自:http://blog.csdn.net/zhangchiytu/article/details/6777039 高通7系列硬件架构分析 如上图,高通7系列 Display的硬件部分主要由 ...

  5. 手机低端市场,联发科 vs 高通

    联发科(MTK) 是山寨机的源头,我过去曾经鄙视他,现在来了180度转弯. 其实联发科是台湾的上市公司,手机如此复杂的东西,当年 联发科能把基础的手机做出来,而后小山寨厂改改外形,配件就能出若干款手机 ...

  6. 高通camera基本代码架构【转】

    本文转载自:http://blog.sina.com.cn/s/blog_c0de2be70102vyn1.html 1  camera基本代码架构 高通平台对于camera的代码组织,大体上还是遵循 ...

  7. 2017最新技术java高级架构、千万高并发、分布式集群、架构师入门到精通视频教程

    * { font-family: "Microsoft YaHei" !important } h1 { color: #FF0 } 15套java架构师.集群.高可用.高可扩展. ...

  8. 架构师入门:搭建双注册中心的高可用Eureka架构(基于项目实战)

    本文的案例是基于 架构师入门:搭建基本的Eureka架构(从项目里抽取) 改写的. 在上文里,我们演示Eureka客户端调用服务的整个流程,在这部分里我们将在架构上有所改进.大家可以想象下,在上文里案 ...

  9. 高通平台MSM8916LCM模块移植(一)-bootloader部分

    此次移植打算分成两个模块来说,bootloader部分和kernel部分.在实际的移植调试过程中也是这么分成了两个部分分别调试. 高通平台中的bootloader叫做LK(Little Kernel, ...

随机推荐

  1. 05C++引用

    1.变量名 变量名实质上是一段连续存储空间的别名,是一个标号(门牌号): 通过变量来申请并命名内存空间: 通过变量的名字可以使用内存空间. 2.引用的概念 变量名,本身是一段内存的引用,即别名(ali ...

  2. java BIO/NIO

    一.BIO Blocking IO(即阻塞IO); 1.      特点: a)   Socket服务端在监听过程中每次accept到一个客户端的Socket连接,就要处理这个请求,而此时其他连接过来 ...

  3. centos7数据库连接使用127.0.0.1报permission denied,使用localhost报No such file or directory

    安装lamp环境后,测试数据库连接. 当host使用127.0.0.1时,报错:(HY000/2002): Permission denied. 把host换成localhost后,又报错:SQLST ...

  4. CoreException: Could not get the value for parameter compilerId for plugin execution default-compile Maven项目pom文件报错,插件引用不到

    CoreException: Could not get the value for parameter compilerId for plugin execution default-compile ...

  5. 串口转以太客户端(增加uci、可连接多个服务器)

    1. 进入barrier_breaker/package/utils文件夹,新建ttl_client 2. 该目录下的Makefile # # Copyright (C) OpenWrt.org # ...

  6. 协程实现多并发socket,跟NGINX一样

    server: #!/usr/bin/env python # -*- coding: utf-8 -*- # author aliex-hrg import gevent from gevent i ...

  7. selenium phantomjs 设置代理ip方法

    最近遇到phantomjs动态更换ip的功能,在知乎上看到一篇不错的文章,顺手记下来以备后用 phantomjs selenium 如何动态修改代理? 可以这样做(Python代码): # 不使用代理 ...

  8. JDBC相关概念介绍

    一.JDBC相关概念介绍 1.1.数据库驱动 这里的驱动的概念和平时听到的那种驱动的概念是一样的,比如平时购买的声卡,网卡直接插到计算机上面是不能用的,必须要安装相应的驱动程序之后才能够使用声卡和网卡 ...

  9. windows服务命令 转载

    OnCustomCommand executes when the Service Control Manager (SCM) passes a custom command to the servi ...

  10. NGINX 资料

    查看资料详情     nginx