[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
10
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitattributes
vendored
Normal file
10
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitattributes
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# Explicitly declare text files you want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
*.c text
|
||||
*.h text
|
||||
|
||||
# Declare files that will always have CRLF line endings on checkout.
|
||||
*.sln text eol=lf
|
||||
63
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/CONTRIBUTING.md
vendored
Normal file
63
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
|
||||
documentation, we greatly value feedback and contributions from our community.
|
||||
|
||||
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
|
||||
information to effectively respond to your bug report or contribution.
|
||||
|
||||
|
||||
## Reporting Bugs/Feature Requests
|
||||
|
||||
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
|
||||
|
||||
When filing an issue, please check [existing open](https://github.com/FreeRTOS/backoffAlgorithm/issues), or [recently closed](https://github.com/FreeRTOS/backoffAlgorithm/issues?q=is%3Aissue+is%3Aclosed), issues to make sure somebody else hasn't already
|
||||
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
|
||||
|
||||
* A reproducible test case or series of steps
|
||||
* The version of our code being used
|
||||
* Any modifications you've made relevant to the bug
|
||||
* Anything unusual about your environment or deployment
|
||||
|
||||
|
||||
## Contributing via Pull Requests
|
||||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
|
||||
|
||||
1. You are working against the latest source on the *main* branch.
|
||||
1. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
|
||||
1. You open an issue to discuss any significant work - we would hate for your time to be wasted.
|
||||
|
||||
To send us a pull request, please:
|
||||
|
||||
1. Fork the repository.
|
||||
1. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
|
||||
1. Ensure that your contributions conform to the [style guide](https://docs.aws.amazon.com/embedded-csdk/202011.00/lib-ref/docs/doxygen/output/html/guide_developer_styleguide.html).
|
||||
1. Format your code with uncrustify, using the config available in [FreeRTOS/CI-CD-Github-Actions](https://github.com/FreeRTOS/CI-CD-Github-Actions/blob/main/formatting/uncrustify.cfg).
|
||||
1. Ensure local tests pass.
|
||||
1. Commit to your fork using clear commit messages.
|
||||
1. Send us a pull request, answering any default questions in the pull request interface.
|
||||
1. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
|
||||
|
||||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
|
||||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
|
||||
|
||||
|
||||
## Finding contributions to work on
|
||||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/FreeRTOS/backoffAlgorithm/labels?q=help+wanted) issues is a great place to start.
|
||||
|
||||
|
||||
## Code of Conduct
|
||||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
|
||||
|
||||
## Security issue notifications
|
||||
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
|
||||
|
||||
|
||||
## Licensing
|
||||
|
||||
See the [LICENSE](../LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
|
||||
|
||||
We may ask you to sign a [Contributor License Agreement (CLA)](https://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
|
||||
22
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/memory_statistics_config.json
vendored
Normal file
22
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/memory_statistics_config.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"lib_name" : "cellularLibrary",
|
||||
"src": [
|
||||
"source/cellular_3gpp_api.c",
|
||||
"source/cellular_3gpp_urc_handler.c",
|
||||
"source/cellular_at_core.c",
|
||||
"source/cellular_common_api.c",
|
||||
"source/cellular_common.c",
|
||||
"source/cellular_pkthandler.c",
|
||||
"source/cellular_pktio.c"
|
||||
],
|
||||
"include": [
|
||||
"source/include",
|
||||
"source/include/common",
|
||||
"source/include/private",
|
||||
"source/interface",
|
||||
"test/unit-test"
|
||||
],
|
||||
"compiler_flags": [
|
||||
"CELLULAR_DO_NOT_USE_CUSTOM_CONFIG"
|
||||
]
|
||||
}
|
||||
101
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/ci.yml
vendored
Normal file
101
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
name: CI Checks
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
unittest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone This Repo
|
||||
uses: actions/checkout@v2
|
||||
- name: Build
|
||||
run: |
|
||||
sudo apt-get install -y lcov
|
||||
cmake -S test -B build/ \
|
||||
-G "Unix Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DBUILD_CLONE_SUBMODULES=ON \
|
||||
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG'
|
||||
make -C build/ all
|
||||
- name: Test
|
||||
run: |
|
||||
cd build/
|
||||
ctest -E system --output-on-failure
|
||||
cd ..
|
||||
- name: Run Coverage
|
||||
run: |
|
||||
make -C build/ coverage
|
||||
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*")
|
||||
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
|
||||
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
|
||||
- name: Check Coverage
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
|
||||
with:
|
||||
path: ./build/coverage.info
|
||||
complexity:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Check complexity - Common
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/complexity@main
|
||||
with:
|
||||
path: ./
|
||||
doxygen:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run doxygen build
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/doxygen@main
|
||||
with:
|
||||
path: ./
|
||||
spell-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone This Repo
|
||||
uses: actions/checkout@v2
|
||||
- name: Run spellings check
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/spellings@main
|
||||
with:
|
||||
path: ./
|
||||
formatting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Check formatting
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/formatting@main
|
||||
with:
|
||||
path: ./
|
||||
git-secrets:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout awslabs/git-secrets
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: awslabs/git-secrets
|
||||
ref: master
|
||||
path: git-secrets
|
||||
- name: Install git-secrets
|
||||
run: cd git-secrets && sudo make install && cd ..
|
||||
- name: Run git-secrets
|
||||
run: |
|
||||
git-secrets --register-aws
|
||||
git-secrets --scan
|
||||
memory_statistics:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Install Python3
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.7.10'
|
||||
- name: Measure sizes
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/memory_statistics@main
|
||||
with:
|
||||
config: .github/memory_statistics_config.json
|
||||
check_against: docs/doxygen/include/size_table.md
|
||||
22
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/memory_statistics.yml
vendored
Normal file
22
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/memory_statistics.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Memory statistics
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
memory_statistics:
|
||||
name: Calculate object sizes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: Measure sizes
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/memory_statistics@main
|
||||
with:
|
||||
config: .github/memory_statistics_config.json
|
||||
- name: Upload table
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: size_table
|
||||
path: size_table.md
|
||||
139
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/release.yml
vendored
Normal file
139
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
name: Release automation
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
commit_id:
|
||||
description: 'Commit ID to tag and create a release for'
|
||||
required: true
|
||||
version_number:
|
||||
description: 'Release Version Number (Eg, v1.0.0)'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
tag-commit:
|
||||
name: Generate SBOM and tag commit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.commit_id }}
|
||||
- name: Configure git identity
|
||||
run: |
|
||||
git config --global user.name ${{ github.actor }}
|
||||
git config --global user.email ${{ github.actor }}@users.noreply.github.com
|
||||
- name: create a new branch that references commit id
|
||||
run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
|
||||
- name: Generate SBOM
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
|
||||
with:
|
||||
repo_path: ./
|
||||
source_path: ./source
|
||||
- name: commit SBOM file
|
||||
run: |
|
||||
git add .
|
||||
git commit -m 'Update SBOM'
|
||||
git push -u origin ${{ github.event.inputs.version_number }}
|
||||
- name: Tag Commit and Push to remote
|
||||
run: |
|
||||
git tag ${{ github.event.inputs.version_number }} -a -m "FreeRTOS-Cellular-Interface Library ${{ github.event.inputs.version_number }}"
|
||||
git push origin --tags
|
||||
- name: Verify tag on remote
|
||||
run: |
|
||||
git tag -d ${{ github.event.inputs.version_number }}
|
||||
git remote update
|
||||
git checkout tags/${{ github.event.inputs.version_number }}
|
||||
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
|
||||
create-zip:
|
||||
needs: tag-commit
|
||||
name: Create ZIP and verify package for release asset.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install ZIP tools
|
||||
run: sudo apt-get install zip unzip
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.commit_id }}
|
||||
path: FreeRTOS-Cellular-Interface
|
||||
submodules: recursive
|
||||
- name: Checkout disabled submodules
|
||||
run: |
|
||||
cd FreeRTOS-Cellular-Interface
|
||||
git submodule update --init --checkout --recursive
|
||||
- name: Create ZIP
|
||||
run: |
|
||||
zip -r FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip FreeRTOS-Cellular-Interface -x "*.git*"
|
||||
ls ./
|
||||
- name: Validate created ZIP
|
||||
run: |
|
||||
mkdir zip-check
|
||||
mv FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip zip-check
|
||||
cd zip-check
|
||||
unzip FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip -d FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}
|
||||
ls FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}
|
||||
diff -r -x "*.git*" FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface/ ../FreeRTOS-Cellular-Interface/
|
||||
cd ../
|
||||
- name: Build
|
||||
run: |
|
||||
cd zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface
|
||||
sudo apt-get install -y lcov
|
||||
cmake -S test -B build/ \
|
||||
-G "Unix Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DBUILD_CLONE_SUBMODULES=ON \
|
||||
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG'
|
||||
make -C build/ all
|
||||
- name: Test
|
||||
run: |
|
||||
cd zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface/build/
|
||||
ctest -E system --output-on-failure
|
||||
cd ..
|
||||
- name: Create artifact of ZIP
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip
|
||||
path: zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip
|
||||
deploy-doxygen:
|
||||
needs: tag-commit
|
||||
name: Deploy doxygen documentation
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Doxygen generation
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main
|
||||
with:
|
||||
ref: ${{ github.event.inputs.version_number }}
|
||||
add_release: "true"
|
||||
create-release:
|
||||
needs:
|
||||
- create-zip
|
||||
- deploy-doxygen
|
||||
name: Create Release and Upload Release Asset
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.event.inputs.version_number }}
|
||||
release_name: ${{ github.event.inputs.version_number }}
|
||||
body: Release ${{ github.event.inputs.version_number }} of the FreeRTOS-Cellular-Interface Library.
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Download ZIP artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip
|
||||
asset_name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip
|
||||
asset_content_type: application/zip
|
||||
1
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitignore
vendored
Normal file
1
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
output
|
||||
3
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitmodules
vendored
Normal file
3
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "test/unit-test/CMock"]
|
||||
path = test/unit-test/CMock
|
||||
url = https://github.com/ThrowTheSwitch/CMock
|
||||
@ -0,0 +1,54 @@
|
||||
# Change Log for FreeRTOS Cellular Interface Library
|
||||
|
||||
## v1.3.0 (October 2022)
|
||||
### Updates
|
||||
- [#102](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/102) MISRA C:2012 Compliance update.
|
||||
- [#101](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/101) Add Cellular common AT command timeout.
|
||||
- [#99](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/99) CBMC Starter kit update.
|
||||
- [#98](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/98) HL7802 Finish processing packets after remote disconnect.
|
||||
- [#96](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/96) Add config to disable hardware flow control.
|
||||
- [#94](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/94) Cellular Socket State design update.
|
||||
- [#92](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/92) Socket CONNECTING state change.
|
||||
- [#90](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/90) Handle network registration URC in AT Command response callback.
|
||||
- [#88](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/88) Set TCP Local Port.
|
||||
- [#86](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/86) Restore URC String when using generic URC callback.
|
||||
- [#85](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/85) SARA-R4 socket receive response handling.
|
||||
- [#84](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/84) HL7802 Signal processing function update.
|
||||
- [#82](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/82) Add default RAT selection list.
|
||||
- [#80](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/80) Hl7802 Delay after reboot.
|
||||
- [#79](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/79) SARA-R4 Get PDN Status.
|
||||
- [#77](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/77) HL7802 AT command timeout update.
|
||||
- [#76](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/76) HL7802 band config detection and changes to log messages.
|
||||
- [#75](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/75) SARA-R4 Reboot on init and changes to log messages.
|
||||
|
||||
## v1.2.0 (December 2021)
|
||||
### Updates
|
||||
- [#62](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/62) Fix uintptr compile error.
|
||||
- [#67](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/67) Fix too many arguments log.
|
||||
- [#64](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/64) Remove strnlen usage.
|
||||
|
||||
### Other
|
||||
- [#63](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/63) Fix broken links.
|
||||
- [#61](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/61) Fix typo in README.md.
|
||||
- [#69](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/69) Loop invariant update.
|
||||
- [#65](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/65) Submodule community ports repo to third party folder.
|
||||
- [#70](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/70) fix CBMC potential issues.
|
||||
|
||||
## v1.1.0 (November 2021)
|
||||
### Updates
|
||||
- [#40](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/40) Fix the module logging mechanism format.
|
||||
- [#53](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/53) Use the stdint.h header file for integer types.
|
||||
- [#55](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/55) Add function for validating the prefix character of cellular module response.
|
||||
- [#57](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/57) Fix unknown type issue.
|
||||
|
||||
### Other
|
||||
- [#52](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/52) Resolve ublox sara r4 build warnings.
|
||||
- [#42](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/42) Fix spelling check failure in CI tools.
|
||||
- [#43](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/43) [#46](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/46) [#54](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/54) Minor documentation updates.
|
||||
- [#48](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/pull/48) Header Guards for C++ linkage.
|
||||
|
||||
## v1.0.0 (September 2021)
|
||||
|
||||
This is the first release of the FreeRTOS Cellular Interface library in this repository.
|
||||
|
||||
The FreeRTOS Cellular Interface library provides an implementation of the standard AT commands for the [3GPP TS v27.007](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1515) and support for the 3 cellular modems [Quectel BG96](https://www.quectel.com/product/bg96.htm), [Sierra Wireless HL7802](https://www.sierrawireless.com/products-and-solutions/embedded-solutions/products/hl7802/) and [U-Blox Sara-R4](https://www.u-blox.com/en/product/sara-r4-series).
|
||||
@ -0,0 +1,4 @@
|
||||
## Code of Conduct
|
||||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
@ -0,0 +1,19 @@
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
113
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/MISRA.md
Normal file
113
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/MISRA.md
Normal file
@ -0,0 +1,113 @@
|
||||
# MISRA Compliance
|
||||
|
||||
The FreeRTOS-Cellular-Interface library files conform to the [MISRA C:2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx)
|
||||
guidelines, with the deviations listed below. Compliance is checked with Coverity static analysis.
|
||||
The specific deviations, suppressed inline, are listed below.
|
||||
|
||||
Additionally, [MISRA configuration file](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/tools/coverity/misra.config) contains the project wide deviations.
|
||||
|
||||
### Suppressed with Coverity Comments
|
||||
To find the violation references in the source files run grep on the source code
|
||||
with ( Assuming rule 10.4 violation; with justification in point 1 ):
|
||||
```
|
||||
grep 'MISRA Ref 10.4.1' . -rI
|
||||
```
|
||||
|
||||
#### Directive 4.6
|
||||
_Ref 4.6.1_
|
||||
|
||||
- MISRA C-2012 Directive 4.6 warns against using types that do not contain size
|
||||
and sign information. The use of isalpha, isdigit, and isspace set this directive
|
||||
off since they use base types that don't contain this information. We do not have
|
||||
control over these functions so we are suppressing these violations.
|
||||
|
||||
#### Directive 4.7
|
||||
_Ref 4.7.1_
|
||||
|
||||
- MISRA C 2012 Directive 4.7 requires that when a function returns error information,
|
||||
that error information shall be tested. The following line violates MISRA rule 4.7
|
||||
because return value of strtol() is not checked for error. This violation is
|
||||
justified because error checking by "errno" for any POSIX API is not thread
|
||||
safe in FreeRTOS unless "configUSE_POSIX_ERRNO" is enabled. In order to avoid the
|
||||
dependency on this feature, errno variable is not used.
|
||||
|
||||
#### Rule 10.4
|
||||
_Ref 10.4.1_
|
||||
|
||||
- MISRA C-2012 Rule 10.4 warns about using different types in an operation.
|
||||
This rule is being flagged because of use of the standard library functions
|
||||
isalpha, isdigit, and isspace. We do not have control over these functions so we
|
||||
are suppressing these violations.
|
||||
|
||||
#### Rule 10.5
|
||||
_Ref 10.5.1_
|
||||
|
||||
- MISRA C-2012 Rule 10.5 Converting to an enum type. The variables
|
||||
are checked to ensure that they are valid, and within a valid range.
|
||||
Hence, assigning the value of the variable with a enum cast.
|
||||
|
||||
#### Rule 10.8
|
||||
_Ref 10.8.1_
|
||||
|
||||
- MISRA C-2012 Rule 10.8 warns about casting from unsigned to signed types.
|
||||
This rule is being flagged because of use of the standard library functions
|
||||
isalpha and isdigit. We do not have control over these so we are suppressing
|
||||
these violations.
|
||||
|
||||
#### Rule 11.3
|
||||
_Ref 11.3.1_
|
||||
|
||||
- MISRA C-2012 Rule 11.3 does not allow casting of a pointer to different object types.
|
||||
We are passing in a length variable which is then checked to determine what to
|
||||
cast this value to. As such we are not worried about the chance of
|
||||
misaligned access when using the cast variable.
|
||||
|
||||
#### Rule 21.6
|
||||
_Ref 21.6.1_
|
||||
|
||||
- MISRA C-2012 Rule 21.6 warns about the use of standard library input/output
|
||||
functions as they might have implementation defined or undefined
|
||||
behaviour. The max length of the strings are fixed and checked offline.
|
||||
|
||||
#### Rule 21.9
|
||||
_Ref 21.9.1_
|
||||
|
||||
- MISRA C-2012 Rule 21.9 does not allow the use of bsearch. This is becasue of
|
||||
unspecified behavior, which relates to the treatment of elements that compare as
|
||||
equal, can be avoided by ensuring that the comparison function never returns 0.
|
||||
When two elements are otherwise equal, the comparison function could
|
||||
return a value that indicates their relative order in the initial array.
|
||||
This the token table must be checked without duplicated string. The return value
|
||||
is 0 only if the string is exactly the same.
|
||||
|
||||
#### Rule 22.8
|
||||
_Ref 22.8.1_
|
||||
|
||||
- MISRA C 2012 Rule 22.8 Requires the errno variable must be "zero" before calling
|
||||
strtol function. This violation is justified because error checking by "errno"
|
||||
for any POSIX API is not thread safe in FreeRTOS unless "configUSE_POSIX_ERRNO"
|
||||
is enabled. In order to avoid the dependency on this feature, errno variable is
|
||||
not used. The function strtol returns LONG_MIN and LONG_MAX in case of underflow
|
||||
and overflow respectively and sets the errno to ERANGE. It is not possible to
|
||||
distinguish between valid LONG_MIN and LONG_MAX return values and underflow and
|
||||
overflow scenarios without checking errno. Therefore, we cannot check return value
|
||||
of strtol for errors. We ensure that strtol performed a valid conversion by
|
||||
checking that *pEndPtr is '\0'. strtol stores the address of the first invalid
|
||||
character in *pEndPtr and therefore, '\0' value of *pEndPtr means that the complete
|
||||
pToken string passed for conversion was valid and a valid conversion wasperformed.
|
||||
|
||||
#### Rule 22.9
|
||||
_Ref 22.9.1_
|
||||
|
||||
- MISRA C 2012 Rule 22.9 requires that errno must be tested after strtol function is
|
||||
called.This violation is justified because error checking by "errno"
|
||||
for any POSIX API is not thread safe in FreeRTOS unless "configUSE_POSIX_ERRNO"
|
||||
is enabled. In order to avoid the dependency on this feature, errno variable is
|
||||
not used. The function strtol returns LONG_MIN and LONG_MAX in case of underflow
|
||||
and overflow respectively and sets the errno to ERANGE. It is not possible to
|
||||
distinguish between valid LONG_MIN and LONG_MAX return values and underflow and
|
||||
overflow scenarios without checking errno. Therefore, we cannot check return value
|
||||
of strtol for errors. We ensure that strtol performed a valid conversion by
|
||||
checking that *pEndPtr is '\0'. strtol stores the address of the first invalid
|
||||
character in *pEndPtr and therefore, '\0' value of *pEndPtr means that the complete
|
||||
pToken string passed for conversion was valid and a valid conversion wasperformed.
|
||||
@ -0,0 +1,151 @@
|
||||
# FreeRTOS Cellular Interface
|
||||
|
||||
## On this page:
|
||||
* [Introduction](#Introduction)
|
||||
* [Getting Started](#Getting-Started)
|
||||
* [Download the source code](#Download-the-source-code)
|
||||
* [Folder Structure](#Folder-Structure)
|
||||
* [Integrate FreeRTOS Cellular Interface with MCU platforms](#Integrate-FreeRTOS-Cellular-Interface-with-MCU-platforms)
|
||||
* [Adding support for new cellular modems](#Adding-support-for-new-cellular-modems)
|
||||
* [Integrate FreeRTOS Cellular Interface with Cellular Modules](#integrate-freertos-cellular-interface-with-cellular-modules)
|
||||
* [Building Unit Tests](#Building-Unit-Tests)
|
||||
* [Generating documentation](#Generating-documentation)
|
||||
* [Contributing](#Contributing)
|
||||
|
||||
## Introduction
|
||||
|
||||
The Cellular Interface library implement a simple unified [Application Programing Interfaces (APIs)](https://www.freertos.org/Documentation/api-ref/cellular/index.html) that hide the complexity of AT commands. The cellular modems to be interchangeable with the popular options built upon TCP stack and exposes a socket-like interface to C programmers.
|
||||
|
||||
Most cellular modems implement more or less the AT commands defined by the [3GPP TS v27.007](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1515) standard. This project provides an implementation of such standard AT commands in a [reusable common component](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/main/source/include/common). The three Cellular libraries in this project all take advantage of that common code. The library for each modem only implements the vendor-specific AT commands, then exposes the complete Cellular API.
|
||||
|
||||
The common component that implements the 3GPP TS v27.007 standard has been written in compliance of the following code quality criteria:
|
||||
|
||||
* GNU Complexity scores are not over 8.
|
||||
* MISRA coding standard. Any deviations from the MISRA C:2012 guidelines are documented in source code comments marked by "`coverity`".
|
||||
|
||||
**FreeRTOS Cellular Interface v1.3.0 [source code](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/v1.3.0/source) is part of the [FreeRTOS 202210.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202210.00-LTS) release.**
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Download the source code
|
||||
|
||||
To clone using HTTPS:
|
||||
|
||||
```
|
||||
git clone https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git
|
||||
```
|
||||
|
||||
Using SSH:
|
||||
|
||||
```
|
||||
git clone git@github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git
|
||||
```
|
||||
|
||||
### Folder structure
|
||||
|
||||
At the root of this repository are these folders:
|
||||
|
||||
* source : reusable common code that implements the standard AT commands defined by 3GPP TS v27.007.
|
||||
* docs : documentations.
|
||||
* test : unit test and cbmc.
|
||||
* tools : tools for Coverity static analysis and CMock.
|
||||
|
||||
## Implement Comm Interface with MCU platforms
|
||||
|
||||
The FreeRTOS Cellular Interface runs on MCUs. It uses an abstracted interface - the [Comm Interface](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/main/source/interface/cellular_comm_interface.h), to communicate with cellular modems. A Comm Interface must be implemented as well on the MCU platform. The most common implementations of the Comm Interface are over UART hardware, but it can be implemented over other physical interfaces such as SPI as well. The documentation of the Comm Interface is found within the [Cellular API References](https://www.freertos.org/Documentation/api-ref/cellular/cellular_porting.html#cellular_porting_comm_if). These are example implementations of the Comm Interface:
|
||||
|
||||
* [FreeRTOS windows simulator comm interface](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c)
|
||||
* [FreeRTOS Common IO UART comm interface](https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/st/boards/stm32l475_discovery/ports/comm_if/comm_if_uart.c)
|
||||
* [STM32 L475 discovery board comm interface](https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/st/boards/stm32l475_discovery/ports/comm_if/comm_if_st.c)
|
||||
* [Sierra Sensor Hub board comm interface](https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/sierra/boards/sensorhub/ports/comm_if/comm_if_sierra.c)
|
||||
|
||||
The FreeRTOS Cellular Interface uses kernel APIs for task synchronization and memory management.
|
||||
|
||||
## Adding support for new cellular modems
|
||||
|
||||
FreeRTOS Cellular Interface now supports AT commands, TCP offloaded Cellular abstraction Layer. In order to add support for a new cellular modem, the developer can use the [common component](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/main/source/include/common) that has already implemented the 3GPP standard AT commands.
|
||||
|
||||
In order to port the [common component](https://www.freertos.org/Documentation/api-ref/cellular/cellular_porting_module_guide.html):
|
||||
|
||||
1. Implement the cellular modem porting interface defined in [cellular_common_portable.h](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/main/source/include/common/cellular_common_portable.h) ([Document](https://www.freertos.org/Documentation/api-ref/cellular/cellular__common__portable_8h.html)).
|
||||
2. Implement the subset of Cellular Library APIs that use vendor-specific (non-3GPP) AT commands. The APIs to be implemented are the ones not marked with an "o" in [this table](https://www.freertos.org/Documentation/api-ref/cellular/cellular_common__a_p_is.html).
|
||||
3. Implement Cellular Library callback functions that handle vendor-specific (non-3GPP) Unsolicited Result Code (URC). The URC handlers to be implemented are the ones not marked with an "o" in [this table](https://www.freertos.org/Documentation/api-ref/cellular/cellular_common__u_r_c_handlers.html).
|
||||
|
||||
The [Cellular common APIs document](https://www.freertos.org/Documentation/api-ref/cellular/cellular_porting_module_guide.html) provides detail information required in each steps.
|
||||
It is recommended that you start by cloning the implementation of one of the existing modems, then make modifications where your modem's vendor-specific (non-3GPP) AT commands are different.
|
||||
|
||||
Current Example Implementations:
|
||||
|
||||
* [Quectel BG96](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96)
|
||||
* [Sierra Wireless HL7802](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Sierra-Wireless-HL7802)
|
||||
* [U-Blox Sara-R4](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4)
|
||||
|
||||
## Integrate FreeRTOS Cellular Interface with application
|
||||
|
||||
Once comm interface and cellular module implementation are ready, we can start to integrate
|
||||
FreeRTOS Cellular Interface. The following diagram depicts the relationship of these software components:
|
||||
<p align="center"><img src="/docs/plantuml/images/cellular_components.svg" width="50%"><br>
|
||||
|
||||
Follow these steps to integrate FreeRTOS Cellular Interface into your project:
|
||||
1. Clone this repository into your project.
|
||||
2. Clone one of the refenerce cellular module implementations ( BG96 / HL7802 / SARA-R4 )
|
||||
or create your own cellular module implementaion in your project.
|
||||
3. Implement comm interface.
|
||||
4. Build these software components with your application and execute.
|
||||
|
||||
We also provide [Demos for FreeRTOS-Cellular-Interface on Windows simulator](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator)
|
||||
as references for these three cellular modems example implementations.
|
||||
|
||||
## Building Unit Tests
|
||||
|
||||
### Checkout CMock Submodule
|
||||
By default, the submodules in this repository are configured with `update=none` in [.gitmodules](.gitmodules) to avoid increasing clone time and disk space usage of other repositories (like [amazon-freertos](https://github.com/aws/amazon-freertos) that submodules this repository).
|
||||
|
||||
|
||||
To build unit tests, the submodule dependency of CMock is required. Use the following command to clone the submodule:
|
||||
```
|
||||
git submodule update --checkout --init --recursive test/unit-test/CMock
|
||||
```
|
||||
|
||||
### Platform Prerequisites
|
||||
|
||||
- For building the unit tests, **CMake 3.13.0** or later and a **C90 compiler**.
|
||||
- For running unit tests, **Ruby 2.0.0** or later is additionally required for the CMock test framework (that we use).
|
||||
- For running the coverage target, **gcov** and **lcov** are additionally required.
|
||||
|
||||
### Steps to build unit tests
|
||||
|
||||
1. Go to the root directory of this repository. (Make sure that the **CMock** submodule is cloned as described [above](#checkout-cmock-submodule).)
|
||||
|
||||
1. Run the *cmake* command: `cmake -S test -B build`
|
||||
|
||||
1. Run this command to build the library and unit tests: `make -C build all`
|
||||
|
||||
1. The generated test executables will be present in `build/bin/tests` folder.
|
||||
|
||||
1. Run `cd build && ctest` to execute all tests and view the test run summary.
|
||||
|
||||
## CBMC
|
||||
|
||||
To learn more about CBMC and proofs specifically, review the training material [here](https://model-checking.github.io/cbmc-training).
|
||||
|
||||
The `test/cbmc/proofs` directory contains CBMC proofs.
|
||||
|
||||
In order to run these proofs you will need to install CBMC and other tools by following the instructions [here](https://model-checking.github.io/cbmc-training/installation.html).
|
||||
|
||||
## Reference examples
|
||||
|
||||
Please refer to the demos of the Cellular Interface library [here](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator) using FreeRTOS on the Windows simulator platform. These can be used as reference examples for the library API.
|
||||
|
||||
## Generating documentation
|
||||
|
||||
The Doxygen references were created using Doxygen version 1.9.2. To generate the
|
||||
Doxygen pages, please run the following command from the root of this repository:
|
||||
|
||||
```shell
|
||||
doxygen docs/doxygen/config.doxyfile
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for information on contributing.
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3"><center><b>Code Size of cellularLibrary (example generated with GCC for ARM Cortex-M)</b></center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>File</b></td>
|
||||
<td><b><center>With -O1 Optimization</center></b></td>
|
||||
<td><b><center>With -Os Optimization</center></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_3gpp_api.c</td>
|
||||
<td><center>6.4K</center></td>
|
||||
<td><center>5.9K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_3gpp_urc_handler.c</td>
|
||||
<td><center>0.9K</center></td>
|
||||
<td><center>0.8K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_at_core.c</td>
|
||||
<td><center>1.4K</center></td>
|
||||
<td><center>1.2K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_common_api.c</td>
|
||||
<td><center>0.7K</center></td>
|
||||
<td><center>0.6K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_common.c</td>
|
||||
<td><center>1.7K</center></td>
|
||||
<td><center>1.5K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_pkthandler.c</td>
|
||||
<td><center>1.7K</center></td>
|
||||
<td><center>1.6K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellular_pktio.c</td>
|
||||
<td><center>2.0K</center></td>
|
||||
<td><center>1.8K</center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Total estimates</b></td>
|
||||
<td><b><center>14.8K</center></b></td>
|
||||
<td><b><center>13.4K</center></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -0,0 +1,228 @@
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.8.20 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title=""/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<!-- Hide the default "Data Structures" tab and use the "Modules" tab for data
|
||||
structures. This allows internal data structures to be hidden. -->
|
||||
<tab type="modules" visible="yes" title="Data types and Constants" intro="This library defines the following data types and constants."/>
|
||||
<tab type="namespaces" visible="yes" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="interfaces" visible="no" title="">
|
||||
<tab type="interfacelist" visible="no" title="" intro=""/>
|
||||
<tab type="interfaceindex" visible="no" title=""/>
|
||||
<tab type="interfacehierarchy" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classes" visible="no" title="">
|
||||
<tab type="classlist" visible="no" title="" intro=""/>
|
||||
<tab type="classindex" visible="no" title=""/>
|
||||
<tab type="hierarchy" visible="no" title="" intro=""/>
|
||||
<tab type="classmembers" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="structs" visible="no" title="">
|
||||
<tab type="structlist" visible="no" title="" intro=""/>
|
||||
<tab type="structindex" visible="no" title=""/>
|
||||
</tab>
|
||||
<tab type="exceptions" visible="no" title="">
|
||||
<tab type="exceptionlist" visible="no" title="" intro=""/>
|
||||
<tab type="exceptionindex" visible="no" title=""/>
|
||||
<tab type="exceptionhierarchy" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="files" visible="no" title="">
|
||||
<tab type="filelist" visible="yes" title="Files" intro="The following files are associated with this library."/>
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<interfaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<structs visible="yes" title=""/>
|
||||
<exceptions visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<interfaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<structs visible="yes" title=""/>
|
||||
<exceptions visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title=""/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<sequences title=""/>
|
||||
<dictionaries title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
@ -0,0 +1,421 @@
|
||||
/**
|
||||
@mainpage Overview
|
||||
@anchor cellular
|
||||
@brief FreeRTOS Cellular library
|
||||
|
||||
FreeRTOS Cellular Library use communication interface to communicate with cellular modules to provide cellular network connectivity.
|
||||
|
||||
<b>FreeRTOS Cellular Library</b>
|
||||
- <b>Repository structure</b><br>
|
||||
This library contains the following three components in three folders.
|
||||
| FreeRTOS Cellular Library folders | High Level Description |
|
||||
| :--------------------| :--------------------- |
|
||||
| source | Reusable common code that implements the standard AT commands defined by 3GPP TS v27.007. |
|
||||
| docs | Documentations. |
|
||||
| test | Unit test and cbmc. |
|
||||
| tools | tools for Coverity static analysis and CMock. |
|
||||
|
||||
- <b>Supported cellular modules</b><br>
|
||||
Three cellular modules are supported in this library.
|
||||
| Cellular module |
|
||||
| :--------------------|
|
||||
| [Quectel BG96](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96) |
|
||||
| [Sierra HL7802](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Sierra-Wireless-HL7802) |
|
||||
| [Ublox SARA R4 series](https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4) |
|
||||
New cellular module can reference these module porting to be integrated into FreeRTOS Cellular Library.<br>
|
||||
Please reference [Porting module Guide](https://www.freertos.org/Documentation/api-ref/cellular/cellular_porting_module_guide.html) document for detail information about porting new cellular module.
|
||||
- <b>Currently Supported Features in FreeRTOS Cellular Library</b>
|
||||
- User of FreeRTOS Cellular Library is able to use Cat-M1 cellular technology to connect to network.
|
||||
- User of FreeRTOS Cellular Library is able to perform control plane operations like (initialize modem, register on a network etc.) in a vendor agnostic way.
|
||||
- User of FreeRTOS Cellular Library is able to send and receive data using TCP/IP in a vendor agnostic way given that TCP/IP stack is running on the cellular modem.
|
||||
- User of FreeRTOS Cellular Library is able to put the modem in different low power modes (PSM and eDRX) in a vendor agnostic way.
|
||||
- User of FreeRTOS Cellular Library is able to receive asynchronous notifications about various events like "disconnected", "signal strength changed" etc. to enable them to take appropriate action as desired.
|
||||
- User of FreeRTOS Cellular Library is able to use the existing application protocol clients (MQTT, HTTP) over cellular seamlessly. i.e. any existing user application using MQTT which works over WiFi/Ethernet shall work over Cellular given the underlying cellular technology permits that.<br>
|
||||
|
||||
|
||||
@section cellular_memory_requirements Memory Requirements
|
||||
@brief Memory requirements of the Cellular library.
|
||||
|
||||
@include{doc} size_table.md
|
||||
*/
|
||||
|
||||
/**
|
||||
@page Design
|
||||
|
||||
@section FreeRTOS_Cellular_Library_Design Cellular Interface Design
|
||||
|
||||
FreeRTOS Cellular Library uses communication interface to communicate with cellular modules.<br>
|
||||
Users of FreeRTOS Cellular Library should create a instance of CellularCommInterface and pass it
|
||||
to Cellular_Init function as paremeters.
|
||||
|
||||
\image html comm_interaction.png "Cellular library interacts with comm interface" width=800px
|
||||
|
||||
The following communication interface implementation can be used as reference.
|
||||
- <a href="https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/pc/boards/windows/ports/comm_if/comm_if_windows.c">FreeRTOS windows simulator comm interface </a>
|
||||
- <a href="https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/st/boards/stm32l475_discovery/ports/comm_if/comm_if_st.c"> STM32 L475 discovery board comm interface </a>
|
||||
- <a href="https://github.com/aws/amazon-freertos/blob/feature/cellular/vendors/sierra/boards/sensorhub/ports/comm_if/comm_if_sierra.c"> Sierra sensorhub board comm interface </a>
|
||||
<b></b>
|
||||
|
||||
@section cellular_socket_api_desing Cellular Socket API Design
|
||||
|
||||
FreeRTOS Cellular Interface offloads the TCP/IP stacks to cellular module. The implementation
|
||||
of the socket APIs use module specific AT commands. Cellular socket APIs abstract the differences
|
||||
between different cellular module. The following are cellular socket APIs:
|
||||
- @function_name{Cellular_CreateSocket}
|
||||
- @function_name{Cellular_SocketSetSockOpt}
|
||||
- @function_name{Cellular_SocketSend}
|
||||
- @function_name{Cellular_SocketRecv}
|
||||
- @function_name{Cellular_SocketClose}
|
||||
- @function_name{Cellular_GetHostByName}
|
||||
- @function_name{Cellular_SocketRegisterDataReadyCallback}
|
||||
- @function_name{Cellular_SocketRegisterClosedCallback}
|
||||
- @function_name{Cellular_SocketRegisterSocketOpenCallback}
|
||||
|
||||
Cellular socket APIs and cellular modem events change cellular socket state.
|
||||
See the below graph for the socket state transitions:
|
||||
@image html cellular_socket_state.png width=70%
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_config Configurations
|
||||
@brief Configurations of the Cellular Library.
|
||||
|
||||
Some configuration settings are C pre-processor constants, and some are function-like macros for logging. They can be set with a `#define` in the config file (**cellular_config.h**) or by using a compiler option such as -D in gcc.
|
||||
|
||||
@section CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
@copydoc CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
|
||||
@section CELLULAR_MCC_MAX_SIZE
|
||||
@copydoc CELLULAR_MCC_MAX_SIZE
|
||||
|
||||
@section CELLULAR_MNC_MAX_SIZE
|
||||
@copydoc CELLULAR_MNC_MAX_SIZE
|
||||
|
||||
@section CELLULAR_ICCID_MAX_SIZE
|
||||
@copydoc CELLULAR_ICCID_MAX_SIZE
|
||||
|
||||
@section CELLULAR_IMSI_MAX_SIZE
|
||||
@copydoc CELLULAR_IMSI_MAX_SIZE
|
||||
|
||||
@section CELLULAR_FW_VERSION_MAX_SIZE
|
||||
@copydoc CELLULAR_FW_VERSION_MAX_SIZE
|
||||
|
||||
@section CELLULAR_HW_VERSION_MAX_SIZE
|
||||
@copydoc CELLULAR_HW_VERSION_MAX_SIZE
|
||||
|
||||
@section CELLULAR_SERIAL_NUM_MAX_SIZE
|
||||
@copydoc CELLULAR_SERIAL_NUM_MAX_SIZE
|
||||
|
||||
@section CELLULAR_IMEI_MAX_SIZE
|
||||
@copydoc CELLULAR_IMEI_MAX_SIZE
|
||||
|
||||
@section CELLULAR_NETWORK_NAME_MAX_SIZE
|
||||
@copydoc CELLULAR_NETWORK_NAME_MAX_SIZE
|
||||
|
||||
@section CELLULAR_APN_MAX_SIZE
|
||||
@copydoc CELLULAR_APN_MAX_SIZE
|
||||
|
||||
@section CELLULAR_PDN_USERNAME_MAX_SIZE
|
||||
@copydoc CELLULAR_PDN_USERNAME_MAX_SIZE
|
||||
|
||||
@section CELLULAR_PDN_PASSWORD_MAX_SIZE
|
||||
@copydoc CELLULAR_PDN_PASSWORD_MAX_SIZE
|
||||
|
||||
@section CELLULAR_IP_ADDRESS_MAX_SIZE
|
||||
@copydoc CELLULAR_IP_ADDRESS_MAX_SIZE
|
||||
|
||||
@section CELLULAR_AT_CMD_MAX_SIZE
|
||||
@copydoc CELLULAR_AT_CMD_MAX_SIZE
|
||||
|
||||
@section CELLULAR_NUM_SOCKET_MAX
|
||||
@copydoc CELLULAR_NUM_SOCKET_MAX
|
||||
|
||||
@section CELLULAR_MANUFACTURE_ID_MAX_SIZE
|
||||
@copydoc CELLULAR_MANUFACTURE_ID_MAX_SIZE
|
||||
|
||||
@section CELLULAR_MODEL_ID_MAX_SIZE
|
||||
@copydoc CELLULAR_MODEL_ID_MAX_SIZE
|
||||
|
||||
@section CELLULAR_EDRX_LIST_MAX_SIZE
|
||||
@copydoc CELLULAR_EDRX_LIST_MAX_SIZE
|
||||
|
||||
@section CELLULAR_PDN_CONTEXT_ID_MIN
|
||||
@copydoc CELLULAR_PDN_CONTEXT_ID_MIN
|
||||
|
||||
@section CELLULAR_PDN_CONTEXT_ID_MAX
|
||||
@copydoc CELLULAR_PDN_CONTEXT_ID_MAX
|
||||
|
||||
@section CELLULAR_MAX_RAT_PRIORITY_COUNT
|
||||
@copydoc CELLULAR_MAX_RAT_PRIORITY_COUNT
|
||||
|
||||
@section CELLULAR_MAX_SEND_DATA_LEN
|
||||
@copydoc CELLULAR_MAX_SEND_DATA_LEN
|
||||
|
||||
@section CELLULAR_MAX_RECV_DATA_LEN
|
||||
@copydoc CELLULAR_MAX_RECV_DATA_LEN
|
||||
|
||||
@section CELLULAR_SUPPORT_GETHOSTBYNAME
|
||||
@copydoc CELLULAR_SUPPORT_GETHOSTBYNAME
|
||||
|
||||
@section CELLULAR_COMM_IF_SEND_TIMEOUT_MS
|
||||
@copydoc CELLULAR_COMM_IF_SEND_TIMEOUT_MS
|
||||
|
||||
@section CELLULAR_COMM_IF_RECV_TIMEOUT_MS
|
||||
@copydoc CELLULAR_COMM_IF_RECV_TIMEOUT_MS
|
||||
|
||||
@section CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT
|
||||
@copydoc CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT
|
||||
|
||||
@section CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION
|
||||
@copydoc CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION
|
||||
|
||||
@section CELLULAR_CONFIG_DEFAULT_RAT
|
||||
@copydoc CELLULAR_CONFIG_DEFAULT_RAT
|
||||
|
||||
@section CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION
|
||||
@copydoc CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION
|
||||
|
||||
@section cellular_logerror LogError
|
||||
@copydoc LogError
|
||||
|
||||
@section cellular_logwarn LogWarn
|
||||
@copydoc LogWarn
|
||||
|
||||
@section cellular_loginfo LogInfo
|
||||
@copydoc LogInfo
|
||||
|
||||
@section cellular_logdebug LogDebug
|
||||
@copydoc LogDebug
|
||||
|
||||
@section CELLULAR_MODEM_NO_EPS_NETWORK
|
||||
@brief Macro to disable querying evolved packet system (EPS) network registration status in Cellular_CommonGetServiceStatus.<br>
|
||||
@note Cellular modem porting can define this macro in cellular_config.h to disable this function.<br>
|
||||
|
||||
<b>Default value:</b> undefined
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@functions_page{cellular,cellular}
|
||||
@functions_brief{cellular}
|
||||
|
||||
<b>Control plane APIs</b>
|
||||
|
||||
- @function_name{Cellular_Init}
|
||||
@function_brief{Cellular_Init}
|
||||
- @function_name{Cellular_Cleanup}
|
||||
@function_brief{Cellular_Cleanup}
|
||||
- @function_name{Cellular_SetRatPriority}
|
||||
@function_brief{Cellular_SetRatPriority}
|
||||
- @function_name{Cellular_GetRatPriority}
|
||||
@function_brief{Cellular_GetRatPriority}
|
||||
- @function_name{Cellular_RfOn}
|
||||
@function_brief{Cellular_RfOn}
|
||||
- @function_name{Cellular_RfOff}
|
||||
@function_brief{Cellular_RfOff}
|
||||
|
||||
<b>Hardware info</b>
|
||||
|
||||
- @function_name{Cellular_GetSimCardStatus}
|
||||
@function_brief{Cellular_GetSimCardStatus}
|
||||
- @function_name{Cellular_GetSimCardInfo}
|
||||
@function_brief{Cellular_GetSimCardInfo}
|
||||
- @function_name{Cellular_GetModemInfo}
|
||||
@function_brief{Cellular_GetModemInfo}
|
||||
|
||||
<b>Network registration</b>
|
||||
|
||||
- @function_name{Cellular_GetRegisteredNetwork}
|
||||
@function_brief{Cellular_GetRegisteredNetwork}
|
||||
- @function_name{Cellular_GetNetworkTime}
|
||||
@function_brief{Cellular_GetNetworkTime}
|
||||
- @function_name{Cellular_GetSignalInfo}
|
||||
@function_brief{Cellular_GetSignalInfo}
|
||||
- @function_name{Cellular_GetServiceStatus}
|
||||
@function_brief{Cellular_GetServiceStatus}
|
||||
|
||||
<b>Enable data network</b>
|
||||
|
||||
- @function_name{Cellular_SetPdnConfig}
|
||||
@function_brief{Cellular_SetPdnConfig}
|
||||
- @function_name{Cellular_GetPdnStatus}
|
||||
@function_brief{Cellular_GetPdnStatus}
|
||||
- @function_name{Cellular_ActivatePdn}
|
||||
@function_brief{Cellular_ActivatePdn}
|
||||
- @function_name{Cellular_DeactivatePdn}
|
||||
@function_brief{Cellular_DeactivatePdn}
|
||||
- @function_name{Cellular_GetIPAddress}
|
||||
@function_brief{Cellular_GetIPAddress}
|
||||
- @function_name{Cellular_SetDns}
|
||||
@function_brief{Cellular_SetDns}
|
||||
|
||||
<b>Device and network status callback functions</b>
|
||||
|
||||
- @function_name{Cellular_RegisterUrcNetworkRegistrationEventCallback}
|
||||
@function_brief{Cellular_RegisterUrcNetworkRegistrationEventCallback}
|
||||
- @function_name{Cellular_RegisterUrcPdnEventCallback}
|
||||
@function_brief{Cellular_RegisterUrcPdnEventCallback}
|
||||
- @function_name{Cellular_RegisterUrcSignalStrengthChangedCallback}
|
||||
@function_brief{Cellular_RegisterUrcSignalStrengthChangedCallback}
|
||||
- @function_name{Cellular_RegisterModemEventCallback}
|
||||
@function_brief{Cellular_RegisterModemEventCallback}
|
||||
- @function_name{Cellular_RegisterUrcGenericCallback}
|
||||
@function_brief{Cellular_RegisterUrcGenericCallback}
|
||||
|
||||
<b>Power saveing modes</b>
|
||||
|
||||
- @function_name{Cellular_GetPsmSettings}
|
||||
@function_brief{Cellular_GetPsmSettings}
|
||||
- @function_name{Cellular_SetPsmSettings}
|
||||
@function_brief{Cellular_SetPsmSettings}
|
||||
- @function_name{Cellular_GetEidrxSettings}
|
||||
@function_brief{Cellular_GetEidrxSettings}
|
||||
- @function_name{Cellular_SetEidrxSettings}
|
||||
@function_brief{Cellular_SetEidrxSettings}
|
||||
|
||||
<b>Custom AT command</b>
|
||||
|
||||
- @function_name{Cellular_ATCommandRaw}
|
||||
@function_brief{Cellular_ATCommandRaw}
|
||||
|
||||
<b>Data plan APIs</b>
|
||||
|
||||
- @function_name{Cellular_CreateSocket}
|
||||
@function_brief{Cellular_CreateSocket}
|
||||
- @function_name{Cellular_SocketConnect}
|
||||
@function_brief{Cellular_SocketConnect}
|
||||
- @function_name{Cellular_SocketSend}
|
||||
@function_brief{Cellular_SocketSend}
|
||||
- @function_name{Cellular_SocketRecv}
|
||||
@function_brief{Cellular_SocketRecv}
|
||||
- @function_name{Cellular_SocketClose}
|
||||
@function_brief{Cellular_SocketClose}
|
||||
- @function_name{Cellular_GetHostByName}
|
||||
@function_brief{Cellular_GetHostByName}
|
||||
- @function_name{Cellular_SocketSetSockOpt}
|
||||
@function_brief{Cellular_SocketSetSockOpt}
|
||||
- @function_name{Cellular_SocketRegisterSocketOpenCallback}
|
||||
@function_brief{Cellular_SocketRegisterSocketOpenCallback}
|
||||
- @function_name{Cellular_SocketRegisterDataReadyCallback}
|
||||
@function_brief{Cellular_SocketRegisterDataReadyCallback}
|
||||
- @function_name{Cellular_SocketRegisterClosedCallback}
|
||||
@function_brief{Cellular_SocketRegisterClosedCallback}
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_porting Porting Guide
|
||||
@brief Guide for porting Cellular library to a new platform.
|
||||
|
||||
To use the Cellular library, a platform must implement the following components:
|
||||
1. [Configuration Macros](@ref cellular_porting_config)
|
||||
2. [Cellular Communication Interface](@ref cellular_porting_comm_if)
|
||||
3. [Cellular platform dependency](@ref cellular_platform_dependency)
|
||||
|
||||
@section cellular_porting_config Configuration Macros
|
||||
@brief Settings that must be set as macros in the config header `cellular_config.h`, or passed in as compiler options.
|
||||
|
||||
@note If a custom configuration header `cellular_config.h` is not provided, then the @ref CELLULAR_DO_NOT_USE_CUSTOM_CONFIG macro must be defined.
|
||||
|
||||
@see [Configurations](@ref cellular_config)
|
||||
|
||||
In addition, the following logging macros are used throughout the library:
|
||||
- @ref LogError
|
||||
- @ref LogWarn
|
||||
- @ref LogInfo
|
||||
- @ref LogDebug
|
||||
|
||||
@section cellular_porting_comm_if Cellular Communication Interface
|
||||
@brief FreeRTOS Cellular Library use communication interface to communicate with cellular modules.
|
||||
|
||||
CellularCommInterface includes the following four function pointers.
|
||||
Reference the document page for prototype.
|
||||
- @subpage CellularCommInterfaceOpen_t
|
||||
@copybrief CellularCommInterfaceOpen_t
|
||||
- @subpage CellularCommInterfaceSend_t
|
||||
@copybrief CellularCommInterfaceSend_t
|
||||
- @subpage CellularCommInterfaceRecv_t
|
||||
@copybrief CellularCommInterfaceRecv_t
|
||||
- @subpage CellularCommInterfaceClose_t
|
||||
@copybrief CellularCommInterfaceClose_t
|
||||
|
||||
@section cellular_platform_dependency Cellular platform dependency
|
||||
@brief Cellular platform depndency
|
||||
|
||||
FreeRTOS Cellular Library makes use of the following OS platform functions.<br>
|
||||
<b>"cellular_platform.h"</b> is referenced during FreeRTOS Cellular Library compilation.<br>
|
||||
User of FreeRTOS Cellular Library should provide these APIs and data structures in "cellular_platform.h".<br>
|
||||
A default implementation with FreeRTOS is provided in FreeRTOS Labs cellular demo.
|
||||
- <b>Threads</b><br>The following APIs and macros should be provided in cellular_platform.h
|
||||
```
|
||||
|
||||
bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * ),
|
||||
void * pArgument,
|
||||
int32_t priority,
|
||||
size_t stackSize );
|
||||
|
||||
#define PLATFORM_THREAD_DEFAULT_STACK_SIZE ( 2048U )
|
||||
#define PLATFORM_THREAD_DEFAULT_PRIORITY ( 5U )
|
||||
```
|
||||
- <b>Mutex</b><br>The following APIs and data structure should be provided in cellular_platform.h.<br>
|
||||
FreeRTOS Cellular Library use static mutex allocation. Data fields in PlatformMutex can be defined by developers.
|
||||
```
|
||||
typedef struct PlatformMutex
|
||||
{
|
||||
...
|
||||
} PlatformMutex_t;
|
||||
|
||||
bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
|
||||
bool recursive );
|
||||
void PlatformMutex_Destroy( PlatformMutex_t * pMutex );
|
||||
void PlatformMutex_Lock( PlatformMutex_t * pMutex );
|
||||
bool PlatformMutex_TryLock( PlatformMutex_t * pMutex );
|
||||
void PlatformMutex_Unlock( PlatformMutex_t * pMutex );
|
||||
```
|
||||
- <b>Memory</b><br>The following malloc/free style APIs should be provided in cellular_platform.h.<br>
|
||||
The <a href="https://www.freertos.org/a00111.html">FreeRTOS memory management document</a> can be referenced for these APIs.
|
||||
```
|
||||
// Example implementation of FreeRTOS malloc/free
|
||||
#define Platform_Malloc pvPortMalloc
|
||||
#define Platform_Free vPortFree
|
||||
```
|
||||
- <b>EventGroup</b><br>The following APIs and handle should be provided in cellular_platform.h.<br>
|
||||
Please reference <a href="https://www.freertos.org/event-groups-API.html">FreeRTOS EvengGroup function prototypes</a>.
|
||||
```
|
||||
// Example implementation of FreeRTOS EvengGroup
|
||||
#define PlatformEventGroupHandle_t EventGroupHandle_t
|
||||
#define PlatformEventGroup_Delete vEventGroupDelete
|
||||
#define PlatformEventGroup_ClearBits xEventGroupClearBits
|
||||
#define PlatformEventGroup_Create xEventGroupCreate
|
||||
#define PlatformEventGroup_GetBits xEventGroupGetBits
|
||||
#define PlatformEventGroup_SetBits xEventGroupSetBits
|
||||
#define PlatformEventGroup_SetBitsFromISR xEventGroupSetBitsFromISR
|
||||
#define PlatformEventGroup_WaitBits xEventGroupWaitBits
|
||||
|
||||
```
|
||||
- <b>Delay</b><br>The following API should be provided in cellular_platform.h.<br>
|
||||
Please reference <a href="https://www.freertos.org/a00127.html">FreeRTOS Task Control function prototypes</a>.
|
||||
```
|
||||
// Example implementation of FreeRTOS Task Control
|
||||
#define Platform_Delay( delayMs ) vTaskDelay( pdMS_TO_TICKS( delayMs ) )
|
||||
```
|
||||
*/
|
||||
|
||||
/**
|
||||
* @paramstructs_group{cellular,Cellular}
|
||||
* @paramstructs_brief{cellular,cellular}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @handles_group{cellular,Cellular}
|
||||
* @handles_brief{cellular library}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @functionpointers_group{cellular,Cellular}
|
||||
* @functionpointers_brief{cellular library}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @enums_group{cellular,Cellular}
|
||||
* @enums_brief{cellular library}
|
||||
*/
|
||||
@ -0,0 +1,338 @@
|
||||
/**
|
||||
@page cellular_porting_module_guide Porting Module Guide
|
||||
@brief FreeRTOS Cellular Common Library<br>
|
||||
|
||||
|
||||
FreeRTOS Cellular Common Library provides the following functions to help cellular module implementing FreeRTOS Cellular Library APIs.<br>
|
||||
- FreeRTOS Cellular Library APIs implementation with 3GPP TS v27.007 AT commands.
|
||||
- AT command functions to help implementing FreeRTOS Cellular Library APIs with vendor specific AT commands.
|
||||
<br>
|
||||
|
||||
The following diagram illustrates the relation between cellular common and cellular module porting.<br>
|
||||
Reference @subpage porting_cellular_module for detail porting information and implemented @subpage cellular_common_functions.
|
||||
@image html cellular_common_module.png width=70%
|
||||
<br>
|
||||
*/
|
||||
|
||||
/**
|
||||
@page porting_cellular_module Porting cellular module
|
||||
@brief Introduction to cellular module porting<br>
|
||||
|
||||
Cellular common library provides APIS and URC handler implemented with 3GPP v27.007 AT commands.<br>
|
||||
These APIs and URC handler can be reused when porting cellular module. <br>
|
||||
Reference the following pages for detail information.
|
||||
- @subpage cellular_common_APIs
|
||||
- @subpage cellular_common_URC_handlers
|
||||
|
||||
Porting cellular module with cellular common portable with the following steps.<br>
|
||||
-# <b>Create a folder in modules with the following files. </b>
|
||||
- modules/(module_name)/cellular_(module_name).c
|
||||
- modules/(module_name)/cellular_(module_name)_api.c
|
||||
- modules/(module_name)/cellular_(module_name)_urc_handler.c
|
||||
- modules/(module_name)/cellular_(module_name)_wrapper.c
|
||||
-# <b>Implement cellular module porting interface @ref cellular_common_portable.h in cellular_(module_name).c </b><br>
|
||||
Reference @subpage cellular_module for detail information.
|
||||
-# <b>Implement FreeRTOS Cellular Library API with cellular module specific AT commands in cellular_(module_name)_api.c </b><br>
|
||||
Reference @subpage cellular_module_api for detail information.
|
||||
-# <b>Implement URC handler to handle URC event and call the corresponding callback function in cellular_(module_name)_urc_handler.c </b><br>
|
||||
Reference @subpage cellular_module_urc_handler for detail information.
|
||||
-# <b>Create FreeRTOS Cellular Library APIs implemented with 3GPP TS v27.007 AT commands ( @ref cellular_common_api.h ) in cellular_(module_name)_wrapper.c</b><br>
|
||||
|
||||
<b>Cellular module porting examples</b><br>
|
||||
Three cellular module portings can be referenced.<br>
|
||||
It is recommended that you start by cloning the implementation of one of the existing modems,<br>
|
||||
then make modifications where your modem's vendor-specific (non-3GPP) AT commands are different. <br>
|
||||
- <a href="https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96">BG96</a>
|
||||
- <a href="https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Sierra-Wireless-HL7802">HL7802</a>
|
||||
- <a href="https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4">SARA R4 series</a>
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_common_APIs Cellular common APIs
|
||||
@brief Cellular common supported APIs
|
||||
|
||||
<b>Cellular common supported APIs</b><br>
|
||||
Cellular common library has 3GPP AT command implemented APIs.<br>
|
||||
They can be used to minimize porting efforts when implement FreeRTOS Cellular Library APIs.<br>
|
||||
| FreeRTOS Cellular Library APIs | Cellular common supported |
|
||||
| :-------------------------------------------------------| :-----------------------: |
|
||||
| Cellular_Init | O |
|
||||
| Cellular_Cleanup | O |
|
||||
| Cellular_SetRatPriority | |
|
||||
| Cellular_GetRatPriority | |
|
||||
| Cellular_RfOn | O |
|
||||
| Cellular_RfOff | O |
|
||||
| Cellular_GetSimCardStatus | |
|
||||
| Cellular_GetSimCardInfo | O |
|
||||
| Cellular_GetModemInfo | O |
|
||||
| Cellular_GetRegisteredNetwork | O |
|
||||
| Cellular_GetNetworkTime | O |
|
||||
| Cellular_GetSignalInfo | |
|
||||
| Cellular_GetServiceStatus | O |
|
||||
| Cellular_SetPdnConfig | O |
|
||||
| Cellular_GetPdnStatus | |
|
||||
| Cellular_ActivatePdn | |
|
||||
| Cellular_DeactivatePdn | |
|
||||
| Cellular_GetIPAddress | O |
|
||||
| Cellular_SetDns | |
|
||||
| Cellular_RegisterUrcNetworkRegistrationEventCallback | O |
|
||||
| Cellular_RegisterUrcPdnEventCallback | O |
|
||||
| Cellular_RegisterUrcSignalStrengthChangedCallback | |
|
||||
| Cellular_RegisterModemEventCallback | O |
|
||||
| Cellular_RegisterUrcGenericCallback | O |
|
||||
| Cellular_GetPsmSettings | O |
|
||||
| Cellular_SetPsmSettings | O |
|
||||
| Cellular_GetEidrxSettings | O |
|
||||
| Cellular_SetEidrxSettings | O |
|
||||
| Cellular_ATCommandRaw | O |
|
||||
| Cellular_CreateSocket | O |
|
||||
| Cellular_SocketConnect | |
|
||||
| Cellular_SocketSend | |
|
||||
| Cellular_SocketRecv | |
|
||||
| Cellular_SocketClose | |
|
||||
| Cellular_GetHostByName | |
|
||||
| Cellular_SocketSetSockOpt | O |
|
||||
| Cellular_SocketRegisterSocketOpenCallback | O |
|
||||
| Cellular_SocketRegisterDataReadyCallback | O |
|
||||
| Cellular_SocketRegisterClosedCallback | O |
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_common_URC_handlers Cellular common URC handlers
|
||||
@brief Cellular common supported URC handlers
|
||||
|
||||
<b>Cellular common supported URC handler</b><br>
|
||||
FreeRTOS Cellular Library APIs callback function is called in URC handler. <br>
|
||||
3GPP URC handlers are also provided by cellular common library. <br>
|
||||
They can be used to reduce porting effort. <br>
|
||||
| FreeRTOS Cellular Library callback functions | Event | Cellular common supported |
|
||||
| :----------------------------------------------------| :----------------------------------------- | :-----------------------: |
|
||||
| Cellular_RegisterUrcNetworkRegistrationEventCallback | CELLULAR_URC_EVENT_NETWORK_CS_REGISTRATION | O |
|
||||
| Cellular_RegisterUrcNetworkRegistrationEventCallback | CELLULAR_URC_EVENT_NETWORK_PS_REGISTRATION | O |
|
||||
| Cellular_RegisterUrcPdnEventCallback | CELLULAR_URC_EVENT_PDN_ACTIVATED | |
|
||||
| Cellular_RegisterUrcPdnEventCallback | CELLULAR_URC_EVENT_PDN_DEACTIVATED | |
|
||||
| Cellular_RegisterUrcSignalStrengthChangedCallback | CELLULAR_URC_EVENT_SIGNAL_CHANGED | |
|
||||
| Cellular_RegisterModemEventCallback | CELLULAR_MODEM_EVENT_BOOTUP_OR_REBOOT | |
|
||||
| Cellular_RegisterModemEventCallback | CELLULAR_MODEM_EVENT_POWERED_DOWN | |
|
||||
| Cellular_RegisterModemEventCallback | CELLULAR_MODEM_EVENT_PSM_ENTER | |
|
||||
| Cellular_SocketRegisterSocketOpenCallback | CELLULAR_URC_SOCKET_OPENED | |
|
||||
| Cellular_SocketRegisterSocketOpenCallback | CELLULAR_URC_SOCKET_OPEN_FAILED | |
|
||||
| Cellular_SocketRegisterDataReadyCallback | None | |
|
||||
| Cellular_SocketRegisterClosedCallback | None | |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_module cellular_module
|
||||
@brief Implement cellular module porting interface. <br>
|
||||
- Implement functions defined cellular_common_portable.h
|
||||
- @ref Cellular_ModuleInit
|
||||
- @ref Cellular_ModuleCleanUp
|
||||
- @ref Cellular_ModuleEnableUE
|
||||
- @ref Cellular_ModuleEnableUrc
|
||||
@image html cellular_module_porting_functions.png width=80%
|
||||
- Create variable instance defined in cellular_common_portable.h
|
||||
- AT command response token tables.
|
||||
- \ref CellularTokenTable_t.pCellularSrcTokenErrorTable : indicate AT command is success
|
||||
- @ref CellularTokenTable_t.cellularSrcTokenErrorTableSize
|
||||
- @ref CellularTokenTable_t.pCellularSrcTokenSuccessTable : indicat AT command fails
|
||||
- @ref CellularTokenTable_t.cellularSrcTokenSuccessTableSize
|
||||
- URC handler table
|
||||
- @ref CellularTokenTable_t.pCellularUrcTokenWoPrefixTable : URC token without prefix "+". These tokens are used in URC handler tables.<br>
|
||||
( E.X "APP READY", "POWER ON" )
|
||||
- @ref CellularTokenTable_t.cellularUrcTokenWoPrefixTableSize
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_module_api cellular_module_api
|
||||
@brief Implement FreeRTOS Cellular Library API with cellular module specific AT commands. <br>
|
||||
- Create FreeRTOS Cellular Library APIs implemented with module specific AT commands with cellular_common.h and cellular_at_core.h
|
||||
- AT command related data structure
|
||||
- @ref CellularAtReq_t : AT command request data structure
|
||||
- @ref CellularAtDataReq_t : Data send data structure
|
||||
- Send AT command APIs
|
||||
- @ref _Cellular_AtcmdRequestWithCallback : Default timeout
|
||||
- @ref _Cellular_TimeoutAtcmdRequestWithCallback : Custom timeout
|
||||
- Send AT command APIs for data receive ( E.X socket data receive )
|
||||
- @ref _Cellular_TimeoutAtcmdDataRecvRequestWithCallback
|
||||
- Send AT command APIS for data send ( E.X socket data send )
|
||||
- @ref _Cellular_TimeoutAtcmdDataSendRequestWithCallback : Basic data send API
|
||||
- @ref _Cellular_AtcmdDataSend : Prefix callback function to indicate data mode start
|
||||
- @ref _Cellular_TimeoutAtcmdDataSendSuccessToken : Extra success token to indicate AT commnad success
|
||||
@image html cellular_API_implementation.png width=80%
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@page cellular_module_urc_handler cellular_module_urc_handler
|
||||
@brief Implement URC handler to handle URC event and call the corresponding callback function. <br>
|
||||
- @ref CellularTokenTable_t.pCellularUrcHandlerTable : URC handler table of @ref CellularAtParseTokenHandler_t
|
||||
- @ref CellularTokenTable_t.cellularPrefixToParserMapSize
|
||||
Example URC handler table.
|
||||
```
|
||||
CellularAtParseTokenMap_t CellularUrcHandlerTable[] =
|
||||
{
|
||||
{ "CEREG", Cellular_CommonUrcProcessCereg },
|
||||
{ "CGREG", Cellular_CommonUrcProcessCgreg },
|
||||
{ "CREG", Cellular_CommonUrcProcessCreg },
|
||||
{ "NORMAL POWER DOWN", _Cellular_ProcessPowerDown },
|
||||
}
|
||||
uint32_t CellularUrcHandlerTableSize = 4;
|
||||
```
|
||||
@image html cellular_URC_handler_implementation.png width=80%
|
||||
*/
|
||||
|
||||
/**
|
||||
@paramstructs_group{cellular_common,Cellular_common}
|
||||
@paramstructs_brief{cellular_common,cellular_common}
|
||||
*/
|
||||
|
||||
/**
|
||||
@functionpointers_group{cellular_common,Cellular_common}
|
||||
@functionpointers_brief{cellular_common library}
|
||||
*/
|
||||
|
||||
/**
|
||||
@enums_group{cellular_common,Cellular_common}
|
||||
@enums_brief{cellular_common library}
|
||||
*/
|
||||
|
||||
/**
|
||||
@functions_page{cellular_common,cellular_common}
|
||||
@functions_brief{cellular_common}
|
||||
|
||||
<b>The following APIs are 3GPP v27.007 AT command implemented FreeRTOS Cellular Library APIs.</b><br>
|
||||
- @function_name{Cellular_CommonInit}
|
||||
@function_brief{Cellular_CommonInit}
|
||||
- @function_name{Cellular_CommonCleanup}
|
||||
@function_brief{Cellular_CommonCleanup}
|
||||
- @function_name{Cellular_CommonRegisterUrcNetworkRegistrationEventCallback}
|
||||
@function_brief{Cellular_CommonRegisterUrcNetworkRegistrationEventCallback}
|
||||
- @function_name{Cellular_CommonRegisterUrcPdnEventCallback}
|
||||
@function_brief{Cellular_CommonRegisterUrcPdnEventCallback}
|
||||
- @function_name{Cellular_CommonRegisterUrcSignalStrengthChangedCallback}
|
||||
@function_brief{Cellular_CommonRegisterUrcSignalStrengthChangedCallback}
|
||||
- @function_name{Cellular_CommonRegisterUrcGenericCallback}
|
||||
@function_brief{Cellular_CommonRegisterUrcGenericCallback}
|
||||
- @function_name{Cellular_CommonRegisterModemEventCallback}
|
||||
@function_brief{Cellular_CommonRegisterModemEventCallback}
|
||||
- @function_name{Cellular_CommonATCommandRaw}
|
||||
@function_brief{Cellular_CommonATCommandRaw}
|
||||
- @function_name{Cellular_CommonCreateSocket}
|
||||
@function_brief{Cellular_CommonCreateSocket}
|
||||
- @function_name{Cellular_CommonSocketSetSockOpt}
|
||||
@function_brief{Cellular_CommonSocketSetSockOpt}
|
||||
- @function_name{Cellular_CommonSocketRegisterDataReadyCallback}
|
||||
@function_brief{Cellular_CommonSocketRegisterDataReadyCallback}
|
||||
- @function_name{Cellular_CommonSocketRegisterSocketOpenCallback}
|
||||
@function_brief{Cellular_CommonSocketRegisterSocketOpenCallback}
|
||||
- @function_name{Cellular_CommonSocketRegisterClosedCallback}
|
||||
@function_brief{Cellular_CommonSocketRegisterClosedCallback}
|
||||
- @function_name{Cellular_CommonRfOn}
|
||||
@function_brief{Cellular_CommonRfOn}
|
||||
- @function_name{Cellular_CommonRfOff}
|
||||
@function_brief{Cellular_CommonRfOff}
|
||||
- @function_name{Cellular_CommonGetIPAddress}
|
||||
@function_brief{Cellular_CommonGetIPAddress}
|
||||
- @function_name{Cellular_CommonGetModemInfo}
|
||||
@function_brief{Cellular_CommonGetModemInfo}
|
||||
- @function_name{Cellular_CommonGetEidrxSettings}
|
||||
@function_brief{Cellular_CommonGetEidrxSettings}
|
||||
- @function_name{Cellular_CommonSetEidrxSettings}
|
||||
@function_brief{Cellular_CommonSetEidrxSettings}
|
||||
- @function_name{Cellular_CommonGetRegisteredNetwork}
|
||||
@function_brief{Cellular_CommonGetRegisteredNetwork}
|
||||
- @function_name{Cellular_CommonGetNetworkTime}
|
||||
@function_brief{Cellular_CommonGetNetworkTime}
|
||||
- @function_name{Cellular_CommonGetServiceStatus}
|
||||
@function_brief{Cellular_CommonGetServiceStatus}
|
||||
- @function_name{Cellular_CommonSetPdnConfig}
|
||||
@function_brief{Cellular_CommonSetPdnConfig}
|
||||
- @function_name{Cellular_CommonGetPsmSettings}
|
||||
@function_brief{Cellular_CommonGetPsmSettings}
|
||||
- @function_name{Cellular_CommonSetPsmSettings}
|
||||
@function_brief{Cellular_CommonSetPsmSettings}
|
||||
- @function_name{Cellular_CommonGetSimCardInfo}
|
||||
@function_brief{Cellular_CommonGetSimCardInfo}
|
||||
- @function_name{Cellular_CommonGetSimCardLockStatus}
|
||||
@function_brief{Cellular_CommonGetSimCardLockStatus}
|
||||
|
||||
The following APIs can be used when implementating FreeRTOS Cellular Library APIs with module specific AT command.<br>
|
||||
<b>AT command parsing functions</b><br>
|
||||
- @function_name{Cellular_ATRemovePrefix}
|
||||
@function_brief{Cellular_ATRemovePrefix}
|
||||
- @function_name{Cellular_ATRemoveLeadingWhiteSpaces}
|
||||
@function_brief{Cellular_ATRemoveLeadingWhiteSpaces}
|
||||
- @function_name{Cellular_ATRemoveTrailingWhiteSpaces}
|
||||
@function_brief{Cellular_ATRemoveTrailingWhiteSpaces}
|
||||
- @function_name{Cellular_ATRemoveAllWhiteSpaces}
|
||||
@function_brief{Cellular_ATRemoveAllWhiteSpaces}
|
||||
- @function_name{Cellular_ATRemoveOutermostDoubleQuote}
|
||||
@function_brief{Cellular_ATRemoveOutermostDoubleQuote}
|
||||
- @function_name{Cellular_ATRemoveAllDoubleQuote}
|
||||
@function_brief{Cellular_ATRemoveAllDoubleQuote}
|
||||
- @function_name{Cellular_ATGetNextTok}
|
||||
@function_brief{Cellular_ATGetNextTok}
|
||||
- @function_name{Cellular_ATGetSpecificNextTok}
|
||||
@function_brief{Cellular_ATGetSpecificNextTok}
|
||||
- @function_name{Cellular_ATHexStrToHex}
|
||||
@function_brief{Cellular_ATHexStrToHex}
|
||||
- @function_name{Cellular_ATIsStrDigit}
|
||||
@function_brief{Cellular_ATIsStrDigit}
|
||||
- @function_name{Cellular_ATIsPrefixPresent}
|
||||
@function_brief{Cellular_ATIsPrefixPresent}
|
||||
- @function_name{Cellular_ATStrDup}
|
||||
@function_brief{Cellular_ATStrDup}
|
||||
- @function_name{Cellular_ATStrStartWith}
|
||||
@function_brief{Cellular_ATStrStartWith}
|
||||
- @function_name{Cellular_ATcheckErrorCode}
|
||||
@function_brief{Cellular_ATcheckErrorCode}
|
||||
- @function_name{Cellular_ATStrtoi}
|
||||
@function_brief{Cellular_ATStrtoi}
|
||||
|
||||
<b>Cellular common library helper functions</b><br>
|
||||
- @function_name{_Cellular_LibInit}
|
||||
@function_brief{_Cellular_LibInit}
|
||||
- @function_name{_Cellular_LibCleanup}
|
||||
@function_brief{_Cellular_LibCleanup}
|
||||
- @function_name{_Cellular_CheckLibraryStatus}
|
||||
@function_brief{_Cellular_CheckLibraryStatus}
|
||||
- @function_name{_Cellular_TranslatePktStatus}
|
||||
@function_brief{_Cellular_TranslatePktStatus}
|
||||
- @function_name{_Cellular_CreateSocketData}
|
||||
@function_brief{_Cellular_CreateSocketData}
|
||||
- @function_name{_Cellular_RemoveSocketData}
|
||||
@function_brief{_Cellular_RemoveSocketData}
|
||||
- @function_name{_Cellular_IsValidSocket}
|
||||
@function_brief{_Cellular_IsValidSocket}
|
||||
- @function_name{_Cellular_IsValidPdn}
|
||||
@function_brief{_Cellular_IsValidPdn}
|
||||
- @function_name{_Cellular_ConvertCsqSignalRssi}
|
||||
@function_brief{_Cellular_ConvertCsqSignalRssi}
|
||||
- @function_name{_Cellular_ConvertCsqSignalBer}
|
||||
@function_brief{_Cellular_ConvertCsqSignalBer}
|
||||
- @function_name{_Cellular_GetModuleContext}
|
||||
@function_brief{_Cellular_GetModuleContext}
|
||||
- @function_name{_Cellular_ComputeSignalBars}
|
||||
@function_brief{_Cellular_ComputeSignalBars}
|
||||
- @function_name{_Cellular_GetCurrentRat}
|
||||
@function_brief{_Cellular_GetCurrentRat}
|
||||
- @function_name{_Cellular_TranslatePktStatus}
|
||||
@function_brief{_Cellular_TranslatePktStatus}
|
||||
- @function_name{_Cellular_TranslateAtCoreStatus}
|
||||
@function_brief{_Cellular_TranslateAtCoreStatus}
|
||||
- @function_name{_Cellular_AtcmdRequestWithCallback}
|
||||
@function_brief{_Cellular_AtcmdRequestWithCallback}
|
||||
- @function_name{_Cellular_TimeoutAtcmdRequestWithCallback}
|
||||
@function_brief{_Cellular_TimeoutAtcmdRequestWithCallback}
|
||||
- @function_name{_Cellular_TimeoutAtcmdDataRecvRequestWithCallback}
|
||||
@function_brief{_Cellular_TimeoutAtcmdDataRecvRequestWithCallback}
|
||||
- @function_name{_Cellular_TimeoutAtcmdDataSendRequestWithCallback}
|
||||
@function_brief{_Cellular_TimeoutAtcmdDataSendRequestWithCallback}
|
||||
- @function_name{_Cellular_AtcmdDataSend}
|
||||
@function_brief{_Cellular_AtcmdDataSend}
|
||||
- @function_name{_Cellular_TimeoutAtcmdDataSendSuccessToken}
|
||||
@function_brief{_Cellular_TimeoutAtcmdDataSendSuccessToken}
|
||||
|
||||
*/
|
||||
|
||||
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Stylesheet for Doxygen HTML output.
|
||||
*
|
||||
* This file defines styles for custom elements in the header/footer and
|
||||
* overrides some of the default Doxygen styles.
|
||||
*
|
||||
* Styles in this file do not affect the treeview sidebar.
|
||||
*/
|
||||
|
||||
/* Set the margins to place a small amount of whitespace on the left and right
|
||||
* side of the page. */
|
||||
div.contents {
|
||||
margin-left:4em;
|
||||
margin-right:4em;
|
||||
}
|
||||
|
||||
/* Justify text in paragraphs. */
|
||||
p {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
/* Style of section headings. */
|
||||
h1 {
|
||||
border-bottom: 1px solid #879ECB;
|
||||
color: #354C7B;
|
||||
font-size: 160%;
|
||||
font-weight: normal;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
/* Style of subsection headings. */
|
||||
h2:not(.memtitle):not(.groupheader) {
|
||||
font-size: 125%;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 16px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
/* Style of paragraphs immediately after subsection headings. */
|
||||
h2 + p {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
/* Style of subsection headings. */
|
||||
h3 {
|
||||
font-size: 100%;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 2em;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
/* Style of paragraphs immediately after subsubsection headings. */
|
||||
h3 + p {
|
||||
margin-top: 0px;
|
||||
margin-left: 2em;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
/* Style of the prefix "AWS IoT Device SDK C" that appears in the header. */
|
||||
#csdkprefix {
|
||||
color: #757575;
|
||||
}
|
||||
|
||||
/* Style of the "Return to main page" link that appears in the header. */
|
||||
#returntomain {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
/* Style of the dividers on Configuration Settings pages. */
|
||||
div.configpagedivider {
|
||||
margin-left: 0px !important;
|
||||
margin-right: 0px !important;
|
||||
margin-top: 20px !important;
|
||||
}
|
||||
|
||||
/* Style of configuration setting names. */
|
||||
dl.section.user ~ h1 {
|
||||
border-bottom: none;
|
||||
color: #000000;
|
||||
font-family: monospace, fixed;
|
||||
font-size: 16px;
|
||||
margin-bottom: 0px;
|
||||
margin-left: 2em;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
/* Style of paragraphs on a configuration settings page. */
|
||||
dl.section.user ~ * {
|
||||
margin-bottom: 10px;
|
||||
margin-left: 4em;
|
||||
margin-right: 4em;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* Hide the configuration setting marker. */
|
||||
dl.section.user {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Overrides for code fragments and lines. */
|
||||
div.fragment {
|
||||
background: #ffffff;
|
||||
border: none;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
div.line {
|
||||
color: #3a3a3a;
|
||||
}
|
||||
|
||||
/* Overrides for code syntax highlighting colors. */
|
||||
span.comment {
|
||||
color: #008000;
|
||||
}
|
||||
|
||||
span.keyword, span.keywordtype, span.keywordflow {
|
||||
color: #0000ff;
|
||||
}
|
||||
|
||||
span.preprocessor {
|
||||
color: #50015a;
|
||||
}
|
||||
|
||||
span.stringliteral, span.charliteral {
|
||||
color: #800c0c;
|
||||
}
|
||||
|
||||
a.code, a.code:visited, a.line, a.line:visited {
|
||||
color: #496194;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
@startuml
|
||||
|
||||
Title FreeRTOS Cellular Library URC handler implementation
|
||||
|
||||
participant Application
|
||||
participant Cellular_modules_porting
|
||||
participant Cellular_common
|
||||
participant Cellular_modem
|
||||
|
||||
note over Cellular_modules_porting : Create variable CellularUrcHandlerTable\n\nCellularAtParseTokenMap_t CellularUrcHandlerTable[] =\n{\n { "CEREG", Cellular_CommonUrcProcessCereg },\n { "CGREG", Cellular_CommonUrcProcessCgreg },\n { "CREG", Cellular_CommonUrcProcessCreg },\n { "NORMAL POWER DOWN", _Cellular_ProcessPowerDown }\n}\nuint32_t CellularUrcHandlerTableSize = 4;
|
||||
|
||||
Cellular_modem ->Cellular_common : "NORMAL POWER DOWN"
|
||||
|
||||
Cellular_common -> Cellular_modules_porting : Call the callback function\n_Cellular_ProcessPowerDown( pContext, "NORMAL POWER DOWN" )
|
||||
|
||||
Cellular_modules_porting ->Application : Call the callback function registered in\nCellular_RegisterModemEventCallback()
|
||||
|
||||
Cellular_modem ->Cellular_common : "+CREG: 2,0"
|
||||
Cellular_common -> Cellular_common : Call the callback function\nCellular_CommonUrcProcessCreg( pContext, "+CREG: 2,0" )
|
||||
Cellular_common->Application : callback function registered in\nCellular_RegisterUrcNetworkRegistrationEventCallback()
|
||||
|
||||
@enduml
|
||||
@ -0,0 +1,31 @@
|
||||
@startuml
|
||||
|
||||
Title FreeRTOS Cellular Library API implementation
|
||||
|
||||
participant Application
|
||||
participant "FreeRTOS Cellular Library"
|
||||
participant Cellular_modules_porting
|
||||
participant Cellular_common
|
||||
participant Cellular_modem
|
||||
|
||||
Application ->"FreeRTOS Cellular Library" : Cellular_GetSimCardStatus()
|
||||
|
||||
"FreeRTOS Cellular Library"->Cellular_modules_porting :Cellular_GetSimCardStatus()
|
||||
|
||||
Cellular_modules_porting->Cellular_common:Get module context passed in Cellular_ModuleInt() :\n_Cellular_GetModuleContext()
|
||||
|
||||
Cellular_modules_porting->Cellular_modules_porting:Setup AT commnand request:\nCellularAtReq_t = \n{\n pAtCmd = "AT+QSIMSTAT?"\n atCmdType = CELLULAR_AT_WITH_PREFIX\n pAtRspPrefix = "+QSIMSTAT"\n respCallback = _Cellular_RecvFuncGetSimCardStatus\n pData = &simCardState\n dataLen = sizeof( CellularSimCardState_t )\n};\n
|
||||
|
||||
Cellular_modules_porting->Cellular_common:Send AT command with cellular common APIs:\n _Cellular_AtcmdRequestWithCallback( CellularAtReq_t )
|
||||
|
||||
Cellular_common ->Cellular_modem : AT+QSIMSTAT?
|
||||
|
||||
Cellular_modem -> Cellular_common : +QSIMSTAT: ....
|
||||
|
||||
Cellular_modem -> Cellular_common : OK
|
||||
|
||||
Cellular_common ->Cellular_modules_porting : Call the callback function with corresponding data field \n_Cellular_RecvFuncGetSimCardStatus( pData, dataLen )
|
||||
|
||||
Cellular_modules_porting ->Application : Return parsing status and data
|
||||
|
||||
@enduml
|
||||
@ -0,0 +1,35 @@
|
||||
@startuml
|
||||
|
||||
Title FreeRTOS Cellular Library interaction with cellular module porting APIs
|
||||
|
||||
participant Application
|
||||
participant "FreeRTOS Cellular Library"
|
||||
participant Cellular_common
|
||||
participant Cellular_modules_porting
|
||||
|
||||
Application ->"FreeRTOS Cellular Library" : Cellular_Init()
|
||||
|
||||
"FreeRTOS Cellular Library" -> Cellular_common : Cellular_CommonInit()
|
||||
|
||||
Cellular_common -> Cellular_modules_porting : Cellular_moduleInit()
|
||||
|
||||
Cellular_common -> Cellular_modules_porting : Cellular_moduleEnableUE()
|
||||
|
||||
Cellular_common -> Cellular_modules_porting : Cellular_moduleEnableUrc
|
||||
|
||||
Cellular_common --> "FreeRTOS Cellular Library" :
|
||||
|
||||
"FreeRTOS Cellular Library" --> Application :
|
||||
|
||||
|
||||
Application ->"FreeRTOS Cellular Library" : Cellular_CleanUp()
|
||||
|
||||
"FreeRTOS Cellular Library" -> Cellular_common : Cellular_CommonCleanUp()
|
||||
|
||||
Cellular_common -> Cellular_modules_porting : Cellular_moduleCleanUp()
|
||||
|
||||
Cellular_common --> "FreeRTOS Cellular Library" :
|
||||
|
||||
"FreeRTOS Cellular Library" --> Application :
|
||||
|
||||
@enduml
|
||||
@ -0,0 +1,74 @@
|
||||
@startuml
|
||||
|
||||
Title FreeRTOS Cellular Library interaction with com interface
|
||||
|
||||
participant Application
|
||||
participant "FreeRTOS Cellular Library"
|
||||
participant cellular_comm_interface
|
||||
participant cellular_modem
|
||||
|
||||
note over Application : Application needs cellular connecitvity.\nCellular_Init() is called to open FreeRTOS \nCellular Library. Communication interface\n, pCommInterface, is provided by\napplication to "FreeRTOS Cellular Library".
|
||||
|
||||
Application -> "FreeRTOS Cellular Library" : Cellular_Init( pCommInterface )
|
||||
|
||||
activate Application
|
||||
|
||||
"FreeRTOS Cellular Library" ->cellular_comm_interface : pCommInterface->Open( receiveCallback )
|
||||
|
||||
cellular_comm_interface->cellular_modem : Register receive callback\nOpen and setup communication device driver\nPower on and enable device
|
||||
|
||||
cellular_comm_interface-->"FreeRTOS Cellular Library":
|
||||
|
||||
"FreeRTOS Cellular Library"-->Application:
|
||||
|
||||
deactivate Application
|
||||
|
||||
note over Application : "FreeRTOS Cellular Library" APIs ready.\nApplication get network time with\nCellular_GetNetworkTime() function
|
||||
|
||||
Application -> "FreeRTOS Cellular Library" : Cellular_GetNetworkTime()
|
||||
|
||||
activate Application
|
||||
|
||||
"FreeRTOS Cellular Library"->cellular_comm_interface : pCommInterface->Send()
|
||||
|
||||
cellular_comm_interface->cellular_modem : AT+CCLK?
|
||||
|
||||
cellular_modem->cellular_comm_interface : +CCLK: "20/06/09,12:06:33+32"
|
||||
|
||||
cellular_comm_interface->cellular_comm_interface : Store `+CCLK: "20/06/09,12:06:33+32"` in buffer
|
||||
|
||||
cellular_comm_interface->"FreeRTOS Cellular Library" : receiveCallback
|
||||
|
||||
"FreeRTOS Cellular Library"->cellular_comm_interface : pCommInterface->recv()
|
||||
|
||||
cellular_comm_interface-->"FreeRTOS Cellular Library" : Return data in buffer
|
||||
|
||||
cellular_modem->cellular_comm_interface : OK
|
||||
|
||||
cellular_comm_interface->cellular_comm_interface : Store `OK` in buffer
|
||||
|
||||
cellular_comm_interface->"FreeRTOS Cellular Library" : receiveCallback
|
||||
|
||||
cellular_comm_interface-->"FreeRTOS Cellular Library" : Return data in buffer
|
||||
|
||||
"FreeRTOS Cellular Library"->Application : Return network time
|
||||
|
||||
deactivate Application
|
||||
|
||||
note over Application : Applicaton no longer need cellular\nconnectivity. Cellular_Cleanup() is \ncalled to close FreeRTOS Cellular Library.
|
||||
|
||||
Application -> "FreeRTOS Cellular Library" : Cellular_Cleanup()
|
||||
|
||||
activate Application
|
||||
|
||||
"FreeRTOS Cellular Library"->cellular_comm_interface : pCommInterface->Close()
|
||||
|
||||
cellular_comm_interface->cellular_modem : Power off device\nClose communication device driver\n
|
||||
|
||||
cellular_comm_interface-->"FreeRTOS Cellular Library":
|
||||
|
||||
"FreeRTOS Cellular Library"-->Application:
|
||||
|
||||
deactivate Application
|
||||
|
||||
@enduml
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="9in" height="7in" class="slides-canvas" viewBox="0 0 648 504">
|
||||
<defs>
|
||||
<linearGradient id="lg_b1cbe9_I0a3c1e5_92b9e4_90_4a_740a2" x1="0" y1="33" x2="0" y2="91" spreadMethod="reflect" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#B1CBE9" />
|
||||
<stop offset="0.5" stop-color="#A3C1E5" />
|
||||
<stop offset="1" stop-color="#92B9E4" />
|
||||
</linearGradient>
|
||||
<linearGradient id="lg_b1cbe9_I0a3c1e5_92b9e4_90_65_798b5" x1="0" y1="47" x2="0" y2="107" spreadMethod="reflect" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#B1CBE9" />
|
||||
<stop offset="0.5" stop-color="#A3C1E5" />
|
||||
<stop offset="1" stop-color="#92B9E4" />
|
||||
</linearGradient>
|
||||
<linearGradient id="lg_ffdd9c_I0ffd78e_ffd479_90_f9_d0275" x1="0" y1="202" x2="0" y2="306" spreadMethod="reflect" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#FFDD9C" />
|
||||
<stop offset="0.5" stop-color="#FFD78E" />
|
||||
<stop offset="1" stop-color="#FFD479" />
|
||||
</linearGradient>
|
||||
<marker id="ah1" markerUnits="userSpaceOnUse" markerWidth="36" markerHeight="21" viewBox="-18 -10.5 36 21" orient="auto">
|
||||
<path d="M-9 5.25L0 0-9-5.25" fill="none" stroke="#000000" stroke-width="3" stroke-linecap="round" />
|
||||
</marker>
|
||||
</defs>
|
||||
<g text-rendering="geometricPrecision" transform="scale(1, 1)">
|
||||
<rect x="0" y="0" width="648" height="504" fill="#FFFFFF" />
|
||||
<path fill="url(#lg_b1cbe9_I0a3c1e5_92b9e4_90_4a_740a2)" d="M13.75 381.88L623.4 381.88 623.4 439.9 13.75 439.9z" />
|
||||
<path stroke-width="0.5" stroke="#5B9BD5" fill="none" d="M13.75 381.88L623.4 381.88 623.4 439.9 13.75 439.9z" />
|
||||
<g transform="matrix(1, 0, 0, 1, 20.952362, 385.47693)"><text font-family="Noto Sans" font-style="normal" font-weight="normal" font-stretch="normal" font-size="18pt" fill="#000000" x="206.31061" y="33.614155"><tspan x="206.80165" y="34.1052" id="tp_0_shadow" fill="#000000" fill-opacity="0.27">Comm Interface</tspan><tspan x="206.31061" y="33.614155" id="tp_0">Comm Interface</tspan></text></g>
|
||||
<path fill="url(#lg_b1cbe9_I0a3c1e5_92b9e4_90_65_798b5)" d="M13.75 48.12L623.4 48.12 623.4 108.89 13.75 108.89z" />
|
||||
<path stroke-width="0.5" stroke="#5B9BD5" fill="none" d="M13.75 48.12L623.4 48.12 623.4 108.89 13.75 108.89z" />
|
||||
<g transform="matrix(1, 0, 0, 1, 20.952362, 51.7163)"><text font-family="Noto Sans" font-style="normal" font-weight="normal" font-stretch="normal" font-size="18pt" fill="#000000" x="234.31061" y="34.990295"><tspan x="234.80165" y="35.481342" id="tp_1_shadow" fill="#000000" fill-opacity="0.27">Application</tspan><tspan x="234.31061" y="34.990295" id="tp_1">Application</tspan></text></g>
|
||||
<g transform="matrix(1, 0, 0, 1, 338.37567, 109.73605)"><text font-family="Noto Sans" font-style="normal" font-weight="normal" font-stretch="normal" font-size="15pt" fill="#000000" x="0" y="42.83686"><tspan x="0" y="18.836859">FreeRTOS Cellular Interface</tspan><tspan xml:space="preserve" x="257.48438" y="18.836859"> </tspan><tspan x="0" y="42.83686">APIs request</tspan></text></g>
|
||||
<path fill="#FFE699" fill-opacity="0.5" d="M13.75 161.67L623.4 161.67 623.4 349.85 13.75 349.85z" />
|
||||
<path fill="url(#lg_ffdd9c_I0ffd78e_ffd479_90_f9_d0275)" d="M59.93 202.83L299.01 202.83 299.01 306.91 59.93 306.91z" />
|
||||
<path stroke-width="0.5" stroke="#FFC000" fill="none" d="M59.93 202.83L299.01 202.83 299.01 306.91 59.93 306.91z" />
|
||||
<g transform="matrix(1, 0, 0, 1, 67.13109, 206.43106)"><text font-family="Noto Sans" font-style="normal" font-weight="normal" font-stretch="normal" font-size="18pt" fill="#000000" x="22.080612" y="71.0426"><tspan x="7.376346" y="42.733643" id="tp_2_shadow" fill="#000000" fill-opacity="0.27">FreeRTOS-Cellular-</tspan><tspan x="6.8852997" y="42.242596" id="tp_2">FreeRTOS-Cellular-</tspan><tspan x="22.57166" y="71.533646" id="tp_3_shadow" fill="#000000" fill-opacity="0.27">Interface library</tspan><tspan x="22.080612" y="71.0426" id="tp_3">Interface library</tspan></text></g>
|
||||
<path fill="url(#lg_ffdd9c_I0ffd78e_ffd479_90_f9_d0275)" d="M348.12 202.83L587.19 202.83 587.19 306.91 348.12 306.91z" />
|
||||
<path stroke-width="0.5" stroke="#FFC000" fill="none" d="M348.12 202.83L587.19 202.83 587.19 306.91 348.12 306.91z" />
|
||||
<g transform="matrix(1, 0, 0, 1, 355.31573, 206.43106)"><text font-family="Noto Sans" font-style="normal" font-weight="normal" font-stretch="normal" font-size="18pt" fill="#000000" x="22.088425" y="71.0426"><tspan x="24.079472" y="42.733643" id="tp_4_shadow" fill="#000000" fill-opacity="0.27">Cellular Module</tspan><tspan x="23.588425" y="42.242596" id="tp_4">Cellular Module</tspan><tspan xml:space="preserve" x="201.08842" y="42.242596"> </tspan><tspan x="22.579472" y="71.533646" id="tp_5_shadow" fill="#000000" fill-opacity="0.27">implementation</tspan><tspan x="22.088425" y="71.0426" id="tp_5">implementation</tspan></text></g>
|
||||
<path marker-end="url(#ah1)" stroke-width="3" stroke="#000000" fill="none" d="M318.58 108.89L318.58 156.09 318.58 157.59" />
|
||||
<path marker-end="url(#ah1)" stroke-width="3" stroke="#000000" fill="none" d="M318.58 349.85L318.58 376.29 318.58 377.79" />
|
||||
</g>
|
||||
</svg>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
@ -0,0 +1,880 @@
|
||||
accessmode
|
||||
activatepdn
|
||||
activetimevalue
|
||||
actstatus
|
||||
af
|
||||
aka
|
||||
api
|
||||
apis
|
||||
apn
|
||||
apnname
|
||||
app
|
||||
args
|
||||
async
|
||||
atcheckerrorcode
|
||||
atcmddatasend
|
||||
atcmdqueryregstatus
|
||||
atcmdrequestwithcallback
|
||||
atcmdtype
|
||||
atcmdupdatemccmnc
|
||||
atcommandraw
|
||||
atcommandtype
|
||||
atcore
|
||||
atgetnexttok
|
||||
atgetspecificnexttok
|
||||
athexstrtohex
|
||||
atisprefixpresent
|
||||
atisstrdigit
|
||||
atlib
|
||||
atoi
|
||||
atparseinit
|
||||
atremovealldoublequote
|
||||
atremoveallwhitespaces
|
||||
atremoveleadingwhitespaces
|
||||
atremoveoutermostdoublequote
|
||||
atremoveprefix
|
||||
atremovetrailingwhitespaces
|
||||
atreq
|
||||
atreqgetfirmwareversion
|
||||
atreqgethplmn
|
||||
atreqgeticcid
|
||||
atreqgetimei
|
||||
atreqgetimsi
|
||||
atreqgetmanufactureid
|
||||
atreqgetmodelid
|
||||
atreqgetnoresult
|
||||
atresp
|
||||
atresptype
|
||||
atstrdup
|
||||
atstrstartwith
|
||||
atstrtoi
|
||||
attimeoutms
|
||||
attype
|
||||
auth
|
||||
aws
|
||||
basetype
|
||||
beginging
|
||||
ber
|
||||
bg
|
||||
blibclosing
|
||||
blibopened
|
||||
blibshutdown
|
||||
bool
|
||||
bootup
|
||||
bpktioup
|
||||
br
|
||||
bsearch
|
||||
bufferlength
|
||||
bytesbeforedata
|
||||
bytesdata
|
||||
bytesinbuffer
|
||||
bytesleft
|
||||
bytesread
|
||||
callbackevents
|
||||
catm
|
||||
cbevents
|
||||
cbmc
|
||||
cclk
|
||||
cedrxs
|
||||
cellid
|
||||
cellularatcommanddataprefixcallback
|
||||
cellularatcommanddatasendprefixcallback
|
||||
cellularatcommandline
|
||||
cellularatcommandresponsereceivedcallback
|
||||
cellularatcommandtype
|
||||
cellularatdata
|
||||
cellularatdatareq
|
||||
cellularatparsetokenhandler
|
||||
cellularatparsetokenmap
|
||||
cellularatreq
|
||||
cellularcomminterface
|
||||
cellularcomminterfaceclose
|
||||
cellularcomminterfaceopen
|
||||
cellularcomminterfacerecv
|
||||
cellularcomminterfacesend
|
||||
cellulareidrxsettings
|
||||
cellularerror
|
||||
cellularhandle
|
||||
cellularipaddress
|
||||
cellularipaddresstype
|
||||
cellularlib
|
||||
cellularnetworkregistrationmode
|
||||
cellularnetworkregistrationstatus
|
||||
cellularoperatornameformat
|
||||
cellularpdnauthtype
|
||||
cellularpdncontexttype
|
||||
cellularpdnstatus
|
||||
cellularpktstatus
|
||||
cellularplmninfo
|
||||
cellularprefixtoparsermapsize
|
||||
cellularpsmsettings
|
||||
cellularrat
|
||||
cellularsimcardlockstate
|
||||
cellularsimcardstate
|
||||
cellularsocketaccessmode
|
||||
cellularsocketaddress
|
||||
cellularsocketclosedcallback
|
||||
cellularsocketcontext
|
||||
cellularsocketdatareadycallback
|
||||
cellularsocketdomain
|
||||
cellularsocketopencallback
|
||||
cellularsocketprotocol
|
||||
cellularsocketstate
|
||||
cellularsockettype
|
||||
cellularsrcextratokensuccesstablesize
|
||||
cellularsrctokenerrortablesize
|
||||
cellularsrctokensuccesstablesize
|
||||
cellulartokentable
|
||||
cellularurchandlertable
|
||||
cellularurchandlertablesize
|
||||
cellularurctokenwoprefixtablesize
|
||||
celular
|
||||
cereg
|
||||
cesq
|
||||
cfun
|
||||
cgact
|
||||
cgdcont
|
||||
cgerep
|
||||
cgev
|
||||
cgpaddr
|
||||
cgreg
|
||||
charater
|
||||
checkcrsmmemorystatus
|
||||
checkcrsmreadstatus
|
||||
checklibrarystatus
|
||||
chk
|
||||
ci
|
||||
ciev
|
||||
clearbits
|
||||
closedcallback
|
||||
cmakelists
|
||||
cmd
|
||||
cmdbuf
|
||||
cmock
|
||||
com
|
||||
comm
|
||||
commad
|
||||
comminterfacehandle
|
||||
commmand
|
||||
commmon
|
||||
commnad
|
||||
commonatcommandraw
|
||||
commoncleanup
|
||||
commoncreatesocket
|
||||
commongeteidrxsettings
|
||||
commongetipaddress
|
||||
commongetmodeminfo
|
||||
commongetnetworktime
|
||||
commongetpsmsettings
|
||||
commongetregisterednetwork
|
||||
commongetservicestatus
|
||||
commongetsimcardinfo
|
||||
commongetsimcardlockstatus
|
||||
commoninit
|
||||
commonregistermodemeventcallback
|
||||
commonregisterurcgenericcallback
|
||||
commonregisterurcnetworkregistrationeventcallback
|
||||
commonregisterurcpdneventcallback
|
||||
commonregisterurcsignalstrengthchangedcallback
|
||||
commonrfoff
|
||||
commonrfon
|
||||
commonseteidrxsettings
|
||||
commonsetpdnconfig
|
||||
commonsetpsmsettings
|
||||
commonsocketregisterclosedcallback
|
||||
commonsocketregisterdatareadycallback
|
||||
commonsocketregistersocketopencallback
|
||||
commonsocketsetsockopt
|
||||
commonurcprocesscereg
|
||||
commonurcprocesscgreg
|
||||
commonurcprocesscreg
|
||||
comparevalue
|
||||
computesignalbars
|
||||
cond
|
||||
config
|
||||
configuse
|
||||
const
|
||||
contextactstate
|
||||
contextid
|
||||
contextspresent
|
||||
convertcsqsignalber
|
||||
convertcsqsignalrssi
|
||||
copybrief
|
||||
copydoc
|
||||
corehttp
|
||||
corp
|
||||
coverity
|
||||
cpin
|
||||
cpsms
|
||||
createatdatamutex
|
||||
createdetachedthread
|
||||
createlibstatusmutex
|
||||
createpktrequestmutex
|
||||
createpktresponsemutex
|
||||
createsocket
|
||||
createsocketdata
|
||||
creg
|
||||
crsm
|
||||
crsmmemorystatus
|
||||
csq
|
||||
csqber
|
||||
csqrssi
|
||||
csregistrationstatus
|
||||
csregstatus
|
||||
csrejcause
|
||||
csrejectioncause
|
||||
csrejectiontype
|
||||
csrejecttype
|
||||
cts
|
||||
dataaccessmode
|
||||
datalen
|
||||
datalength
|
||||
datamode
|
||||
datareadycallback
|
||||
datareq
|
||||
datatimeoutms
|
||||
datatypes
|
||||
db
|
||||
dbm
|
||||
de
|
||||
deact
|
||||
deactivatepdn
|
||||
dec
|
||||
decihours
|
||||
declar
|
||||
defgroup
|
||||
deinitialization
|
||||
delayms
|
||||
democonfigmqtt
|
||||
depndency
|
||||
deregister
|
||||
deregistration
|
||||
descr
|
||||
destroypktrequestmutex
|
||||
destroypktresponsemutex
|
||||
dgram
|
||||
dns
|
||||
dnsindex
|
||||
dnsquerymutex
|
||||
dnsresultnumber
|
||||
doxygen
|
||||
drx
|
||||
dst
|
||||
dtr
|
||||
ecn
|
||||
ecno
|
||||
edrx
|
||||
ef
|
||||
efhplmnwact
|
||||
eidrxlist
|
||||
eidrxsettingslist
|
||||
emerg
|
||||
endcond
|
||||
endif
|
||||
endpatternlen
|
||||
enougth
|
||||
enum
|
||||
enums
|
||||
eps
|
||||
erange
|
||||
errno
|
||||
ethernet
|
||||
evenggroup
|
||||
eventbits
|
||||
eventgroup
|
||||
eventgrouphandle
|
||||
evt
|
||||
fasle
|
||||
ff
|
||||
fffe
|
||||
ffffff
|
||||
findlineinstream
|
||||
firmwareversion
|
||||
freertos
|
||||
freertosconfig
|
||||
fucntion
|
||||
functionpointers
|
||||
fw
|
||||
gcc
|
||||
genericcallback
|
||||
getbits
|
||||
getcurrentrat
|
||||
geteidrxsettings
|
||||
gethostbyname
|
||||
getipaddress
|
||||
getmodeminfo
|
||||
getmodulecontext
|
||||
getmsgtype
|
||||
getnetworktime
|
||||
getnexttok
|
||||
getpdnstatus
|
||||
getpsmsettings
|
||||
getratpriority
|
||||
getregisterednetwork
|
||||
getservicestatus
|
||||
getsignalinfo
|
||||
getsimcardinfo
|
||||
getsimcardstatus
|
||||
getsocketdata
|
||||
github
|
||||
gpp
|
||||
gprs
|
||||
gprsreadytimer
|
||||
gsm
|
||||
handledata
|
||||
handleleftoverbuffer
|
||||
handlepacket
|
||||
handlepacketcb
|
||||
hardwareversion
|
||||
hexdatalen
|
||||
hl
|
||||
hpktiocommintf
|
||||
hplmn
|
||||
hplmnwact
|
||||
href
|
||||
hsdpa
|
||||
hsdpahsupa
|
||||
hsupa
|
||||
html
|
||||
http
|
||||
https
|
||||
hw
|
||||
iccid
|
||||
ifndef
|
||||
imei
|
||||
implemenation
|
||||
implementating
|
||||
imsi
|
||||
inc
|
||||
incliudes
|
||||
ind
|
||||
indicat
|
||||
inet
|
||||
ingroup
|
||||
inidcate
|
||||
init
|
||||
inputline
|
||||
int
|
||||
interdelayms
|
||||
intf
|
||||
io
|
||||
iot
|
||||
iotat
|
||||
iotmutex
|
||||
ip
|
||||
ipaddress
|
||||
ipaddresstype
|
||||
iptype
|
||||
ipv
|
||||
isalpha
|
||||
isdigit
|
||||
iso
|
||||
isr
|
||||
isspace
|
||||
isurc
|
||||
isvalidpdn
|
||||
isvalidsocket
|
||||
jan
|
||||
keylist
|
||||
keylistlen
|
||||
kselacq
|
||||
ktcp
|
||||
ktcprcv
|
||||
ktcpstat
|
||||
lac
|
||||
len
|
||||
libatdata
|
||||
libcleanup
|
||||
libinit
|
||||
linelength
|
||||
liniked
|
||||
linux
|
||||
localip
|
||||
localipaddress
|
||||
localport
|
||||
logdebug
|
||||
logerror
|
||||
loginfo
|
||||
logwarn
|
||||
lte
|
||||
mainpage
|
||||
malloc
|
||||
manufactureid
|
||||
maxlen
|
||||
mcc
|
||||
md
|
||||
mem
|
||||
memorystatus
|
||||
metadata
|
||||
min
|
||||
misra
|
||||
mnc
|
||||
mno
|
||||
modelid
|
||||
modemevent
|
||||
modemeventcallback
|
||||
modulecleanup
|
||||
moduleenableue
|
||||
moduleenableurc
|
||||
moduleinit
|
||||
mqtt
|
||||
mutex
|
||||
mutexes
|
||||
nb
|
||||
nbiot
|
||||
netsub
|
||||
networ
|
||||
networkregistrationcallback
|
||||
networkregistrationmode
|
||||
networkregmode
|
||||
netwrok
|
||||
newcmdlen
|
||||
noninfringement
|
||||
notif
|
||||
num
|
||||
numstatusbuffers
|
||||
nwprovidededrxvaue
|
||||
nwscanseq
|
||||
ok
|
||||
ommited
|
||||
opencallback
|
||||
operatorname
|
||||
operatornameformat
|
||||
optionlevel
|
||||
optionvaluelength
|
||||
org
|
||||
os
|
||||
pagingtimewindow
|
||||
pakcet
|
||||
param
|
||||
params
|
||||
paramstructs
|
||||
paremeters
|
||||
pargument
|
||||
parsecops
|
||||
parsecopsnetworknameformattoken
|
||||
parsecopsnetworknametoken
|
||||
parsecopsrattoken
|
||||
parsecopsregmodetoken
|
||||
parseeidrxtoken
|
||||
parsehplmn
|
||||
parseregstatus
|
||||
parserfunc
|
||||
parsesocketopen
|
||||
parsetimeincclkresponse
|
||||
parsetimezoneincclkresponse
|
||||
parsetimezoneinfo
|
||||
parseyearmonthdayincclkresponse
|
||||
partialdata
|
||||
partialdatarcvdlen
|
||||
patbuf
|
||||
patcmd
|
||||
patcommandpayload
|
||||
patcommandpayloadin
|
||||
patcommandprefix
|
||||
patresp
|
||||
patrspprefix
|
||||
pbandcfg
|
||||
pbervalue
|
||||
pbuf
|
||||
pbuffer
|
||||
pbytesread
|
||||
pc
|
||||
pcallbackcontext
|
||||
pcellularhandle
|
||||
pcellularsrcextratokensuccesstable
|
||||
pcellularsrctokenerrortable
|
||||
pcellularsrctokensuccesstable
|
||||
pcellularurchandlertable
|
||||
pcellularurctokenwoprefixtable
|
||||
pchead
|
||||
pchostname
|
||||
pclosedcallbackcontext
|
||||
pcomminterface
|
||||
pcomminterfacehandle
|
||||
pcommintf
|
||||
pcontext
|
||||
pcurrentcmd
|
||||
pcwriteto
|
||||
pdata
|
||||
pdatalength
|
||||
pdataprefixcbcontext
|
||||
pdatareadycallbackcontext
|
||||
pdatareceivedlength
|
||||
pdatasendprefixcbcontext
|
||||
pdatasentlength
|
||||
pdatastart
|
||||
pdelimiter
|
||||
pdms
|
||||
pdn
|
||||
pdnauthtype
|
||||
pdncontextid
|
||||
pdncontexttype
|
||||
pdneventcallback
|
||||
pdnsserveraddress
|
||||
pdnstatusbuffers
|
||||
pdnsusrdata
|
||||
pdp
|
||||
peidrxsettings
|
||||
peidrxsettingslist
|
||||
pendpattern
|
||||
pendpatternline
|
||||
pendptr
|
||||
pendstr
|
||||
periodicrauvalue
|
||||
periodictauvalue
|
||||
ph
|
||||
phexdata
|
||||
pinputbuf
|
||||
pinputline
|
||||
pinputptr
|
||||
pitm
|
||||
pkio
|
||||
pkt
|
||||
pktdataprefixcallback
|
||||
pktdataprefixcb
|
||||
pktdatasendprefixcallback
|
||||
pktdatasendprefixcb
|
||||
pktdnsqueue
|
||||
pkthandler
|
||||
pkthandlercleanup
|
||||
pkthandlerinit
|
||||
pkthanlder
|
||||
pktio
|
||||
pktiobuffer
|
||||
pktioinit
|
||||
pktioreadbuf
|
||||
pktioreadthread
|
||||
pktiosendatcmd
|
||||
pktiosenddata
|
||||
pktioshutdown
|
||||
pktrequestmutex
|
||||
pktrespmutex
|
||||
pktrespqueue
|
||||
pktrxcallback
|
||||
pktstatus
|
||||
pktusrdatalen
|
||||
platformeventgroup
|
||||
platformeventgrouphandle
|
||||
platformmutex
|
||||
platfrommutex
|
||||
pline
|
||||
plmn
|
||||
plmninfo
|
||||
pmodemdata
|
||||
pmodeminfo
|
||||
pmutex
|
||||
pnetworkinfo
|
||||
pnetworktime
|
||||
pnewmutex
|
||||
pnext
|
||||
png
|
||||
pnumstatus
|
||||
popencallbackcontext
|
||||
poptionvalue
|
||||
portings
|
||||
pos
|
||||
posix
|
||||
poutputratprioritieslength
|
||||
ppatresponse
|
||||
ppdatastart
|
||||
ppdnconfig
|
||||
ppdnstatusbuffers
|
||||
ppdptypestr
|
||||
ppdst
|
||||
ppkeylist
|
||||
ppktiocommevent
|
||||
ppktioreadptr
|
||||
ppktusrdata
|
||||
ppmodulecontext
|
||||
ppouttoken
|
||||
pprefix
|
||||
ppsmsettings
|
||||
ppstartofdata
|
||||
ppstring
|
||||
pptokoutput
|
||||
prat
|
||||
pratpriorities
|
||||
prawdata
|
||||
pre
|
||||
pread
|
||||
preceiveddatalength
|
||||
precvdatalength
|
||||
pregpayload
|
||||
premotesocketaddress
|
||||
preprocess
|
||||
presolvedaddress
|
||||
presp
|
||||
presult
|
||||
printf
|
||||
prioirty
|
||||
prl
|
||||
processmodemrdy
|
||||
processpowerdown
|
||||
prssivalue
|
||||
ps
|
||||
psaveptr
|
||||
psentdatalength
|
||||
pservicestatus
|
||||
psignalinfo
|
||||
psimcardinfo
|
||||
psimcardstatus
|
||||
psm
|
||||
psmsettings
|
||||
psocketdata
|
||||
psockethandle
|
||||
psrc
|
||||
psregistrationstatus
|
||||
psregstatus
|
||||
psrejcause
|
||||
psrejectioncause
|
||||
psrejectiontype
|
||||
psrejecttype
|
||||
pstartofdata
|
||||
pstr
|
||||
pstring
|
||||
pstrvalue
|
||||
ptemp
|
||||
ptempstring
|
||||
ptestusrdata
|
||||
ptofree
|
||||
ptoken
|
||||
ptokenptr
|
||||
ptokentable
|
||||
ptr
|
||||
puk
|
||||
puserdata
|
||||
pvportmalloc
|
||||
pwr
|
||||
px
|
||||
qccid
|
||||
qcfg
|
||||
qird
|
||||
qsort
|
||||
qual
|
||||
quectel
|
||||
querynetworkstatus
|
||||
queuedefinition
|
||||
queuehandle
|
||||
queuereturnfail
|
||||
rac
|
||||
ratindex
|
||||
ratprioritieslength
|
||||
ratselectcmd
|
||||
rau
|
||||
rcv
|
||||
rcvdata
|
||||
rdy
|
||||
readline
|
||||
receivecallback
|
||||
recognise
|
||||
recv
|
||||
recvfuncgeteidrxsettings
|
||||
recvfuncgethplmn
|
||||
recvfuncgeticcid
|
||||
recvfuncgetimsi
|
||||
recvfuncgetnetworkreg
|
||||
recvfuncgetnetworktime
|
||||
recvfuncgetpsmsettings
|
||||
recvfuncgetsimlockstatus
|
||||
recvfuncipaddress
|
||||
recvfuncupdatemccmnc
|
||||
recvlen
|
||||
recvtimeoutms
|
||||
reg
|
||||
registermodemeventcallback
|
||||
registerurcgenericcallback
|
||||
registerurcnetworkregistrationeventcallback
|
||||
registerurcpdneventcallback
|
||||
registerurcsignalstrengthchangedcallback
|
||||
regpayload
|
||||
regstatus
|
||||
regtype
|
||||
rem
|
||||
remdata
|
||||
remotesocketaddress
|
||||
removesocketdata
|
||||
reponse
|
||||
reponses
|
||||
req
|
||||
requestededrxvaue
|
||||
resp
|
||||
respcallback
|
||||
respnose
|
||||
respone
|
||||
responsereceivedcallback
|
||||
retruned
|
||||
rf
|
||||
rfc
|
||||
rfoff
|
||||
rfon
|
||||
rquest
|
||||
rscp
|
||||
rsp
|
||||
rsrp
|
||||
rsrq
|
||||
rssi
|
||||
rtos
|
||||
rts
|
||||
ruese
|
||||
rx
|
||||
rxlev
|
||||
rxqual
|
||||
sara
|
||||
saveing
|
||||
scanseq
|
||||
sdk
|
||||
searchcomparefunc
|
||||
sec
|
||||
semophores
|
||||
sendendpatternlen
|
||||
sendtimeoutms
|
||||
sensorhub
|
||||
seperator
|
||||
serialnumber
|
||||
servicestatus
|
||||
sessionid
|
||||
setbits
|
||||
setbitsfromisr
|
||||
setdns
|
||||
seteidrxsettings
|
||||
setpdnconfig
|
||||
setpsmsettings
|
||||
setratpriority
|
||||
setsocketopt
|
||||
setsockopt
|
||||
shutdowncallback
|
||||
signalstrengthchangedcallback
|
||||
simcardlockstate
|
||||
simcardstate
|
||||
simlockstate
|
||||
sinr
|
||||
sms
|
||||
snprintf
|
||||
socketclose
|
||||
socketconnect
|
||||
socketdomain
|
||||
sockethandle
|
||||
socketid
|
||||
socketindex
|
||||
socketopencallback
|
||||
socketprotocol
|
||||
socketrecv
|
||||
socketregisterclosedcallback
|
||||
socketregisterdatareadycallback
|
||||
socketregistersocketopencallback
|
||||
socketsend
|
||||
socketsetsockopt
|
||||
socketstate
|
||||
sockettype
|
||||
sockindex
|
||||
sortcomparefunc
|
||||
sp
|
||||
spi
|
||||
src
|
||||
stacksize
|
||||
stanard
|
||||
standalone
|
||||
stat
|
||||
staticqueue
|
||||
staticsemaphore
|
||||
stm
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
stringlength
|
||||
strlen
|
||||
strncpy
|
||||
strnlen
|
||||
strstr
|
||||
strtok
|
||||
strtol
|
||||
struct
|
||||
subclause
|
||||
sublicense
|
||||
sw
|
||||
tac
|
||||
tcp
|
||||
tcpconnectionfailure
|
||||
tcpnotif
|
||||
tcpsocketstate
|
||||
technoloyg
|
||||
tempvalue
|
||||
testindex
|
||||
testresultnumber
|
||||
threadreturn
|
||||
threadroutine
|
||||
ticktype
|
||||
timeoutatcmddatarecvrequestwithcallback
|
||||
timeoutatcmddatasendrequestwithcallback
|
||||
timeoutatcmddatasendsuccesstoken
|
||||
timeoutatcmdrequestwithcallback
|
||||
timeoutmilliseconds
|
||||
timeoutms
|
||||
timezonenegative
|
||||
todo
|
||||
tokentabletype
|
||||
translateatcorestatus
|
||||
translatepktstatus
|
||||
trylock
|
||||
txt
|
||||
uart
|
||||
uauthreq
|
||||
ubandmask
|
||||
ublox
|
||||
udp
|
||||
ue
|
||||
uint
|
||||
uknown
|
||||
umnoprof
|
||||
undefinedrespcallback
|
||||
unneccessary
|
||||
urat
|
||||
urc
|
||||
urcevent
|
||||
urcprocesscgev
|
||||
urcprocessciev
|
||||
urcprocessktcpdata
|
||||
urcprocessktcpind
|
||||
urcprocessktcpnotif
|
||||
urcprocessuupsmr
|
||||
urcprocessuusocl
|
||||
urcprocessuusoco
|
||||
urcprocessuusord
|
||||
urcs
|
||||
userdata
|
||||
usocl
|
||||
usocr
|
||||
usord
|
||||
usrod
|
||||
utc
|
||||
utest
|
||||
utran
|
||||
uupsmr
|
||||
uusocl
|
||||
uusoco
|
||||
uusord
|
||||
var
|
||||
veventgroupdelete
|
||||
vportfree
|
||||
vtaskdelay
|
||||
waitbits
|
||||
wcdma
|
||||
wifi
|
||||
wo
|
||||
www
|
||||
xab
|
||||
xeventgroupclearbits
|
||||
xeventgroupcreate
|
||||
xeventgroupgetbits
|
||||
xeventgroupsetbits
|
||||
xeventgroupsetbitsfromisr
|
||||
xeventgroupwaitbits
|
||||
xff
|
||||
xhigherprioritytaskwoken
|
||||
xmutex
|
||||
xqueuecreate
|
||||
xqueuereceive
|
||||
xqueuesend
|
||||
xxxx
|
||||
yd
|
||||
@ -0,0 +1,5 @@
|
||||
name : "FreeRTOS-Cellular-Interface"
|
||||
version: "v1.3.0"
|
||||
description: |
|
||||
"FreeRTOS Cellular Interface implementation of the 3GPP TS v27.007 standard..\n"
|
||||
license: "MIT"
|
||||
@ -0,0 +1,71 @@
|
||||
SPDXVersion: SPDX-2.2
|
||||
DataLicense: CC0-1.0
|
||||
SPDXID: SPDXRef-DOCUMENT
|
||||
DocumentName: FreeRTOS-Cellular-Interface
|
||||
DocumentNamespace: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/v1.3.0/sbom.spdx
|
||||
Creator: Amazon Web Services
|
||||
Created: 2022-10-14T18:01:52Z
|
||||
CreatorComment: NOASSERTION
|
||||
DocumentComment: NOASSERTION
|
||||
|
||||
PackageName: FreeRTOS-Cellular-Interface
|
||||
SPDXID: SPDXRef-Package-FreeRTOS-Cellular-Interface
|
||||
PackageVersion: v1.3.0
|
||||
PackageDownloadLocation: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/tree/v1.3.0
|
||||
PackageLicenseConcluded: MIT
|
||||
FilesAnalyzed: True
|
||||
PackageVerificationCode: 785491a232cadb33474793630c32e397a47ddb3c
|
||||
PackageCopyrightText: NOASSERTION
|
||||
PackageSummary: NOASSERTION
|
||||
PackageDescription: "FreeRTOS Cellular Interface implementation of the 3GPP TS v27.007 standard..\n"
|
||||
|
||||
|
||||
FileName: ./cellular_3gpp_api.c
|
||||
SPDXID: SPDXRef-File-cellular_3gpp_api.c
|
||||
FileChecksum: SHA1: 24ec7e7b0209ecd015700afa88149f46a2c5cc1a
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_3gpp_urc_handler.c
|
||||
SPDXID: SPDXRef-File-cellular_3gpp_urc_handler.c
|
||||
FileChecksum: SHA1: 50537ab6120e88cf439465772503f737243df7f1
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_at_core.c
|
||||
SPDXID: SPDXRef-File-cellular_at_core.c
|
||||
FileChecksum: SHA1: 8e059abd0393f927d9b973bf0b2d1277d9af0973
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_pkthandler.c
|
||||
SPDXID: SPDXRef-File-cellular_pkthandler.c
|
||||
FileChecksum: SHA1: 469f2f0ce4b307a5880b51c956fd7ce1bf78714b
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_pktio.c
|
||||
SPDXID: SPDXRef-File-cellular_pktio.c
|
||||
FileChecksum: SHA1: 0c3fbb315eba5e004a784de05c8827a3de2a9e01
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_common.c
|
||||
SPDXID: SPDXRef-File-cellular_common.c
|
||||
FileChecksum: SHA1: ccd01b796b1e43419f8cbeaab1594be1c06ed56d
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
FileName: ./cellular_common_api.c
|
||||
SPDXID: SPDXRef-File-cellular_common_api.c
|
||||
FileChecksum: SHA1: c181582a8564a486d1bbf46ad1a5d9729b55cd20
|
||||
LicenseConcluded: MIT
|
||||
FileCopyrightText: NOASSERTION
|
||||
FileComment: NOASSERTION
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,703 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS Cellular Library URC handler implemenation with 3GPP URC.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_internal.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define CELLULAR_REG_POS_STAT ( 2U )
|
||||
#define CELLULAR_REG_POS_LAC_TAC ( 3U )
|
||||
#define CELLULAR_REG_POS_CELL_ID ( 4U )
|
||||
#define CELLULAR_REG_POS_RAT ( 5U )
|
||||
#define CELLULAR_REG_POS_REJ_TYPE ( 6U )
|
||||
#define CELLULAR_REG_POS_REJ_CAUSE ( 7U )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
static CellularPktStatus_t _parseRegStatusInRegStatusParsing( CellularContext_t * pContext,
|
||||
CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _parseLacTacInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _parseCellIdInRegStatus( const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _parseRatInfoInRegStatus( const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _parseRejectTypeInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _parseRejectCauseInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static CellularPktStatus_t _regStatusSwitchParsingFunc( CellularContext_t * pContext,
|
||||
uint8_t i,
|
||||
CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData );
|
||||
static void _regStatusGenerateLog( char * pRegPayload,
|
||||
CellularNetworkRegType_t regType );
|
||||
static void _regStatusGenerateEvent( const CellularContext_t * pContext,
|
||||
CellularNetworkRegType_t regType,
|
||||
const cellularAtData_t * pLibAtData );
|
||||
static bool _Cellular_RegEventStatus( const cellularAtData_t * pLibAtData,
|
||||
CellularNetworkRegType_t regType,
|
||||
CellularNetworkRegistrationStatus_t prevCsRegStatus,
|
||||
CellularNetworkRegistrationStatus_t prevPsRegStatus );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseRegStatusInRegStatusParsing( CellularContext_t * pContext,
|
||||
CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t tempValue = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
CellularNetworkRegistrationStatus_t regStatus = REGISTRATION_STATUS_UNKNOWN;
|
||||
|
||||
if( ( regType != CELLULAR_REG_TYPE_CREG ) && ( regType != CELLULAR_REG_TYPE_CEREG ) &&
|
||||
( regType != CELLULAR_REG_TYPE_CGREG ) )
|
||||
{
|
||||
packetStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( ( tempValue >= 0 ) && ( tempValue < ( int32_t ) REGISTRATION_STATUS_MAX ) )
|
||||
{
|
||||
/* MISRA Ref 10.5.1 [Essential type casting] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-105 */
|
||||
/* coverity[misra_c_2012_rule_10_5_violation] */
|
||||
regStatus = ( CellularNetworkRegistrationStatus_t ) tempValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
}
|
||||
|
||||
if( packetStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
if( regType == CELLULAR_REG_TYPE_CREG )
|
||||
{
|
||||
pLibAtData->csRegStatus = regStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLibAtData->psRegStatus = regStatus;
|
||||
}
|
||||
|
||||
if( regStatus == REGISTRATION_STATUS_REGISTERED_HOME )
|
||||
{
|
||||
LogDebug( ( "Netowrk registration : HOME" ) );
|
||||
}
|
||||
else if( regStatus == REGISTRATION_STATUS_ROAMING_REGISTERED )
|
||||
{
|
||||
LogDebug( ( "Netowrk registration : ROAMING" ) );
|
||||
}
|
||||
else if( regStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
|
||||
{
|
||||
/* clear the atlib data if the registration failed. */
|
||||
LogDebug( ( "Netowrk registration : DEINED" ) );
|
||||
_Cellular_InitAtData( pContext, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* clear the atlib data if the registration failed. */
|
||||
LogDebug( ( "Netowrk registration : OTHERS" ) );
|
||||
_Cellular_InitAtData( pContext, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseLacTacInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t tempValue = 0;
|
||||
uint16_t var = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 16, &tempValue );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( ( tempValue >= 0 ) && ( tempValue <= UINT16_MAX ) )
|
||||
{
|
||||
var = ( uint16_t ) tempValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
/* Parsing Location area code for CREG or CGREG. */
|
||||
if( ( regType == CELLULAR_REG_TYPE_CREG ) || ( regType == CELLULAR_REG_TYPE_CGREG ) )
|
||||
{
|
||||
pLibAtData->lac = ( uint16_t ) var;
|
||||
}
|
||||
/* Parsing Tracking area code for CEREG. */
|
||||
else if( regType == CELLULAR_REG_TYPE_CEREG )
|
||||
{
|
||||
pLibAtData->tac = ( uint16_t ) var;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Empty else MISRA 15.7 */
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseCellIdInRegStatus( const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t tempValue = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 16, &tempValue );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( tempValue >= 0 )
|
||||
{
|
||||
pLibAtData->cellId = ( uint32_t ) tempValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError( ( "Error in processing Cell Id. Token %s", pToken ) );
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseRatInfoInRegStatus( const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t var = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &var );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( var >= ( int32_t ) CELLULAR_RAT_MAX )
|
||||
{
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
LogError( ( "Error in processing RAT. Token %s", pToken ) );
|
||||
}
|
||||
else if( ( var == ( int32_t ) CELLULAR_RAT_GSM ) || ( var == ( int32_t ) CELLULAR_RAT_EDGE ) ||
|
||||
( var == ( int32_t ) CELLULAR_RAT_CATM1 ) || ( var == ( int32_t ) CELLULAR_RAT_NBIOT ) )
|
||||
{
|
||||
/* MISRA Ref 10.5.1 [Essential type casting] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-105 */
|
||||
/* coverity[misra_c_2012_rule_10_5_violation] */
|
||||
pLibAtData->rat = ( CellularRat_t ) var;
|
||||
}
|
||||
else if( var == ( int32_t ) CELLULAR_RAT_LTE )
|
||||
{
|
||||
/* Some cellular module use 7 : CELLULAR_RAT_LTE to indicate CAT-M1. */
|
||||
pLibAtData->rat = ( CellularRat_t ) CELLULAR_RAT_LTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLibAtData->rat = CELLULAR_RAT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseRejectTypeInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t tempValue = 0;
|
||||
uint8_t rejType = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( ( tempValue >= 0 ) && ( tempValue <= ( int32_t ) UINT8_MAX ) )
|
||||
{
|
||||
rejType = ( uint8_t ) tempValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( regType == CELLULAR_REG_TYPE_CREG )
|
||||
{
|
||||
/* Reject Type is only stored if the registration status is denied. */
|
||||
if( pLibAtData->csRegStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
|
||||
{
|
||||
pLibAtData->csRejectType = rejType;
|
||||
}
|
||||
}
|
||||
else if( ( regType == CELLULAR_REG_TYPE_CGREG ) || ( regType == CELLULAR_REG_TYPE_CEREG ) )
|
||||
{
|
||||
if( pLibAtData->psRegStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
|
||||
{
|
||||
pLibAtData->psRejectType = rejType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Empty else MISRA 15.7 */
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _parseRejectCauseInRegStatus( CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
int32_t tempValue = 0;
|
||||
uint8_t rejCause = 0;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
atCoreStatus = Cellular_ATStrtoi( pToken, 10, &tempValue );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( ( tempValue >= 0 ) && ( tempValue <= ( int32_t ) UINT8_MAX ) )
|
||||
{
|
||||
rejCause = ( uint8_t ) tempValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
atCoreStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
if( regType == CELLULAR_REG_TYPE_CREG )
|
||||
{
|
||||
if( pLibAtData->csRegStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
|
||||
{
|
||||
pLibAtData->csRejCause = rejCause;
|
||||
}
|
||||
}
|
||||
else if( ( regType == CELLULAR_REG_TYPE_CGREG ) || ( regType == CELLULAR_REG_TYPE_CEREG ) )
|
||||
{
|
||||
if( pLibAtData->psRegStatus == REGISTRATION_STATUS_REGISTRATION_DENIED )
|
||||
{
|
||||
pLibAtData->psRejCause = rejCause;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Empty else MISRA 15.7 */
|
||||
}
|
||||
}
|
||||
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _regStatusSwitchParsingFunc( CellularContext_t * pContext,
|
||||
uint8_t i,
|
||||
CellularNetworkRegType_t regType,
|
||||
const char * pToken,
|
||||
cellularAtData_t * pLibAtData )
|
||||
{
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
switch( i )
|
||||
{
|
||||
/* Parsing network Registration status in CREG or CGREG or CEREG response. */
|
||||
case CELLULAR_REG_POS_STAT:
|
||||
packetStatus = _parseRegStatusInRegStatusParsing( pContext, regType, pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
case CELLULAR_REG_POS_LAC_TAC:
|
||||
packetStatus = _parseLacTacInRegStatus( regType, pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
/* Parsing Cell ID. */
|
||||
case CELLULAR_REG_POS_CELL_ID:
|
||||
packetStatus = _parseCellIdInRegStatus( pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
/* Parsing RAT Information. */
|
||||
case CELLULAR_REG_POS_RAT:
|
||||
packetStatus = _parseRatInfoInRegStatus( pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
/* Parsing Reject Type. */
|
||||
case CELLULAR_REG_POS_REJ_TYPE:
|
||||
packetStatus = _parseRejectTypeInRegStatus( regType, pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
/* Parsing the Reject Cause. */
|
||||
case CELLULAR_REG_POS_REJ_CAUSE:
|
||||
packetStatus = _parseRejectCauseInRegStatus( regType, pToken, pLibAtData );
|
||||
break;
|
||||
|
||||
default:
|
||||
LogDebug( ( "Unknown Parameter Position in Registration URC" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void _regStatusGenerateLog( char * pRegPayload,
|
||||
CellularNetworkRegType_t regType )
|
||||
{
|
||||
( void ) pRegPayload;
|
||||
|
||||
if( regType == CELLULAR_REG_TYPE_CREG )
|
||||
{
|
||||
LogDebug( ( "URC: CREG: %s", pRegPayload ) );
|
||||
}
|
||||
else if( regType == CELLULAR_REG_TYPE_CGREG )
|
||||
{
|
||||
LogDebug( ( "URC: CGREG: %s", pRegPayload ) );
|
||||
}
|
||||
else if( regType == CELLULAR_REG_TYPE_CEREG )
|
||||
{
|
||||
LogDebug( ( "URC: CEREG: %s", pRegPayload ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug( ( " URC: Unknown " ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void _regStatusGenerateEvent( const CellularContext_t * pContext,
|
||||
CellularNetworkRegType_t regType,
|
||||
const cellularAtData_t * pLibAtData )
|
||||
{
|
||||
CellularServiceStatus_t serviceStatus;
|
||||
|
||||
( void ) memset( &serviceStatus, 0, sizeof( CellularServiceStatus_t ) );
|
||||
serviceStatus.rat = pLibAtData->rat;
|
||||
serviceStatus.csRegistrationStatus = pLibAtData->csRegStatus;
|
||||
serviceStatus.psRegistrationStatus = pLibAtData->psRegStatus;
|
||||
serviceStatus.csRejectionCause = pLibAtData->csRejCause;
|
||||
serviceStatus.csRejectionType = pLibAtData->csRejectType;
|
||||
serviceStatus.psRejectionCause = pLibAtData->psRejCause;
|
||||
serviceStatus.psRejectionType = pLibAtData->psRejectType;
|
||||
|
||||
/* Data should be obtained from COPS commmand. User should obtain with APIs. */
|
||||
( void ) strcpy( serviceStatus.plmnInfo.mcc, "FFF" );
|
||||
( void ) strcpy( serviceStatus.plmnInfo.mnc, "FFF" );
|
||||
( void ) strcpy( serviceStatus.operatorName, "FFF" );
|
||||
serviceStatus.operatorNameFormat = OPERATOR_NAME_FORMAT_NOT_PRESENT;
|
||||
serviceStatus.networkRegistrationMode = REGISTRATION_MODE_UNKNOWN;
|
||||
|
||||
if( pContext->cbEvents.networkRegistrationCallback != NULL )
|
||||
{
|
||||
if( regType == CELLULAR_REG_TYPE_CREG )
|
||||
{
|
||||
_Cellular_NetworkRegistrationCallback( pContext, CELLULAR_URC_EVENT_NETWORK_CS_REGISTRATION, &serviceStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_NetworkRegistrationCallback( pContext, CELLULAR_URC_EVENT_NETWORK_PS_REGISTRATION, &serviceStatus );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* check registration event change to decide to generate event. */
|
||||
static bool _Cellular_RegEventStatus( const cellularAtData_t * pLibAtData,
|
||||
CellularNetworkRegType_t regType,
|
||||
CellularNetworkRegistrationStatus_t prevCsRegStatus,
|
||||
CellularNetworkRegistrationStatus_t prevPsRegStatus )
|
||||
{
|
||||
bool retEventChanged = false;
|
||||
|
||||
switch( regType )
|
||||
{
|
||||
case CELLULAR_REG_TYPE_CREG:
|
||||
|
||||
if( pLibAtData->csRegStatus != prevCsRegStatus )
|
||||
{
|
||||
retEventChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CELLULAR_REG_TYPE_CGREG:
|
||||
case CELLULAR_REG_TYPE_CEREG:
|
||||
|
||||
if( pLibAtData->psRegStatus != prevPsRegStatus )
|
||||
{
|
||||
retEventChanged = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
LogInfo( ( "_Cellular_RegEventStatus : unknown reg type " ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return retEventChanged;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
|
||||
char * pRegPayload,
|
||||
bool isUrc,
|
||||
CellularNetworkRegType_t regType )
|
||||
{
|
||||
uint8_t i = 0;
|
||||
char * pRegStr = NULL, * pToken = NULL;
|
||||
cellularAtData_t * pLibAtData = NULL;
|
||||
CellularPktStatus_t packetStatus = CELLULAR_PKT_STATUS_OK;
|
||||
CellularATError_t atCoreStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularNetworkRegistrationStatus_t prevCsRegStatus = REGISTRATION_STATUS_UNKNOWN;
|
||||
CellularNetworkRegistrationStatus_t prevPsRegStatus = REGISTRATION_STATUS_UNKNOWN;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
packetStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
}
|
||||
else if( pRegPayload == NULL )
|
||||
{
|
||||
packetStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLibAtData = &pContext->libAtData;
|
||||
|
||||
if( isUrc == true )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
pRegStr = pRegPayload;
|
||||
|
||||
atCoreStatus = Cellular_ATRemoveAllDoubleQuote( pRegStr );
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
atCoreStatus = Cellular_ATRemoveAllWhiteSpaces( pRegStr );
|
||||
}
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
atCoreStatus = Cellular_ATGetNextTok( &pRegStr, &pToken );
|
||||
}
|
||||
|
||||
if( atCoreStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
/* Backup the previous regStatus. */
|
||||
prevCsRegStatus = pLibAtData->csRegStatus;
|
||||
prevPsRegStatus = pLibAtData->psRegStatus;
|
||||
|
||||
while( pToken != NULL )
|
||||
{
|
||||
i++;
|
||||
packetStatus = _regStatusSwitchParsingFunc( pContext, i, regType,
|
||||
pToken, pLibAtData );
|
||||
|
||||
/* Getting next token to parse. */
|
||||
if( Cellular_ATGetNextTok( &pRegStr, &pToken ) != CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate logs. */
|
||||
if( isUrc == true )
|
||||
{
|
||||
_regStatusGenerateLog( pRegPayload, regType );
|
||||
}
|
||||
|
||||
/* If Registration Status changed, generate the event. */
|
||||
if( ( _Cellular_RegEventStatus( pLibAtData, regType, prevCsRegStatus, prevPsRegStatus ) == true ) )
|
||||
{
|
||||
_regStatusGenerateEvent( pContext, regType, pLibAtData );
|
||||
}
|
||||
|
||||
if( atCoreStatus != CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
packetStatus = _Cellular_TranslateAtCoreStatus( atCoreStatus );
|
||||
}
|
||||
}
|
||||
|
||||
return packetStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCreg( CellularContext_t * pContext,
|
||||
char * pInputLine )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
_Cellular_LockAtDataMutex( pContext );
|
||||
pktStatus = _Cellular_ParseRegStatus( pContext, pInputLine, true, CELLULAR_REG_TYPE_CREG );
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogDebug( ( "Creg Parse failure" ) );
|
||||
}
|
||||
|
||||
_Cellular_UnlockAtDataMutex( pContext );
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCgreg( CellularContext_t * pContext,
|
||||
char * pInputLine )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
_Cellular_LockAtDataMutex( pContext );
|
||||
pktStatus = _Cellular_ParseRegStatus( pContext, pInputLine, true, CELLULAR_REG_TYPE_CGREG );
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogDebug( ( "Cgreg Parse failure" ) );
|
||||
}
|
||||
|
||||
_Cellular_UnlockAtDataMutex( pContext );
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCereg( CellularContext_t * pContext,
|
||||
char * pInputLine )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
_Cellular_LockAtDataMutex( pContext );
|
||||
pktStatus = _Cellular_ParseRegStatus( pContext, pInputLine, true, CELLULAR_REG_TYPE_CEREG );
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogDebug( ( "Cereg Parse failure" ) );
|
||||
}
|
||||
|
||||
_Cellular_UnlockAtDataMutex( pContext );
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
@ -0,0 +1,863 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS Cellular Library common AT command parsing functions.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
#include "cellular_at_core.h"
|
||||
#include "cellular_internal.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifndef CELLULAR_CHECK_IS_PREFIX_CHAR
|
||||
#define CELLULAR_CHECK_IS_PREFIX_CHAR( inputChar ) \
|
||||
( ( ( ( int32_t ) isalpha( ( ( int8_t ) ( inputChar ) ) ) ) == 0 ) && \
|
||||
( ( ( int32_t ) isdigit( ( ( int8_t ) ( inputChar ) ) ) ) == 0 ) && \
|
||||
( ( inputChar ) != '+' ) && ( ( inputChar ) != '_' ) )
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief String validation results.
|
||||
*/
|
||||
typedef enum CellularATStringValidationResult
|
||||
{
|
||||
CELLULAR_AT_STRING_VALID, /**< String is valid. */
|
||||
CELLULAR_AT_STRING_EMPTY, /**< String is empty. */
|
||||
CELLULAR_AT_STRING_TOO_LARGE, /**< String is too large. */
|
||||
CELLULAR_AT_STRING_UNKNOWN /**< Unknown String validation state. */
|
||||
} CellularATStringValidationResult_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void validateString( const char * pString,
|
||||
CellularATStringValidationResult_t * pStringValidationResult );
|
||||
static uint8_t _charToNibble( char c );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void validateString( const char * pString,
|
||||
CellularATStringValidationResult_t * pStringValidationResult )
|
||||
{
|
||||
const char * pNullCharacterLocation = NULL;
|
||||
|
||||
/* Validate the string length. If the string length is longer than expected, return
|
||||
* error to stop further processing.
|
||||
*
|
||||
* CELLULAR_AT_MAX_STRING_SIZE defines the valid string length excluding NULL terminating
|
||||
* character. The longest valid string has '\0' at ( CELLULAR_AT_MAX_STRING_SIZE + 1U )
|
||||
*/
|
||||
pNullCharacterLocation = memchr( pString, ( int32_t ) '\0', ( CELLULAR_AT_MAX_STRING_SIZE + 1U ) );
|
||||
|
||||
if( pNullCharacterLocation == pString )
|
||||
{
|
||||
*pStringValidationResult = CELLULAR_AT_STRING_EMPTY;
|
||||
}
|
||||
else if( pNullCharacterLocation == NULL )
|
||||
{
|
||||
*pStringValidationResult = CELLULAR_AT_STRING_TOO_LARGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pStringValidationResult = CELLULAR_AT_STRING_VALID;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATIsPrefixPresent( const char * pString,
|
||||
bool * pResult )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
char * ptrPrefixChar = NULL;
|
||||
char * ptrChar = NULL;
|
||||
|
||||
if( ( pResult == NULL ) || ( pString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find location of first ':'. */
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
*pResult = true;
|
||||
|
||||
ptrPrefixChar = strchr( pString, ( int32_t ) ':' );
|
||||
|
||||
if( ptrPrefixChar == NULL )
|
||||
{
|
||||
*pResult = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There should be only '+', '_', characters or digit before seperator. */
|
||||
for( ptrChar = ( char * ) pString; ptrChar < ptrPrefixChar; ptrChar++ )
|
||||
{
|
||||
/* It's caused by stanard api isalpha and isdigit. */
|
||||
/* MISRA Ref 4.6.1 [Basic numerical type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
|
||||
/* MISRA Ref 10.4.1 [Same essential type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-104 */
|
||||
/* MISRA Ref 10.8.1 [Essential type casting] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-108 */
|
||||
/* coverity[misra_c_2012_directive_4_6_violation] */
|
||||
/* coverity[misra_c_2012_rule_10_4_violation] */
|
||||
/* coverity[misra_c_2012_rule_10_8_violation] */
|
||||
if( CELLULAR_CHECK_IS_PREFIX_CHAR( ( char ) ( *ptrChar ) ) )
|
||||
{
|
||||
*pResult = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATStrStartWith( const char * pString,
|
||||
const char * pPrefix,
|
||||
bool * pResult )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
const char * pTempString = pString;
|
||||
const char * pTempPrefix = pPrefix;
|
||||
|
||||
if( ( pResult == NULL ) || ( pString == NULL ) || ( pPrefix == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempPrefix, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
*pResult = true;
|
||||
|
||||
while( *pTempPrefix != '\0' )
|
||||
{
|
||||
if( *pTempPrefix != *pTempString )
|
||||
{
|
||||
*pResult = false;
|
||||
break;
|
||||
}
|
||||
|
||||
pTempPrefix++;
|
||||
pTempString++;
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemovePrefix( char ** ppString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
|
||||
if( ( ppString == NULL ) || ( *ppString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( *ppString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
/* The strchr() function returns a pointer to the first occurrence of
|
||||
* the character in the string or NULL if the character is not found.
|
||||
*
|
||||
* In case of AT response, prefix is always followed by a colon (':'). */
|
||||
*ppString = strchr( *ppString, ( int32_t ) ':' );
|
||||
|
||||
if( *ppString == NULL )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Note that we remove both the prefix and the colon. */
|
||||
( *ppString )++;
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveLeadingWhiteSpaces( char ** ppString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
|
||||
if( ( ppString == NULL ) || ( *ppString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( *ppString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
/* isspace is a standard library function and we cannot control it. */
|
||||
/* MISRA Ref 4.6.1 [Basic numerical type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
|
||||
/* MISRA Ref 21.13.1 [Character representation] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-2113 */
|
||||
/* coverity[misra_c_2012_rule_21_13_violation] */
|
||||
/* coverity[misra_c_2012_directive_4_6_violation] */
|
||||
while( ( **ppString != '\0' ) && ( isspace( ( ( int ) ( **ppString ) ) ) != 0U ) )
|
||||
{
|
||||
( *ppString )++;
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveTrailingWhiteSpaces( char * pString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
char * p = NULL;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
uint32_t stringLen = 0;
|
||||
|
||||
if( pString == NULL )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
stringLen = ( uint32_t ) strlen( pString );
|
||||
|
||||
/* This API intend to remove the trailing space, and this should be functional
|
||||
* when the string length is greater than 2. */
|
||||
if( stringLen > 2U )
|
||||
{
|
||||
p = &pString[ stringLen ];
|
||||
|
||||
do
|
||||
{
|
||||
--p;
|
||||
/* isspace is a standard library function and we cannot control it. */
|
||||
/* MISRA Ref 4.6.1 [Basic numerical type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
|
||||
/* MISRA Ref 21.13.1 [Character representation] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-2113 */
|
||||
/* coverity[misra_c_2012_directive_4_6_violation] */
|
||||
/* coverity[misra_c_2012_rule_21_13_violation] */
|
||||
} while( ( p > pString ) && ( isspace( ( int ) ( *p ) ) != 0U ) );
|
||||
|
||||
p[ 1 ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveAllWhiteSpaces( char * pString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
char * p = NULL;
|
||||
uint16_t ind = 0;
|
||||
char * pTempString = pString;
|
||||
|
||||
if( pString == NULL )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
p = pTempString;
|
||||
|
||||
while( ( *pTempString ) != '\0' )
|
||||
{
|
||||
/* isspace is a standard library function and we cannot control it. */
|
||||
/* MISRA Ref 4.6.1 [Basic numerical type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
|
||||
/* MISRA Ref 21.13.1 [Character representation] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-2113 */
|
||||
/* coverity[misra_c_2012_rule_21_13_violation] */
|
||||
/* coverity[misra_c_2012_directive_4_6_violation] */
|
||||
if( isspace( ( ( int ) ( *pTempString ) ) ) == 0U )
|
||||
{
|
||||
p[ ind ] = *pTempString;
|
||||
ind++;
|
||||
}
|
||||
|
||||
pTempString++;
|
||||
}
|
||||
|
||||
p[ ind ] = '\0';
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveOutermostDoubleQuote( char ** ppString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
char * p = NULL;
|
||||
uint32_t stringLen = 0;
|
||||
|
||||
if( ( ppString == NULL ) || ( *ppString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( *ppString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
stringLen = ( uint32_t ) strlen( *ppString );
|
||||
|
||||
if( stringLen > 2U )
|
||||
{
|
||||
if( **ppString == '\"' )
|
||||
{
|
||||
( *ppString )++;
|
||||
}
|
||||
|
||||
p = *ppString;
|
||||
|
||||
while( *p != '\0' )
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if( *--p == '\"' )
|
||||
{
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveAllDoubleQuote( char * pString )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
char * p = NULL;
|
||||
uint16_t ind = 0;
|
||||
char * pTempString = pString;
|
||||
|
||||
if( pString == NULL )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
p = pTempString;
|
||||
|
||||
while( ( *pTempString ) != '\0' )
|
||||
{
|
||||
if( *pTempString != '\"' )
|
||||
{
|
||||
p[ ind ] = *pTempString;
|
||||
ind++;
|
||||
}
|
||||
|
||||
pTempString++;
|
||||
}
|
||||
|
||||
p[ ind ] = '\0';
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATGetNextTok( char ** ppString,
|
||||
char ** ppTokOutput )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
const char * pDelimiter = ",";
|
||||
|
||||
if( ( ppString == NULL ) || ( ppTokOutput == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
atStatus = Cellular_ATGetSpecificNextTok( ppString, pDelimiter, ppTokOutput );
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATGetSpecificNextTok( char ** ppString,
|
||||
const char * pDelimiter,
|
||||
char ** ppTokOutput )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
uint16_t tokStrLen = 0, dataStrlen = 0;
|
||||
char * tok = NULL;
|
||||
|
||||
if( ( ppString == NULL ) || ( pDelimiter == NULL ) ||
|
||||
( ppTokOutput == NULL ) || ( *ppString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( *ppString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
dataStrlen = ( uint16_t ) strlen( *ppString );
|
||||
|
||||
if( ( **ppString ) == ( *pDelimiter ) )
|
||||
{
|
||||
**ppString = '\0';
|
||||
tok = *ppString;
|
||||
}
|
||||
else
|
||||
{
|
||||
tok = strtok( *ppString, pDelimiter );
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
tokStrLen = ( uint16_t ) strlen( tok );
|
||||
|
||||
if( ( tokStrLen < dataStrlen ) && ( ( *ppString )[ tokStrLen + 1U ] != '\0' ) )
|
||||
{
|
||||
*ppString = &tok[ strlen( tok ) + 1U ];
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppString = &tok[ strlen( tok ) ];
|
||||
}
|
||||
|
||||
*ppTokOutput = tok;
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static uint8_t _charToNibble( char c )
|
||||
{
|
||||
uint8_t ret = 0xFF;
|
||||
|
||||
if( ( c >= '0' ) && ( c <= '9' ) )
|
||||
{
|
||||
ret = ( uint8_t ) ( ( uint32_t ) c - ( uint32_t ) '0' );
|
||||
}
|
||||
else if( ( c >= 'a' ) && ( c <= 'f' ) )
|
||||
{
|
||||
ret = ( uint8_t ) ( ( uint32_t ) c - ( uint32_t ) 'a' + ( uint32_t ) 10 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( c >= 'A' ) && ( c <= 'F' ) )
|
||||
{
|
||||
ret = ( uint8_t ) ( ( uint32_t ) c - ( uint32_t ) 'A' + ( uint32_t ) 10 );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATHexStrToHex( const char * pString,
|
||||
uint8_t * pHexData,
|
||||
uint16_t hexDataLen )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
uint16_t strHexLen = 0, i = 0;
|
||||
const char * p;
|
||||
uint8_t firstNibble = 0, secondNibble = 0;
|
||||
|
||||
if( ( pString == NULL ) || ( pHexData == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
strHexLen = ( uint16_t ) ( strlen( pString ) / 2U );
|
||||
|
||||
if( strHexLen >= hexDataLen )
|
||||
{
|
||||
atStatus = CELLULAR_AT_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
p = pString;
|
||||
|
||||
for( i = 0; i < strHexLen; i++ )
|
||||
{
|
||||
firstNibble = _charToNibble( *p );
|
||||
secondNibble = _charToNibble( p[ 1 ] );
|
||||
|
||||
if( firstNibble == 0xFFU )
|
||||
{
|
||||
( pHexData )[ i ] = firstNibble;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstNibble = firstNibble << 4;
|
||||
( pHexData )[ i ] = firstNibble | secondNibble;
|
||||
}
|
||||
|
||||
p = &p[ 2 ];
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATIsStrDigit( const char * pString,
|
||||
bool * pResult )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
const char * pTempString = pString;
|
||||
|
||||
if( ( pResult == NULL ) || ( pString == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempString, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
*pResult = true;
|
||||
|
||||
while( ( *pTempString != '\0' ) )
|
||||
{
|
||||
/* isdigit is a standard library function and we cannot control it. */
|
||||
/* MISRA Ref 4.6.1 [Basic numerical type] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
|
||||
/* coverity[misra_c_2012_directive_4_6_violation] */
|
||||
if( isdigit( ( ( int ) ( *pTempString ) ) ) == 0U )
|
||||
{
|
||||
*pResult = false;
|
||||
}
|
||||
|
||||
pTempString++;
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATcheckErrorCode( const char * pInputBuf,
|
||||
const char * const * const ppKeyList,
|
||||
size_t keyListLen,
|
||||
bool * pResult )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
uint8_t i = 0;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
bool tmpResult;
|
||||
|
||||
if( ( pInputBuf == NULL ) || ( ppKeyList == NULL ) || ( pResult == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pInputBuf, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
*pResult = false;
|
||||
|
||||
for( i = 0; i < keyListLen; i++ )
|
||||
{
|
||||
if( ( Cellular_ATStrStartWith( pInputBuf, ppKeyList[ i ], &tmpResult ) == CELLULAR_AT_SUCCESS ) && tmpResult )
|
||||
{
|
||||
*pResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATStrDup( char ** ppDst,
|
||||
const char * pSrc )
|
||||
{
|
||||
char * p = NULL;
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
const char * pTempSrc = pSrc;
|
||||
CellularATStringValidationResult_t stringValidationResult = CELLULAR_AT_STRING_UNKNOWN;
|
||||
|
||||
if( ( ppDst == NULL ) || ( pTempSrc == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
validateString( pTempSrc, &stringValidationResult );
|
||||
|
||||
if( stringValidationResult != CELLULAR_AT_STRING_VALID )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
*ppDst = ( char * ) Platform_Malloc( sizeof( char ) * ( strlen( pTempSrc ) + 1U ) );
|
||||
|
||||
if( *ppDst != NULL )
|
||||
{
|
||||
p = *ppDst;
|
||||
|
||||
while( *pTempSrc != '\0' )
|
||||
{
|
||||
*p = *pTempSrc;
|
||||
p++;
|
||||
pTempSrc++;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
atStatus = CELLULAR_AT_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularATError_t Cellular_ATStrtoi( const char * pStr,
|
||||
int32_t base,
|
||||
int32_t * pResult )
|
||||
{
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
int32_t retStrtol = 0;
|
||||
char * pEndStr = NULL;
|
||||
|
||||
if( ( pStr == NULL ) || ( pResult == NULL ) )
|
||||
{
|
||||
atStatus = CELLULAR_AT_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* MISRA Ref 22.8.1 [Initialize errno] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-228 */
|
||||
/* coverity[misra_c_2012_rule_22_8_violation] */
|
||||
retStrtol = ( int32_t ) strtol( pStr, &pEndStr, base );
|
||||
|
||||
/* The return value zero may stand for the failure of strtol. So if the return value
|
||||
* is zero, need to check the address of pEndStr, if it's greater than the pStr, that
|
||||
* means there is an real parsed zero before pEndStr.
|
||||
*/
|
||||
if( pEndStr == pStr )
|
||||
{
|
||||
atStatus = CELLULAR_AT_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pResult = retStrtol;
|
||||
}
|
||||
}
|
||||
|
||||
/* MISRA Ref 4.7.1 [Testing errno] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-47 */
|
||||
/* MISRA Ref 22.9.1 [Testing errno] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-229 */
|
||||
/* coverity[need_errno_test] */
|
||||
/* coverity[return_without_test] */
|
||||
return atStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,543 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS Cellular Library APIs implementation without AT commands.
|
||||
*/
|
||||
|
||||
/* The config header is always included first. */
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_api.h"
|
||||
#include "cellular_internal.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_pkthandler_internal.h"
|
||||
#include "cellular_pktio_internal.h"
|
||||
#include "cellular_common_portable.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularError_t _socketSetSockOptLevelTransport( CellularSocketOption_t option,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
const uint8_t * pOptionValue,
|
||||
uint32_t optionValueLength );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Internal function of Cellular_SocketSetSockOpt to reduce complexity. */
|
||||
static CellularError_t _socketSetSockOptLevelTransport( CellularSocketOption_t option,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
const uint8_t * pOptionValue,
|
||||
uint32_t optionValueLength )
|
||||
{
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
const uint32_t * pTimeoutMs = NULL;
|
||||
|
||||
if( option == CELLULAR_SOCKET_OPTION_SEND_TIMEOUT )
|
||||
{
|
||||
if( optionValueLength == sizeof( uint32_t ) )
|
||||
{
|
||||
/* MISRA Ref 11.3 [Misaligned access] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-113 */
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
pTimeoutMs = ( const uint32_t * ) pOptionValue;
|
||||
socketHandle->sendTimeoutMs = *pTimeoutMs;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellularStatus = CELLULAR_INTERNAL_FAILURE;
|
||||
}
|
||||
}
|
||||
else if( option == CELLULAR_SOCKET_OPTION_RECV_TIMEOUT )
|
||||
{
|
||||
if( optionValueLength == sizeof( uint32_t ) )
|
||||
{
|
||||
/* MISRA Ref 11.3 [Misaligned access] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-113 */
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
pTimeoutMs = ( const uint32_t * ) pOptionValue;
|
||||
socketHandle->recvTimeoutMs = *pTimeoutMs;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellularStatus = CELLULAR_INTERNAL_FAILURE;
|
||||
}
|
||||
}
|
||||
else if( option == CELLULAR_SOCKET_OPTION_PDN_CONTEXT_ID )
|
||||
{
|
||||
if( ( socketHandle->socketState == SOCKETSTATE_ALLOCATED ) && ( optionValueLength == sizeof( uint8_t ) ) )
|
||||
{
|
||||
socketHandle->contextId = *pOptionValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the contextID in this state %d or length %d is invalid.",
|
||||
socketHandle->socketState, optionValueLength ) );
|
||||
cellularStatus = CELLULAR_INTERNAL_FAILURE;
|
||||
}
|
||||
}
|
||||
else if( option == CELLULAR_SOCKET_OPTION_SET_LOCAL_PORT )
|
||||
{
|
||||
if( ( socketHandle->socketState == SOCKETSTATE_ALLOCATED ) && ( optionValueLength == sizeof( uint16_t ) ) )
|
||||
{
|
||||
/* MISRA Ref 11.3 [Misaligned access] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-113 */
|
||||
/* coverity[misra_c_2012_rule_11_3_violation] */
|
||||
socketHandle->localPort = *( ( uint16_t * ) pOptionValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError( ( "Cellular_SocketSetSockOpt: Cannot change the localPort in this state %d or length %d is invalid.",
|
||||
socketHandle->socketState, optionValueLength ) );
|
||||
cellularStatus = CELLULAR_INTERNAL_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError( ( "Cellular_SocketSetSockOpt: Option not supported" ) );
|
||||
cellularStatus = CELLULAR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonInit( CellularHandle_t * pCellularHandle,
|
||||
const CellularCommInterface_t * pCommInterface,
|
||||
const CellularTokenTable_t * pTokenTable )
|
||||
{
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
CellularContext_t * pContext = NULL;
|
||||
|
||||
/* Init the common library. */
|
||||
cellularStatus = _Cellular_LibInit( pCellularHandle, pCommInterface, pTokenTable );
|
||||
|
||||
/* Init the module. */
|
||||
if( cellularStatus == CELLULAR_SUCCESS )
|
||||
{
|
||||
pContext = *pCellularHandle;
|
||||
cellularStatus = Cellular_ModuleInit( pContext, &pContext->pModueContext );
|
||||
}
|
||||
|
||||
/* Setup UE, URC and query register status. */
|
||||
if( cellularStatus == CELLULAR_SUCCESS )
|
||||
{
|
||||
cellularStatus = Cellular_ModuleEnableUE( pContext );
|
||||
}
|
||||
|
||||
if( cellularStatus == CELLULAR_SUCCESS )
|
||||
{
|
||||
cellularStatus = Cellular_ModuleEnableUrc( pContext );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonCleanup( CellularHandle_t cellularHandle )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
( void ) Cellular_ModuleCleanUp( pContext );
|
||||
( void ) _Cellular_LibCleanup( cellularHandle );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonRegisterUrcNetworkRegistrationEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->cbEvents.networkRegistrationCallback = networkRegistrationCallback;
|
||||
pContext->cbEvents.pNetworkRegistrationCallbackContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonRegisterUrcPdnEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcPdnEventCallback_t pdnEventCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->cbEvents.pdnEventCallback = pdnEventCallback;
|
||||
pContext->cbEvents.pPdnEventCallbackContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonRegisterUrcSignalStrengthChangedCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->cbEvents.signalStrengthChangedCallback = signalStrengthChangedCallback;
|
||||
pContext->cbEvents.pSignalStrengthChangedCallbackContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonRegisterUrcGenericCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcGenericCallback_t genericCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->cbEvents.genericCallback = genericCallback;
|
||||
pContext->cbEvents.pGenericCallbackContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonRegisterModemEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularModemEventCallback_t modemEventCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->cbEvents.modemEventCallback = modemEventCallback;
|
||||
pContext->cbEvents.pModemEventCallbackContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonATCommandRaw( CellularHandle_t cellularHandle,
|
||||
const char * pATCommandPrefix,
|
||||
const char * pATCommandPayload,
|
||||
CellularATCommandType_t atCommandType,
|
||||
CellularATCommandResponseReceivedCallback_t responseReceivedCallback,
|
||||
void * pData,
|
||||
uint16_t dataLen )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
CellularAtReq_t atReqGetResult = { 0 };
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( pATCommandPayload == NULL )
|
||||
{
|
||||
LogError( ( "Cellular_ATCommandRaw: Input parameter is NULL" ) );
|
||||
cellularStatus = CELLULAR_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
atReqGetResult.atCmdType = atCommandType;
|
||||
atReqGetResult.pAtRspPrefix = ( const char * ) pATCommandPrefix;
|
||||
atReqGetResult.pAtCmd = ( const char * ) pATCommandPayload;
|
||||
atReqGetResult.pData = pData;
|
||||
atReqGetResult.dataLen = dataLen;
|
||||
atReqGetResult.respCallback = responseReceivedCallback;
|
||||
|
||||
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext,
|
||||
atReqGetResult,
|
||||
CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS );
|
||||
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonCreateSocket( CellularHandle_t cellularHandle,
|
||||
uint8_t pdnContextId,
|
||||
CellularSocketDomain_t socketDomain,
|
||||
CellularSocketType_t socketType,
|
||||
CellularSocketProtocol_t socketProtocol,
|
||||
CellularSocketHandle_t * pSocketHandle )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( pSocketHandle == NULL )
|
||||
{
|
||||
LogError( ( "pSocketHandle is NULL" ) );
|
||||
cellularStatus = CELLULAR_BAD_PARAMETER;
|
||||
}
|
||||
else if( _Cellular_IsValidPdn( pdnContextId ) != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogError( ( "_Cellular_IsValidPdn failed" ) );
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellularStatus = _Cellular_CreateSocketData( pContext, pdnContextId,
|
||||
socketDomain, socketType, socketProtocol, pSocketHandle );
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonSocketSetSockOpt( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOptionLevel_t optionLevel,
|
||||
CellularSocketOption_t option,
|
||||
const uint8_t * pOptionValue,
|
||||
uint32_t optionValueLength )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( socketHandle == NULL )
|
||||
{
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else if( ( pOptionValue == NULL ) || ( optionValueLength == 0U ) )
|
||||
{
|
||||
LogError( ( "Cellular_SocketSetSockOpt: Invalid parameter" ) );
|
||||
cellularStatus = CELLULAR_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( optionLevel == CELLULAR_SOCKET_OPTION_LEVEL_IP )
|
||||
{
|
||||
LogError( ( "Cellular_SocketSetSockOpt: Option not supported" ) );
|
||||
cellularStatus = CELLULAR_UNSUPPORTED;
|
||||
}
|
||||
else /* optionLevel CELLULAR_SOCKET_OPTION_LEVEL_TRANSPORT. */
|
||||
{
|
||||
cellularStatus = _socketSetSockOptLevelTransport( option, socketHandle, pOptionValue, optionValueLength );
|
||||
}
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonSocketRegisterDataReadyCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketDataReadyCallback_t dataReadyCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( socketHandle == NULL )
|
||||
{
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
socketHandle->dataReadyCallback = dataReadyCallback;
|
||||
socketHandle->pDataReadyCallbackContext = pCallbackContext;
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonSocketRegisterSocketOpenCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOpenCallback_t socketOpenCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( socketHandle == NULL )
|
||||
{
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
socketHandle->openCallback = socketOpenCallback;
|
||||
socketHandle->pOpenCallbackContext = pCallbackContext;
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularError_t Cellular_CommonSocketRegisterClosedCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketClosedCallback_t closedCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle;
|
||||
CellularError_t cellularStatus = CELLULAR_SUCCESS;
|
||||
|
||||
/* pContext is checked in _Cellular_CheckLibraryStatus function. */
|
||||
cellularStatus = _Cellular_CheckLibraryStatus( pContext );
|
||||
|
||||
if( cellularStatus != CELLULAR_SUCCESS )
|
||||
{
|
||||
LogDebug( ( "_Cellular_CheckLibraryStatus failed" ) );
|
||||
}
|
||||
else if( socketHandle == NULL )
|
||||
{
|
||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
socketHandle->closedCallback = closedCallback;
|
||||
socketHandle->pClosedCallbackContext = pCallbackContext;
|
||||
}
|
||||
|
||||
return cellularStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
@ -0,0 +1,917 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS Cellular Library common packet handler functions to dispatch packet.
|
||||
*/
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_internal.h"
|
||||
#include "cellular_pkthandler_internal.h"
|
||||
#include "cellular_pktio_internal.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
|
||||
#endif
|
||||
|
||||
/* Windows simulator implementation. */
|
||||
#if defined( _WIN32 ) || defined( _WIN64 )
|
||||
#define strtok_r strtok_s
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _convertAndQueueRespPacket( CellularContext_t * pContext,
|
||||
const void * pBuf );
|
||||
static CellularPktStatus_t urcParseToken( CellularContext_t * pContext,
|
||||
char * pInputLine );
|
||||
static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext,
|
||||
const char * pBuf );
|
||||
static CellularPktStatus_t _Cellular_AtcmdRequestTimeoutWithCallbackRaw( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS );
|
||||
static CellularPktStatus_t _Cellular_DataSendWithTimeoutDelayRaw( CellularContext_t * pContext,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t timeoutMs,
|
||||
uint32_t interDelayMS );
|
||||
static void _Cellular_PktHandlerAcquirePktRequestMutex( CellularContext_t * pContext );
|
||||
static void _Cellular_PktHandlerReleasePktRequestMutex( CellularContext_t * pContext );
|
||||
static int _searchCompareFunc( const void * pInputToken,
|
||||
const void * pBase );
|
||||
static int32_t _sortCompareFunc( const void * pElem1Ptr,
|
||||
const void * pElem2Ptr );
|
||||
static void _Cellular_ProcessGenericUrc( const CellularContext_t * pContext,
|
||||
const char * pInputLine );
|
||||
static CellularPktStatus_t _atParseGetHandler( CellularContext_t * pContext,
|
||||
const char * pTokenPtr,
|
||||
char * pSavePtr );
|
||||
static CellularPktStatus_t _handleUndefinedMessage( CellularContext_t * pContext,
|
||||
const char * pLine );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _convertAndQueueRespPacket( CellularContext_t * pContext,
|
||||
const void * pBuf )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
const CellularATCommandResponse_t * pAtResp = NULL;
|
||||
|
||||
if( ( pBuf != NULL ) )
|
||||
{
|
||||
pAtResp = ( const CellularATCommandResponse_t * ) pBuf;
|
||||
|
||||
if( pAtResp->status == false )
|
||||
{
|
||||
/* The modem returns error code to indicate that the command failed. */
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
}
|
||||
|
||||
if( ( pContext->pktRespCB != NULL ) && ( pktStatus == CELLULAR_PKT_STATUS_OK ) )
|
||||
{
|
||||
pktStatus = pContext->pktRespCB( pContext,
|
||||
( const CellularATCommandResponse_t * ) pBuf,
|
||||
pContext->pPktUsrData,
|
||||
pContext->PktUsrDataLen );
|
||||
}
|
||||
|
||||
/* Notify calling thread, Not blocking immediately comes back if the queue is full. */
|
||||
if( xQueueSend( pContext->pktRespQueue, ( void * ) &pktStatus, ( TickType_t ) 0 ) != pdPASS )
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
LogError( ( "_convertAndQueueRespPacket: Got a response when the Resp Q is full!!" ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t urcParseToken( CellularContext_t * pContext,
|
||||
char * pInputLine )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
/* pInputLine = "+" pTokenPtr + ":" + pSavePtr.
|
||||
* if string not start with "+", then pTokenPtr = pSavePtr = pInputPtr. */
|
||||
char * pSavePtr = pInputLine, * pTokenPtr = pInputLine;
|
||||
|
||||
|
||||
LogDebug( ( "Next URC token to parse [%s]", pInputLine ) );
|
||||
|
||||
/* First check for + at the beginning and advance to point to the next
|
||||
* byte. Use that string to pass to strtok and retrieve the token. Once the
|
||||
* token use is retrieved, get the function handler map and call that
|
||||
* function. */
|
||||
if( *pSavePtr == '+' )
|
||||
{
|
||||
pSavePtr++;
|
||||
pTokenPtr = strtok_r( pSavePtr, ":", &pSavePtr );
|
||||
|
||||
if( pTokenPtr == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_AtParse : input string error, start with \"+\" but no token %s", pInputLine ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_REQUEST;
|
||||
}
|
||||
}
|
||||
|
||||
if( pktStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
/* Now get the handler function based on the token. */
|
||||
pktStatus = _atParseGetHandler( pContext, pTokenPtr, pSavePtr );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief copy the URC log in the buffer to a heap memory and process it.
|
||||
*/
|
||||
static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext,
|
||||
const char * pBuf )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
CellularATError_t atStatus = CELLULAR_AT_SUCCESS;
|
||||
char * payload = NULL;
|
||||
|
||||
if( pBuf != NULL )
|
||||
{
|
||||
atStatus = Cellular_ATStrDup( &payload, pBuf );
|
||||
|
||||
if( atStatus == CELLULAR_AT_SUCCESS )
|
||||
{
|
||||
/* The payload is null terminated. */
|
||||
pktStatus = urcParseToken( pContext, ( char * ) payload );
|
||||
Platform_Free( payload );
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
LogWarn( ( "Couldn't allocate memory of %u for urc", ( uint32_t ) strlen( pBuf ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
static CellularPktStatus_t _Cellular_AtcmdRequestTimeoutWithCallbackRaw( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS )
|
||||
{
|
||||
CellularPktStatus_t respCode = CELLULAR_PKT_STATUS_OK;
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
BaseType_t qRet = pdFALSE;
|
||||
|
||||
if( atReq.pAtCmd == NULL )
|
||||
{
|
||||
LogError( ( "PKT_STATUS_BAD_REQUEST, null AT param" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_REQUEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug( ( ">>>>>Start sending [%s]<<<<<", atReq.pAtCmd ) );
|
||||
|
||||
/* Fill in request info structure. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->pktRespCB = atReq.respCallback;
|
||||
pContext->pPktUsrData = atReq.pData;
|
||||
pContext->PktUsrDataLen = ( uint16_t ) atReq.dataLen;
|
||||
pContext->pCurrentCmd = atReq.pAtCmd;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
pktStatus = _Cellular_PktioSendAtCmd( pContext, atReq.pAtCmd, atReq.atCmdType, atReq.pAtRspPrefix );
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogError( ( "Can't send req packet" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait for a response. */
|
||||
qRet = xQueueReceive( pContext->pktRespQueue, &respCode, pdMS_TO_TICKS( timeoutMS ) );
|
||||
|
||||
if( qRet == pdTRUE )
|
||||
{
|
||||
pktStatus = ( CellularPktStatus_t ) respCode;
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogWarn( ( "Modem returns error in sending AT command %s, pktStatus %d.",
|
||||
atReq.pAtCmd, pktStatus ) );
|
||||
} /* Ignore errors from callbacks as they will be handled elsewhere. */
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_TIMED_OUT;
|
||||
LogError( ( "pkt_recv status=%d, AT cmd %s timed out", pktStatus, atReq.pAtCmd ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* No command is waiting response. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->PktioAtCmdType = CELLULAR_AT_NO_COMMAND;
|
||||
pContext->pktRespCB = NULL;
|
||||
pContext->pCurrentCmd = NULL;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
LogDebug( ( "<<<<<Exit sending [%s] status[%d]<<<<<", atReq.pAtCmd, pktStatus ) );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _Cellular_DataSendWithTimeoutDelayRaw( CellularContext_t * pContext,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t timeoutMs,
|
||||
uint32_t interDelayMS )
|
||||
{
|
||||
CellularPktStatus_t respCode = CELLULAR_PKT_STATUS_OK;
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
BaseType_t qStatus = pdFALSE;
|
||||
uint32_t sendEndPatternLen = 0U;
|
||||
|
||||
if( ( dataReq.pData == NULL ) || ( dataReq.pSentDataLength == NULL ) )
|
||||
{
|
||||
LogError( ( "_Cellular_DataSendWithTimeoutDelayRaw, null input" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_REQUEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug( ( ">>>>>Start sending Data <<<<<" ) );
|
||||
|
||||
/* Send the packet. Data send is regarded as CELLULAR_AT_NO_RESULT. Only
|
||||
* success or error token is expected in the result. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->PktioAtCmdType = CELLULAR_AT_NO_RESULT;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
*dataReq.pSentDataLength = _Cellular_PktioSendData( pContext, dataReq.pData, dataReq.dataLen );
|
||||
|
||||
if( *dataReq.pSentDataLength != dataReq.dataLen )
|
||||
{
|
||||
LogError( ( "_Cellular_DataSendWithTimeoutDelayRaw, incomplete data transfer" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_SEND_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Some driver required wait for a minimum of delay before sending data. */
|
||||
Platform_Delay( interDelayMS );
|
||||
|
||||
/* End pattern for specific modem. */
|
||||
if( ( pktStatus == CELLULAR_PKT_STATUS_OK ) && ( dataReq.pEndPattern != NULL ) )
|
||||
{
|
||||
sendEndPatternLen = _Cellular_PktioSendData( pContext, dataReq.pEndPattern, dataReq.endPatternLen );
|
||||
|
||||
if( sendEndPatternLen != dataReq.endPatternLen )
|
||||
{
|
||||
LogError( ( "_Cellular_DataSendWithTimeoutDelayRaw, incomplete endpattern transfer" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_SEND_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for a response. */
|
||||
if( pktStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
qStatus = xQueueReceive( pContext->pktRespQueue, &respCode, pdMS_TO_TICKS( timeoutMs ) );
|
||||
|
||||
if( qStatus == pdTRUE )
|
||||
{
|
||||
pktStatus = ( CellularPktStatus_t ) respCode;
|
||||
|
||||
if( pktStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogDebug( ( "Data sent successfully!" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWarn( ( "Modem returns error in sending data, pktStatus %d.", pktStatus ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_TIMED_OUT;
|
||||
LogError( ( "pkt_recv status=%d, data sending timed out", pktStatus ) );
|
||||
}
|
||||
|
||||
/* Set AT command type to CELLULAR_AT_NO_COMMAND for timeout case here. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->PktioAtCmdType = CELLULAR_AT_NO_COMMAND;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
LogDebug( ( "<<<<<Exit sending data ret[%d]>>>>>", pktStatus ) );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void _Cellular_PktHandlerAcquirePktRequestMutex( CellularContext_t * pContext )
|
||||
{
|
||||
PlatformMutex_Lock( &pContext->pktRequestMutex );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void _Cellular_PktHandlerReleasePktRequestMutex( CellularContext_t * pContext )
|
||||
{
|
||||
PlatformMutex_Unlock( &pContext->pktRequestMutex );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static int _searchCompareFunc( const void * pInputToken,
|
||||
const void * pBase )
|
||||
{
|
||||
int compareValue = 0;
|
||||
const char * pToken = ( const char * ) pInputToken;
|
||||
const CellularAtParseTokenMap_t * pBasePtr = ( const CellularAtParseTokenMap_t * ) pBase;
|
||||
uint32_t tokenLen = ( uint32_t ) strlen( pInputToken );
|
||||
uint32_t strLen = ( uint32_t ) strlen( pBasePtr->pStrValue );
|
||||
|
||||
compareValue = strncmp( pToken,
|
||||
pBasePtr->pStrValue,
|
||||
MIN( tokenLen, strLen ) );
|
||||
|
||||
/* To avoid undefined behavior, the table should not contain duplicated item and
|
||||
* compareValue is 0 only if the string is exactly the same. */
|
||||
if( ( compareValue == 0 ) && ( tokenLen != strLen ) )
|
||||
{
|
||||
if( tokenLen > strLen )
|
||||
{
|
||||
compareValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
compareValue = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return compareValue;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static int32_t _sortCompareFunc( const void * pElem1Ptr,
|
||||
const void * pElem2Ptr )
|
||||
{
|
||||
int32_t compareValue = 0;
|
||||
const CellularAtParseTokenMap_t * pElement1Ptr = ( const CellularAtParseTokenMap_t * ) pElem1Ptr;
|
||||
const CellularAtParseTokenMap_t * pElement2Ptr = ( const CellularAtParseTokenMap_t * ) pElem2Ptr;
|
||||
uint32_t element1PtrLen = ( uint32_t ) strlen( pElement1Ptr->pStrValue );
|
||||
uint32_t element2PtrLen = ( uint32_t ) strlen( pElement2Ptr->pStrValue );
|
||||
|
||||
compareValue = strncmp( pElement1Ptr->pStrValue,
|
||||
pElement2Ptr->pStrValue,
|
||||
MIN( element1PtrLen, element2PtrLen ) );
|
||||
|
||||
/* To avoid undefined behavior, the table should not contain duplicated item and
|
||||
* compareValue is 0 only if the string is exactly the same. */
|
||||
if( ( compareValue == 0 ) && ( element1PtrLen != element2PtrLen ) )
|
||||
{
|
||||
if( element1PtrLen > element2PtrLen )
|
||||
{
|
||||
compareValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
compareValue = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return compareValue;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void _Cellular_ProcessGenericUrc( const CellularContext_t * pContext,
|
||||
const char * pInputLine )
|
||||
{
|
||||
_Cellular_GenericCallback( pContext, pInputLine );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static CellularPktStatus_t _atParseGetHandler( CellularContext_t * pContext,
|
||||
const char * pTokenPtr,
|
||||
char * pSavePtr )
|
||||
{
|
||||
/* Now get the handler function based on the token. */
|
||||
const CellularAtParseTokenMap_t * pElementPtr = NULL;
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
const CellularAtParseTokenMap_t * pTokenMap = pContext->tokenTable.pCellularUrcHandlerTable;
|
||||
uint32_t tokenMapSize = pContext->tokenTable.cellularPrefixToParserMapSize;
|
||||
uint8_t decrementPointer = 0U;
|
||||
|
||||
/* MISRA Ref 21.9.1 [Use of bsearch] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#rule-219 */
|
||||
/* coverity[misra_c_2012_rule_21_9_violation] */
|
||||
pElementPtr = ( CellularAtParseTokenMap_t * ) bsearch( ( const void * ) pTokenPtr,
|
||||
( const void * ) pTokenMap,
|
||||
tokenMapSize,
|
||||
sizeof( CellularAtParseTokenMap_t ),
|
||||
_searchCompareFunc );
|
||||
|
||||
if( pElementPtr != NULL )
|
||||
{
|
||||
if( pElementPtr->parserFunc != NULL )
|
||||
{
|
||||
pElementPtr->parserFunc( pContext, pSavePtr );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWarn( ( "No URC Callback func avail %s", pTokenPtr ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No URC callback function available, check for generic call back. */
|
||||
LogDebug( ( "No URC Callback func avail %s, now trying generic URC Callback", pTokenPtr ) );
|
||||
|
||||
if( pSavePtr != pTokenPtr )
|
||||
{
|
||||
/* pSavePtr != pTokenPtr means the string starts with '+'.
|
||||
* Restore string to "+pTokenPtr:pSavePtr" for callback function. */
|
||||
decrementPointer = 1U;
|
||||
*( pSavePtr - 1 ) = ':';
|
||||
}
|
||||
|
||||
_Cellular_ProcessGenericUrc( pContext, pTokenPtr - decrementPointer );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* @brief Handle AT_UNDEFINED message type.
|
||||
*/
|
||||
static CellularPktStatus_t _handleUndefinedMessage( CellularContext_t * pContext,
|
||||
const char * pLine )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
LogInfo( ( "AT_UNDEFINED message received %s\r\n", pLine ) );
|
||||
|
||||
/* undefined message received. Try to handle it with cellular module
|
||||
* specific handler. */
|
||||
if( pContext->undefinedRespCallback == NULL )
|
||||
{
|
||||
LogError( ( "No undefined callback for AT_UNDEFINED type message %s received.",
|
||||
pLine ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = pContext->undefinedRespCallback( pContext->pUndefinedRespCBContext, pLine );
|
||||
|
||||
if( pktStatus != CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
LogError( ( "undefinedRespCallback returns error %d for AT_UNDEFINED type message %s received.",
|
||||
pktStatus, pLine ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void _Cellular_PktHandlerCleanup( CellularContext_t * pContext )
|
||||
{
|
||||
if( ( pContext != NULL ) && ( pContext->pktRespQueue != NULL ) )
|
||||
{
|
||||
/* Wait for response to finish. */
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
/* This is platform dependent api. */
|
||||
|
||||
( void ) vQueueDelete( pContext->pktRespQueue );
|
||||
pContext->pktRespQueue = NULL;
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_HandlePacket( CellularContext_t * pContext,
|
||||
_atRespType_t atRespType,
|
||||
const void * pBuf )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
switch( atRespType )
|
||||
{
|
||||
case AT_SOLICITED:
|
||||
pktStatus = _convertAndQueueRespPacket( pContext, pBuf );
|
||||
break;
|
||||
|
||||
case AT_UNSOLICITED:
|
||||
pktStatus = _processUrcPacket( pContext, pBuf );
|
||||
break;
|
||||
|
||||
case AT_UNDEFINED:
|
||||
pktStatus = _handleUndefinedMessage( pContext, pBuf );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
LogError( ( "_Cellular_HandlePacket Callback type (%d) error", atRespType ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_PktHandler_AtcmdRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_TimeoutAtcmdRequestWithCallback : Invalid cellular context" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
pktStatus = _Cellular_AtcmdRequestTimeoutWithCallbackRaw( pContext, atReq, timeoutMS );
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_AtcmdRequestSuccessToken( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t atTimeoutMS,
|
||||
const char ** pCellularSrcTokenSuccessTable,
|
||||
uint32_t cellularSrcTokenSuccessTableSize )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_AtcmdRequestSuccessToken : Invalid cellular context" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
else if( pCellularSrcTokenSuccessTable == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_AtcmdRequestSuccessToken : pCellularSrcTokenSuccessTable is NULL" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
|
||||
/* Set the extra Token table for this AT command. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->tokenTable.pCellularSrcExtraTokenSuccessTable = pCellularSrcTokenSuccessTable;
|
||||
pContext->tokenTable.cellularSrcExtraTokenSuccessTableSize = cellularSrcTokenSuccessTableSize;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
pktStatus = _Cellular_AtcmdRequestTimeoutWithCallbackRaw( pContext, atReq, atTimeoutMS );
|
||||
|
||||
/* Clear the extra Token table for this AT command. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->tokenTable.cellularSrcExtraTokenSuccessTableSize = 0;
|
||||
pContext->tokenTable.pCellularSrcExtraTokenSuccessTable = NULL;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataRecvRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS,
|
||||
CellularATCommandDataPrefixCallback_t pktDataPrefixCallback,
|
||||
void * pCallbackContext )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_TimeoutAtcmdDataRecvRequestWithCallback : Invalid cellular context" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
|
||||
/* Set the data receive prefix. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->pktDataPrefixCB = pktDataPrefixCallback;
|
||||
pContext->pDataPrefixCBContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
pktStatus = _Cellular_AtcmdRequestTimeoutWithCallbackRaw( pContext, atReq, timeoutMS );
|
||||
|
||||
/* Clear the data receive prefix. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->pktDataPrefixCB = NULL;
|
||||
pContext->pDataPrefixCBContext = NULL;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_AtcmdDataSend( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCallback,
|
||||
void * pCallbackContext,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS,
|
||||
uint32_t interDelayMS )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_TimeoutAtcmdDataSendRequestWithCallback : Invalid cellular context" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
|
||||
/* Set the data send prefix callback. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->pktDataSendPrefixCB = pktDataSendPrefixCallback;
|
||||
pContext->pDataSendPrefixCBContext = pCallbackContext;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
pktStatus = _Cellular_AtcmdRequestTimeoutWithCallbackRaw( pContext, atReq, atTimeoutMS );
|
||||
|
||||
/* Clear the data send prefix callback. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->pDataSendPrefixCBContext = NULL;
|
||||
pContext->pktDataSendPrefixCB = NULL;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
if( pktStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
pktStatus = _Cellular_DataSendWithTimeoutDelayRaw( pContext, dataReq, dataTimeoutMS, interDelayMS );
|
||||
}
|
||||
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS )
|
||||
{
|
||||
return _Cellular_AtcmdDataSend( pContext, atReq, dataReq, NULL, NULL, atTimeoutMS, dataTimeoutMS, 0U );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendSuccessToken( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS,
|
||||
const char ** pCellularSrcTokenSuccessTable,
|
||||
uint32_t cellularSrcTokenSuccessTableSize )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext == NULL )
|
||||
{
|
||||
LogError( ( "_Cellular_TimeoutAtcmdDataSendSuccessToken : Invalid cellular context" ) );
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Cellular_PktHandlerAcquirePktRequestMutex( pContext );
|
||||
|
||||
/* Set the extra token table. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->tokenTable.pCellularSrcExtraTokenSuccessTable = pCellularSrcTokenSuccessTable;
|
||||
pContext->tokenTable.cellularSrcExtraTokenSuccessTableSize = cellularSrcTokenSuccessTableSize;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
pktStatus = _Cellular_AtcmdRequestTimeoutWithCallbackRaw( pContext, atReq, atTimeoutMS );
|
||||
|
||||
/* Clear the extra token table. */
|
||||
PlatformMutex_Lock( &pContext->PktRespMutex );
|
||||
pContext->tokenTable.cellularSrcExtraTokenSuccessTableSize = 0;
|
||||
pContext->tokenTable.pCellularSrcExtraTokenSuccessTable = NULL;
|
||||
PlatformMutex_Unlock( &pContext->PktRespMutex );
|
||||
|
||||
if( pktStatus == CELLULAR_PKT_STATUS_OK )
|
||||
{
|
||||
pktStatus = _Cellular_DataSendWithTimeoutDelayRaw( pContext, dataReq, dataTimeoutMS, 0U );
|
||||
}
|
||||
|
||||
_Cellular_PktHandlerReleasePktRequestMutex( pContext );
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_PktHandlerInit( CellularContext_t * pContext )
|
||||
{
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
/* Create the response queue which is used to post reponses to the sender. */
|
||||
pContext->pktRespQueue = xQueueCreate( 1, ( uint32_t ) sizeof( CellularPktStatus_t ) );
|
||||
|
||||
if( pContext->pktRespQueue == NULL )
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_FAILURE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
CellularPktStatus_t _Cellular_AtParseInit( const CellularContext_t * pContext )
|
||||
{
|
||||
uint32_t i = 0;
|
||||
bool finit = true;
|
||||
const CellularAtParseTokenMap_t * pTokenMap = NULL;
|
||||
uint32_t tokenMapSize = 0;
|
||||
int32_t result = 0;
|
||||
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
|
||||
|
||||
if( ( pContext != NULL ) && ( pContext->tokenTable.pCellularUrcHandlerTable != NULL ) &&
|
||||
( pContext->tokenTable.cellularPrefixToParserMapSize > 0U ) )
|
||||
{
|
||||
pTokenMap = pContext->tokenTable.pCellularUrcHandlerTable;
|
||||
tokenMapSize = pContext->tokenTable.cellularPrefixToParserMapSize;
|
||||
|
||||
/* Check order of the sorted Map. */
|
||||
for( i = 0; i < ( tokenMapSize - 1U ); i++ )
|
||||
{
|
||||
result = _sortCompareFunc( &pTokenMap[ i ], &pTokenMap[ i + 1U ] );
|
||||
|
||||
if( result >= 0 )
|
||||
{
|
||||
LogError( ( "AtParseFail for %u: %d %s %s", i, result,
|
||||
pTokenMap[ i ].pStrValue, pTokenMap[ i + 1U ].pStrValue ) );
|
||||
finit = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( finit != true )
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_BAD_PARAM;
|
||||
LogError( ( "AtParseFail URC token table is not sorted" ) );
|
||||
}
|
||||
|
||||
configASSERT( finit == true );
|
||||
|
||||
for( i = 0; i < tokenMapSize; i++ )
|
||||
{
|
||||
LogDebug( ( "Callbacks setup for %u : %s", i, pTokenMap[ i ].pStrValue ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pktStatus = CELLULAR_PKT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return pktStatus;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool _Cellular_CreatePktRequestMutex( CellularContext_t * pContext )
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
status = PlatformMutex_Create( &pContext->pktRequestMutex, false );
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool _Cellular_CreatePktResponseMutex( CellularContext_t * pContext )
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if( pContext != NULL )
|
||||
{
|
||||
status = PlatformMutex_Create( &pContext->PktRespMutex, false );
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void _Cellular_DestroyPktRequestMutex( CellularContext_t * pContext )
|
||||
{
|
||||
if( pContext != NULL )
|
||||
{
|
||||
PlatformMutex_Destroy( &pContext->pktRequestMutex );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void _Cellular_DestroyPktResponseMutex( CellularContext_t * pContext )
|
||||
{
|
||||
if( pContext != NULL )
|
||||
{
|
||||
PlatformMutex_Destroy( &pContext->PktRespMutex );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,646 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_api.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_API_H__
|
||||
#define __CELLULAR_API_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* IoT Cellular data types. */
|
||||
#include "cellular_types.h"
|
||||
|
||||
/* Hardware interface. */
|
||||
#include "cellular_comm_interface.h"
|
||||
|
||||
/**
|
||||
* @brief One time initialization function.
|
||||
*
|
||||
* This function initializes and returns the supplied context. It must be called
|
||||
* once (and only once) before calling any other function of this library.
|
||||
*
|
||||
* @param[in,out] pCellularHandle the handle pointer to store the cellular handle.
|
||||
* @param[in] pCommInterface Comm interface for communicating with the module.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_Init( CellularHandle_t * pCellularHandle,
|
||||
const CellularCommInterface_t * pCommInterface );
|
||||
|
||||
/**
|
||||
* @brief One time deinitialization function.
|
||||
*
|
||||
* This function frees resources taken in Cellular_Init. After this function
|
||||
* returns, Cellular_Init must be called again before calling any other function
|
||||
* of this library.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_Cleanup( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief Configure the priority order in which the networks are searched.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pRatPriorities An array of RATs in priority order. For example, to
|
||||
* search NB-IoT first, then Cat-M1 and then LTE, the array should contain:
|
||||
* { CELLULAR_RAT_NBIOT, CELLULAR_RAT_CATM1, CELLULAR_RAT_LTE }.
|
||||
* @param[in] ratPrioritiesLength Length of the pRatPriorities array.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SetRatPriority( CellularHandle_t cellularHandle,
|
||||
const CellularRat_t * pRatPriorities,
|
||||
uint8_t ratPrioritiesLength );
|
||||
|
||||
/**
|
||||
* @brief Get the priority order in which the networks are searched.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pRatPriorities An array of current RATs in priority order.
|
||||
* @param[in] ratPrioritiesLength Length of the pRatPriorities array.
|
||||
* @param[out] pOutputRatPrioritiesLength Actual number of items filled into pRatPriorities
|
||||
* by this function when it returns.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetRatPriority( CellularHandle_t cellularHandle,
|
||||
CellularRat_t * pRatPriorities,
|
||||
uint8_t ratPrioritiesLength,
|
||||
uint8_t * pOutputRatPrioritiesLength );
|
||||
|
||||
/**
|
||||
* @brief Turn on RF i.e. turn-off airplane mode.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RfOn( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief Turn off RF i.e. turn-on airplane mode.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RfOff( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief Get SIM card status (activated/Pin set etc.).
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pSimCardStatus Out parameter to provide the SIM card status.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetSimCardStatus( CellularHandle_t cellularHandle,
|
||||
CellularSimCardStatus_t * pSimCardStatus );
|
||||
|
||||
/**
|
||||
* @brief Get SIM card information (IMSI, SIM Card number etc.).
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pSimCardInfo Out parameter to provide the SIM card information.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetSimCardInfo( CellularHandle_t cellularHandle,
|
||||
CellularSimCardInfo_t * pSimCardInfo );
|
||||
|
||||
/**
|
||||
* @brief Get the information about the modem (HW version, FW version etc.).
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pModemInfo Out parameter to provide the modem information.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetModemInfo( CellularHandle_t cellularHandle,
|
||||
CellularModemInfo_t * pModemInfo );
|
||||
|
||||
/**
|
||||
* @brief Get the network on which SIM is currently registered/camped.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pNetworkInfo Out parameter to provide the network information.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetRegisteredNetwork( CellularHandle_t cellularHandle,
|
||||
CellularPlmnInfo_t * pNetworkInfo );
|
||||
|
||||
/**
|
||||
* @brief Get the network time.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pNetworkTime Out parameter to provide the network time.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetNetworkTime( CellularHandle_t cellularHandle,
|
||||
CellularTime_t * pNetworkTime );
|
||||
|
||||
/**
|
||||
* @brief Get signal information.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pSignalInfo Out parameter to provide the signal information.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetSignalInfo( CellularHandle_t cellularHandle,
|
||||
CellularSignalInfo_t * pSignalInfo );
|
||||
|
||||
/**
|
||||
* @brief Get network service status.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pServiceStatus Out parameter to provide the service status.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetServiceStatus( CellularHandle_t cellularHandle,
|
||||
CellularServiceStatus_t * pServiceStatus );
|
||||
|
||||
/**
|
||||
* @brief Set PDN config for a PDN context.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN to set the config for. Context ID value
|
||||
* should be in range between CELLULAR_PDN_CONTEXT_ID_MIN and CELLULAR_PDN_CONTEXT_ID_MAX.
|
||||
* The context ID with specified PDN config will be used with other CELLULAR APIs.
|
||||
* @param[in] pPdnConfig PDN config to set.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SetPdnConfig( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
const CellularPdnConfig_t * pPdnConfig );
|
||||
|
||||
/**
|
||||
* @brief Get status reports for all PDN contexts.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pPdnStatusBuffers Out parameter to provide array of PDN contexts.
|
||||
* @param[in] numStatusBuffers Number of CellularPdnStatus_t buffers in the
|
||||
* provided array pPdnStatusBuffers.
|
||||
* @param[out] pNumStatus Out parameter to provide the number of PDN statuses
|
||||
* returned.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetPdnStatus( CellularHandle_t cellularHandle,
|
||||
CellularPdnStatus_t * pPdnStatusBuffers,
|
||||
uint8_t numStatusBuffers,
|
||||
uint8_t * pNumStatus );
|
||||
|
||||
/**
|
||||
* @brief Activate a PDN context.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN context to activate. The same context ID
|
||||
* should be used with Cellular_SetPdnConfig before calling this API.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ActivatePdn( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId );
|
||||
|
||||
/**
|
||||
* @brief Deactivate a PDN context.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN context to deactivate.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_DeactivatePdn( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId );
|
||||
|
||||
/**
|
||||
* @brief Get the IP Address assigned to the module.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN context for which IP address is requested.
|
||||
* @param[out] pBuffer the buffer to receive the IP address into. The returned pBuffer
|
||||
* is a NULL terminated string.
|
||||
* @param[in] bufferLength of the buffer pBuffer.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetIPAddress( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
char * pBuffer,
|
||||
uint32_t bufferLength );
|
||||
|
||||
/**
|
||||
* @brief Set the DNS server to use.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN context for which DNS needs to be set.
|
||||
* @param[in] pDnsServerAddress The address of the DNS server to set.
|
||||
* It should be a NULL terminated string.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SetDns( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
const char * pDnsServerAddress );
|
||||
|
||||
/**
|
||||
* @brief Register/Remove callback for Network Registration URC events.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] networkRegistrationCallback The callback to register. Set to NULL
|
||||
* to remove the existing callback.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RegisterUrcNetworkRegistrationEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register/Remove callback for PDN related URC events.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pdnEventCallback The callback to register. Set to NULL remove the
|
||||
* existing callback.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RegisterUrcPdnEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcPdnEventCallback_t pdnEventCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register callback for Signal Strength changed URC events.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] signalStrengthChangedCallback The callback to register. Set to
|
||||
* NULL to remove the existing callback.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RegisterUrcSignalStrengthChangedCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register callback for all modem related events.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] modemEventCallback The callback to register. Set to NULL to remove
|
||||
* the existing callback.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RegisterModemEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularModemEventCallback_t modemEventCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register generic callback for all other URC events than covered in
|
||||
* above callbacks.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] genericCallback The callback to register. Set to NULL to remove
|
||||
* the existing callback.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_RegisterUrcGenericCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcGenericCallback_t genericCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Get current PSM settings.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pPsmSettings Out parameter to provide the PSM settings.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetPsmSettings( CellularHandle_t cellularHandle,
|
||||
CellularPsmSettings_t * pPsmSettings );
|
||||
|
||||
/**
|
||||
* @brief Set PSM settings.
|
||||
*
|
||||
* Enable/disable PSM by using CellularPsmSettings_t structure.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pPsmSettings PSM settings to set.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SetPsmSettings( CellularHandle_t cellularHandle,
|
||||
const CellularPsmSettings_t * pPsmSettings );
|
||||
|
||||
/**
|
||||
* @brief Get current e-I-DRX settings.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pEidrxSettingsList Out parameter to provide the e-I-DRX settings.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetEidrxSettings( CellularHandle_t cellularHandle,
|
||||
CellularEidrxSettingsList_t * pEidrxSettingsList );
|
||||
|
||||
/**
|
||||
* @brief Set e-I-DRX settings.
|
||||
*
|
||||
* This API can be used to enable/disable e-I-DRX by using the mode member of
|
||||
* CellularEidrxSettings_t.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pEidrxSettings e-I-DRX settings to set.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SetEidrxSettings( CellularHandle_t cellularHandle,
|
||||
const CellularEidrxSettings_t * pEidrxSettings );
|
||||
|
||||
/**
|
||||
* @brief Send the raw AT command to the module.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pATCommandPrefix The AT command response prefix. NULL if the response
|
||||
* has no prefix.
|
||||
* @param[in] pATCommandPayload The AT command to send. It should be a NULL terminated
|
||||
* string.
|
||||
* @param[in] atCommandType Type of AT command.
|
||||
* @param[in] responseReceivedCallback Callback to be invoked when a response for the
|
||||
* command is received.
|
||||
* @param[in] pData The pData pointer will be passed in responseReceivedCallback.
|
||||
* @param[in] dataLen The dataLen value will be passed in responseReceivedCallback.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ATCommandRaw( CellularHandle_t cellularHandle,
|
||||
const char * pATCommandPrefix,
|
||||
const char * pATCommandPayload,
|
||||
CellularATCommandType_t atCommandType,
|
||||
CellularATCommandResponseReceivedCallback_t responseReceivedCallback,
|
||||
void * pData,
|
||||
uint16_t dataLen );
|
||||
|
||||
/**
|
||||
* @brief Create a socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pdnContextId pdn context id on which this socket needs to be created. The pdn
|
||||
* context must be previously activated by Cellular_ActivatePdn function.
|
||||
* @param[in] socketDomain Socket domain.
|
||||
* @param[in] socketType Socket Type.
|
||||
* @param[in] socketProtocol Socket Protocol.
|
||||
* @param[out] pSocketHandle Out parameter to provide the created handle.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_CreateSocket( CellularHandle_t cellularHandle,
|
||||
uint8_t pdnContextId,
|
||||
CellularSocketDomain_t socketDomain,
|
||||
CellularSocketType_t socketType,
|
||||
CellularSocketProtocol_t socketProtocol,
|
||||
CellularSocketHandle_t * pSocketHandle );
|
||||
|
||||
/**
|
||||
* @brief Connect to a remote socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] dataAccessMode Data access mode of the socket. Buffer, Direct Push or Transparent.
|
||||
* @param[in] pRemoteSocketAddress Address (IP and Port) of the remote socket to connect to.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketConnect( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketAccessMode_t dataAccessMode,
|
||||
const CellularSocketAddress_t * pRemoteSocketAddress );
|
||||
|
||||
/**
|
||||
* @brief Send data to the connected remote socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] pData The buffer containing that data to be sent.
|
||||
* @param[in] dataLength Length of the data in the pData buffer.
|
||||
* @param[out] pSentDataLength Out parameter to provide the length of the actual
|
||||
* data sent. Note that it may be less than the dataLength in case complete data
|
||||
* could not be sent.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketSend( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
const uint8_t * pData,
|
||||
uint32_t dataLength,
|
||||
uint32_t * pSentDataLength );
|
||||
|
||||
/**
|
||||
* @brief Receive data on a connected socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[out] pBuffer The buffer to receive the data into.
|
||||
* @param[in] bufferLength Length of the buffer pBuffer.
|
||||
* @param[out] pReceivedDataLength Out parameter to provide the of the actual
|
||||
* data received in the buffer pBuffer. Note that it may be less than
|
||||
* bufferLength.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketRecv( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
uint8_t * pBuffer,
|
||||
uint32_t bufferLength,
|
||||
uint32_t * pReceivedDataLength );
|
||||
|
||||
/**
|
||||
* @brief Close the socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketClose( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle );
|
||||
|
||||
/**
|
||||
* @brief Resolve a host name using Domain Name Service.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Context ID of the PDN context for which DNS is set.
|
||||
* @param[in] pcHostName The host name to resolve.
|
||||
* It should be a NULL terminated string.
|
||||
* The length of the string should not exceed RFC1035 defined.
|
||||
* @param[out] pResolvedAddress The output parameter to return the resolved
|
||||
* address. The length of this buffer should be at least CELLULAR_IP_ADDRESS_MAX_SIZE.
|
||||
* The returned buffer is a NULL terminated string.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_GetHostByName( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
const char * pcHostName,
|
||||
char * pResolvedAddress );
|
||||
|
||||
/**
|
||||
* @brief Set options for a socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] optionLevel Socket option level (IP or TCP/UDP).
|
||||
* @param[in] option Socket option to set.
|
||||
* @param[in] pOptionValue Buffer containing the socket option value.
|
||||
* @param[in] optionValueLength Length of the value pointed to by pOptionValue.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketSetSockOpt( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOptionLevel_t optionLevel,
|
||||
CellularSocketOption_t option,
|
||||
const uint8_t * pOptionValue,
|
||||
uint32_t optionValueLength );
|
||||
|
||||
/**
|
||||
* @brief Register Socket open callback on the socket.
|
||||
*
|
||||
* This callback is invoked when modem confirms that a socket is opened.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] socketOpenCallback The callback to register.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketRegisterSocketOpenCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOpenCallback_t socketOpenCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register data ready callback on the socket.
|
||||
*
|
||||
* This callback is invoked whenever data is ready to be read from the socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] dataReadyCallback The callback to register.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketRegisterDataReadyCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketDataReadyCallback_t dataReadyCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Register closed callback on the socket.
|
||||
*
|
||||
* This callback is invoked whenever remote end closes the connection on a
|
||||
* connected socket.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
* @param[in] closedCallback The callback to register.
|
||||
* @param[in] pCallbackContext The context to be passed to callback function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_SocketRegisterClosedCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketClosedCallback_t closedCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_API_H__ */
|
||||
@ -0,0 +1,480 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_config_defaults.h
|
||||
* @brief This represents the default values for the configuration macros
|
||||
* for the Cellular library.
|
||||
*
|
||||
* @note This file SHOULD NOT be modified. If custom values are needed for
|
||||
* any configuration macro, a cellular_config.h file should be provided to
|
||||
* the Cellular library to override the default values defined in this file.
|
||||
* To use the custom config file, the CELLULAR_DO_NOT_USE_CUSTOM_CONFIG preprocessor
|
||||
* macro SHOULD NOT be set.
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_CONFIG_DEFAULTS_H__
|
||||
#define __CELLULAR_CONFIG_DEFAULTS_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* The macro definition for CELLULAR_DO_NOT_USE_CUSTOM_CONFIG is for Doxygen
|
||||
* documentation only. */
|
||||
|
||||
/**
|
||||
* @brief Define this macro to build the Cellular library without the custom config
|
||||
* file cellular_config.h.
|
||||
*
|
||||
* Without the custom config, the Cellular library builds with
|
||||
* default values of config macros defined in cellular_config_defaults.h file.
|
||||
*
|
||||
* If a custom config is provided, then CELLULAR_DO_NOT_USE_CUSTOM_CONFIG should not
|
||||
* be defined.
|
||||
*/
|
||||
#ifdef DOXYGEN
|
||||
#define CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mobile country code max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 3
|
||||
*/
|
||||
#ifndef CELLULAR_MCC_MAX_SIZE
|
||||
#define CELLULAR_MCC_MAX_SIZE ( 3U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mobile network code max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 3
|
||||
*/
|
||||
#ifndef CELLULAR_MNC_MAX_SIZE
|
||||
#define CELLULAR_MNC_MAX_SIZE ( 3U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Integrate circuit card identity max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 20
|
||||
*/
|
||||
#ifndef CELLULAR_ICCID_MAX_SIZE
|
||||
#define CELLULAR_ICCID_MAX_SIZE ( 20U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief International Mobile Subscriber Identity max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 15
|
||||
*/
|
||||
#ifndef CELLULAR_IMSI_MAX_SIZE
|
||||
#define CELLULAR_IMSI_MAX_SIZE ( 15U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module firmware version max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_FW_VERSION_MAX_SIZE
|
||||
#define CELLULAR_FW_VERSION_MAX_SIZE ( 32U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module hardware version max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 12
|
||||
*/
|
||||
#ifndef CELLULAR_HW_VERSION_MAX_SIZE
|
||||
#define CELLULAR_HW_VERSION_MAX_SIZE ( 12U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module serial number max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 12
|
||||
*/
|
||||
#ifndef CELLULAR_SERIAL_NUM_MAX_SIZE
|
||||
#define CELLULAR_SERIAL_NUM_MAX_SIZE ( 12U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief International Mobile Equipment Identity number max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 15
|
||||
*/
|
||||
#ifndef CELLULAR_IMEI_MAX_SIZE
|
||||
#define CELLULAR_IMEI_MAX_SIZE ( 15U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Registered network operator name max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_NETWORK_NAME_MAX_SIZE
|
||||
#define CELLULAR_NETWORK_NAME_MAX_SIZE ( 32U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Access point name max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_APN_MAX_SIZE
|
||||
#define CELLULAR_APN_MAX_SIZE ( 64U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Packet data network username max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_PDN_USERNAME_MAX_SIZE
|
||||
#define CELLULAR_PDN_USERNAME_MAX_SIZE ( 32U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Packet data network password max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_PDN_PASSWORD_MAX_SIZE
|
||||
#define CELLULAR_PDN_PASSWORD_MAX_SIZE ( 32u )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular data network IP address max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 40
|
||||
*/
|
||||
#ifndef CELLULAR_IP_ADDRESS_MAX_SIZE
|
||||
#define CELLULAR_IP_ADDRESS_MAX_SIZE ( 40U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular AT command max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 200
|
||||
*/
|
||||
#ifndef CELLULAR_AT_CMD_MAX_SIZE
|
||||
#define CELLULAR_AT_CMD_MAX_SIZE ( 200U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module number of socket max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 12
|
||||
*/
|
||||
#ifndef CELLULAR_NUM_SOCKET_MAX
|
||||
#define CELLULAR_NUM_SOCKET_MAX ( 12U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module manufacture ID max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 20
|
||||
*/
|
||||
#ifndef CELLULAR_MANUFACTURE_ID_MAX_SIZE
|
||||
#define CELLULAR_MANUFACTURE_ID_MAX_SIZE ( 20U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module ID max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 10
|
||||
*/
|
||||
#ifndef CELLULAR_MODEL_ID_MAX_SIZE
|
||||
#define CELLULAR_MODEL_ID_MAX_SIZE ( 10U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular EDRX list max size.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 4
|
||||
*/
|
||||
#ifndef CELLULAR_EDRX_LIST_MAX_SIZE
|
||||
#define CELLULAR_EDRX_LIST_MAX_SIZE ( 4U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular PDN context ID min value.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1
|
||||
*/
|
||||
#ifndef CELLULAR_PDN_CONTEXT_ID_MIN
|
||||
#define CELLULAR_PDN_CONTEXT_ID_MIN ( 1U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular PDN context ID max value.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1
|
||||
*/
|
||||
#ifndef CELLULAR_PDN_CONTEXT_ID_MAX
|
||||
#define CELLULAR_PDN_CONTEXT_ID_MAX ( 16U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular RAT ( radio access technology ) priority count.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1
|
||||
*/
|
||||
#ifndef CELLULAR_MAX_RAT_PRIORITY_COUNT
|
||||
#define CELLULAR_MAX_RAT_PRIORITY_COUNT ( 3U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular socket max send data length.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1460
|
||||
*/
|
||||
#ifndef CELLULAR_MAX_SEND_DATA_LEN
|
||||
#define CELLULAR_MAX_SEND_DATA_LEN ( 1460U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular socket max receive data length.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1500
|
||||
*/
|
||||
#ifndef CELLULAR_MAX_RECV_DATA_LEN
|
||||
#define CELLULAR_MAX_RECV_DATA_LEN ( 1500U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular module support getHostByName.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`0 or 1`<br>
|
||||
* <b>Default value (if undefined):</b> 1
|
||||
*/
|
||||
#ifndef CELLULAR_SUPPORT_GETHOSTBYNAME
|
||||
#define CELLULAR_SUPPORT_GETHOSTBYNAME ( 1U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular comm interface send timeout in MS.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1000
|
||||
*/
|
||||
#ifndef CELLULAR_COMM_IF_SEND_TIMEOUT_MS
|
||||
#define CELLULAR_COMM_IF_SEND_TIMEOUT_MS ( 1000U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular comm interface receive timeout in MS.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 1000
|
||||
*/
|
||||
#ifndef CELLULAR_COMM_IF_RECV_TIMEOUT_MS
|
||||
#define CELLULAR_COMM_IF_RECV_TIMEOUT_MS ( 1000U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief FreeRTOS Cellular Library use static context.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`0 or 1`<br>
|
||||
* <b>Default value (if undefined):</b> 0
|
||||
*/
|
||||
#ifndef CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT
|
||||
#define CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT ( 0U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular comm interface use static context.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`0 or 1`<br>
|
||||
* <b>Default value (if undefined):</b> 0
|
||||
*/
|
||||
#ifndef CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION
|
||||
#define CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION ( 0U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default radio access technoloyg.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`Any value before CELLULAR_RAT_MAX` ( Reference : @ref CellularRat_t )<br>
|
||||
* <b>Default value (if undefined):</b> CELLULAR_RAT_CATM1
|
||||
*/
|
||||
#ifndef CELLULAR_CONFIG_DEFAULT_RAT
|
||||
#define CELLULAR_CONFIG_DEFAULT_RAT ( 8 ) /* Set default RAT to CELLULAR_RAT_CATM1 @ref CellularRat_t. */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular comm interface use static socket context.<br>
|
||||
*
|
||||
* <b>Possible values:</b>`0 or 1`<br>
|
||||
* <b>Default value (if undefined):</b> 0
|
||||
*/
|
||||
#ifndef CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION
|
||||
#define CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION ( 0 )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular common AT command timeout.<br>
|
||||
*
|
||||
* The timeout value for Cellular_Common prefix APIs. The timeout value should be
|
||||
* set according to spec. It should be long enough for AT command used in cellular
|
||||
* common APIs.
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 5000
|
||||
*/
|
||||
#ifndef CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
|
||||
#define CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS ( 5000U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular AT command raw timeout.<br>
|
||||
*
|
||||
* The timeout value for Cellular_ATCommandRaw API.
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 5000
|
||||
*/
|
||||
#ifndef CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS
|
||||
#define CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS ( 5000U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Cellular AT command response prefix string length.<br>
|
||||
*
|
||||
* The maximum length of AT command response prefix string.
|
||||
*
|
||||
* <b>Possible values:</b>`Any positive integer`<br>
|
||||
* <b>Default value (if undefined):</b> 32
|
||||
*/
|
||||
#ifndef CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH
|
||||
#define CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH ( 32U )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro that is called in the cellular library for logging "Error" level
|
||||
* messages.
|
||||
*
|
||||
* To enable error level logging in the cellular library, this macro should be mapped to the
|
||||
* application-specific logging implementation that supports error logging.
|
||||
*
|
||||
* @note This logging macro is called in the cellular library with parameters wrapped in
|
||||
* double parentheses to be ISO C89/C90 standard compliant. For a reference
|
||||
* POSIX implementation of the logging macros, refer to cellular_config.h files.
|
||||
*
|
||||
* <b>Default value</b>: Error logging is turned off, and no code is generated for calls
|
||||
* to the macro in the cellular library on compilation.
|
||||
*/
|
||||
#ifndef LogError
|
||||
#define LogError( message )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro that is called in the cellular library for logging "Warning" level
|
||||
* messages.
|
||||
*
|
||||
* To enable warning level logging in the cellular library, this macro should be mapped to the
|
||||
* application-specific logging implementation that supports warning logging.
|
||||
*
|
||||
* @note This logging macro is called in the cellular library with parameters wrapped in
|
||||
* double parentheses to be ISO C89/C90 standard compliant. For a reference
|
||||
* POSIX implementation of the logging macros, refer to cellular_config.h files.
|
||||
*
|
||||
* <b>Default value</b>: Warning logs are turned off, and no code is generated for calls
|
||||
* to the macro in the cellular library on compilation.
|
||||
*/
|
||||
#ifndef LogWarn
|
||||
#define LogWarn( message )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro that is called in the cellular library for logging "Info" level
|
||||
* messages.
|
||||
*
|
||||
* To enable info level logging in the cellular library, this macro should be mapped to the
|
||||
* application-specific logging implementation that supports info logging.
|
||||
*
|
||||
* @note This logging macro is called in the cellular library with parameters wrapped in
|
||||
* double parentheses to be ISO C89/C90 standard compliant. For a reference
|
||||
* POSIX implementation of the logging macros, refer to cellular_config.h files.
|
||||
*
|
||||
* <b>Default value</b>: Info logging is turned off, and no code is generated for calls
|
||||
* to the macro in the cellular library on compilation.
|
||||
*/
|
||||
#ifndef LogInfo
|
||||
#define LogInfo( message )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro that is called in the cellular library for logging "Debug" level
|
||||
* messages.
|
||||
*
|
||||
* To enable debug level logging from cellular library, this macro should be mapped to the
|
||||
* application-specific logging implementation that supports debug logging.
|
||||
*
|
||||
* @note This logging macro is called in the cellular library with parameters wrapped in
|
||||
* double parentheses to be ISO C89/C90 standard compliant. For a reference
|
||||
* POSIX implementation of the logging macros, refer to cellular_config.h files.
|
||||
*
|
||||
* <b>Default value</b>: Debug logging is turned off, and no code is generated for calls
|
||||
* to the macro in the cellular library on compilation.
|
||||
*/
|
||||
#ifndef LogDebug
|
||||
#define LogDebug( message )
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_CONFIG_DEFAULTS_H__ */
|
||||
@ -0,0 +1,831 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_types.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_TYPES_H__
|
||||
#define __CELLULAR_TYPES_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Includes for standard bool and int. */
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Invalid signal value.
|
||||
*/
|
||||
#define CELLULAR_INVALID_SIGNAL_VALUE ( -32768 )
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Invalid signal bar value.
|
||||
*/
|
||||
#define CELLULAR_INVALID_SIGNAL_BAR_VALUE ( 0xFFU )
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_handles
|
||||
* @brief Opaque Cellular context structure.
|
||||
*/
|
||||
struct CellularContext;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_handles
|
||||
* @brief Opaque Cellular context structure type.
|
||||
*/
|
||||
typedef struct CellularContext CellularContext_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_handles
|
||||
* @brief Opaque Cellular handle.
|
||||
*/
|
||||
typedef struct CellularContext * CellularHandle_t;
|
||||
|
||||
struct CellularSocketContext;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_handles
|
||||
* @brief Opaque socket handle.
|
||||
*/
|
||||
typedef struct CellularSocketContext * CellularSocketHandle_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Status code returns from APIs.
|
||||
*/
|
||||
typedef enum CellularError
|
||||
{
|
||||
CELLULAR_SUCCESS = 0, /**< The operation was successful. */
|
||||
CELLULAR_INVALID_HANDLE, /**< Invalid handle. */
|
||||
CELLULAR_MODEM_NOT_READY, /**< The modem is not ready yet. */
|
||||
CELLULAR_LIBRARY_NOT_OPEN, /**< The cellular library is not open yet. */
|
||||
CELLULAR_LIBRARY_ALREADY_OPEN, /**< The cellular library is already open. */
|
||||
CELLULAR_BAD_PARAMETER, /**< One or more of the input parameters is not valid. */
|
||||
CELLULAR_NO_MEMORY, /**< Memory allocation failure. */
|
||||
CELLULAR_TIMEOUT, /**< The operation timed out. */
|
||||
CELLULAR_SOCKET_CLOSED, /**< The supplied socket is already closed. */
|
||||
CELLULAR_SOCKET_NOT_CONNECTED, /**< The supplied socket is not connected. */
|
||||
CELLULAR_INTERNAL_FAILURE, /**< The Cellular library internal failure. */
|
||||
CELLULAR_RESOURCE_CREATION_FAIL, /**< Resource creation for Cellular library failed. */
|
||||
CELLULAR_UNSUPPORTED, /**< The operation is not supported. */
|
||||
CELLULAR_NOT_ALLOWED, /**< The operation is not allowed. */
|
||||
CELLULAR_UNKNOWN /**< Any other error other than the above mentioned ones. */
|
||||
} CellularError_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Enums representing Radio Access Technologies (RATs). Reference 3GPP TS 27.007 PLMN selection +COPS.
|
||||
*/
|
||||
typedef enum CellularRat
|
||||
{
|
||||
CELLULAR_RAT_GSM = 0, /**< The GSM RATs network. */
|
||||
CELLULAR_RAT_WCDMA = 2, /**< The WCDMA RATs network. */
|
||||
CELLULAR_RAT_EDGE = 3, /**< The EDGE RATs network. */
|
||||
CELLULAR_RAT_HSDPA = 4, /**< The HSDPA RATs network. */
|
||||
CELLULAR_RAT_HSUPA = 5, /**< The HSUPA RATs network. */
|
||||
CELLULAR_RAT_HSDPAHSUPA = 6, /**< The HSDPAHSUPA RATs network. */
|
||||
CELLULAR_RAT_LTE = 7, /**< The LTE RATs network. */
|
||||
CELLULAR_RAT_CATM1 = 8, /**< The CAT M1 RATs network. */
|
||||
CELLULAR_RAT_NBIOT = 9, /**< The NBIOT RATs network. */
|
||||
CELLULAR_RAT_MAX, /**< The max supported number for RATs network. */
|
||||
CELLULAR_RAT_INVALID = 0xFF /**< Any other error other than the above mentioned ones. */
|
||||
} CellularRat_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief SIM card state codes.
|
||||
*/
|
||||
typedef enum CellularSimCardState
|
||||
{
|
||||
CELLULAR_SIM_CARD_REMOVED = 0, /**< The state stands for cellular sim card removed. */
|
||||
CELLULAR_SIM_CARD_INSERTED, /**< The state stands for cellular sim card inserted. */
|
||||
CELLULAR_SIM_CARD_STATUS_MAX, /**< The number of supported sim card status. */
|
||||
CELLULAR_SIM_CARD_UNKNOWN /**< The state stands for unknown cellular sim card. */
|
||||
} CellularSimCardState_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief SIM card lock state codes. Reference 3GPP TS 27.007 Enter PIN +CPIN.
|
||||
*/
|
||||
typedef enum CellularSimCardLockState
|
||||
{
|
||||
CELLULAR_SIM_CARD_READY = 0, /**< The cellular sim card in a lock state of ready. */
|
||||
CELLULAR_SIM_CARD_PIN, /**< The cellular sim card in a lock state of pin(personal identification number). */
|
||||
CELLULAR_SIM_CARD_PUK, /**< The cellular sim card in a lock state of puk(personal unlocking key). */
|
||||
CELLULAR_SIM_CARD_PIN2, /**< The cellular sim card in a lock state of pin2. */
|
||||
CELLULAR_SIM_CARD_PUK2, /**< The cellular sim card in a lock state of puk2. */
|
||||
CELLULAR_SIM_CARD_PH_NET_PIN, /**< The cellular sim card in a lock state of ph-net pin. */
|
||||
CELLULAR_SIM_CARD_PH_NET_PUK, /**< The cellular sim card in a lock state of ph-net puk. */
|
||||
CELLULAR_SIM_CARD_PH_NETSUB_PIN, /**< The cellular sim card in a lock state of ph-netsub pin. */
|
||||
CELLULAR_SIM_CARD_PH_NETSUB_PUK, /**< The cellular sim card in a lock state of ph-netsub puk. */
|
||||
CELLULAR_SIM_CARD_SP_PIN, /**< The cellular sim card in a lock state of ph-sp pin. */
|
||||
CELLULAR_SIM_CARD_SP_PUK, /**< The cellular sim card in a lock state of ph-sp puk. */
|
||||
CELLULAR_SIM_CARD_CORP_PIN, /**< The cellular sim card in a lock state of ph-corp pin. */
|
||||
CELLULAR_SIM_CARD_CORP_PUK, /**< The cellular sim card in a lock state of ph-sp puk. */
|
||||
CELLULAR_SIM_CARD_IMSI_PIN, /**< The cellular sim card in a lock state of imsi pin. */
|
||||
CELLULAR_SIM_CARD_IMSI_PUK, /**< The cellular sim card in a lock state of imsi puk. */
|
||||
CELLULAR_SIM_CARD_INVALID, /**< The cellular sim card in a lock state of invalid. */
|
||||
CELLULAR_SIM_CARD_LOCK_UNKNOWN /**< The cellular sim card in a lock state of unknown. */
|
||||
} CellularSimCardLockState_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents network registration mode. Reference 3GPP TS 27.007 PLMN selection +COPS.
|
||||
*/
|
||||
typedef enum CellularNetworkRegistrationMode
|
||||
{
|
||||
REGISTRATION_MODE_AUTO = 0, /**< Auto network registration mode. */
|
||||
REGISTRATION_MODE_MANUAL = 1, /**< Manual network registration mode. */
|
||||
REGISTRATION_MODE_DEREGISTER = 2, /**< Deregister network registration mode. */
|
||||
REGISTRATION_MODE_MANUAL_THEN_AUTO = 4, /**< Manual then auto network registration mode. */
|
||||
REGISTRATION_MODE_MAX, /**< The number of supported registration mode. */
|
||||
REGISTRATION_MODE_UNKNOWN /**< Unknown network registration mode. */
|
||||
} CellularNetworkRegistrationMode_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents network registration status. Reference 3GPP TS 27.007 network registration status.
|
||||
*/
|
||||
typedef enum CellularNetworkRegistrationStatus
|
||||
{
|
||||
REGISTRATION_STATUS_NO_REGISTERED_SEARCHING = 0, /**< No registered searching network registration status. */
|
||||
REGISTRATION_STATUS_REGISTERED_HOME = 1, /**< Registered home network registration status. */
|
||||
REGISTRATION_STATUS_NOT_REGISTERED_SEARCHING = 2, /**< Not registered searching network registration status. */
|
||||
REGISTRATION_STATUS_REGISTRATION_DENIED = 3, /**< Registration denied network registration status. */
|
||||
REGISTRATION_STATUS_UNKNOWN = 4, /**< Unknown network registration status. */
|
||||
REGISTRATION_STATUS_ROAMING_REGISTERED = 5, /**< Roaming registered network registration status. */
|
||||
REGISTRATION_STATUS_HOME_SMS_ONLY_REGISTERED = 6, /**< Home SMS only registered network registration status. */
|
||||
REGISTRATION_STATUS_SMS_ONLY_ROAMING_REGISTERED = 7, /**< SMS only roaming registered network registration status. */
|
||||
REGISTRATION_STATUS_ATTACHED_EMERG_SERVICES_ONLY = 8, /**< Attached emergency service only network registration status. */
|
||||
REGISTRATION_STATUS_MAX /**< The max supported number for registration status. */
|
||||
} CellularNetworkRegistrationStatus_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents operator name format.
|
||||
*/
|
||||
typedef enum CellularOperatorNameFormat
|
||||
{
|
||||
OPERATOR_NAME_FORMAT_LONG = 0, /**< Long operator name format. */
|
||||
OPERATOR_NAME_FORMAT_SHORT = 1, /**< Short operator name format. */
|
||||
OPERATOR_NAME_FORMAT_NUMERIC = 2, /**< Numeric operator name format. */
|
||||
OPERATOR_NAME_FORMAT_NOT_PRESENT = 9, /**< Not present operator name format. */
|
||||
OPERATOR_NAME_FORMAT_MAX /**< The max supported number for operator name format. */
|
||||
} CellularOperatorNameFormat_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents URC events.
|
||||
*/
|
||||
typedef enum CellularUrcEvent
|
||||
{
|
||||
CELLULAR_URC_EVENT_NETWORK_CS_REGISTRATION, /**< Network CS registration URC event. */
|
||||
CELLULAR_URC_EVENT_NETWORK_PS_REGISTRATION, /**< Network PS registration URC event. */
|
||||
CELLULAR_URC_EVENT_PDN_ACTIVATED, /**< PDN activated registration URC event. */
|
||||
CELLULAR_URC_EVENT_PDN_DEACTIVATED, /**< PDN deactivated registration URC event. */
|
||||
CELLULAR_URC_EVENT_SIGNAL_CHANGED, /**< Signal changed registration URC event. */
|
||||
CELLULAR_URC_SOCKET_OPENED, /**< Socket opened registration URC event. */
|
||||
CELLULAR_URC_SOCKET_OPEN_FAILED, /**< Socket open failed registration URC event. */
|
||||
CELLULAR_URC_EVENT_OTHER /**< Any URC event other than above. */
|
||||
} CellularUrcEvent_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents Modem events.
|
||||
*/
|
||||
typedef enum CellularModemEvent
|
||||
{
|
||||
CELLULAR_MODEM_EVENT_BOOTUP_OR_REBOOT, /**< Bootup or reboot modem event. */
|
||||
CELLULAR_MODEM_EVENT_POWERED_DOWN, /**< Power down modem event. */
|
||||
CELLULAR_MODEM_EVENT_PSM_ENTER /**< PSM enter modem event. */
|
||||
} CellularModemEvent_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents PDN context type.
|
||||
*/
|
||||
typedef enum CellularPdnContextType
|
||||
{
|
||||
CELLULAR_PDN_CONTEXT_IPV4 = 1, /**< IPV4 PDN CONTEXT. */
|
||||
CELLULAR_PDN_CONTEXT_IPV6 = 2, /**< IPV6 PDN CONTEXT. */
|
||||
CELLULAR_PDN_CONTEXT_IPV4V6 = 3, /**< IPV4V6 PDN CONTEXT. */
|
||||
CELLULAR_PDN_CONTEXT_TYPE_MAX /**< The max number of supported PDN CONTEXT. */
|
||||
} CellularPdnContextType_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents PDN authentication type.
|
||||
*/
|
||||
typedef enum CellularPdnAuthType
|
||||
{
|
||||
CELLULAR_PDN_AUTH_NONE = 0, /**< No authentication. */
|
||||
CELLULAR_PDN_AUTH_PAP, /**< Password Authentication Protocol (PAP). */
|
||||
CELLULAR_PDN_AUTH_CHAP, /**< Challenge Handshake Authentication Protocol (CHAP). */
|
||||
CELLULAR_PDN_AUTH_PAP_OR_CHAP /**< PAP or CHAP. */
|
||||
} CellularPdnAuthType_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents socket domain.
|
||||
*/
|
||||
typedef enum CellularSocketDomain
|
||||
{
|
||||
CELLULAR_SOCKET_DOMAIN_AF_INET, /**< IPv4 Internet Protocols. */
|
||||
CELLULAR_SOCKET_DOMAIN_AF_INET6 /**< IPv6 Internet Protocols. */
|
||||
} CellularSocketDomain_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents socket type.
|
||||
*/
|
||||
typedef enum CellularSocketType
|
||||
{
|
||||
CELLULAR_SOCKET_TYPE_DGRAM, /**< Datagram. */
|
||||
CELLULAR_SOCKET_TYPE_STREAM /**< Byte-stream. */
|
||||
} CellularSocketType_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents socket protocol.
|
||||
*/
|
||||
typedef enum CellularSocketProtocol
|
||||
{
|
||||
CELLULAR_SOCKET_PROTOCOL_UDP,
|
||||
CELLULAR_SOCKET_PROTOCOL_TCP
|
||||
} CellularSocketProtocol_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents data access modes.
|
||||
*/
|
||||
typedef enum CellularSocketAccessMode
|
||||
{
|
||||
CELLULAR_ACCESSMODE_BUFFER = 0, /* Data access buffer mode. */
|
||||
CELLULAR_ACCESSMODE_DIRECT_PUSH, /* Data access direct push mode. */
|
||||
CELLULAR_ACCESSMODE_TRANSPARENT, /* Data access transparent mode. */
|
||||
CELLULAR_ACCESSMODE_NOT_SET /* Data access not set. */
|
||||
} CellularSocketAccessMode_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents IP address.
|
||||
*/
|
||||
typedef enum CellularIPAddressType
|
||||
{
|
||||
CELLULAR_IP_ADDRESS_V4, /**< IP V4 IP address. */
|
||||
CELLULAR_IP_ADDRESS_V6 /**< IP V6 IP address. */
|
||||
} CellularIPAddressType_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents socket option level.
|
||||
*/
|
||||
typedef enum CellularSocketOptionLevel
|
||||
{
|
||||
CELLULAR_SOCKET_OPTION_LEVEL_IP, /**< IP layer options. */
|
||||
CELLULAR_SOCKET_OPTION_LEVEL_TRANSPORT /**< Transport (TCP/UDP) layer options. */
|
||||
} CellularSocketOptionLevel_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Socket option names.
|
||||
*/
|
||||
typedef enum CellularSocketOption
|
||||
{
|
||||
CELLULAR_SOCKET_OPTION_MAX_IP_PACKET_SIZE, /**< Set Max IP packet size. */
|
||||
CELLULAR_SOCKET_OPTION_SEND_TIMEOUT, /**< Set send timeout (in milliseconds). */
|
||||
CELLULAR_SOCKET_OPTION_RECV_TIMEOUT, /**< Set receive timeout (in milliseconds). */
|
||||
CELLULAR_SOCKET_OPTION_PDN_CONTEXT_ID, /**< Set PDN Context ID to use for the socket. */
|
||||
CELLULAR_SOCKET_OPTION_SET_LOCAL_PORT /**< Set local port. */
|
||||
} CellularSocketOption_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief packet Status Names.
|
||||
*/
|
||||
typedef enum CellularPktStatus
|
||||
{
|
||||
CELLULAR_PKT_STATUS_OK = 0, /* The operation was successful. */
|
||||
CELLULAR_PKT_STATUS_TIMED_OUT, /* The operation timed out. */
|
||||
CELLULAR_PKT_STATUS_FAILURE, /* There was some internal failure. */
|
||||
CELLULAR_PKT_STATUS_BAD_REQUEST, /* Request was not valid. */
|
||||
CELLULAR_PKT_STATUS_BAD_RESPONSE, /* The response received was not valid. */
|
||||
CELLULAR_PKT_STATUS_SIZE_MISMATCH, /* There is a size mismatch between the params. */
|
||||
CELLULAR_PKT_STATUS_BAD_PARAM, /* One or more params is not valid. */
|
||||
CELLULAR_PKT_STATUS_SEND_ERROR, /* Modem returned a send error. */
|
||||
CELLULAR_PKT_STATUS_INVALID_HANDLE, /* Invalid context. */
|
||||
CELLULAR_PKT_STATUS_CREATION_FAIL, /* Resource creation fail. */
|
||||
CELLULAR_PKT_STATUS_PREFIX_MISMATCH, /* Invalid prefix from Modem resp. */
|
||||
CELLULAR_PKT_STATUS_INVALID_DATA, /* Invalid data from Modem resp. */
|
||||
CELLULAR_PKT_STATUS_PENDING_DATA, /* Pending data from Modem resp. */
|
||||
CELLULAR_PKT_STATUS_PENDING_BUFFER /* Pending data from Modem resp. */
|
||||
} CellularPktStatus_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_enums
|
||||
* @brief Represents AT Command type.
|
||||
*/
|
||||
typedef enum CellularATCommandType
|
||||
{
|
||||
CELLULAR_AT_NO_RESULT, /**< no response expected, only OK, ERROR etc. */
|
||||
CELLULAR_AT_WO_PREFIX, /**< string response without a prefix. */
|
||||
CELLULAR_AT_WITH_PREFIX, /**< string response with a prefix. */
|
||||
CELLULAR_AT_MULTI_WITH_PREFIX, /**< multiple line response all start with a prefix. */
|
||||
CELLULAR_AT_MULTI_WO_PREFIX, /**< multiple line response with or without a prefix. */
|
||||
CELLULAR_AT_MULTI_DATA_WO_PREFIX, /**< multiple line data response with or without a prefix. */
|
||||
CELLULAR_AT_NO_COMMAND /**< no command is waiting response. */
|
||||
} CellularATCommandType_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief SIM Card status.
|
||||
*/
|
||||
typedef struct CellularSimCardStatus
|
||||
{
|
||||
CellularSimCardState_t simCardState; /**< Cellular sim card state. */
|
||||
CellularSimCardLockState_t simCardLockState; /**< Cellular sim card lock state. */
|
||||
} CellularSimCardStatus_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Public Land Mobile Network (PLMN) information.
|
||||
*/
|
||||
typedef struct CellularPlmnInfo
|
||||
{
|
||||
char mcc[ CELLULAR_MCC_MAX_SIZE + 1 ]; /**< Mobile Country Code (MCC). */
|
||||
char mnc[ CELLULAR_MNC_MAX_SIZE + 1 ]; /**< Mobile Network Code (MNC). */
|
||||
} CellularPlmnInfo_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief SIM Card information.
|
||||
*/
|
||||
typedef struct CellularSimCardInfo
|
||||
{
|
||||
char iccid[ CELLULAR_ICCID_MAX_SIZE + 1 ]; /**< Integrated Circuit Card Identifier aka SIM Card Number. */
|
||||
char imsi[ CELLULAR_IMSI_MAX_SIZE + 1 ]; /**< International Mobile Subscriber Identity. */
|
||||
CellularPlmnInfo_t plmn; /**< Public Land Mobile Network (PLMN) information. */
|
||||
} CellularSimCardInfo_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Modem information.
|
||||
*/
|
||||
typedef struct CellularModemInfo
|
||||
{
|
||||
char hardwareVersion[ CELLULAR_HW_VERSION_MAX_SIZE + 1 ]; /**< Hardware version number. */
|
||||
char firmwareVersion[ CELLULAR_FW_VERSION_MAX_SIZE + 1 ]; /**< Firmware version number. */
|
||||
char serialNumber[ CELLULAR_SERIAL_NUM_MAX_SIZE + 1 ]; /**< Module serial number. */
|
||||
char imei[ CELLULAR_IMEI_MAX_SIZE + 1 ]; /**< International Mobile Equipment Identity (IMEI). */
|
||||
char manufactureId[ CELLULAR_MANUFACTURE_ID_MAX_SIZE + 1 ]; /**< Manufacture Identity. */
|
||||
char modelId[ CELLULAR_MODEL_ID_MAX_SIZE + 1 ]; /**< Model Identity. */
|
||||
} CellularModemInfo_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents time.
|
||||
*/
|
||||
typedef struct CellularTime
|
||||
{
|
||||
uint8_t month; /**< 1..12 (Jan = 1 .. Dec = 12). */
|
||||
uint8_t day; /**< Day of the month 1..31. */
|
||||
uint8_t hour; /**< Hour of the day 0..23. */
|
||||
uint8_t minute; /**< Minute of the hour 0..59. */
|
||||
uint8_t second; /**< Second of the minute 0..59. */
|
||||
uint16_t year; /**< Year (like 2019). */
|
||||
int32_t timeZone; /**< Timezone represented in 15 minute increments (UTC+1 will be 4 because 1 hour = 60 minutes = 4 * 15 minutes). */
|
||||
uint8_t dst; /**< Daylight savings ( 0 = No adjustment for daylight savings
|
||||
* 1 = +1 hour for daylight savings
|
||||
* 2 = +2 hours for daylight savings ). */
|
||||
} CellularTime_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents signal information.
|
||||
*/
|
||||
typedef struct CellularSignalInfo
|
||||
{
|
||||
int16_t rssi; /**< Received Signal Strength Indicator (RSSI) in dBm.*/
|
||||
int16_t rsrp; /**< LTE Reference Signal Received Power (RSRP) in dBm. */
|
||||
int16_t rsrq; /**< LTE Reference Signal Received Quality (RSRQ) in dB. */
|
||||
int16_t sinr; /**< LTE Signal to Interference-Noise Ratio in dB. */
|
||||
int16_t ber; /**< Bit Error Rate (BER) in 0.01%. */
|
||||
uint8_t bars; /**< A number between 0 to 5 (both inclusive) indicating signal strength. */
|
||||
} CellularSignalInfo_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents network service status.
|
||||
*/
|
||||
typedef struct CellularServiceStatus
|
||||
{
|
||||
CellularRat_t rat; /**< Radio Access Technology (RAT). */
|
||||
CellularNetworkRegistrationMode_t networkRegistrationMode; /**< Network registration mode (auto/manual etc.) currently selected. */
|
||||
CellularNetworkRegistrationStatus_t csRegistrationStatus; /**< CS (Circuit Switched) registration status (registered/searching/roaming etc.). */
|
||||
CellularNetworkRegistrationStatus_t psRegistrationStatus; /**< PS (Packet Switched) registration status (registered/searching/roaming etc.). */
|
||||
CellularPlmnInfo_t plmnInfo; /**< Registered MCC and MNC information. */
|
||||
CellularOperatorNameFormat_t operatorNameFormat; /**< Format of registered network operator name. */
|
||||
char operatorName[ CELLULAR_NETWORK_NAME_MAX_SIZE + 1 ]; /**< Registered network operator name. */
|
||||
uint8_t csRejectionType; /**< CS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
|
||||
uint8_t csRejectionCause; /**< Reason why the CS (Circuit Switched) registration attempt was rejected. */
|
||||
uint8_t psRejectionType; /**< PS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
|
||||
uint8_t psRejectionCause; /**< Reason why the PS (Packet Switched) registration attempt was rejected. */
|
||||
} CellularServiceStatus_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents A singly-lined list of intermediate AT responses.
|
||||
*/
|
||||
typedef struct CellularATCommandLine
|
||||
{
|
||||
struct CellularATCommandLine * pNext; /**< The CellularATCommandLine structure pointer points to the next element of the liniked list. */
|
||||
char * pLine; /**< The content of the at command. */
|
||||
} CellularATCommandLine_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents AT Command response.
|
||||
*/
|
||||
typedef struct CellularATCommandResponse
|
||||
{
|
||||
bool status; /**< true: modem returns Success, false: Error. */
|
||||
CellularATCommandLine_t * pItm; /**< Any intermediate responses. */
|
||||
} CellularATCommandResponse_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents PSM settings.
|
||||
*/
|
||||
typedef struct CellularPsmSettings
|
||||
{
|
||||
/*
|
||||
* 0 = PSM Disable
|
||||
* 1 = PSM Enable.
|
||||
*/
|
||||
uint8_t mode; /**< PSM mode value (as shown above). */
|
||||
|
||||
/*
|
||||
* Bits 5 to 1 represent the binary coded timer value
|
||||
* Bits 6 to 8 define the timer value unit as follows:
|
||||
* Bits
|
||||
* 8 7 6
|
||||
* 0 0 0 value is incremented in multiples of 10 minutes
|
||||
* 0 0 1 value is incremented in multiples of 1 hour
|
||||
* 0 1 0 value is incremented in multiples of 10 hours
|
||||
* 0 1 1 value is incremented in multiples of 2 seconds
|
||||
* 1 0 0 value is incremented in multiples of 30 seconds
|
||||
* 1 0 1 value is incremented in multiples of 1 minute
|
||||
*
|
||||
* e.g. "00001010" equals to 100 minutes.
|
||||
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
|
||||
*/
|
||||
uint32_t periodicTauValue; /**< TAU (T3412) value encoded as per spec (as shown above). */
|
||||
|
||||
/*
|
||||
* Bits 5 to 1 represent the binary coded timer value
|
||||
* Bits 6 to 8 define the timer value unit as follows:
|
||||
* Bits
|
||||
* 8 7 6
|
||||
* 0 0 0 value is incremented in multiples of 10 minutes
|
||||
* 0 0 1 value is incremented in multiples of 1 hour
|
||||
* 0 1 0 value is incremented in multiples of 10 hours
|
||||
* 0 1 1 value is incremented in multiples of 2 seconds
|
||||
* 1 0 0 value is incremented in multiples of 30 seconds
|
||||
* 1 0 1 value is incremented in multiples of 1 minute
|
||||
*
|
||||
* e.g. "00001010" equals to 100 minutes.
|
||||
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
|
||||
*/
|
||||
uint32_t periodicRauValue; /**< RAU (T3312) value encoded as per Spec (as shown above). */
|
||||
|
||||
/*
|
||||
* Bits 5 to 1 represent the binary coded timer value
|
||||
* Bits 6 to 8 define the timer value unit as follows:
|
||||
* Bits
|
||||
* 8 7 6
|
||||
* 0 0 0 value is incremented in multiples of 10 minutes
|
||||
* 0 0 1 value is incremented in multiples of 1 hour
|
||||
* 0 1 0 value is incremented in multiples of 10 hours
|
||||
* 0 1 1 value is incremented in multiples of 2 seconds
|
||||
* 1 0 0 value is incremented in multiples of 30 seconds
|
||||
* 1 0 1 value is incremented in multiples of 1 minute
|
||||
*
|
||||
* e.g. "00001010" equals to 100 minutes.
|
||||
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
|
||||
*/
|
||||
uint32_t gprsReadyTimer; /**< GPRS Ready timer (T3314) value encoded as per Spec. */
|
||||
|
||||
/*
|
||||
* Bits 5 to 1 represent the binary coded timer value.
|
||||
* Bits 6 to 8 define the timer value unit as follows:
|
||||
* Bits
|
||||
* 8 7 6
|
||||
* 0 0 0 value is incremented in multiples of 2 seconds
|
||||
* 0 0 1 value is incremented in multiples of 1 minute
|
||||
* 0 1 0 value is incremented in multiples of decihours
|
||||
* 1 1 1 value indicates that the timer is deactivated.
|
||||
*
|
||||
* "00001111" equals to 30 seconds.
|
||||
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
|
||||
*/
|
||||
uint32_t activeTimeValue; /**< Active Time (T3324) value encoded as per spec (as shown above). */
|
||||
} CellularPsmSettings_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents e-I-DRX settings.
|
||||
*/
|
||||
typedef struct CellularEidrxSettings
|
||||
{
|
||||
/*
|
||||
* 0 Disable the use of e-I-DRX
|
||||
* 1 Enable the use of e-I-DRX
|
||||
* 2 Enable the use of e-I-DRX and enable the unsolicited result code
|
||||
* 3 Disable the use of e-I-DRX and discard all parameters for e-I-DRX or,
|
||||
* if available, reset to the manufacturer specific default values.
|
||||
*/
|
||||
uint8_t mode; /**< e-I-DRX mode (as shown above). */
|
||||
|
||||
/*
|
||||
* 2 GSM
|
||||
* 3 UTRAN
|
||||
* 4 LTE Cat M1
|
||||
* 5 LTE Cat NB1
|
||||
*/
|
||||
uint8_t rat; /**< Radio Access Technology (as shown above). */
|
||||
|
||||
/*
|
||||
* String type. Half a byte in a 4 bit format.
|
||||
* bit
|
||||
* 4 3 2 1 E-UTRAN e-I-DRX cycle length duration
|
||||
* 0 0 0 0 5.12 seconds
|
||||
* 0 0 0 1 10.24 seconds
|
||||
* 0 0 1 0 20.48 seconds
|
||||
* 0 0 1 1 40.96 seconds
|
||||
* 0 1 0 0 61.44 seconds
|
||||
* 0 1 0 1 81.92 seconds
|
||||
* 0 1 1 0 102.4 seconds
|
||||
* 0 1 1 1 122.88 seconds
|
||||
* 1 0 0 0 143.36 seconds
|
||||
* 1 0 0 1 163.84 seconds
|
||||
* 1 0 1 0 327.68 seconds
|
||||
* 1 0 1 1 655,36 seconds
|
||||
* 1 1 0 0 1310.72 seconds
|
||||
* 1 1 0 1 2621.44 seconds
|
||||
* 1 1 1 0 5242.88 seconds
|
||||
* 1 1 1 1 10485.76 seconds
|
||||
*/
|
||||
uint8_t requestedEdrxVaue; /**< Requested eDRX value encoded as per spec (as shown above). */
|
||||
uint8_t nwProvidedEdrxVaue; /**< Network provided eDRX value encoded as per spec (as shown above). Only applicable in URC. */
|
||||
|
||||
/*
|
||||
* LTE Cat M1 mode
|
||||
* bit
|
||||
* 4 3 2 1 Paging Time Window length
|
||||
* 0 0 0 0 1.28 seconds
|
||||
* 0 0 0 1 2.56 seconds
|
||||
* 0 0 1 0 3.84 seconds
|
||||
* 0 0 1 1 5.12 seconds
|
||||
* 0 1 0 0 6.4 seconds
|
||||
* 0 1 0 1 7.68 seconds
|
||||
* 0 1 1 0 8.96 seconds
|
||||
* 0 1 1 1 10.24 seconds
|
||||
* 1 0 0 0 11.52 seconds
|
||||
* 1 0 0 1 12.8 seconds
|
||||
* 1 0 1 0 14.08 seconds
|
||||
* 1 0 1 1 15.36 seconds
|
||||
* 1 1 0 0 16.64 seconds
|
||||
* 1 1 0 1 17.92 seconds
|
||||
* 1 1 1 0 19.20 seconds
|
||||
* 1 1 1 1 20.48 seconds
|
||||
*
|
||||
* LTE Cat NB1 mode
|
||||
* bit
|
||||
* 4 3 2 1 Paging Time Window length
|
||||
* 0 0 0 0 2.56 seconds
|
||||
* 0 0 0 1 5.12 seconds
|
||||
* 0 0 1 0 7.68 seconds
|
||||
* 0 0 1 1 10.24 seconds
|
||||
* 0 1 0 0 12.8 seconds
|
||||
* 0 1 0 1 15.36 seconds
|
||||
* 0 1 1 0 17.92 seconds
|
||||
* 0 1 1 1 20.48 seconds
|
||||
* 1 0 0 0 23.04 seconds
|
||||
* 1 0 0 1 25.6 seconds
|
||||
* 1 0 1 0 28.16 seconds
|
||||
* 1 0 1 1 30.72 seconds
|
||||
* 1 1 0 0 33.28 seconds
|
||||
* 1 1 0 1 35.84 seconds
|
||||
* 1 1 1 0 38.4 seconds
|
||||
* 1 1 1 1 40.96 seconds
|
||||
*/
|
||||
uint8_t pagingTimeWindow; /**< Paging time window encoded as per spec (as shown above). Only applicable in URC. */
|
||||
} CellularEidrxSettings_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Cellular Represents e-I-DRX settings Lists.
|
||||
*/
|
||||
typedef struct CellularEidrxSettingsList
|
||||
{
|
||||
CellularEidrxSettings_t eidrxList[ CELLULAR_EDRX_LIST_MAX_SIZE ]; /**< Cellular e-I-DRX settings list. */
|
||||
uint8_t count; /**< Cellular e-I-DRX settings list number. */
|
||||
} CellularEidrxSettingsList_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents IP Address.
|
||||
*/
|
||||
typedef struct CellularIPAddress
|
||||
{
|
||||
CellularIPAddressType_t ipAddressType; /**< Type of IP address (IPv4/IPv6). */
|
||||
char ipAddress[ CELLULAR_IP_ADDRESS_MAX_SIZE + 1 ]; /**< IP Address. NULL terminated. */
|
||||
} CellularIPAddress_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents a PDN config.
|
||||
*/
|
||||
typedef struct CellularPdnConfig
|
||||
{
|
||||
CellularPdnContextType_t pdnContextType; /**< PDN Context type. */
|
||||
CellularPdnAuthType_t pdnAuthType; /**< PDN Authentication type. */
|
||||
const char apnName[ CELLULAR_APN_MAX_SIZE + 1 ]; /**< APN name. */
|
||||
const char username[ CELLULAR_PDN_USERNAME_MAX_SIZE + 1 ]; /**< Username. */
|
||||
const char password[ CELLULAR_PDN_PASSWORD_MAX_SIZE + 1 ]; /**< Password. */
|
||||
} CellularPdnConfig_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents status of a PDN context.
|
||||
*/
|
||||
typedef struct CellularPdnStatus
|
||||
{
|
||||
uint8_t contextId; /**< 1-16 are valid values. */
|
||||
uint8_t state; /**< 0 = Deactivated, 1 = Activated. */
|
||||
CellularPdnContextType_t pdnContextType; /**< PDN Context type. */
|
||||
CellularIPAddress_t ipAddress; /**< Local IP address after the context is activated. */
|
||||
} CellularPdnStatus_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_paramstructs
|
||||
* @brief Represents socket address.
|
||||
*/
|
||||
typedef struct CellularSocketAddress
|
||||
{
|
||||
CellularIPAddress_t ipAddress; /**< IP address. */
|
||||
uint16_t port; /**< Port number. */
|
||||
} CellularSocketAddress_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about the response of an AT command sent
|
||||
* using Cellular_ATCommandRaw API.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pAtResp The response received for the AT command.
|
||||
* @param[in] pData is pATCommandPayload pointer in Cellular_ATCommandRaw parameters.
|
||||
* @param[in] dataLen is the string length of pATCommandPayloadin in Cellular_ATCommandRaw parameters.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularPktStatus_t ( * CellularATCommandResponseReceivedCallback_t ) ( CellularHandle_t cellularHandle,
|
||||
const CellularATCommandResponse_t * pAtResp,
|
||||
void * pData,
|
||||
uint16_t dataLen );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about a Network Registration URC event.
|
||||
*
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] pServiceStatus The status of the network service.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_RegisterUrcNetworkRegistrationEventCallback function.
|
||||
*/
|
||||
typedef void ( * CellularUrcNetworkRegistrationCallback_t )( CellularUrcEvent_t urcEvent,
|
||||
const CellularServiceStatus_t * pServiceStatus,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about PDN URC events.
|
||||
*
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] contextId Context ID of the PDN context
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_RegisterUrcPdnEventCallback function.
|
||||
*/
|
||||
typedef void ( * CellularUrcPdnEventCallback_t )( CellularUrcEvent_t urcEvent,
|
||||
uint8_t contextId,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about signal strength changed URC event.
|
||||
*
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] pSignalInfo The new signal information.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_RegisterUrcSignalStrengthChangedCallback function.
|
||||
*/
|
||||
typedef void ( * CellularUrcSignalStrengthChangedCallback_t )( CellularUrcEvent_t urcEvent,
|
||||
const CellularSignalInfo_t * pSignalInfo,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Generic callback used to inform all other URC events.
|
||||
*
|
||||
* @param[in] pRawData Raw data received in the URC event.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_RegisterUrcGenericCallback function.
|
||||
*/
|
||||
typedef void ( * CellularUrcGenericCallback_t )( const char * pRawData,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about modem events.
|
||||
*
|
||||
* @param[in] modemEvent The modem event.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_RegisterModemEventCallback function.
|
||||
*/
|
||||
typedef void ( * CellularModemEventCallback_t )( CellularModemEvent_t modemEvent,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform about the status of socket open.
|
||||
*
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] socketHandle Socket handle for which data is ready.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_SocketRegisterSocketOpenCallback function.
|
||||
*/
|
||||
typedef void ( * CellularSocketOpenCallback_t )( CellularUrcEvent_t urcEvent,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform that data is ready for reading on a socket.
|
||||
*
|
||||
* @param[in] socketHandle Socket handle for which data is ready.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_SocketRegisterDataReadyCallback function.
|
||||
*/
|
||||
typedef void ( * CellularSocketDataReadyCallback_t )( CellularSocketHandle_t socketHandle,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_datatypes_functionpointers
|
||||
* @brief Callback used to inform that remote end closed the connection for a
|
||||
* connected socket.
|
||||
*
|
||||
* @param[in] socketHandle Socket handle for which remote end closed the
|
||||
* connection.
|
||||
* @param[in] pCallbackContext pCallbackContext parameter in
|
||||
* Cellular_SocketRegisterClosedCallback function.
|
||||
*/
|
||||
typedef void ( * CellularSocketClosedCallback_t )( CellularSocketHandle_t socketHandle,
|
||||
void * pCallbackContext );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_TYPES_H__ */
|
||||
@ -0,0 +1,411 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_at_core.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_AT_CORE_H__
|
||||
#define __CELLULAR_AT_CORE_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Standard includes */
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Maximum size of an AT string.
|
||||
*/
|
||||
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
|
||||
|
||||
/**
|
||||
* @brief Maximum size of an AT prefix.
|
||||
*/
|
||||
#define CELLULAR_AT_MAX_PREFIX_SIZE ( 32 )
|
||||
|
||||
/**
|
||||
* @brief The array size of an array.
|
||||
*/
|
||||
#define ARRY_SIZE( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Represents error codes returned from AT Core APIs.
|
||||
*/
|
||||
typedef enum CellularATError
|
||||
{
|
||||
CELLULAR_AT_SUCCESS = 0, /**< The operation was successful. */
|
||||
CELLULAR_AT_BAD_PARAMETER, /**< One or more of the input parameters is not valid. */
|
||||
CELLULAR_AT_NO_MEMORY, /**< Memory allocation failure. */
|
||||
CELLULAR_AT_UNSUPPORTED, /**< The operation is not supported. */
|
||||
CELLULAR_AT_MODEM_ERROR, /**< Error in modem response. */
|
||||
CELLULAR_AT_ERROR, /**< Generic Error or boolean false. */
|
||||
CELLULAR_AT_UNKNOWN /**< Any other error other than the above mentioned ones. */
|
||||
} CellularATError_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Remove prefix from a string
|
||||
*
|
||||
* Many AT responses contain prefix of the form +XXXX. This function removes the
|
||||
* prefix by moving the pointer after the prefix. For example:
|
||||
*
|
||||
* Input:
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | + | C | P | I | N | : | R | E | A | D | Y |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* Output:
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | + | C | P | I | N | : | R | E | A | D | Y |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* Note that a prefix is always followed by colon (':') and this function
|
||||
* removes colon as well.
|
||||
*
|
||||
* @param[in,out] ppString The AT response to remove the prefix from. In
|
||||
* case of success, the pointer is updated to move past the prefix.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemovePrefix( char ** ppString );
|
||||
|
||||
/**
|
||||
* @brief Remove all leading white spaces from an AT response.
|
||||
*
|
||||
* Leading white spaces are removed by updating the pointer to the first
|
||||
* non-white space character. For example:
|
||||
*
|
||||
* Input:
|
||||
* +--+--+--+---+---+---+---+---+---+---+---+------+
|
||||
* | | | | r | e | s | p | o | n | s | e | '\0' |
|
||||
* +--+--+--+---+---+---+---+---+---+---+---+------+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* Output:
|
||||
* +--+--+--+---+---+---+---+---+---+---+---+------+
|
||||
* | | | | r | e | s | p | o | n | s | e | '\0' |
|
||||
* +--+--+--+---+---+---+---+---+---+---+---+------+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* @param[in,out] ppString The AT response to remove the leading white spaces
|
||||
* from. In case of success, the pointer is updated to the first non white space
|
||||
* character.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemoveLeadingWhiteSpaces( char ** ppString );
|
||||
|
||||
/**
|
||||
* @brief Remove all trailing white spaces from an AT response.
|
||||
*
|
||||
* Trailing spaces are removed by making the character next to the last
|
||||
* non white space character NULL ('\0'). For example:
|
||||
*
|
||||
* Input:
|
||||
* +---+---+---+---+---+---+---+---+--+--+--+------+
|
||||
* | r | e | s | p | o | n | s | e | | | | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+--+--+--+------+
|
||||
*
|
||||
* Output:
|
||||
* +---+---+---+---+---+---+---+---+------+--+--+------+
|
||||
* | r | e | s | p | o | n | s | e | '\0' | | | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+------+--+--+------+
|
||||
*
|
||||
* @param[in,out] pString The AT response to remove the trailing white
|
||||
* spaces from.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemoveTrailingWhiteSpaces( char * pString );
|
||||
|
||||
/**
|
||||
* @brief Remove all white spaces from an AT response.
|
||||
*
|
||||
* White spaces are removed by copying the non-white space characters to the
|
||||
* beginning. The character next to the last non-white space character is set
|
||||
* to the null character ('\0'). For example:
|
||||
*
|
||||
* Input:
|
||||
* +--+--+--+---+---+---+---+---+---+---+-- +---+------+
|
||||
* | | | | r | e | s | p | | o | n | s | e | '\0' |
|
||||
* +--+--+--+---+---+---+---+---+---+---+---+---+------+
|
||||
*
|
||||
* Output:
|
||||
* +---+---+---+---+---+---+---+---+------+------+
|
||||
* | r | e | s | p | o | n | s | e | '\0' | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+------+------+
|
||||
*
|
||||
* @param[in,out] pString The AT response to remove the white spaces from.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemoveAllWhiteSpaces( char * pString );
|
||||
|
||||
/**
|
||||
* @brief Remove outermost double quotes from an AT response.
|
||||
*
|
||||
* If the first character is double quote, it is removed by updating the pointer
|
||||
* to point to the next character. If the last character is double quote, it
|
||||
* is removed by making it the null character. Nothing else is done in any other
|
||||
* case. For example:
|
||||
*
|
||||
* Input:
|
||||
* +---+---+---+---+---+---+---+---+---+---+------+
|
||||
* | " | r | e | s | p | o | n | s | e | " | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+---+---+------+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* Output:
|
||||
* +---+---+---+---+---+---+---+---+---+------+------+
|
||||
* | " | r | e | s | p | o | n | s | e | '\0' | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+---+------+------+
|
||||
* ^
|
||||
* |
|
||||
* *ppString
|
||||
*
|
||||
* @param[in,out] ppString The AT response to remove the double quotes
|
||||
* from.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemoveOutermostDoubleQuote( char ** ppString );
|
||||
|
||||
/**
|
||||
* @brief Remove all double quotes from an AT response.
|
||||
*
|
||||
* Double quotes are removed by copying all the other characters to the
|
||||
* beginning. The character next to the last character is set to the null
|
||||
* character ('\0'). For example:
|
||||
*
|
||||
* Input:
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+------+
|
||||
* | " | r | e | s | " | p | " | o | n | s | e | " | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+------+
|
||||
*
|
||||
* Output:
|
||||
* +---+---+---+---+---+---+---+---+------+---+---+---+------+
|
||||
* | r | e | s | p | o | n | s | e | '\0' | s | e | " | '\0' |
|
||||
* +---+---+---+---+---+---+---+---+------+---+---+---+------+
|
||||
*
|
||||
* @param[in,out] pString The AT response to remove the double quotes
|
||||
* from.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATRemoveAllDoubleQuote( char * pString );
|
||||
|
||||
/**
|
||||
* @brief Extract the next token based on comma (',') as delimiter.
|
||||
*
|
||||
* @param[in,out] ppString The AT response to extract the token from.
|
||||
* @param[in,out] ppTokOutput The output parameter to return the location of the
|
||||
* token.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATGetNextTok( char ** ppString,
|
||||
char ** ppTokOutput );
|
||||
|
||||
/**
|
||||
* @brief Extract the next token based on the provided delimiter.
|
||||
*
|
||||
* This function uses *ppATResponse as the starting location to scan for tokens
|
||||
* which are sequences of contiguous characters separated by delimiters. When it
|
||||
* finds a token, *ppOutToken is updated to point to starting location of the
|
||||
* token and *ppATResponse is updated to point to the next character after the
|
||||
* token. This ensures that the next call to this function will extract the next
|
||||
* occurrence of the token.
|
||||
*
|
||||
* @param[in,out] ppString The AT response to extract the token from.
|
||||
* @param[in] pDelimiter The delimiter string.
|
||||
* @param[in,out] ppTokOutput The output parameter to return the location of the
|
||||
* token.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATGetSpecificNextTok( char ** ppString,
|
||||
const char * pDelimiter,
|
||||
char ** ppTokOutput );
|
||||
|
||||
/**
|
||||
* @brief Convert HEX string to HEX.
|
||||
*
|
||||
* This function requires the provided string to be of even length and returns
|
||||
* CELLULAR_AT_BAD_PARAMETER if it is not. It also requires the output buffer to be
|
||||
* of exactly half the length of the given hex string to ensure that it exactly
|
||||
* fits the converted data.
|
||||
*
|
||||
* It reads two characters and constructs a HEX byte by treating them upper and
|
||||
* lower nibble of the byte. For example:
|
||||
*
|
||||
* Input:
|
||||
* +---+---+---+---+------+
|
||||
* | 1 | 0 | A | B | '\0' |
|
||||
* +---+---+---+---+------+
|
||||
*
|
||||
* Output:
|
||||
* +----+-----+------+
|
||||
* | 16 | 171 | '\0' |
|
||||
* +----+-----+------+
|
||||
*
|
||||
* Decimal 16 is 0x10 and decimal 171 is 0xAB.
|
||||
*
|
||||
* @param[in] pString The hex string to convert to HEX.
|
||||
* @param[out] pHexData The buffer to return the converted HEX data into.
|
||||
* @param[in] hexDataLen The length of the buffer.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATHexStrToHex( const char * pString,
|
||||
uint8_t * pHexData,
|
||||
uint16_t hexDataLen );
|
||||
|
||||
/**
|
||||
* @brief Check if a string is numeric.
|
||||
*
|
||||
* A string is numeric if all the characters in it are digits. For example,
|
||||
* "1234" is numeric but "123YD" is not because 'Y' and 'D' are not digits.
|
||||
*
|
||||
* @param[in] pString The input string to check.
|
||||
* @param[out] pResult The bool output parameter to return whether or not the
|
||||
* string is numeric.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATIsStrDigit( const char * pString,
|
||||
bool * pResult );
|
||||
|
||||
/**
|
||||
* @brief check if a string as prefix present by determine present of ':'
|
||||
*
|
||||
* @param[in] pString input string
|
||||
* @param[out] pResult The bool output parameter to return whether or not the
|
||||
* string is numeric.
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATIsPrefixPresent( const char * pString,
|
||||
bool * pResult );
|
||||
|
||||
/**
|
||||
* @brief duplicate string from pSrc to ppDst, malloc is use to allocate mem space for ppDst
|
||||
*
|
||||
* @param[in] pSrc: input string to be copied
|
||||
* @param[out] ppDst: destination pointer
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATStrDup( char ** ppDst,
|
||||
const char * pSrc );
|
||||
|
||||
/**
|
||||
* @brief check if a string starts with certain prefix
|
||||
*
|
||||
* @param[in] pString input string
|
||||
* @param[in] pPrefix input prefix
|
||||
* @param[out] pResult return true if prefix is at start of pString, else false
|
||||
*
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATStrStartWith( const char * pString,
|
||||
const char * pPrefix,
|
||||
bool * pResult );
|
||||
|
||||
/**
|
||||
* @brief check if certain success code/error code present in the input buffer
|
||||
*
|
||||
* @param[in] pInputBuf: the haystack buffer
|
||||
* @param[in] ppKeyList: list of keys
|
||||
* @param[in] keyListLen: size of the keyList array
|
||||
* @param[out] pResult: return true if any of Keys in ppKeyList is found in is at start of pString, else false
|
||||
* *
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATcheckErrorCode( const char * pInputBuf,
|
||||
const char * const * const ppKeyList,
|
||||
size_t keyListLen,
|
||||
bool * pResult );
|
||||
|
||||
/**
|
||||
* @brief Convert string to int32_t.
|
||||
*
|
||||
* @param[in] pStr: the input string buffer.
|
||||
* @param[in] base: Numerical base (radix) of pStr.
|
||||
* Input string should not contain leading space or zero.
|
||||
* @param[out] pResult: converted int32_t result.
|
||||
* *
|
||||
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
|
||||
* error code indicating the cause of the error.
|
||||
*/
|
||||
CellularATError_t Cellular_ATStrtoi( const char * pStr,
|
||||
int32_t base,
|
||||
int32_t * pResult );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_AT_CORE_H__ */
|
||||
@ -0,0 +1,630 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_common.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_COMMON_H__
|
||||
#define __CELLULAR_COMMON_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Cellular includes. */
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_comm_interface.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_at_core.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_paramstructs
|
||||
* @brief The AT command request structure.
|
||||
*/
|
||||
typedef struct CellularAtReq
|
||||
{
|
||||
const char * pAtCmd; /**< The At command string used for at command request. */
|
||||
CellularATCommandType_t atCmdType; /**< The At command type. */
|
||||
const char * pAtRspPrefix; /**< The prefix of at command response. */
|
||||
CellularATCommandResponseReceivedCallback_t respCallback; /**< The callback function #CellularATCommandResponseReceivedCallback_t. */
|
||||
void * pData; /**< The data pointer to the data. */
|
||||
uint16_t dataLen; /**< The length of the data pointer . */
|
||||
} CellularAtReq_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_paramstructs
|
||||
* @brief The data command request structure.
|
||||
*/
|
||||
typedef struct CellularAtDataReq
|
||||
{
|
||||
const uint8_t * pData; /**< Data to send. */
|
||||
uint32_t dataLen; /**< Data length to send. */
|
||||
uint32_t * pSentDataLength; /**< Data actually sent. */
|
||||
const uint8_t * pEndPattern; /**< End pattern after pData is sent completely.
|
||||
* Set NULL if not required. Cellular modem uses
|
||||
* end pattern instead of length in AT command
|
||||
* can make use of this variable. */
|
||||
uint32_t endPatternLen; /**< End pattern length. */
|
||||
} CellularAtDataReq_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_functionpointers
|
||||
* @brief URC handler function.
|
||||
*
|
||||
* @return Void.
|
||||
*/
|
||||
typedef void ( * CellularAtParseTokenHandler_t )( CellularContext_t * pContext,
|
||||
char * pInputStr );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_paramstructs
|
||||
* @brief the URC token and URC handler mapping structure used by pkthanlder.
|
||||
*/
|
||||
typedef struct CellularAtParseTokenMap
|
||||
{
|
||||
const char * pStrValue; /**< The URC token string. */
|
||||
CellularAtParseTokenHandler_t parserFunc; /**< The function pointer points to #CellularAtParseTokenHandler_t. */
|
||||
} CellularAtParseTokenMap_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_enums
|
||||
* @brief enum representing different Socket State.
|
||||
*/
|
||||
typedef enum CellularSocketState
|
||||
{
|
||||
SOCKETSTATE_ALLOCATED = 0, /**< Socket is created. */
|
||||
SOCKETSTATE_CONNECTING, /**< Socket is connecting in progress with remote peer. */
|
||||
SOCKETSTATE_CONNECTED, /**< Socket is connected. */
|
||||
SOCKETSTATE_DISCONNECTED /**< Socket is disconnected by remote peer or due to network error. */
|
||||
} CellularSocketState_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_paramstructs
|
||||
* @brief Parameters involved in sending/receiving data through sockets.
|
||||
*/
|
||||
typedef struct CellularSocketContext
|
||||
{
|
||||
uint8_t contextId; /**< PDN context ID on which this socket exists. */
|
||||
uint32_t socketId; /**< Socket ID of this socket. */
|
||||
CellularSocketState_t socketState; /**< State of the socket, Allocated, Free etc. */
|
||||
CellularSocketType_t socketType; /**< Type of socket, DGRAM or STREAM. */
|
||||
CellularSocketDomain_t socketDomain; /**< Socket domain, IPV4 or V6. */
|
||||
CellularSocketProtocol_t socketProtocol; /**< Socket transport protocol, TCP or UDP. */
|
||||
CellularIPAddress_t localIpAddress; /**< IP address assigned to the device. */
|
||||
uint16_t localPort; /**< Local Port. */
|
||||
CellularSocketAccessMode_t dataMode; /**< Data Access mode enabled for this socket. */
|
||||
|
||||
/* Set using socket options. */
|
||||
uint32_t sendTimeoutMs; /**< Send timeout value in milliseconds. */
|
||||
uint32_t recvTimeoutMs; /**< Receive timeout value in milliseconds. */
|
||||
|
||||
/* Set during socket connect. */
|
||||
CellularSocketAddress_t remoteSocketAddress; /**< Remote IP address and port. */
|
||||
|
||||
/* Callback functions. */
|
||||
CellularSocketDataReadyCallback_t dataReadyCallback; /**< Informs data on this socket. */
|
||||
void * pDataReadyCallbackContext; /**< Data ready callback context. */
|
||||
CellularSocketOpenCallback_t openCallback; /**< Informs the socket open status. */
|
||||
void * pOpenCallbackContext; /**< socket open callback context. */
|
||||
CellularSocketClosedCallback_t closedCallback; /**< Informs the socket is closed. */
|
||||
void * pClosedCallbackContext; /**< socket closed callback context. */
|
||||
|
||||
/* Modem data. */
|
||||
void * pModemData; /**< Modem specific data. */
|
||||
} CellularSocketContext_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_paramstructs
|
||||
* @brief Parameters to setup pktio and pkthandler token tables.
|
||||
*/
|
||||
typedef struct CellularTokenTable
|
||||
{
|
||||
/* URC handler mapping table. */
|
||||
CellularAtParseTokenMap_t * pCellularUrcHandlerTable; /**< URC handler table. */
|
||||
uint32_t cellularPrefixToParserMapSize; /**< URC handler table size. */
|
||||
|
||||
/* Table to decide AT command respone status. */
|
||||
const char ** pCellularSrcTokenErrorTable; /**< Solicited error token table. */
|
||||
uint32_t cellularSrcTokenErrorTableSize; /**< Solicited error token table size. */
|
||||
const char ** pCellularSrcTokenSuccessTable; /**< Solicited success token table. */
|
||||
uint32_t cellularSrcTokenSuccessTableSize; /**< Solicited success token table size. */
|
||||
|
||||
/* Table to URC with prefix Token. */
|
||||
const char ** pCellularUrcTokenWoPrefixTable; /**< URC token without prefix table. */
|
||||
uint32_t cellularUrcTokenWoPrefixTableSize; /**< URC token without prefix table size. */
|
||||
|
||||
/* Extra success token for specific AT command. */
|
||||
const char ** pCellularSrcExtraTokenSuccessTable; /**< Extra token success table. */
|
||||
uint32_t cellularSrcExtraTokenSuccessTableSize; /**< Extra token success table size. */
|
||||
} CellularTokenTable_t;
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_functionpointers
|
||||
* @brief Callback used to inform pktio the data start and the length of the data.
|
||||
*
|
||||
* @param[in] pCallbackContext The pCallbackContext in _Cellular_TimeoutAtcmdDataRecvRequestWithCallback.
|
||||
* @param[in] pLine The input line form cellular modem.
|
||||
* @param[in] lineLength The length of the input line from cellular modem.
|
||||
* @param[out] pDataStart Is the start of of data in pLine.
|
||||
* @param[out] pDataLength Is the data length.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful.
|
||||
* CELLULAR_PKT_STATUS_SIZE_MISMATCH if more data is required.
|
||||
* Otherwise an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularPktStatus_t ( * CellularATCommandDataPrefixCallback_t ) ( void * pCallbackContext,
|
||||
char * pLine,
|
||||
uint32_t lineLength,
|
||||
char ** pDataStart,
|
||||
uint32_t * pDataLength );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_functionpointers
|
||||
* @brief Callback used to fix the stream before the send data.
|
||||
*
|
||||
* @param[in] pCallbackContext The pCallbackContext in CellularATCommandDataSendPrefixCallback_t.
|
||||
* @param[in,out] pLine The input line form cellular modem.
|
||||
* @param[in,out] pBytesRead The length of the input line from cellular modem.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularPktStatus_t ( * CellularATCommandDataSendPrefixCallback_t ) ( void * pCallbackContext,
|
||||
char * pLine,
|
||||
uint32_t * pBytesRead );
|
||||
|
||||
/**
|
||||
* @ingroup cellular_common_datatypes_functionpointers
|
||||
* @brief Undefined response callback function.
|
||||
*
|
||||
* @param[in] pCallbackContext The pCallbackContext parameter in _Cellular_RegisterUndefinedRespCallback.
|
||||
* @param[in] pLine The input line form cellular modem.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularPktStatus_t ( * CellularUndefinedRespCallback_t )( void * pCallbackContext,
|
||||
const char * pLine );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief One time initialization function.
|
||||
*
|
||||
* This function initializes and returns the supplied context. It must be called
|
||||
* once (and only once) before calling any other function of this library.
|
||||
*
|
||||
* @param[in,out] pCellularHandle The handle pointer to store the cellular handle.
|
||||
* @param[in] pCommInterface Comm interface for communicating with the module.
|
||||
* @param[in] pTokenTable Token tables for pkthandler and pktio.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
|
||||
const CellularCommInterface_t * pCommInterface,
|
||||
const CellularTokenTable_t * pTokenTable );
|
||||
|
||||
/**
|
||||
* @brief One time deinitialization function.
|
||||
*
|
||||
* This function frees resources taken in Cellular_Init. After this function
|
||||
* returns, Cellular_Init must be called again before calling any other function
|
||||
* of this library.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_LibCleanup( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief Call the network registration callback if the callback is previously set by
|
||||
* Cellular_CommonRegisterUrcNetworkRegistrationEventCallback.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] pServiceStatus The status of the network service.
|
||||
*/
|
||||
void _Cellular_NetworkRegistrationCallback( const CellularContext_t * pContext,
|
||||
CellularUrcEvent_t urcEvent,
|
||||
const CellularServiceStatus_t * pServiceStatus );
|
||||
|
||||
/**
|
||||
* @brief Call the network registration callback if the callback is previously set by
|
||||
* Cellular_RegisterUrcPdnEventCallback.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] contextId Context ID of the PDN context.
|
||||
*/
|
||||
void _Cellular_PdnEventCallback( const CellularContext_t * pContext,
|
||||
CellularUrcEvent_t urcEvent,
|
||||
uint8_t contextId );
|
||||
|
||||
/**
|
||||
* @brief Call the network registration callback if the callback is previously set by
|
||||
* Cellular_RegisterUrcSignalStrengthChangedCallback.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] urcEvent URC Event that happened.
|
||||
* @param[in] pSignalInfo The new signal information.
|
||||
*/
|
||||
void _Cellular_SignalStrengthChangedCallback( const CellularContext_t * pContext,
|
||||
CellularUrcEvent_t urcEvent,
|
||||
const CellularSignalInfo_t * pSignalInfo );
|
||||
|
||||
/**
|
||||
* @brief Call the network registration callback if the callback is previously set by
|
||||
* Cellular_RegisterUrcGenericCallback.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pRawData Raw data received in the URC event.
|
||||
*/
|
||||
void _Cellular_GenericCallback( const CellularContext_t * pContext,
|
||||
const char * pRawData );
|
||||
|
||||
/**
|
||||
* @brief Call the network registration callback if the callback is previously set by
|
||||
* Cellular_RegisterModemEventCallback.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] modemEvent The modem event.
|
||||
*/
|
||||
void _Cellular_ModemEventCallback( const CellularContext_t * pContext,
|
||||
CellularModemEvent_t modemEvent );
|
||||
|
||||
/**
|
||||
* @brief Check Library Status.
|
||||
*
|
||||
* This Functions checks if the FreeRTOS Cellular Library is already opened and set up
|
||||
* for cellular modem operation for control and data plane function.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful , otherwise return error code.
|
||||
*/
|
||||
CellularError_t _Cellular_CheckLibraryStatus( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Translate error code packet status to cellular Status.
|
||||
*
|
||||
* This Functions translates packet status to cellular Status.
|
||||
*
|
||||
* @param[in] status The packet status to translate.
|
||||
*
|
||||
* @return The corresponding CellularError_t.
|
||||
*/
|
||||
CellularError_t _Cellular_TranslatePktStatus( CellularPktStatus_t status );
|
||||
|
||||
/**
|
||||
* @brief Translate Error Code AT Core status to Packet Status.
|
||||
*
|
||||
* This Functions translates AT Core status to Packet Status.
|
||||
*
|
||||
* @param[in] status The AT Core status to translate.
|
||||
*
|
||||
* @return The corresponding CellularPktStatus_t.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_TranslateAtCoreStatus( CellularATError_t status );
|
||||
|
||||
/**
|
||||
* @brief Create a socket.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] contextId Pdn context id on which this socket needs to be created.
|
||||
* @param[in] socketDomain Socket domain.
|
||||
* @param[in] socketType Socket Type.
|
||||
* @param[in] socketProtocol Socket Protocol.
|
||||
* @param[out] pSocketHandle Out parameter to provide the created handle.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_CreateSocketData( CellularContext_t * pContext,
|
||||
uint8_t contextId,
|
||||
CellularSocketDomain_t socketDomain,
|
||||
CellularSocketType_t socketType,
|
||||
CellularSocketProtocol_t socketProtocol,
|
||||
CellularSocketHandle_t * pSocketHandle );
|
||||
|
||||
/**
|
||||
* @brief Remove the socket.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_RemoveSocketData( CellularContext_t * pContext,
|
||||
CellularSocketHandle_t socketHandle );
|
||||
|
||||
/**
|
||||
* @brief Check socket index validity.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] sockIndex Socket index returned from cellular modem.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_IsValidSocket( const CellularContext_t * pContext,
|
||||
uint32_t sockIndex );
|
||||
|
||||
/**
|
||||
* @brief Get the socket data structure with socket index.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] sockIndex Socket index returned from cellular modem.
|
||||
*
|
||||
* @return The socket data pointer if the socket index is valid, otherwise NULL is returned.
|
||||
*/
|
||||
CellularSocketContext_t * _Cellular_GetSocketData( const CellularContext_t * pContext,
|
||||
uint32_t sockIndex );
|
||||
|
||||
/**
|
||||
* @brief Check PDN context index validity.
|
||||
*
|
||||
* @param[in] contextId The PDN context index to check.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_IsValidPdn( uint8_t contextId );
|
||||
|
||||
/**
|
||||
* @brief Convert CSQ command returned RSSI value.
|
||||
*
|
||||
* @param[in] csqRssi The CSQ command returned RSSI index.
|
||||
* @param[out] pRssiValue The output parameter to return the converted
|
||||
* RSSI value in dBm.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_ConvertCsqSignalRssi( int16_t csqRssi,
|
||||
int16_t * pRssiValue );
|
||||
|
||||
/**
|
||||
* @brief Convert CSQ command retruned BER value.
|
||||
*
|
||||
* @param[in] csqBer The CSQ command returned BER index.
|
||||
* @param[out] pBerValue The output parameter to return the converted
|
||||
* BER value in 0.01%.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_ConvertCsqSignalBer( int16_t csqBer,
|
||||
int16_t * pBerValue );
|
||||
|
||||
/**
|
||||
* @brief Get the socket data structure with socket index.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] ppModuleContext The module context set in Cellular_ModuleInit function.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_GetModuleContext( const CellularContext_t * pContext,
|
||||
void ** ppModuleContext );
|
||||
|
||||
/**
|
||||
* @brief Convert the signal to bar.
|
||||
*
|
||||
* @param[in] rat Current RAT of the registered network.
|
||||
* @param[in,out] pSignalInfo The signal value of current RAT. The result bar
|
||||
* value is assigned in this structure.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_ComputeSignalBars( CellularRat_t rat,
|
||||
CellularSignalInfo_t * pSignalInfo );
|
||||
|
||||
/**
|
||||
* @brief Return the current RAT if previously received with 3GPP AT command.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pRat Current RAT of the registered network.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_GetCurrentRat( CellularContext_t * pContext,
|
||||
CellularRat_t * pRat );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with default timeout.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_AtcmdRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with extra success token table.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
|
||||
* @param[in] pCellularSrcTokenSuccessTable The extra success token table to indicate the send AT command success.
|
||||
* @param[in] cellularSrcTokenSuccessTableSize The size of extra success token table.
|
||||
*
|
||||
* @note AT command request makes use of cellularSrcTokenSuccessTableSize to obtain
|
||||
* the response status. Some AT commands don't have fixed success token. This function
|
||||
* make use of a temporary table, pCellularSrcTokenSuccessTable, to obtain the response
|
||||
* status.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_AtcmdRequestSuccessToken( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t atTimeoutMS,
|
||||
const char ** pCellularSrcTokenSuccessTable,
|
||||
uint32_t cellularSrcTokenSuccessTableSize );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with data buffer response.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
|
||||
* @param[in] pktDataPrefixCallback The callback function to indicate the start of data and the length of data.
|
||||
* @param[in] pCallbackContext The pCallbackContext passed to the pktDataPrefixCallback callback function.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataRecvRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS,
|
||||
CellularATCommandDataPrefixCallback_t pktDataPrefixCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with send data.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] dataReq The following data request after the at request.
|
||||
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
|
||||
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with send data.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] dataReq The following data request after the at request.
|
||||
* @param[in] pktDataSendPrefixCallback The callback function to inidcate the data sending start.
|
||||
* @param[in] pCallbackContext The callback context pass to pktDataSendPrefixCallback function.
|
||||
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
|
||||
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
|
||||
* @param[in] interDelayMS The delay between AT command and data send.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_AtcmdDataSend( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCallback,
|
||||
void * pCallbackContext,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS,
|
||||
uint32_t interDelayMS );
|
||||
|
||||
/**
|
||||
* @brief Send the AT command to cellular modem with send data and extra success token table
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] dataReq The following data request after the at request.
|
||||
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
|
||||
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
|
||||
* @param[in] pCellularSrcTokenSuccessTable The extra success token table to indicate the send AT command success.
|
||||
* @param[in] cellularSrcTokenSuccessTableSize The size of extra success token table.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendSuccessToken( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
CellularAtDataReq_t dataReq,
|
||||
uint32_t atTimeoutMS,
|
||||
uint32_t dataTimeoutMS,
|
||||
const char ** pCellularSrcTokenSuccessTable,
|
||||
uint32_t cellularSrcTokenSuccessTableSize );
|
||||
|
||||
/**
|
||||
* @brief Register undefined response callback.
|
||||
*
|
||||
* Cellular module can register the callback function to handle AT_UNDEFINED response
|
||||
* through this function.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] undefinedRespCallback The callback function to handle the undefined response.
|
||||
* @param[in] pCallbackContext The pCallbackContext passed to the undefinedRespCallback
|
||||
* callback function if undefinedRespCallback is not NULL.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error code
|
||||
* indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t _Cellular_RegisterUndefinedRespCallback( CellularContext_t * pContext,
|
||||
CellularUndefinedRespCallback_t undefinedRespCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_COMMON_H__ */
|
||||
@ -0,0 +1,312 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_common_api.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_COMMON_API_H__
|
||||
#define __CELLULAR_COMMON_API_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common.h"
|
||||
#include "cellular_comm_interface.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_Init in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonInit( CellularHandle_t * pCellularHandle,
|
||||
const CellularCommInterface_t * pCommInterface,
|
||||
const CellularTokenTable_t * pTokenTable );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_Cleanup in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonCleanup( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RegisterUrcNetworkRegistrationEventCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRegisterUrcNetworkRegistrationEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RegisterUrcPdnEventCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRegisterUrcPdnEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcPdnEventCallback_t pdnEventCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RegisterUrcSignalStrengthChangedCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRegisterUrcSignalStrengthChangedCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RegisterUrcGenericCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRegisterUrcGenericCallback( CellularHandle_t cellularHandle,
|
||||
CellularUrcGenericCallback_t genericCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RegisterModemEventCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRegisterModemEventCallback( CellularHandle_t cellularHandle,
|
||||
CellularModemEventCallback_t modemEventCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_ATCommandRaw in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonATCommandRaw( CellularHandle_t cellularHandle,
|
||||
const char * pATCommandPrefix,
|
||||
const char * pATCommandPayload,
|
||||
CellularATCommandType_t atCommandType,
|
||||
CellularATCommandResponseReceivedCallback_t responseReceivedCallback,
|
||||
void * pData,
|
||||
uint16_t dataLen );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_CreateSocket in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonCreateSocket( CellularHandle_t cellularHandle,
|
||||
uint8_t pdnContextId,
|
||||
CellularSocketDomain_t socketDomain,
|
||||
CellularSocketType_t socketType,
|
||||
CellularSocketProtocol_t socketProtocol,
|
||||
CellularSocketHandle_t * pSocketHandle );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_SocketSetSockOpt in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSocketSetSockOpt( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOptionLevel_t optionLevel,
|
||||
CellularSocketOption_t option,
|
||||
const uint8_t * pOptionValue,
|
||||
uint32_t optionValueLength );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_SocketRegisterDataReadyCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSocketRegisterDataReadyCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketDataReadyCallback_t dataReadyCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_SocketRegisterSocketOpenCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSocketRegisterSocketOpenCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketOpenCallback_t socketOpenCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_SocketRegisterClosedCallback in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSocketRegisterClosedCallback( CellularHandle_t cellularHandle,
|
||||
CellularSocketHandle_t socketHandle,
|
||||
CellularSocketClosedCallback_t closedCallback,
|
||||
void * pCallbackContext );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RfOn in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRfOn( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_RfOff in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonRfOff( CellularHandle_t cellularHandle );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetIPAddress in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetIPAddress( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
char * pBuffer,
|
||||
uint32_t bufferLength );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetModemInfo in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetModemInfo( CellularHandle_t cellularHandle,
|
||||
CellularModemInfo_t * pModemInfo );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetEidrxSettings in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetEidrxSettings( CellularHandle_t cellularHandle,
|
||||
CellularEidrxSettingsList_t * pEidrxSettingsList );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_SetEidrxSettings in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSetEidrxSettings( CellularHandle_t cellularHandle,
|
||||
const CellularEidrxSettings_t * pEidrxSettings );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetRegisteredNetwork in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetRegisteredNetwork( CellularHandle_t cellularHandle,
|
||||
CellularPlmnInfo_t * pNetworkInfo );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetNetworkTime in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetNetworkTime( CellularHandle_t cellularHandle,
|
||||
CellularTime_t * pNetworkTime );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetServiceStatus( CellularHandle_t cellularHandle,
|
||||
CellularServiceStatus_t * pServiceStatus );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSetPdnConfig( CellularHandle_t cellularHandle,
|
||||
uint8_t contextId,
|
||||
const CellularPdnConfig_t * pPdnConfig );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetPsmSettings( CellularHandle_t cellularHandle,
|
||||
CellularPsmSettings_t * pPsmSettings );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonSetPsmSettings( CellularHandle_t cellularHandle,
|
||||
const CellularPsmSettings_t * pPsmSettings );
|
||||
|
||||
/**
|
||||
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
|
||||
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetSimCardInfo( CellularHandle_t cellularHandle,
|
||||
CellularSimCardInfo_t * pSimCardInfo );
|
||||
|
||||
/**
|
||||
* @brief Get SIM card lock status.
|
||||
*
|
||||
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[out] pSimCardStatus Out parameter to provide the SIM card status.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_CommonGetSimCardLockStatus( CellularHandle_t cellularHandle,
|
||||
CellularSimCardStatus_t * pSimCardStatus );
|
||||
|
||||
/**
|
||||
* @brief 3GPP URC AT+CEREG handler for FreeRTOS Cellular Library.
|
||||
*
|
||||
* This function handles the incoming URC and callback function.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
* @param[in] pInputLine the input URC string.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCereg( CellularContext_t * pContext,
|
||||
char * pInputLine );
|
||||
|
||||
/**
|
||||
* @brief 3GPP URC AT+CGREG handler for FreeRTOS Cellular Library.
|
||||
*
|
||||
* This function handles the incoming URC and callback function.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
* @param[in] pInputLine the input URC string.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCgreg( CellularContext_t * pContext,
|
||||
char * pInputLine );
|
||||
|
||||
/**
|
||||
* @brief 3GPP URC AT+CREG handler for FreeRTOS Cellular Library.
|
||||
*
|
||||
* This function handles the incoming URC and callback function.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
* @param[in] pInputLine the input URC string.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t Cellular_CommonUrcProcessCreg( CellularContext_t * pContext,
|
||||
char * pInputLine );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_COMMON_API_H__ */
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_common_portable.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_COMMON_PORTABLE_H__
|
||||
#define __CELLULAR_COMMON_PORTABLE_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cellular_common.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Cellular module init function.
|
||||
*
|
||||
* This function is called in Cellular_CommonInit to setup cellular module context.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
* @param[in] ppModuleContext Cellular module context can be obtained with _Cellular_GetModuleContext.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ModuleInit( const CellularContext_t * pContext,
|
||||
void ** ppModuleContext );
|
||||
|
||||
/**
|
||||
* @brief Cellular module cleanup function.
|
||||
*
|
||||
* This function cleans up the module context.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ModuleCleanUp( const CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Cellular module user equipment setup function.
|
||||
*
|
||||
* This function setups the user equipment of the cellular module.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Cellular module URC enable function.
|
||||
*
|
||||
* This function enable the unsolicited result code of the cellular module.
|
||||
*
|
||||
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularError_t Cellular_ModuleEnableUrc( CellularContext_t * pContext );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* End of __CELLULAR_COMMON_PORTABLE_H__. */
|
||||
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_COMMON_INTERNAL_H__
|
||||
#define __CELLULAR_COMMON_INTERNAL_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Cellular includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_pkthandler_internal.h"
|
||||
#include "cellular_at_core.h"
|
||||
#include "cellular_pktio_internal.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define PKTIO_READ_BUFFER_SIZE ( 1600U ) /* This should be larger than TCP packet size. */
|
||||
#define PKTIO_WRITE_BUFFER_SIZE ( CELLULAR_AT_CMD_MAX_SIZE )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Cellular network register URC type.
|
||||
*/
|
||||
typedef enum CellularNetworkRegType
|
||||
{
|
||||
CELLULAR_REG_TYPE_CREG = 0,
|
||||
CELLULAR_REG_TYPE_CGREG,
|
||||
CELLULAR_REG_TYPE_CEREG,
|
||||
CELLULAR_REG_TYPE_MAX,
|
||||
CELLULAR_REG_TYPE_UNKNOWN
|
||||
} CellularNetworkRegType_t;
|
||||
|
||||
/**
|
||||
* @brief Represents different URC event callback registration function.
|
||||
*/
|
||||
typedef struct _callbackEvents
|
||||
{
|
||||
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback;
|
||||
void * pNetworkRegistrationCallbackContext;
|
||||
CellularUrcPdnEventCallback_t pdnEventCallback;
|
||||
void * pPdnEventCallbackContext;
|
||||
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback;
|
||||
void * pSignalStrengthChangedCallbackContext;
|
||||
CellularUrcGenericCallback_t genericCallback;
|
||||
void * pGenericCallbackContext;
|
||||
CellularModemEventCallback_t modemEventCallback;
|
||||
void * pModemEventCallbackContext;
|
||||
} _callbackEvents_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing all the control plane parameters of Modem.
|
||||
*/
|
||||
typedef struct cellularAtData
|
||||
{
|
||||
CellularRat_t rat; /* Device registered Radio Access Technology (Cat-M, Cat-NB, GPRS etc). */
|
||||
CellularNetworkRegistrationStatus_t csRegStatus; /* CS (Circuit Switched) registration status (registered/searching/roaming etc.). */
|
||||
CellularNetworkRegistrationStatus_t psRegStatus; /* PS (Packet Switched) registration status (registered/searching/roaming etc.). */
|
||||
uint8_t csRejectType; /* CS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
|
||||
uint8_t csRejCause; /* Circuit Switch Reject cause. */
|
||||
uint8_t psRejectType; /* PS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
|
||||
uint8_t psRejCause; /* Packet Switch Reject cause. */
|
||||
uint32_t cellId; /* Registered network operator cell Id. */
|
||||
uint16_t lac; /* Registered network operator Location Area Code. */
|
||||
uint16_t rac; /* Registered network operator Routing Area Code. */
|
||||
uint16_t tac; /* Registered network operator Tracking Area Code. */
|
||||
} cellularAtData_t;
|
||||
|
||||
/**
|
||||
* @brief Parameters involved in maintaining the context for the modem.
|
||||
*/
|
||||
struct CellularContext
|
||||
{
|
||||
/* Communication interface for target specific. */
|
||||
const CellularCommInterface_t * pCommIntf;
|
||||
|
||||
/* Common library. */
|
||||
bool bLibOpened; /* CellularLib is currently open */
|
||||
bool bLibShutdown; /* CellularLib prematurely shut down */
|
||||
bool bLibClosing; /* Graceful shutdown in progress */
|
||||
PlatformMutex_t libStatusMutex;
|
||||
PlatformMutex_t libAtDataMutex;
|
||||
_callbackEvents_t cbEvents; /* Call back functions registered to report events. */
|
||||
cellularAtData_t libAtData; /* Global variables. */
|
||||
|
||||
/* Token table to config pkthandler and pktio. */
|
||||
CellularTokenTable_t tokenTable;
|
||||
|
||||
/* Packet handler. */
|
||||
PlatformMutex_t pktRequestMutex; /* The mutex for sending request. */
|
||||
PlatformMutex_t PktRespMutex; /* The mutex for parsing the response from modem. */
|
||||
QueueHandle_t pktRespQueue;
|
||||
CellularATCommandResponseReceivedCallback_t pktRespCB;
|
||||
CellularATCommandDataPrefixCallback_t pktDataPrefixCB; /* Data prefix callback function for socket receive function. */
|
||||
void * pDataPrefixCBContext; /* The pCallbackContext passed to CellularATCommandDataPrefixCallback_t. */
|
||||
CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCB; /* Data prefix callback function for socket send function. */
|
||||
void * pDataSendPrefixCBContext; /* The pCallbackContext passed to CellularATCommandDataSendPrefixCallback_t. */
|
||||
void * pPktUsrData; /* The pData passed to CellularATCommandResponseReceivedCallback_t. */
|
||||
uint16_t PktUsrDataLen; /* The dataLen passed to CellularATCommandResponseReceivedCallback_t. */
|
||||
const char * pCurrentCmd; /* Debug purpose. */
|
||||
|
||||
/* Packet IO. */
|
||||
bool bPktioUp;
|
||||
CellularCommInterfaceHandle_t hPktioCommIntf;
|
||||
PlatformEventGroupHandle_t pPktioCommEvent;
|
||||
_pPktioShutdownCallback_t pPktioShutdownCB;
|
||||
_pPktioHandlePacketCallback_t pPktioHandlepktCB;
|
||||
char pktioSendBuf[ PKTIO_WRITE_BUFFER_SIZE + 1 ];
|
||||
char pktioReadBuf[ PKTIO_READ_BUFFER_SIZE + 1 ];
|
||||
char * pPktioReadPtr;
|
||||
const char * pRespPrefix;
|
||||
char pktRespPrefixBuf[ CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH ];
|
||||
CellularATCommandType_t PktioAtCmdType;
|
||||
_atRespType_t recvdMsgType;
|
||||
CellularUndefinedRespCallback_t undefinedRespCallback;
|
||||
void * pUndefinedRespCBContext;
|
||||
|
||||
/* PktIo data handling. */
|
||||
uint32_t dataLength;
|
||||
uint32_t partialDataRcvdLen;
|
||||
|
||||
/* Socket. */
|
||||
CellularSocketContext_t * pSocketData[ CELLULAR_NUM_SOCKET_MAX ]; /* All socket related information. */
|
||||
|
||||
/* Module Context. */
|
||||
void * pModueContext;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Netwrok registration respone parsing function.
|
||||
*
|
||||
* Parse the network registration response from AT command response or URC.
|
||||
* The result is stored in the pContext.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pRegPayload The input string from AT command respnose or URC.
|
||||
* @param[in] isUrc The input string source type.
|
||||
* @param[in] regType The network registration type.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
|
||||
char * pRegPayload,
|
||||
bool isUrc,
|
||||
CellularNetworkRegType_t regType );
|
||||
|
||||
/**
|
||||
* @brief Initializes the AT data structures.
|
||||
*
|
||||
* Function is invokes to initialize the AT data structure during
|
||||
* very first initialization, upon deregistration and upon receiving
|
||||
* network reject during registration.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] mode Parameter that identifies which elements in Data Structure
|
||||
* to be initialized.
|
||||
*/
|
||||
void _Cellular_InitAtData( CellularContext_t * pContext,
|
||||
uint32_t mode );
|
||||
|
||||
/**
|
||||
* @brief Create the AT data mutex.
|
||||
*
|
||||
* Create the mutex for AT data in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
bool _Cellular_CreateAtDataMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Destroy the AT data mutex.
|
||||
*
|
||||
* Destroy the mutex for AT data in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
*/
|
||||
void _Cellular_DestroyAtDataMutex( CellularContext_t * pContext );
|
||||
|
||||
|
||||
/**
|
||||
* @brief Lock the AT data mutex.
|
||||
*
|
||||
* Lock the mutex for AT data in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_LockAtDataMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Unlock the AT data mutex.
|
||||
*
|
||||
* Unlock the mutex for AT data in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_UnlockAtDataMutex( CellularContext_t * pContext );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* ifndef __CELLULAR_COMMON_INTERNAL_H__ */
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_INTERNAL_H__
|
||||
#define __CELLULAR_INTERNAL_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#include "cellular_platform.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_INTERNAL_H__ */
|
||||
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_PKTHANDLER_INTERNAL_H__
|
||||
#define __CELLULAR_PKTHANDLER_INTERNAL_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common.h"
|
||||
#include "cellular_pktio_internal.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* AT Command timeout for general AT commands. */
|
||||
#define PACKET_REQ_TIMEOUT_MS CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Create the packet request mutex.
|
||||
*
|
||||
* Create the mutex for packet rquest in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
bool _Cellular_CreatePktRequestMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Destroy the packet request mutex.
|
||||
*
|
||||
* Destroy the mutex for packet rquest in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_DestroyPktRequestMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Create the packet response mutex.
|
||||
*
|
||||
* Create the mutex for packet response in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
bool _Cellular_CreatePktResponseMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Destroy the packet response mutex.
|
||||
*
|
||||
* Destroy the mutex for packet response in cellular context.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_DestroyPktResponseMutex( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Packet handler init function.
|
||||
*
|
||||
* This function init the packet handler in FreeRTOS Cellular Library common.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_PktHandlerInit( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Packet handler cleanup function.
|
||||
*
|
||||
* This function cleanup the pakcet handler in FreeRTOS Cellular Library common.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_PktHandlerCleanup( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Packet handler function.
|
||||
*
|
||||
* This function is the callback function of packet handler. It is called by packet IO thread.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atRespType The AT response type from packet IO.
|
||||
* @param[in] pBuf The input data buffer from packet IO.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_HandlePacket( CellularContext_t * pContext,
|
||||
_atRespType_t atRespType,
|
||||
const void * pBuf );
|
||||
|
||||
/**
|
||||
* @brief The URC handler init function.
|
||||
*
|
||||
* This function setup the URC handler table query function.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_AtParseInit( const CellularContext_t * pContext );
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wrapper for sending the AT command to cellular modem.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atReq The AT command data structure with send command response callback.
|
||||
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_PktHandler_AtcmdRequestWithCallback( CellularContext_t * pContext,
|
||||
CellularAtReq_t atReq,
|
||||
uint32_t timeoutMS );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_PKTHANDLER_INTERNAL_H__ */
|
||||
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CELLULAR_PKTIO_INTERNAL_H__
|
||||
#define __CELLULAR_PKTIO_INTERNAL_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
|
||||
/* Include custom config file before other headers. */
|
||||
#include "cellular_config.h"
|
||||
#endif
|
||||
#include "cellular_config_defaults.h"
|
||||
#include "cellular_types.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The received AT response type.
|
||||
*/
|
||||
typedef enum _atRespType
|
||||
{
|
||||
AT_SOLICITED = 0,
|
||||
AT_UNSOLICITED,
|
||||
AT_UNDEFINED
|
||||
} _atRespType_t;
|
||||
|
||||
/**
|
||||
* @brief Callback used to inform packet received.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] atRespType The received packet type.
|
||||
* @param[in] pBuf The input data buffer from packet IO.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularPktStatus_t ( * _pPktioHandlePacketCallback_t ) ( CellularContext_t * pContext,
|
||||
_atRespType_t atRespType,
|
||||
const void * pBuffer );
|
||||
|
||||
/**
|
||||
* @brief Callback used to inform packet IO thread shutdown.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
typedef void ( * _pPktioShutdownCallback_t ) ( CellularContext_t * pContext );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Packet IO init function.
|
||||
*
|
||||
* This function init the packet IO in FreeRTOS Cellular Library common.
|
||||
* Packet IO thread is created in this function.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] handlePacketCb The callback function to handle the packet received.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_PktioInit( CellularContext_t * pContext,
|
||||
_pPktioHandlePacketCallback_t handlePacketCb );
|
||||
|
||||
/**
|
||||
* @brief Packet IO shutdown function.
|
||||
*
|
||||
* This function shutdown the packet IO in FreeRTOS Cellular Library common.
|
||||
* Packet IO thread is shutdown in this function.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
*/
|
||||
void _Cellular_PktioShutdown( CellularContext_t * pContext );
|
||||
|
||||
/**
|
||||
* @brief Send AT command function.
|
||||
*
|
||||
* This function setup the internal data of pktio and send the AT command through comm interface.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pAtCmd The AT command to send.
|
||||
* @param[in] atType The AT command type.
|
||||
* @param[in] pAtRspPrefix The AT command response prefix.
|
||||
*
|
||||
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
|
||||
* code indicating the cause of the error.
|
||||
*/
|
||||
CellularPktStatus_t _Cellular_PktioSendAtCmd( CellularContext_t * pContext,
|
||||
const char * pAtCmd,
|
||||
CellularATCommandType_t atType,
|
||||
const char * pAtRspPrefix );
|
||||
|
||||
/**
|
||||
* @brief Send data command function.
|
||||
*
|
||||
* This function setup the internal data of pktio and send the data through comm interface.
|
||||
*
|
||||
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
|
||||
* @param[in] pData The data to send.
|
||||
* @param[in] dataLen The data length of pData.
|
||||
*
|
||||
* @return The data actually send to the comm interface.
|
||||
*/
|
||||
uint32_t _Cellular_PktioSendData( CellularContext_t * pContext,
|
||||
const uint8_t * pData,
|
||||
uint32_t dataLen );
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_PKTIO_INTERNAL_H__ */
|
||||
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_comm_interface.h
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_COMM_INTERFACE_H__
|
||||
#define __CELLULAR_COMM_INTERFACE_H__
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#include "cellular_types.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Return codes from various APIs.
|
||||
*/
|
||||
typedef enum CellularCommInterfaceError
|
||||
{
|
||||
IOT_COMM_INTERFACE_SUCCESS = 0, /**< Function successfully completed. */
|
||||
IOT_COMM_INTERFACE_FAILURE, /**< Generic failure not covered by other values. */
|
||||
IOT_COMM_INTERFACE_BAD_PARAMETER, /**< At least one parameter was invalid. */
|
||||
IOT_COMM_INTERFACE_NO_MEMORY, /**< Memory allocation failed. */
|
||||
IOT_COMM_INTERFACE_TIMEOUT, /**< Operation timed out. */
|
||||
IOT_COMM_INTERFACE_DRIVER_ERROR, /**< An error occurred when calling a low level driver API. */
|
||||
IOT_COMM_INTERFACE_BUSY /**< The interface is currently busy. */
|
||||
} CellularCommInterfaceError_t;
|
||||
|
||||
struct CellularCommInterfaceContext;
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to comm interface.
|
||||
*/
|
||||
typedef struct CellularCommInterfaceContext * CellularCommInterfaceHandle_t;
|
||||
|
||||
/**
|
||||
* @brief Provide an asynchronous notification of incoming data.
|
||||
*
|
||||
* A function of this signature is supplied in CellularCommInterfaceOpen_t and is
|
||||
* used to notify whenever data is available for reading on the comm interface.
|
||||
*
|
||||
* @param[in] pUserData Userdata to be provided in the callback.
|
||||
* @param[in] commInterfaceHandle Handle corresponding to the comm interface.
|
||||
*
|
||||
* @return IOT_COMM_INTERFACE_SUCCESS if the operation is successful, and need to yield from ISR
|
||||
* IOT_COMM_INTERFACE_BUSY if the operation is successful,
|
||||
* otherwise an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularCommInterfaceError_t ( * CellularCommInterfaceReceiveCallback_t )( void * pUserData,
|
||||
CellularCommInterfaceHandle_t commInterfaceHandle );
|
||||
|
||||
/**
|
||||
* @brief Open a connection to the comm interface.
|
||||
*
|
||||
* @param[in] receiveCallback Callback to be invoked whenever there is data
|
||||
* available for reading from the comm interface.
|
||||
* @param[in] pUserData Userdata to be provided in the callback.
|
||||
* @param[out] pCommInterfaceHandle Out parameter to provide the comm interface
|
||||
* handle.
|
||||
*
|
||||
* @return IOT_COMM_INTERFACE_SUCCESS if the operation is successful, otherwise
|
||||
* an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularCommInterfaceError_t ( * CellularCommInterfaceOpen_t )( CellularCommInterfaceReceiveCallback_t receiveCallback,
|
||||
void * pUserData,
|
||||
CellularCommInterfaceHandle_t * pCommInterfaceHandle );
|
||||
|
||||
/**
|
||||
* @brief Send data to the comm interface.
|
||||
*
|
||||
* @param[in] commInterfaceHandle Comm interface handle as returned from the
|
||||
* CellularCommInterfaceOpen_t call.
|
||||
* @param[in] pData The data to send.
|
||||
* @param[in] dataLength Length of the data to send.
|
||||
* @param[in] timeoutMilliseconds Timeout in milliseconds for the send operation.
|
||||
* @param[out] pDataSentLength Out parameter to provide the length of the actual
|
||||
* data sent. Note that it may be less than the dataLength in case complete data
|
||||
* could not be sent.
|
||||
*
|
||||
* @return IOT_COMM_INTERFACE_SUCCESS if the operation is successful, otherwise
|
||||
* an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularCommInterfaceError_t ( * CellularCommInterfaceSend_t )( CellularCommInterfaceHandle_t commInterfaceHandle,
|
||||
const uint8_t * pData,
|
||||
uint32_t dataLength,
|
||||
uint32_t timeoutMilliseconds,
|
||||
uint32_t * pDataSentLength );
|
||||
|
||||
/**
|
||||
* @brief Receive data from the comm interface.
|
||||
*
|
||||
* @param[in] commInterfaceHandle Comm interface handle as returned from the
|
||||
* CellularCommInterfaceOpen_t call.
|
||||
* @param[in] pBuffer The buffer to receive the data into.
|
||||
* @param[in] bufferLength The length of the buffer pBuffer.
|
||||
* @param[in] timeoutMilliseconds Timeout in milliseconds for the receive
|
||||
* operation.
|
||||
* @param[out] pDataReceivedLength Out parameter to provide the length of the
|
||||
* actual data received in the buffer pBuffer. Note that it may be less than
|
||||
* the bufferLength.
|
||||
*
|
||||
* @return IOT_COMM_INTERFACE_SUCCESS if the operation is successful, otherwise
|
||||
* an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularCommInterfaceError_t ( * CellularCommInterfaceRecv_t )( CellularCommInterfaceHandle_t commInterfaceHandle,
|
||||
uint8_t * pBuffer,
|
||||
uint32_t bufferLength,
|
||||
uint32_t timeoutMilliseconds,
|
||||
uint32_t * pDataReceivedLength );
|
||||
|
||||
/**
|
||||
* @brief Close the connection to the comm interface.
|
||||
*
|
||||
* @param[in] commInterfaceHandle Comm interface handle as returned from the
|
||||
* CellularCommInterfaceOpen_t call.
|
||||
*
|
||||
* @return IOT_COMM_INTERFACE_SUCCESS if the operation is successful, otherwise
|
||||
* an error code indicating the cause of the error.
|
||||
*/
|
||||
typedef CellularCommInterfaceError_t ( * CellularCommInterfaceClose_t )( CellularCommInterfaceHandle_t commInterfaceHandle );
|
||||
|
||||
/**
|
||||
* @brief Represents the functions of a comm interface.
|
||||
*
|
||||
* Functions of these signature should be implemented against a comm interface
|
||||
* (like UART, SPI etc.).
|
||||
*/
|
||||
typedef struct CellularCommInterface
|
||||
{
|
||||
CellularCommInterfaceOpen_t open; /**< Cellular communication open interface. */
|
||||
CellularCommInterfaceSend_t send; /**< Cellular communication send interface. */
|
||||
CellularCommInterfaceRecv_t recv; /**< Cellular communication recv interface. */
|
||||
CellularCommInterfaceClose_t close; /**< Cellular communication close interface. */
|
||||
} CellularCommInterface_t;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* __CELLULAR_COMM_INTERFACE_H__ */
|
||||
@ -0,0 +1,105 @@
|
||||
cmake_minimum_required ( VERSION 3.13.0 )
|
||||
project ( "cellular_library unit test"
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C )
|
||||
|
||||
# Allow the project to be organized into folders.
|
||||
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
|
||||
|
||||
# Use C90.
|
||||
set( CMAKE_C_STANDARD 90 )
|
||||
set( CMAKE_C_STANDARD_REQUIRED ON )
|
||||
|
||||
# Do not allow in-source build.
|
||||
if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} )
|
||||
message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." )
|
||||
endif()
|
||||
|
||||
# Set global path variables.
|
||||
get_filename_component(__MODULE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||
set(MODULE_ROOT_DIR ${__MODULE_ROOT_DIR} CACHE INTERNAL "cellular_library repository root.")
|
||||
|
||||
# Configure options to always show in CMake GUI.
|
||||
option( BUILD_CLONE_SUBMODULES
|
||||
"Set this to ON to automatically clone any required Git submodules. When OFF, submodules must be manually cloned."
|
||||
OFF )
|
||||
|
||||
# Set output directories.
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
||||
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
|
||||
# ===================================== Coverity Analysis Configuration =================================================
|
||||
|
||||
# Set the source path and include path
|
||||
set( CELLULAR_COMMON_SOURCE ${MODULE_ROOT_DIR}/source )
|
||||
set( CELLULAR_INCLUDE_DIRS ${CELLULAR_COMMON_SOURCE}/include )
|
||||
set( CELLULAR_COMMON_INCLUDE_DIRS ${CELLULAR_INCLUDE_DIRS}/common )
|
||||
set( CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS ${CELLULAR_INCLUDE_DIRS}/private )
|
||||
set( CELLULAR_INTERFACE_INCLUDE_DIRS ${CELLULAR_COMMON_SOURCE}/interface )
|
||||
set( CELLULAR_TEST_DIRS ${MODULE_ROOT_DIR}/test/unit-test )
|
||||
|
||||
# Target for Coverity analysis that builds the library.
|
||||
add_library( coverity_analysis
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_at_core.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_common.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_common_api.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_3gpp_urc_handler.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_3gpp_api.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_pkthandler.c
|
||||
${CELLULAR_COMMON_SOURCE}/cellular_pktio.c )
|
||||
|
||||
# Build Cellular library target without custom config dependency.
|
||||
target_compile_definitions( coverity_analysis PUBLIC CELLULAR_DO_NOT_USE_CUSTOM_CONFIG=1 )
|
||||
|
||||
# Cellular include path.
|
||||
target_include_directories( coverity_analysis PUBLIC ${CELLULAR_COMMON_INCLUDE_DIRS} ${CELLULAR_INCLUDE_DIRS} ${CELLULAR_INTERFACE_INCLUDE_DIRS} ${CELLULAR_TEST_DIRS})
|
||||
|
||||
# Cellular private include path.
|
||||
target_include_directories( coverity_analysis PRIVATE ${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS} )
|
||||
|
||||
# Build without debug enabled when performing static analysis
|
||||
target_compile_options(coverity_analysis PUBLIC -DNDEBUG )
|
||||
|
||||
# ==================================== Test Configuration ========================================
|
||||
|
||||
# Define a CMock resource path.
|
||||
set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." )
|
||||
|
||||
# Include CMock build configuration.
|
||||
include( unit-test/cmock_build.cmake )
|
||||
|
||||
# Check if the CMock source directory exists, and if not present, clone the submodule
|
||||
# if BUILD_CLONE_SUBMODULES configuration is enabled.
|
||||
if( NOT EXISTS ${CMOCK_DIR}/src )
|
||||
# Attempt to clone CMock.
|
||||
if( ${BUILD_CLONE_SUBMODULES} )
|
||||
clone_cmock()
|
||||
else()
|
||||
message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add unit test and coverage configuration.
|
||||
|
||||
# Use CTest utility for managing test runs. This has to be added BEFORE
|
||||
# defining test targets with add_test()
|
||||
enable_testing()
|
||||
|
||||
# Add build targets for CMock and Unit, required for unit testing.
|
||||
add_cmock_targets()
|
||||
|
||||
# Add function to enable CMock based tests and coverage.
|
||||
include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake )
|
||||
|
||||
# Include build configuration for unit tests.
|
||||
add_subdirectory( unit-test )
|
||||
|
||||
# ==================================== Coverage Analysis configuration ========================================
|
||||
|
||||
# Add a target for running coverage on tests.
|
||||
add_custom_target( coverage
|
||||
COMMAND ${CMAKE_COMMAND} -P ${MODULE_ROOT_DIR}/tools/cmock/coverage.cmake
|
||||
DEPENDS cmock unity cellular_at_core_utest cellular_pktio_utest cellular_pkthandler_utest cellular_common_api_utest cellular_common_utest cellular_3gpp_api_utest cellular_3gpp_urc_handler_utest
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
20
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/test/cbmc/.gitignore
vendored
Normal file
20
kernel/FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface/test/cbmc/.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# Emitted when running CBMC proofs
|
||||
proofs/**/logs
|
||||
proofs/**/gotos
|
||||
proofs/**/report
|
||||
proofs/**/html
|
||||
|
||||
# Emitted by CBMC Viewer
|
||||
TAGS-*
|
||||
|
||||
# Emitted by Arpa
|
||||
arpa_cmake/
|
||||
arpa-validation-logs/
|
||||
Makefile.arpa
|
||||
|
||||
# Emitted by litani
|
||||
.ninja_deps
|
||||
.ninja_log
|
||||
.litani_cache_dir
|
||||
|
||||
__pycache__/
|
||||
@ -0,0 +1,6 @@
|
||||
CBMC proof include files
|
||||
========================
|
||||
|
||||
This directory contains include files written for CBMC proof. It is
|
||||
common to write some code to model aspects of the system under test,
|
||||
and the header files for this code go here.
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_cbmc_state.h
|
||||
* @brief Allocation and assumption utilities for the Shadow library CBMC proofs.
|
||||
*/
|
||||
#ifndef CELLULAR_CBMC_STATE_H_
|
||||
#define CELLULAR_CBMC_STATE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Proof model for malloc that can fail and return NULL.
|
||||
*
|
||||
* @param[in] size The size in bytes of memory to allocate.
|
||||
*
|
||||
* @return NULL or requested memory.
|
||||
*/
|
||||
void * mallocCanFail( size_t size );
|
||||
|
||||
#endif /* ifndef CELLULAR_CBMC_STATE_H_ */
|
||||
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cellular_config.h
|
||||
* @brief cellular config options.
|
||||
*/
|
||||
|
||||
#ifndef CELLULAR_CONFIG_H_
|
||||
#define CELLULAR_CONFIG_H_
|
||||
|
||||
/* This is a project specific file and is used to override config values defined
|
||||
* in cellular_config_defaults.h. */
|
||||
|
||||
|
||||
/*
|
||||
* PDN context id for cellular network.
|
||||
*/
|
||||
#define CELLULAR_PDN_CONTEXT_ID ( CELLULAR_PDN_CONTEXT_ID_MIN )
|
||||
|
||||
/*
|
||||
* PDN connect timeout for network registration.
|
||||
*/
|
||||
#define CELLULAR_PDN_CONNECT_TIMEOUT ( 100000UL )
|
||||
|
||||
/*
|
||||
* Overwrite default config for different cellular modules.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GetHostByName API is not used in the demo. IP address is used to store the hostname.
|
||||
* The value should be longer than the length of democonfigMQTT_BROKER_ENDPOINT in demo_config.h.
|
||||
*/
|
||||
#define CELLULAR_IP_ADDRESS_MAX_SIZE ( 64U )
|
||||
|
||||
#endif /* __CELLULAR_CONFIG_H__ */
|
||||
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
#ifndef __CELLULAR_PLATFORM_H__
|
||||
#define __CELLULAR_PLATFORM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Cellular library platform event group APIs.
|
||||
*
|
||||
* Cellular library use platform event group for process synchronization.
|
||||
*
|
||||
* The EventGroup functions in the following link can be referenced as function prototype.
|
||||
* https://www.freertos.org/event-groups-API.html
|
||||
*
|
||||
*/
|
||||
|
||||
#define LogError
|
||||
#define LogDebug
|
||||
#define LogWarn
|
||||
#define LogInfo
|
||||
|
||||
#define configASSERT
|
||||
|
||||
#define Platform_Delay
|
||||
|
||||
typedef void * PVOID;
|
||||
|
||||
#define PlatformEventGroupHandle_t uint16_t
|
||||
#define PlatformEventGroup_Delete MockPlatformEventGroup_Delete
|
||||
#define PlatformEventGroup_ClearBits MockPlatformEventGroup_ClearBits
|
||||
#define PlatformEventGroup_Create MockPlatformEventGroup_Create
|
||||
#define PlatformEventGroup_GetBits MockPlatformEventGroup_GetBits
|
||||
#define PlatformEventGroup_SetBits
|
||||
#define PlatformEventGroup_SetBitsFromISR MockPlatformEventGroup_SetBitsFromISR
|
||||
#define PlatformEventGroup_WaitBits MockPlatformEventGroup_WaitBits
|
||||
#define PlatformEventGroup_EventBits uint32_t
|
||||
|
||||
#define vQueueDelete MockvQueueDelete
|
||||
#define xQueueSend MockxQueueSend
|
||||
#define xQueueReceive MockxQueueReceive
|
||||
#define xQueueCreate MockxQueueCreate
|
||||
|
||||
#define PlatformMutex_Create MockPlatformMutex_Create
|
||||
#define PlatformMutex_Destroy MockPlatformMutex_Destroy
|
||||
#define PlatformMutex_Lock MockPlatformMutex_Lock
|
||||
#define PlatformMutex_TryLock MockPlatformMutex_TryLock
|
||||
#define PlatformMutex_Unlock MockPlatformMutex_Unlock
|
||||
|
||||
#define Platform_CreateDetachedThread MockPlatform_CreateDetachedThread
|
||||
|
||||
#define taskENTER_CRITICAL() PVOID
|
||||
#define taskEXIT_CRITICAL() PVOID
|
||||
|
||||
#define pdFALSE ( 0x0 )
|
||||
#define pdTRUE ( 0x1 )
|
||||
#define pdPASS ( 0x1 )
|
||||
|
||||
#define PlatformTickType uint64_t
|
||||
|
||||
/* Converts a time in milliseconds to a time in ticks. This macro can be
|
||||
* overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
|
||||
* definition here is not suitable for your application. */
|
||||
#ifndef pdMS_TO_TICKS
|
||||
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) 1000 ) / ( TickType_t ) 1000U ) )
|
||||
#endif
|
||||
|
||||
#define CELLULAR_URC_HANDLER_TABLE_SIZE ( sizeof( CellularUrcHandlerTable ) / sizeof( CellularAtParseTokenMap_t ) )
|
||||
#define CELLULAR_SRC_TOKEN_ERROR_TABLE_SIZE ( sizeof( CellularSrcTokenErrorTable ) / sizeof( char * ) )
|
||||
#define CELLULAR_SRC_TOKEN_SUCCESS_TABLE_SIZE ( sizeof( CellularSrcTokenSuccessTable ) / sizeof( char * ) )
|
||||
#define CELLULAR_URC_TOKEN_WO_PREFIX_TABLE_SIZE ( sizeof( CellularUrcTokenWoPrefixTable ) / sizeof( char * ) )
|
||||
#define CELLULAR_SRC_EXTRA_TOKEN_SUCCESS_TABLE_SIZE ( sizeof( CellularSrcExtraTokenSuccessTable ) / sizeof( char * ) )
|
||||
|
||||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||||
#else
|
||||
typedef uint64_t TickType_t;
|
||||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The type that holds event bits always matches TickType_t - therefore the
|
||||
* number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,
|
||||
* 32 bits if set to 0.
|
||||
*
|
||||
* \defgroup EventBits_t EventBits_t
|
||||
* \ingroup EventGroup
|
||||
*/
|
||||
typedef TickType_t EventBits_t;
|
||||
|
||||
/**
|
||||
* @brief Cellular library platform thread API and configuration.
|
||||
*
|
||||
* Cellular library create a detached thread by this API.
|
||||
* The threadRoutine should be called with pArgument in the created thread.
|
||||
*
|
||||
* PLATFORM_THREAD_DEFAULT_STACK_SIZE and PLATFORM_THREAD_DEFAULT_PRIORITY defines
|
||||
* the platform related stack size and priority.
|
||||
*/
|
||||
|
||||
bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * pArgument ),
|
||||
void * pArgument,
|
||||
size_t priority,
|
||||
size_t stackSize );
|
||||
|
||||
#define PLATFORM_THREAD_DEFAULT_STACK_SIZE ( 2048U )
|
||||
#define PLATFORM_THREAD_DEFAULT_PRIORITY ( 5U )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Definition of the queue used by the scheduler.
|
||||
* Items are queued by copy, not reference. See the following link for the
|
||||
* rationale: https://www.FreeRTOS.org/Embedded-RTOS-Queues.html
|
||||
*/
|
||||
struct QueueDefinition /* The old naming convention is used to prevent breaking kernel aware debuggers. */
|
||||
{
|
||||
int8_t * pcHead; /*< Points to the beginning of the queue storage area. */
|
||||
int8_t * pcWriteTo; /*< Points to the free next place in the storage area. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Type by which queues are referenced. For example, a call to xQueueCreate()
|
||||
* returns an QueueHandle_t variable that can then be used as a parameter to
|
||||
* xQueueSend(), xQueueReceive(), etc.
|
||||
*/
|
||||
struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */
|
||||
typedef struct QueueDefinition * QueueHandle_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, especially when supplying a
|
||||
* library that is likely to change in future versions, FreeRTOS implements a
|
||||
* strict data hiding policy. This means the Queue structure used internally by
|
||||
* FreeRTOS is not accessible to application code. However, if the application
|
||||
* writer wants to statically allocate the memory required to create a queue
|
||||
* then the size of the queue object needs to be know. The StaticQueue_t
|
||||
* structure below is provided for this purpose. Its sizes and alignment
|
||||
* requirements are guaranteed to match those of the genuine structure, no
|
||||
* matter which architecture is being used, and no matter how the values in
|
||||
* FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope
|
||||
* users will recognise that it would be unwise to make direct use of the
|
||||
* structure members.
|
||||
*/
|
||||
typedef struct xSTATIC_QUEUE
|
||||
{
|
||||
void * pvDummy1[ 3 ];
|
||||
} StaticQueue_t;
|
||||
typedef StaticQueue_t StaticSemaphore_t;
|
||||
|
||||
/**
|
||||
* @brief Cellular library platform mutex APIs.
|
||||
*
|
||||
* Cellular library use platform mutex to protect resource.
|
||||
*
|
||||
* The IotMutex_ functions can be referenced as function prototype for
|
||||
* PlatfromMutex_ prefix function in the following link.
|
||||
* https://docs.aws.amazon.com/freertos/latest/lib-ref/c-sdk/platform/platform_threads_functions.html
|
||||
*
|
||||
*/
|
||||
typedef long BaseType_t;
|
||||
typedef struct PlatformMutex
|
||||
{
|
||||
StaticSemaphore_t xMutex; /**< FreeRTOS mutex. */
|
||||
BaseType_t recursive; /**< Type; used for indicating if this is reentrant or normal. */
|
||||
bool created;
|
||||
} PlatformMutex_t;
|
||||
|
||||
bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
|
||||
bool recursive );
|
||||
void PlatformMutex_Destroy( PlatformMutex_t * pMutex );
|
||||
void PlatformMutex_Lock( PlatformMutex_t * pMutex );
|
||||
bool PlatformMutex_TryLock( PlatformMutex_t * pMutex );
|
||||
void PlatformMutex_Unlock( PlatformMutex_t * pMutex );
|
||||
int32_t PlatformEventGroup_SetBitsFromISR( PlatformEventGroupHandle_t groupEvent,
|
||||
EventBits_t event,
|
||||
BaseType_t * pHigherPriorityTaskWoken );
|
||||
void * safeMalloc( size_t xWantedSize );
|
||||
void allocateSocket( void * pCellularHandle );
|
||||
bool MockxQueueReceive( int32_t * queue,
|
||||
void * data,
|
||||
uint32_t time );
|
||||
uint16_t MockPlatformEventGroup_Create();
|
||||
uint16_t MockPlatformEventGroup_WaitBits();
|
||||
|
||||
QueueHandle_t xQueueCreate( int32_t uxQueueLength,
|
||||
uint32_t uxItemSize );
|
||||
uint16_t vQueueDelete( QueueHandle_t queue );
|
||||
BaseType_t xQueueSend( QueueHandle_t queue,
|
||||
void * data,
|
||||
uint32_t time );
|
||||
|
||||
uint16_t PlatformEventGroup_ClearBits( PlatformEventGroupHandle_t xEventGroup,
|
||||
TickType_t uxBitsToClear );
|
||||
uint16_t PlatformEventGroup_Delete( PlatformEventGroupHandle_t groupEvent );
|
||||
uint16_t PlatformEventGroup_GetBits( PlatformEventGroupHandle_t groupEvent );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Cellular library platform memory allocation APIs.
|
||||
*
|
||||
* Cellular library use platform memory allocation APIs to allocate memory dynamically.
|
||||
* The FreeRTOS memory management document can be referenced for these APIs.
|
||||
* https://www.freertos.org/a00111.html
|
||||
*
|
||||
*/
|
||||
|
||||
#define Platform_Malloc safeMalloc
|
||||
#define Platform_Free free
|
||||
|
||||
#endif /* __CELLULAR_PLATFORM_H__ */
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATGetNextTok( char ** ppString,
|
||||
char ** ppTokOutput );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATGetNextTok
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
const char ** ppString;
|
||||
const char ** ppTokOutput;
|
||||
|
||||
ppString = ( char * ) safeMalloc( sizeof( *ppString ) );
|
||||
ppTokOutput = ( char * ) safeMalloc( sizeof( *ppTokOutput ) );
|
||||
Cellular_ATGetNextTok( ppString, ppTokOutput );
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATGetNextTok_harness
|
||||
PROOF_UID = Cellular_ATGetNextTok
|
||||
|
||||
DEFINES +=
|
||||
INCLUDES +=
|
||||
|
||||
# Remove this function because it will has its own harness.
|
||||
REMOVE_FUNCTION_BODY += Cellular_ATGetSpecificNextTok
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATGetNextTok proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATGetNextTok.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATGetNextTok",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATGetSpecificNextTok( char ** ppString,
|
||||
const char * pDelimiter,
|
||||
char ** ppTokOutput );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATGetSpecificNextTok
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
const char ** ppString;
|
||||
const char ** ppTokOutput;
|
||||
const char * pDelimiter;
|
||||
uint16_t stringLength;
|
||||
uint16_t delLength;
|
||||
|
||||
__CPROVER_assume( stringLength > 0 && stringLength < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( delLength > 0 && delLength < CBMC_MAX_BUFSIZE );
|
||||
|
||||
char * pString = ( char * ) safeMalloc( stringLength );
|
||||
|
||||
ppString = nondet_bool() ? NULL : &pString;
|
||||
ppTokOutput = ( char * ) safeMalloc( sizeof( *ppTokOutput ) );
|
||||
pDelimiter = ( char * ) safeMalloc( delLength );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLength ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLength - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATGetSpecificNextTok( ppString, pDelimiter, ppTokOutput );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATGetSpecificNextTok_harness
|
||||
PROOF_UID = Cellular_ATGetSpecificNextTok
|
||||
|
||||
DEFINES +=
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=128
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATGetSpecificNextTok.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/strtok.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATGetSpecificNextTok proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATGetSpecificNextTok.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATGetSpecificNextTok",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATHexStrToHex( const char * pString,
|
||||
uint8_t * pHexData,
|
||||
uint16_t hexDataLen );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATHexStrToHex
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t hexDataLen;
|
||||
uint16_t stringLen;
|
||||
|
||||
__CPROVER_assume( stringLen < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLen > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLen );
|
||||
uint8_t * pHexData = ( uint8_t * ) safeMalloc( hexDataLen );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLen ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLen - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATHexStrToHex( pString,
|
||||
pHexData,
|
||||
hexDataLen );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATHexStrToHex_harness
|
||||
PROOF_UID = Cellular_ATHexStrToHex
|
||||
|
||||
DEFINES +=
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=128
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATHexStrToHex.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATHexStrToHex proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATHexStrToHex.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATHexStrToHex",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATIsPrefixPresent( const char * pString,
|
||||
bool * pResult );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATIsPrefixPresent
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLen;
|
||||
|
||||
__CPROVER_assume( stringLen < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLen > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLen );
|
||||
bool * pResult = ( uint8_t * ) safeMalloc( sizeof( bool * ) );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLen ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLen - 1 ] = '\0';
|
||||
|
||||
if( nondet_bool() && ( stringLen > 2 ) )
|
||||
{
|
||||
pString[ 0 ] = '+';
|
||||
}
|
||||
}
|
||||
|
||||
Cellular_ATIsPrefixPresent( pString,
|
||||
pResult );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATIsPrefixPresent_harness
|
||||
PROOF_UID = Cellular_ATIsPrefixPresent
|
||||
|
||||
DEFINES += -D__NO_CTYPE
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=32
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATIsPrefixPresent.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strnlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/strchr.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/strnlen.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATIsPrefixPresent proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATIsPrefixPresent.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATIsPrefixPresent",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATIsStrDigit( const char * pString,
|
||||
bool * pResult );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATIsStrDigit
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLen;
|
||||
|
||||
__CPROVER_assume( stringLen < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLen > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLen );
|
||||
bool * pResult = ( uint8_t * ) safeMalloc( sizeof( bool * ) );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLen ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLen - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATIsStrDigit( pString,
|
||||
pResult );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATIsStrDigit_harness
|
||||
PROOF_UID = Cellular_ATIsStrDigit
|
||||
|
||||
DEFINES += -D__NO_CTYPE
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=128
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATIsStrDigit.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATIsStrDigit proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATIsStrDigit.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATIsStrDigit",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveAllDoubleQuote( char * pString );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATRemoveAllDoubleQuote
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLength;
|
||||
|
||||
__CPROVER_assume( stringLength < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLength > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLength );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLength ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLength - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATRemoveAllDoubleQuote( pString );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATRemoveAllDoubleQuote_harness
|
||||
PROOF_UID = Cellular_ATRemoveAllDoubleQuote
|
||||
|
||||
DEFINES +=
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=32
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATRemoveAllDoubleQuote.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATRemoveAllDoubleQuote proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATRemoveAllDoubleQuote.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATRemoveAllDoubleQuote",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveAllWhiteSpaces( char * pString );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATRemoveAllWhiteSpaces
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLength;
|
||||
|
||||
__CPROVER_assume( stringLength < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLength > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLength );
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLength ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLength - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATRemoveAllWhiteSpaces( pString );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATRemoveAllWhiteSpaces_harness
|
||||
PROOF_UID = Cellular_ATRemoveAllWhiteSpaces
|
||||
|
||||
DEFINES += -D__NO_CTYPE
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=32
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATRemoveAllWhiteSpaces.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATRemoveAllWhiteSpaces proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATRemoveAllWhiteSpaces.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATRemoveAllWhiteSpaces",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveLeadingWhiteSpaces( char ** ppString );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATRemoveLeadingWhiteSpaces
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLength;
|
||||
|
||||
__CPROVER_assume( stringLength < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLength > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLength );
|
||||
char ** ppString = nondet_bool() ? NULL : &pString;
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLength ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLength - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATRemoveLeadingWhiteSpaces( ppString );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATRemoveLeadingWhiteSpaces_harness
|
||||
PROOF_UID = Cellular_ATRemoveLeadingWhiteSpaces
|
||||
|
||||
DEFINES += -D__NO_CTYPE
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=128
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATRemoveLeadingWhiteSpaces.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
@ -0,0 +1,10 @@
|
||||
Cellular_ATRemoveLeadingWhiteSpaces proof
|
||||
==============
|
||||
|
||||
This directory contains a memory safety proof for Cellular_ATRemoveLeadingWhiteSpaces.
|
||||
|
||||
To run the proof.
|
||||
* Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer
|
||||
to your path.
|
||||
* Run "make".
|
||||
* Open html/index.html in a web browser.
|
||||
@ -0,0 +1 @@
|
||||
# This file marks this directory as containing a CBMC proof.
|
||||
@ -0,0 +1,7 @@
|
||||
{ "expected-missing-functions":
|
||||
[
|
||||
|
||||
],
|
||||
"proof-name": "Cellular_ATRemoveLeadingWhiteSpaces",
|
||||
"proof-root": "tools/cbmc/proofs"
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* FreeRTOS-Cellular-Interface v1.3.0
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* Cellular default config includes. */
|
||||
#include "cellular_config.h"
|
||||
#include "cellular_config_defaults.h"
|
||||
|
||||
/* Cellular APIs includes. */
|
||||
#include "cellular_platform.h"
|
||||
#include "cellular_types.h"
|
||||
#include "cellular_common_internal.h"
|
||||
#include "cellular_common_api.h"
|
||||
|
||||
#define ensure_memory_is_valid( px, length ) ( px != NULL ) && ( length > 0 ) && __CPROVER_w_ok( ( px ), length ) && __CPROVER_r_ok( ( px ), length )
|
||||
|
||||
/* Extern the com interface in comm_if_windows.c */
|
||||
extern CellularCommInterface_t CellularCommInterface;
|
||||
|
||||
/****************************************************************
|
||||
* The signature of the function under test.
|
||||
****************************************************************/
|
||||
|
||||
CellularATError_t Cellular_ATRemoveOutermostDoubleQuote( char ** ppString );
|
||||
|
||||
/****************************************************************
|
||||
* The proof of Cellular_ATRemoveOutermostDoubleQuote
|
||||
****************************************************************/
|
||||
void harness()
|
||||
{
|
||||
uint16_t stringLength;
|
||||
|
||||
__CPROVER_assume( stringLength < CBMC_MAX_BUFSIZE );
|
||||
__CPROVER_assume( stringLength > 0 );
|
||||
char * pString = ( char * ) safeMalloc( stringLength );
|
||||
char ** ppString = nondet_bool() ? NULL : &pString;
|
||||
|
||||
if( ( pString == NULL ) || ( ( pString != NULL ) && ensure_memory_is_valid( pString, stringLength ) ) )
|
||||
{
|
||||
if( pString != NULL )
|
||||
{
|
||||
pString[ stringLength - 1 ] = '\0';
|
||||
}
|
||||
|
||||
Cellular_ATRemoveOutermostDoubleQuote( ppString );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
HARNESS_ENTRY=harness
|
||||
HARNESS_FILE=Cellular_ATRemoveOutermostDoubleQuote_harness
|
||||
PROOF_UID = Cellular_ATRemoveOutermostDoubleQuote
|
||||
|
||||
DEFINES +=
|
||||
INCLUDES +=
|
||||
# This value was experimentally chosen to provide 100% coverage
|
||||
# without tripping unwinding assertions and without exhausting memory.
|
||||
CBMC_MAX_BUFSIZE=128
|
||||
|
||||
DEFINES += -DCBMC_MAX_BUFSIZE=$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
UNWINDSET += Cellular_ATRemoveOutermostDoubleQuote.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += strlen.0:$(CBMC_MAX_BUFSIZE)
|
||||
UNWINDSET += memchr.0:$(CBMC_MAX_BUFSIZE)
|
||||
|
||||
|
||||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/cellular_cbmc_state.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/sources/global_state_cellular.c
|
||||
PROOF_SOURCES += $(SRCDIR)/test/cbmc/stubs/memchr.c
|
||||
PROJECT_SOURCES += $(SRCDIR)/source/cellular_at_core.c
|
||||
|
||||
include ../Makefile.common
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user