Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
figures/ | 12-May-2024 | - | ||||
interfaces/hdi_service/ | 12-May-2024 | - | 1,115 | 900 | ||
BUILD.gn | D | 12-May-2024 | 659 | 17 | 15 | |
README.md | D | 12-May-2024 | 5.7 KiB | 118 | 84 | |
README_zh.md | D | 12-May-2024 | 5.3 KiB | 119 | 84 | |
bundle.json | D | 12-May-2024 | 761 | 39 | 38 |
README.md
1# Ril 2 3## Overview 4 5The Ril driver developed based on the Hardware Driver Foundation (HDF) driver framework shields hardware differences and provides APIs for upper-layer services, such as making calls, sending SMS messages, and activating SIM cards. 6 7The Ril driver module contains definitions and implementation code of Ril hardware driver interfaces (HDIs) and provides the telephony driver capability APIs for the upper layer. The HDIs implement service processing related to the following services: 8 9- Call 10- SIM card 11- SMS/MMS 12- Radio 13- Cellular data 14 15**Figure 1** Architecture of the Ril driver module 16 17 18 19## Directory Structure 20 21The source code directory structure is as follows: 22 23``` 24/drivers/peripheral/ril 25├── figures # Readme resource files 26├── interfaces # Driver capability APIs provided for upper-layer services 27│ └── include # APIs exposed externally 28``` 29 30## **Constraints** 31 32- Programming language: C++ 33- Software constraints: This module must work with the Ril Adapter module (ril\_adapter). 34- Hardware constraints: The device must be equipped with a modem capable of independent cellular communication. 35 36## Usage Description 37 38### Available APIs 39 40The Ril driver provides capability APIs that can be directly called by the framework layer. The main functions are as follows: call, SIM card, SMS/MMS, cellular data, and event reporting. The following table lists the APIs provided by the Ril driver module. 41 42**Table 1** Ril HDI APIs 43 44| API | Description | 45| ------------------------------------------------------------ | ------------------------------------------------------------ | 46| int32_t SetCallback(const sptr\<IRilCallback\> &rilCallback) | Sets the IRil callback.| 47| int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) | Makes a call. **slotId** indicates the card slot ID, **serialId** indicates the serial ID of the request, and **dialInfo** indicates the dialing information.| 48| int32_t Answer(int32_t slotId, int32_t serialId) | Answers a call. **slotId** indicates the card slot ID, and **serialId** indicates the serial ID of the request.| 49| int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) | Sends a GSM SMS message. **slotId** indicates the card slot ID, **serialId** indicates the serial ID of the request, and **gsmSmsMessageInfo** indicates the GSM SMS message information.| 50| int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) | Activates or deactivates a SIM card. **slotId** indicates the card slot ID, **serialId** indicates the serial ID of the request, **index** indicates the index value of the SIM card information, and **enable** indicates the activation status.| 51| int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) | Queries the carrier name. **slotId** indicates the card slot ID, and **serialId** indicates the serial ID of the request.| 52| int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) | Activates the PDP context. **slotId** indicates the card slot ID, and **dataCallInfo** indicates the data service information.| 53| int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) | Sets the radio state. **slotId** indicates the card slot ID, **serialId** indicates the serial ID of the request, **fun** indicates the function mode, and **rst** indicates whether to perform a reset.| 54 55For details about the APIs, access [drivers_interface_ril](https://gitee.com/openharmony/drivers_interface/blob/master/ril/v1_1/IRil.idl). 56 57### How to Use 58 59This section uses the call service implementation as an example. 60 61Sample code: 62 63```c++ 64#include "V1_1/iril.h" 65 66/* Ril callback class */ 67class RilCallback : public HDI::Ril::V1_1::IRilCallback { 68 int32_t DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 69 int32_t HangupResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 70 int32_t RejectResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 71 int32_t AnswerResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 72 ... 73} 74 75/* Callback */ 76int32_t RilCallback::DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) 77{ 78 printf("DialResponse"); 79 return 0; 80} 81 82void RilSample(void) 83{ 84 /* Create a Ril interface instance. */ 85 sptr<OHOS::HDI::Ril::V1_1::IRil> g_rilInterface = OHOS::HDI::Ril::V1_1::IRil::Get(); 86 if (g_rilInterface == nullptr) { 87 return; 88 } 89 /* Set a callback. */ 90 sptr<HDI::Ril::V1_1::IRilCallback> g_cbObj = new RilCallback(); 91 g_rilInterface->SetCallback(RilCallback()); 92 93 /** Make a call. **/ 94 int32_t slotId = 0; 95 int32_t serialId = 1; 96 HDI::Ril::V1_1::DialInfo dialInfo = {}; 97 dialInfo.address = "10086"; 98 dialInfo.clir = 0; 99 int32_t ret = g_rilInterface->Dial(slotId, serialId, dialInfo); 100} 101``` 102 103## Repositories Involved 104 105[Driver](https://gitee.com/openharmony/docs/blob/master/en/readme/driver.md) 106 107[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README.md) 108 109[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README.md) 110 111[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README.md) 112 113[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral) 114 115[telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md) 116 117[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README.md) 118
README_zh.md
1# Ril 2 3## 简介 4 5基于HDF(Hardware Driver Foundation)驱动框架开发的Ril驱动,能够屏蔽硬件器件差异,为上层服务提供稳定的拨打电话、发短信、激活SIM卡等稳定的接口。 6 7Ril驱动模块主要包含HDI(Hardware Driver Interface)接口定义及其实现,对上层提供Telephony的驱动能力接口,HDI接口主要提供如下功能: 8 9- 通话相关的业务处理能力 10- SIM卡相关的业务处理能力 11- 短彩信相关的业务处理能力 12- 搜网相关的业务处理能力 13- 蜂窝数据相关的业务处理能力 14 15**图 1** Ril驱动模型图 16 17 18 19## 目录 20 21该仓下源代码目录结构如下所示 22 23``` 24/drivers/peripheral/ril 25├── figures # readme资源文件 26├── interfaces # Ril模块对上层服务提供的驱动能力接口 27│ └── include # Ril模块对外提供的接口定义 28``` 29 30## 约束 31 32- 开发语言:C++ 。 33- 软件约束:需要与RIL Adapter模块(ril\_adapter)配合使用。 34- 硬件约束:需要搭载的设备具备可以进行独立蜂窝通信的Modem以及SIM卡。 35 36## 说明 37 38### 接口说明 39 40Ril驱动提供给framework层可直接调用的能力接口,主要功能有:通话、SIM卡、短彩信、蜂窝数据、事件上报等业务。Ril驱动模型对HDI开放的API接口功能如表1: 41 42**表 1** Ril HDI 接口列表 43 44| 接口名 | 功能描述 | 45| ------------------------------------------------------------ | ------------------------------------------------------------ | 46| int32_t SetCallback(const sptr\<IRilCallback\> &rilCallback) | 设置IRil回调接口。 | 47| int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) | 拨打电话,slotId 表示卡槽ID,serialId 表示请求的序列化ID,dialInfo 表示拨号信息。 | 48| int32_t Answer(int32_t slotId, int32_t serialId) | 接听电话,slotId 表示卡槽ID,serialId 表示请求的序列化ID。 | 49| int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) | 发送GSM短信,slotId 表示卡槽ID,serialId 表示请求的序列化ID,gsmSmsMessageInfo 表示GSM短信信息。| 50| int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) | 激活或去激活SIM卡,slotId 表示卡槽ID,serialId 表示请求的序列化ID,index 表示SIM卡信息的索引值,enable 表示激活状态 | 51| int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) | 查询运营商名称信息,slotId 表示卡槽ID,serialId 表示请求的序列化ID。 | 52| int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) | 查询运营商名称信息,slotId 表示卡槽ID,dataCallInfo 表示数据业务信息。 | 53| int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) | 给Modem上下电,slotId 表示卡槽ID,serialId 表示请求的序列化ID,fun 表示功能模式,rst 表示是否复位。 | 54 55完整的接口说明请参考:[ drivers_interface_ril](https://gitee.com/openharmony/drivers_interface/blob/master/ril/v1_1/IRil.idl)。 56 57### 使用说明 58 59本节以拨打电话为例进行介绍。 60 61代码示例 62 63```c++ 64#include "V1_1/iril.h" 65 66/* Ril回调类 */ 67class RilCallback : public HDI::Ril::V1_1::IRilCallback { 68 int32_t DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 69 int32_t HangupResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 70 int32_t RejectResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 71 int32_t AnswerResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override; 72 ... 73} 74 75/* 回调函数 */ 76int32_t RilCallback::DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) 77{ 78 printf("DialResponse"); 79 return 0; 80} 81 82void RilSample(void) 83{ 84 /* 创建Ril接口实例 */ 85 sptr<OHOS::HDI::Ril::V1_1::IRil> g_rilInterface = OHOS::HDI::Ril::V1_1::IRil::Get(); 86 if (g_rilInterface == nullptr) { 87 return; 88 } 89 /* 设置回调*/ 90 sptr<HDI::Ril::V1_1::IRilCallback> g_cbObj = new RilCallback(); 91 g_rilInterface->SetCallback(RilCallback()); 92 93 /**拨打电话**/ 94 int32_t slotId = 0; 95 int32_t serialId = 1; 96 HDI::Ril::V1_1::DialInfo dialInfo = {}; 97 dialInfo.address = "10086"; 98 dialInfo.clir = 0; 99 int32_t ret = g_rilInterface->Dial(slotId, serialId, dialInfo); 100} 101``` 102 103## 相关仓 104 105[驱动子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E9%A9%B1%E5%8A%A8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) 106 107[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README_zh.md) 108 109[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README_zh.md) 110 111[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README_zh.md) 112 113[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral) 114 115[telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README_zh.md) 116 117[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README_zh.md) 118 119