

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 蜂窝接口库
<a name="cellular-interface"></a>

**注意**  <a name="out-of-date-message"></a>
此页面上的内容可能不是 up-to-date。有关最新更新，请参阅 [FreeRTOS.org 库页面](https://www.freertos.org/Documentation/03-Libraries/01-Library-overview/01-All-libraries)。

## 简介
<a name="freertos-cellular-interface-introduction"></a>

蜂窝接口库实现了一个简单的统一 [API](https://freertos.github.io/FreeRTOS-Cellular-Interface/v1.3.0/)，从而隐藏了特定于蜂窝调制解调器的 AT 命令的复杂性，并向 C 程序员提供了类似套接字的接口。

大多数蜂窝调制解调器或多或少会实现 [3GPP TS v27.007](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1515) 标准定义的 AT 命令。该项目在可[重复使用的通用组件](https://freertos.org/Documentation/api-ref/cellular/cellular_porting_module_guide.html)中提供了此类标准 AT 命令的[实现](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/main/source)。该项目中的三个蜂窝接口库都利用了这种常见代码。每个调制解调器的库仅实现特定于供应商的 AT 命令，然后公开完整的蜂窝接口库 API。

实现 3GPP TS v27.007 标准的通用组件按照以下代码质量标准编写：
+ GNU 复杂度分数不超过 8
+ MISRA C:2012 编码标准。与标准的任何偏差都记录在标记有“Coverity”的源代码注释中。

## 依赖项和要求
<a name="freertos-cellular-interface-dependencies"></a>

蜂窝接口库没有直接依赖关系。但是，以太网、Wi-Fi 和蜂窝网络不能在 FreeRTOS 网络堆栈中共存。开发人员必须选择一个网络接口才能与[安全套接字库](https://docs.aws.amazon.com/freertos/latest/userguide/secure-sockets.html)集成。

## 移植
<a name="freertos-cellular-interface-porting"></a>

有关将蜂窝接口库移植到平台的信息，请参阅《FreeRTOS 移植指南》中的[移植蜂窝接口库](https://docs.aws.amazon.com/freertos/latest/portingguide/freertos-porting-cellular.html)。**

## 内存使用
<a name="freertos-cellular-interface-memory-use"></a>


****  

| 蜂窝接口库的代码大小（使用 GCC for ARM Cortex-M 生成的示例） | 文件 | 使用 -O1 优化 | 使用 -Os 优化 | 
| --- | --- | --- | --- | 
| cellular\$13gpp\$1api.c | 6.3K | 5.7K | 
| cellular\$13gpp\$1urc\$1handler.c | 0.9K | 0.8K | 
| cellular\$1at\$1core.c | 1.4K | 1.2K | 
| cellular\$1common\$1api.c | 0.5K | 0.5K | 
| cellular\$1common.c | 1.6K | 1.4K | 
| cellular\$1pkthandler.c | 1.4K | 1.2K | 
| cellular\$1pktio.c | 1.8K | 1.6K | 
| 估计总数 | 13.9K | 12.4K | 

## 开始使用
<a name="freertos-cellular-interface-getting-started"></a>

### 下载源代码
<a name="freertos-cellular-interface-download-source"></a>

源代码可以作为 FreeRTOS 库的一部分下载，也可以单独下载。

要使用 HTTPS 从 Github 克隆该库，请执行：

```
git clone https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git 
```

使用 SSH：

```
git clone git@github.com:FreeRTOS/FreeRTOS-Cellular-Interface.git 
```

### 文件夹结构
<a name="freertos-cellular-interface-folder-structure"></a>

在此存储库的根目录下，您将看到以下文件夹：
+ `source`：可重复使用的常用代码，用于实现 3GPP TS v27.007 定义的标准 AT 命令
+ `doc`：文档
+ `test`：单元测试和 CBMC
+ `tools`: Coverity 静态分析工具和 CMock

### 配置和构建库
<a name="freertos-cellular-interface-configure"></a>

蜂窝接口库应作为应用程序的一部分进行构建。为此，您必须提供某些配置。[ FreeRTOS\$1Cellular\$1Interface\$1Windows\$1Simulator](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator) 项目提供了有关如何配置构建的[示例](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/cellular_config.h)。在[蜂窝 API 参考](https://freertos.github.io/FreeRTOS-Cellular-Interface/v1.3.0/cellular_config.html)中可找到更多信息。

有关更多信息，请参阅[蜂窝接口](https://www.freertos.org/cellular/index.html)页面。

## 将蜂窝接口库与 MCU 平台集成
<a name="freertos-cellular-interface-integrate"></a>

蜂窝接口库继续 MCUs 使用抽象接口，即[通信](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/source/interface/cellular_comm_interface.h)接口，与蜂窝调制解调器通信。还必须在 MCU 平台上实现通信接口。通信接口的最常见实现通过 UART 硬件进行通信，但也可以通过其他物理接口（例如 SPI）实现。在[蜂窝库 API 参考](https://freertos.github.io/FreeRTOS-Cellular-Interface/v1.3.0/cellular_porting.html#cellular_porting_comm_if)中可找到有关通信接口的文档。其中提供了以下通信接口实现示例：
+ [FreeRTOS Windows 模拟器通信接口](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c)
+ [FreeRTOS Common IO UART 通信接口](https://github.com/aws/amazon-freertos/blob/main/libraries/abstractions/common_io/include/iot_uart.h)
+ [ STM32 L475 发现板通信接口](https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/st/boards/stm32l475_discovery/ports/comm_if/comm_if_uart.c)
+ [Sierra Sensor Hub 主板通信接口](https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/sierra/boards/sensorhub/ports/comm_if/comm_if_sierra.c)