高通AP侧新增AT命令流程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a5103330/article/details/78467211

AP侧新增AT命令

以新增命令“+TEST”为例。

 

1. 在Modem侧添加自定义的AT Command的注册。在*modem_proc/datamodem/interface/atcop/src/dsatclient_ex.c下的LOCAL byteallowed_list[][MAX_CMD_SIZE]数组中添加定义:

 

  LOCAL byte allowed_list[][MAX_CMD_SIZE]={......,"+TEST",........,""};

 

2.在*modem_proc/datamodem/interface/atcop/src/dsatcmdp.c的dsat_result_enum_type dsatcmdp_process_cmd_forwarding ( void ){ 中新增判断条件

if ((......

         && ( 0 !=  dsatutil_strcmp_ig_sp_case( (const byte*)token_ptr->token.name,

                                                        (const byte *)"+TEST") )

......

)){

 

3.在Vendor下添加AT Command的注册。在*/vendor/qcom/proprietary/data/ATFWD-daemon/atfwd_daemon.c下的qmi_atcop_at_cmd_fwd_req_type atCmdFwdReqType[]数组中添加定义

 

    { //AT command fwd type

        1, // Number of commands

        {

            { QMI_ATCOP_AT_CMD_NOT_ABORTABLE,"+TEST"},

        }

    },

 

4.在\vendor\qcom\proprietary\telephony-apps\ATFwd\src\com\qualcomm\atfwd下新增

AtTestCmdHandler.java文件,可以复制其他已有的Java文件,修改内容,如:

 

packagecom.qualcomm.atfwd;

importandroid.content.Context;

//importcom.qualcomm.qcrilhook.QcRilHook;

importandroid.util.Log;

publicclass AtTestCmdHandler extends AtCmdBaseHandler {

         private static final String LOG_TAG ="AtTestCmdHandler";

         //QcRilHook qrh = null;

         public AtTestCmdHandler(Context c)throws AtCmdHandlerInstantiationException{

              super(c);

         }

         @Override

         public String getCommandName(){

                return "+TEST";

         }

        @Override

         public AtCmdResponse handleCommand(AtCmdcmd) {

                   String result = null;//需要最后显示的结果

                   String atTest= null;

                   boolean isAtCmdRespOK =false;

                   switch (cmd.getOpcode()) {

                       case AtCmd.ATCMD_OPCODE_NA_QU:

                            Log.i(LOG_TAG,"ATCOMMAND_TEST");

                            result  = "+TEST:" + "at_command";

                            isAtCmdRespOK =true;

                            break;

                       default:

                            Log.d(LOG_TAG,"atTest OpCode Error");

                            result =cmd.getAtCmdErrStr(AtCmd.AT_ERR_OP_NOT_SUPP);

                            break;

                   }

                   return  isAtCmdRespOK ? newAtCmdResponse(AtCmdResponse.RESULT_OK, result) :

                   new AtCmdResponse(AtCmdResponse.RESULT_ERROR,result);

         }

}

 

5.在\vendor\qcom\proprietary\telephony-apps\ATFwd\src\com\qualcomm\atfwd

\AtCmdFwdService.java中把新增的AtTestCmdHandler.java文件加到HashMap集合中:

 

publicAtCmdFwdService(Context c)

    {

        mContext = c;

        mCmdHandlers = new HashMap<String,AtCmdHandler>();

 

        AtCmdHandler cmd;

       ......

        try {

            cmd = newAtTestCmdHandler(c);

           mCmdHandlers.put(cmd.getCommandName().toUpperCase(), cmd);

        } catch (AtCmdHandlerInstantiationExceptione) {

            Log.e(LOG_TAG, "Unable toinstantiate command", e);

        }

       ......

}

这样,一条新的AT命令添加完成。

超级终端输入验证

 

展开阅读全文

没有更多推荐了,返回首页