Add AT command process in Android

Source: Internet
Author: User

 

This article assumes that the reader has already understood the basic knowledge of RIL.
Starting from the upper layer
In frameworks/base/telephony/Java/COM/Android/Internal/telephony/phone. Java
Add the upper-layer function of the at command.
Phone is an interface. Therefore, after adding the phone interface, you must implement this method in the Java class that implements the phone interface.
Located in
Frameworks/base/telephony/Java/COM/Android/Internal/telephony/GSM/gsmphone. Java
Call the methods in the commandinterface. Therefore, we have to add the methods we want to add to the commandinterface.
Similarly, commandinterface is an interface, and the class implementing this interface has two:
1. Frameworks/base/telephony/Java/COM/Android/Internal/telephony/GSM/RIL. Java
2. Frameworks/base/telephony/Java/COM/Android/Internal/telephony/test/simulatedcommands. Java
Among them, 2nd are used for testing in the simulator. We only need to add the method in it, and then call resultsuccess or umimplement.
And 1st are actually GSM-driven classes.
Therefore, we have to implement communication between the upper and lower layers in RIL. java.
In RIL. in the Java method, you only need to define a mark (which will be mentioned below) of the AT command you need to send, and then assign the value of the parcel member MP in the rilrequest class, and then send it out.
The value assigned to the MP is the value that needs to be sent to the lower layer for processing. For example, if an array is passed down, the length is usually first written, and then the members are written in sequence.
========================================================== ========================================================== ====================
Next, it is the addition Process of the lower layer.
1. Hardware/RIL/include/telephony/RIL. h
In this file, add a macro that identifies the AT command you want to process, that is, the mark mentioned above. Be sure not to conflict with other macros.
Note: The mark here must be defined at the end, otherwise it will cause unnecessary troubles for the following reasons:
The value corresponding to each keyword is defined in RIL. H, and a ing table exists in ril_command.h.
And it is mapped in the Order in RIL. H. You can think of it as the subscript of the array.
Here we need a one-to-one correspondence. If we insert data from the middle, the subsequent field ing will be incorrect.
Unless you modify the value corresponding to the keyword in RIL. H, this will waste a lot of time.
2. Hardware/RIL/libril/RIL. cpp
Add a message ing string to the const char * requesttostring (INT request) function of the file.
3. Hardware/RIL/libril/ril_commands.h
Add a function ing table at the end of the file, for example, {mark, dispatch, response}
Explanation:
First, the first 1st parameters are the identifier we previously defined, that is, Mark.
The 2nd parameters are the lower-layer function used to extract data from the data stream. Here, they correspond to the type passed down by the upper layer. For example, the upper layer transmits an int array, and the dispathints parameter is used here, otherwise, an error occurs.
The first parameter is the value to be returned by the function, which is the same as the first parameter.
4. Hardware/RIL/reference-RIL/reference-ril.c
Here is the core file of the AT command. Add the AT command function to the static void onrequest (INT request, void * data, size_t datalen, ril_token T.
As others write, you can modify it yourself. Here we will describe the two functions that send AT commands:
In general, this is the case. We use at_send_command () for AT commands that only return success or failure (). For commands with return values, we use at_send_command_singleline ().
========================================================== ========================================================== ======================================
Return to RIL. Java at the upper layer and add the return value to processunsolicited () or processsolicited.
Here we only select one of them for processing. In processunsolicited (), IT processes commands of the Active Reporting type, that is, you do not need to send commands to query the type. Processsolicited () is the type of result returned by sending a command.
You only need to check how the values in the function are returned. Note that the selected return function corresponds to the return function in the function ing table we added in ril_command.h.
Here, the AT command is added and the return value of the command is in the message passed in by the function in the phone call. The returned asyncresult is the OBJ Member of the message.
Here we can handle exceptions. Generally, we can use the following code (assuming that the incoming message is MSG ):
Asyncresult AR = (asyncresult) msg. OBJ
If (AR. Exception! = NULL) Processing exception
After processing the result, the AR. result is processed.

 

From: http://mzl626.blog.163.com/blog/static/4770270201085102823416/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.