Android wireless interface layer (Radio layer interface)

Source: Internet
Author: User

Address: http://liangxh2008.blog.163.com/blog/static/1124116792010029490222/

 

 

Index
Introduction
RIL Initialization
RIL Interaction
Active request
Passive request
Implement RIL
RIL Initialization
RIL Functions
RIL active command request
RIL passive Request command

Introduction
The android wireless interface layer (RIL) provides an abstraction layer between Android. telephony and radio hardware. RIL is independent of communication and provides GSM-based network support.
Shows the location of RIL in the Android phone system architecture. Figure 1
  

The solid-box frame represents the android part, and the dotted box represents the part dedicated by the partner.
  
RIL contains two basic components:
RIL daemon: the RIL daemon initializes the vendor RIL, manages all communications from the android communication service, and schedules it to the vendor RIL as the requested command (solicited commands.
Vendor RIL: The radio-specific vender RIL in the RIL. h file manages all communications with the radio hardware and distributes it to the RIL daemon through unsolicited commands.
  
RIL Initialization
Android initializes the communication stack and vendor RIL at startup, which are described as follows:
1. the RIL daemon reads the rild. Lib path and rild. libargs system parameters, and determines the vendor RIL library to be used and the initialization parameters provided to the vendor RIL.
2. the RIL daemon loads the vendor RIL library, executes ril_init to initialize RIL, and obtains parameters for the RIL function.
3. the RIL daemon calls ril_register In the android communication stack to provide a reference for the vendor RIL function.
  
For the source code of the RIL daemon, see // device/commands/rild. C.
  
RIL Interaction
The RIL handle provides two ways of interaction:
Solicited commands: the active Request command comes from RIL Lib, such as dial and hangup.
Passive Request command (Unsolicited Responses): the passive Request command comes from the baseband, such as call_state_changed and new_sms.
  
Active request
The following code snippet is an active Request command
Void onRequest (INT request_id, void * daTa, size_t datalen, ril_token t );
Void onRequestcomplete (ril_token T, ril_error E, void * response, size_t responselen );
  
There are more than 60 active request commands:
* Sim pin, Io and imsi/IMEI (11)
* Phone status and actions (Dialing, answering, mute ...) (16)
* Network status query (4)
* Network settings (prohibit, forward, select ...) (12)
* SMS (3)
* PDP connection (4)
* Power supply and reset (2)
* Auxiliary services (5)
* Supplier definition and support (4)
  
Indicates the phone request process of the Android system. Figure 2


  
Passive request
The following code snippet is a passive Request command.
Void onUnsolicitedresponse (INT unsolresponse, void * daTa, size_t datalen );
  
There are more than 10 passive request commands:
* Network status change (4)
* New SMS notification (3)
* New ussd notification (2)
* Signal strength and time change (2)
  
Call process indicating a passive request in the Android system: Figure 3


Implement RIL
To implement a dedicated RIL for communication, you need to execute a series of functions to create a shared library to ensure android can send wireless communication requests. The required function is defined in the RIL header (/include/telephony/RIL. h)
Android communication interfaces are independent of communication, and vendor RIL can use any protocol for wireless communication. Android provides a reference to vendor RIL, which uses a Hayes at command device and can be used as a commercial Quick Start Guide and communication test. RIL reference source code in/commands/reference-RIL /.
You usually compile your own vendor RIL into the following form:
Libril-<companyName>-<RIL version>. So
For example:
Libril-acme-124.so
Where:
Libril: the beginning of all vendor RIL;
<CompanyName>: Abbreviation of a private company
<RIL version>: RIL version number
So: File Extension
  
RIL Initialization
A specific vendor RIL must define an initialization function that provides a series of handle functions to process each communication request. The android RIL daemon will call ril_init at startup to initialize RIL.
Ril_radiofunctions * ril_init (ril_env * ENV, int argc, char ** argv );
Ril_init returns an ril_radiofunctions struct containing the radio function pointer.
Type Structure {
Int ril_version;
Ril_requestfunc onRequest;
Ril_radiostaterequest onStaterequest;
Ril_supports supports;
Ril_cancel onCancel;
Ril_getversion getversion;
}
Ril_radiofunctions;
  
RIL Functions
RIL. h defines the RIL status and variables, such as ril_unsol_stk_call_setup, ril_sim_ready, and ril_sim_not_ready. The following table describes the specific functions. Ignore header file details.
  
RIL active command request
Vendor RIL must provide functions in the following table to send active commands. The request type of the RIL active command is defined in ril_request_prefix of RIL. h.
  
  
  
  
  
Name
Description
Void (* ril_requestfunc) (INT request, void * daTa, size_t datalen, ril_token t );
RIL active command entry pointer, which must be able to process various RIL active requests (ril_request _ prefix defined in RIL. h)
* Request is a type of ril_request _*
* DaTa is a pointer to ril_request _ * data.
* T should be used for ril_onSubsequent call of response
* Datalen is owned by the caller and should be modified or released by the caller.
Must Call ril_onThe requestcomplete () function completes communication .? Ril_onRequestcomplete () may be called by any thread before or after the function is returned. This function always calls the same thread. Therefore, if it is returned, it means that wireless communication is ready to process other commands (whether or not the preceding commands have completed transmission ).
Ril_radiostate (* ril_radiostaterequest )();
This function should return the current communication synchronization status

INT (* ril_supports) (INT requestcode );
If the specified ril_request code is provided, 1 is returned; otherwise, 0 is returned.


Void (* ril_cancel) (ril_token t );
This function is used to indicate canceling a request to be processed. The function will be called by an independent thread, instead of the ril_requestfunc function.
Once canceled, the caller should discard the request and call ril_onThe ril_errno cancelled of the requestcomplete function.
Call ril_on after responding to the requestRequestcomplete and other results can be accepted, but will be ignored (the canceled request should be ignored ).
The ril_cancel call should be returned immediately without waiting for cancellation.


Const char * (* ril_getversion) (void );
Returns a version string to your vendor RIL.
  
Vendor RIL uses the following callback function to communicate with the android RIL daemon.
Name
Description
Void ril_onRequestcomplete (ril_token T, ril_errno E, void * response, size_t responselen );
* T is the parameter that was previously transmitted to ril_notification.
* If e! = Success, then there can be no corresponding and ignored
* Response is owned by the caller and should be modified or released by the caller.
* Ril_onRequestcomplete will be returned as soon as possible


Void ril_requesttimedcallback (ril_timedcallback, void * Param, const struct timeval * relativetime );
In the thread of the callback function specified by the user, the ril_requestfunc function is called.
If relativetime is specified, a specific time value will be waited before the callback.
If relativetime is null or the pointer points to an empty struct, the callback function will be executed as soon as possible.
  
RIL passive commands
The following table functions are the callback functions used by vedor RIL to wake up the corresponding mechanism of passive commands on the Android platform.
Name
Description
Void ril_onUnsolicitedresponse (INT unsolresponse, const void * daTa, size_t datalen );
* Unsolresponse is one of ril_unsol_response _ *
* DaTa is the pointer to ril_unsol_response _ * Data
* DaTa is owned by the caller and should be modified or released by the caller.
  
Rockie Cheng translation. If you cannot understand it in some places, please refer to the original English text.
Http://www.netmite.com/android/mydroid/development/pdk/docs/telephony.html

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.