mirror of
https://github.com/openharmony/vendor_chipsea.git
synced 2026-06-30 21:47:56 -04:00
@@ -0,0 +1,177 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved" path=".*" desc="original chipsea copyright"/>
|
||||
<policyitem type="license" name="Apache" path=".*" desc="chipsea use apache 2.0 license"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="ARM Limited appache2">
|
||||
<filteritem type="filepath" name="wblink_demo/config.json" desc="ARM limits license"/>
|
||||
<filteritem type="filepath" name="display_demo/config.json" desc="ARM limits license"/>
|
||||
<filteritem type="filepath" name="xts_demo/config.json" desc="ARM limits license"/>
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies" >
|
||||
<filteritem type="filename" name="*.a|*.so|*.bin|*.png|*.mp3|*.jpg|*.gif|.ttf" desc="Temp files"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
@@ -1,36 +0,0 @@
|
||||
# vendor_chipsea
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
|
||||
@@ -1,39 +1,34 @@
|
||||
# vendor_chipsea
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
## 介绍
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
该仓库托管芯海科技开发的产品样例代码,主要包括TODO等特性产品的开发。
|
||||
|
||||
## 软件架构
|
||||
|
||||
支持基于芯海CST85F01 SoC 的cst85_wblink单板进行开发的产品样例。
|
||||
|
||||
代码路径:
|
||||
|
||||
```
|
||||
vendor/chipsea/ --- vendor_chipsea仓库路径
|
||||
└── wblink_demo --- 样例
|
||||
```
|
||||
|
||||
## 安装教程
|
||||
|
||||
参考 [安装调试教程](https://gitee.com/openharmony-sig/device_soc_chipsea/blob/master/README.md)
|
||||
|
||||
## 使用说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
## 贡献
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
[如何参与](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
||||
|
||||
#### 使用说明
|
||||
[Commit message规范](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83?sort_id=4042860)
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
## 相关仓
|
||||
|
||||
#### 参与贡献
|
||||
[device/soc/chipsea](https://gitee.com/openharmony/device_soc_chipsea/blob/HEAD/README_zh.md)
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
print("CHIPSEA-CST85F01-display_demo")
|
||||
group("display_demo") {
|
||||
deps = [
|
||||
"app:example"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("example") {
|
||||
sources = [
|
||||
"example.c",
|
||||
]
|
||||
deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static" ]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "ohos_init.h"
|
||||
#include "log.h"
|
||||
|
||||
void DemoSdkMain(void)
|
||||
{
|
||||
HILOG_INFO(HILOG_MODULE_APP, "%s: demo entry! \r\n", __func__);
|
||||
}
|
||||
APP_FEATURE_INIT(DemoSdkMain);
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"product_name": "display_demo",
|
||||
"ohos_version": "OpenHarmony 2.3",
|
||||
"version": "3.0",
|
||||
"device_company": "chipsea",
|
||||
"board": "cst85_wblink",
|
||||
"kernel_type": "liteos_m",
|
||||
"kernel_version": "3.0.0",
|
||||
"subsystems": [
|
||||
{
|
||||
"subsystem": "kernel",
|
||||
"components": [
|
||||
{ "component": "liteos_m",
|
||||
"features":[
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "utils",
|
||||
"components": [
|
||||
{
|
||||
"component": "kv_store"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"subsystem": "startup",
|
||||
"components": [
|
||||
{
|
||||
"component": "bootstrap_lite"
|
||||
},
|
||||
{
|
||||
"component": "syspara_lite",
|
||||
"features": [
|
||||
"enable_ohos_startup_syspara_lite_use_posix_file_api = true"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "hiviewdfx",
|
||||
"components": [
|
||||
{
|
||||
"component": "hilog_lite",
|
||||
"optional": "true"
|
||||
},
|
||||
{
|
||||
"component": "hievent_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"subsystem": "distributedschedule",
|
||||
"components": [
|
||||
{
|
||||
"component": "samgr_lite",
|
||||
"features": [
|
||||
"config_ohos_distributedschedule_samgr_lite_shared_task_size = 4096"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
"subsystem": "communication",
|
||||
"components": [
|
||||
{
|
||||
"component": "wifi_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"vendor_adapter_dir": "",
|
||||
"third_party_dir": "//third_party",
|
||||
"product_adapter_dir": "//vendor/chipsea/display_demo/hals",
|
||||
"ohos_product_type":"",
|
||||
"ohos_manufacture":"",
|
||||
"ohos_brand":"",
|
||||
"ohos_market_name":"",
|
||||
"ohos_product_series":"",
|
||||
"ohos_product_model":"",
|
||||
"ohos_software_model":"",
|
||||
"ohos_hardware_model":"",
|
||||
"ohos_hardware_profile":"",
|
||||
"ohos_serial":"",
|
||||
"ohos_bootloader_version":"",
|
||||
"ohos_secure_patch_level":"",
|
||||
"ohos_abi_list":""
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2021 chipsea Co., Ltd. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_sysparam") {
|
||||
sources = [ "hal_sys_param.c" ]
|
||||
include_dirs = [ "//base/startup/syspara_lite/hals" ]
|
||||
defines = [
|
||||
"INCREMENTAL_VERSION=\"${ohos_version}\"",
|
||||
"BUILD_TYPE=\"${ohos_build_type}\"",
|
||||
"BUILD_USER=\"${ohos_build_user}\"",
|
||||
"BUILD_TIME=\"${ohos_build_time}\"",
|
||||
"BUILD_HOST=\"${ohos_build_host}\"",
|
||||
"BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2021 chipsea Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_sys_param.h"
|
||||
|
||||
#define OHOS_DEVICE_TYPE "linkiot"
|
||||
#define OHOS_DISPLAY_VERSION "OpenHarmony-2.2-Beta2"
|
||||
#define OHOS_MANUFACTURE "chipsea"
|
||||
#define OHOS_BRAND "chipsea"
|
||||
#define OHOS_MARKET_NAME "****"
|
||||
#define OHOS_PRODUCT_SERIES "****"
|
||||
#define OHOS_PRODUCT_MODEL "****"
|
||||
#define OHOS_SOFTWARE_MODEL "****"
|
||||
#define OHOS_HARDWARE_MODEL "cst85"
|
||||
#define OHOS_HARDWARE_PROFILE "aout:true,display:true"
|
||||
#define OHOS_BOOTLOADER_VERSION "bootloader"
|
||||
#define OHOS_ABI_LIST "****"
|
||||
#define OHOS_SERIAL "1234567890"
|
||||
#define OHOS_FIRST_API_VERSION 1
|
||||
#define ETH_ALEN 6
|
||||
#define MAC_BITS 4
|
||||
#define HEX_A 0xa
|
||||
#define MAC_HIGH_MASK 0xf0
|
||||
#define MAC_LOW_MASK 0x0f
|
||||
#define CHAR_NUM_OFFSET 0x30
|
||||
#define CHAR_CAPITAL_OFFSET 0x37
|
||||
#define STR_END_FLAG '\0'
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
static char serialNumber[2*ETH_ALEN + 1];
|
||||
|
||||
const char* HalGetDeviceType(void)
|
||||
{
|
||||
return OHOS_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetManufacture(void)
|
||||
{
|
||||
return OHOS_MANUFACTURE;
|
||||
}
|
||||
|
||||
const char* HalGetBrand(void)
|
||||
{
|
||||
return OHOS_BRAND;
|
||||
}
|
||||
|
||||
const char* HalGetMarketName(void)
|
||||
{
|
||||
return OHOS_MARKET_NAME;
|
||||
}
|
||||
|
||||
const char* HalGetProductSeries(void)
|
||||
{
|
||||
return OHOS_PRODUCT_SERIES;
|
||||
}
|
||||
|
||||
const char* HalGetProductModel(void)
|
||||
{
|
||||
return OHOS_PRODUCT_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetSoftwareModel(void)
|
||||
{
|
||||
return OHOS_SOFTWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareModel(void)
|
||||
{
|
||||
return OHOS_HARDWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareProfile(void)
|
||||
{
|
||||
return OHOS_HARDWARE_PROFILE;
|
||||
}
|
||||
|
||||
static char Hex2Char(u8 hex)
|
||||
{
|
||||
if (hex < HEX_A) {
|
||||
return hex + CHAR_NUM_OFFSET;
|
||||
} else {
|
||||
return hex + CHAR_CAPITAL_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
const char* HalGetSerial(void)
|
||||
{
|
||||
char macAddr[ETH_ALEN];
|
||||
// as devboard has no production serial number, we just
|
||||
// use wifi mac address as device serial number.
|
||||
if (serialNumber[0] == STR_END_FLAG) {
|
||||
extern int bwifi_get_own_mac(u8 *addr);
|
||||
bwifi_get_own_mac(macAddr);
|
||||
int j = 0;
|
||||
for (int i = 0; i < ETH_ALEN; i++) {
|
||||
u8 lowFour, highFour;
|
||||
highFour = (macAddr[i] & MAC_HIGH_MASK) >> MAC_BITS;
|
||||
serialNumber[j] = Hex2Char(highFour);
|
||||
j++;
|
||||
lowFour = macAddr[i] & MAC_LOW_MASK;
|
||||
serialNumber[j] = Hex2Char(lowFour);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
const char* HalGetBootloaderVersion(void)
|
||||
{
|
||||
return OHOS_BOOTLOADER_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetAbiList(void)
|
||||
{
|
||||
return OHOS_ABI_LIST;
|
||||
}
|
||||
|
||||
const char* HalGetDisplayVersion(void)
|
||||
{
|
||||
return OHOS_DISPLAY_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetIncrementalVersion(void)
|
||||
{
|
||||
return INCREMENTAL_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetBuildType(void)
|
||||
{
|
||||
return BUILD_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetBuildUser(void)
|
||||
{
|
||||
return BUILD_USER;
|
||||
}
|
||||
|
||||
const char* HalGetBuildHost(void)
|
||||
{
|
||||
return BUILD_HOST;
|
||||
}
|
||||
|
||||
const char* HalGetBuildTime(void)
|
||||
{
|
||||
return BUILD_TIME;
|
||||
}
|
||||
|
||||
int HalGetFirstApiVersion(void)
|
||||
{
|
||||
return OHOS_FIRST_API_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief implement for js kvstorekit/filekit
|
||||
*/
|
||||
const char *GetDataPath()
|
||||
{
|
||||
return "/data";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2020 chipsea Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_token_static") {
|
||||
sources = [ "hal_token.c" ]
|
||||
|
||||
include_dirs = [
|
||||
"//base/startup/syspara_lite/hals",
|
||||
"//utils/native/lite/include",
|
||||
]
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2021 chipsea Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_token.h"
|
||||
#include "ohos_errno.h"
|
||||
#include "ohos_types.h"
|
||||
|
||||
static int OEMReadToken(char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, read token from device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, write token to device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get AcKey
|
||||
(void)(acKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdId
|
||||
(void)(productId);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdKey
|
||||
(void)(productKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int HalReadToken(char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMReadToken(token, len);
|
||||
}
|
||||
|
||||
int HalWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMWriteToken(token, len);
|
||||
}
|
||||
|
||||
int HalGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
if (acKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetAcKey(acKey, len);
|
||||
}
|
||||
|
||||
int HalGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
if (productId == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdId(productId, len);
|
||||
}
|
||||
|
||||
int HalGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
if (productKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdKey(productKey, len);
|
||||
}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
# LOSCFG_ARCH_UNALIGNED_EXC is not set
|
||||
LOSCFG_SOC_SERIES_CST85=y
|
||||
LOSCFG_KERNEL_BACKTRACE=y
|
||||
LOSCFG_KERNEL_CPUP=y
|
||||
LOSCFG_PLATFORM_EXC=y
|
||||
LOSCFG_LIBC_NEWLIB=y
|
||||
LOSCFG_DRIVERS_HDF=y
|
||||
LOSCFG_DRIVERS_HDF_PLATFORM=y
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"parts": {
|
||||
"product_display_demo": {
|
||||
"module_list": [
|
||||
"//vendor/chipsea/display_demo:display_demo"
|
||||
]
|
||||
}
|
||||
},
|
||||
"subsystem": "product_display_demo"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
print("CHIPSEA-CST85F01-wblink_demo")
|
||||
group("wblink_demo") {
|
||||
deps = [
|
||||
"app:example"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
# Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
declare_args() {
|
||||
wifi_sta_demo = false
|
||||
wifi_ap_demo = false
|
||||
}
|
||||
|
||||
static_library("example") {
|
||||
sources = [
|
||||
"example.c",
|
||||
]
|
||||
deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static" ]
|
||||
|
||||
if (wifi_sta_demo) {
|
||||
sources += ["wifi_demo/wifi_sta_demo.c"]
|
||||
}
|
||||
|
||||
if (wifi_ap_demo) {
|
||||
sources += ["wifi_demo/wifi_ap_demo.c"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "ohos_init.h"
|
||||
#include "log.h"
|
||||
|
||||
void DemoSdkMain(void)
|
||||
{
|
||||
HILOG_INFO(HILOG_MODULE_APP, "%s: demo entry! \r\n", __func__);
|
||||
}
|
||||
APP_FEATURE_INIT(DemoSdkMain);
|
||||
@@ -0,0 +1,323 @@
|
||||
# CST85_WBLink开发板Wifi编程开发——启用热点
|
||||
|
||||
本文基于CST85_WBLink开发板,演示了如何使用鸿蒙API进行热点功能开发。
|
||||
|
||||
### 1.RegisterWifiEvent
|
||||
|
||||
```c
|
||||
WifiErrorCode RegisterWifiEvent (WifiEvent *event)
|
||||
```
|
||||
|
||||
**描述**:设定wifi设备行为的回调函数。例如:热点扫描结果,连接结果回调等。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| ------ | ---------------------- |
|
||||
| event | 需要注册的行为回调函数 |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 2.SetHotspotConfig
|
||||
|
||||
```c
|
||||
WifiErrorCode SetHotspotConfig(const HotspotConfig* config)
|
||||
```
|
||||
|
||||
**描述**:设置热点配置信息。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| ------ | ------------ |
|
||||
| config | 热点配置信息 |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 3.EnableHotspot
|
||||
|
||||
```c
|
||||
WifiErrorCode EnableHotspot(void)
|
||||
```
|
||||
|
||||
**描述**:打开热点。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 4.IsHotspotActive
|
||||
|
||||
```c
|
||||
int IsHotspotActive(void);
|
||||
```
|
||||
|
||||
**描述**:检查热点是否开启。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 4.DisableHotspot
|
||||
|
||||
```c
|
||||
WifiErrorCode DisableHotspot(void);
|
||||
```
|
||||
|
||||
**描述**:关闭热点。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
## 流程简介
|
||||
|
||||
1. 注册AP回调函数接口,包括sta连接,sta离开以及热点打开三个接口。
|
||||
2. 调用SetHotspotConfig配置热点信息。
|
||||
3. 通过IsHotspotActive检查热点是否正常打开。
|
||||
4. 测试热点加入场景,回调OnHotspotStaJoinHandler函数,在该函数中通过GetStationList打印当前sta列表。
|
||||
5. 测试热点离开场景,回调OnHotspotStaLeaveHandler,在该函数中打印离开热点信息。
|
||||
6. 测试完成
|
||||
|
||||
```c
|
||||
// sta加入回调函数
|
||||
|
||||
static void OnHotspotStaJoinHandler(StationInfo *info)
|
||||
|
||||
{
|
||||
|
||||
if (info == NULL) {
|
||||
|
||||
dbg("HotspotStaJoin:info is null.\r\n");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
StationInfo stainfo[WIFI_MAX_STA_NUM] = {0};
|
||||
|
||||
StationInfo *sta_list_node = NULL;
|
||||
|
||||
unsigned int size = WIFI_MAX_STA_NUM;
|
||||
|
||||
|
||||
|
||||
// 获取当前热点sta列表
|
||||
|
||||
int error = GetStationList(stainfo, &size);
|
||||
|
||||
if (error != WIFI_SUCCESS) {
|
||||
|
||||
dbg("HotspotStaJoin:get list fail, error is %d.\r\n", error);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
sta_list_node = stainfo;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++, sta_list_node++) {
|
||||
|
||||
unsigned char *mac = sta_list_node->macAddress;
|
||||
|
||||
dbg("HotspotSta[%u]: macAddress=%02X:%02X:%02X:%02X:%02X:%02X\r\n", i,
|
||||
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sta离开回调函数
|
||||
|
||||
static void OnHotspotStaLeaveHandler(StationInfo *info)
|
||||
|
||||
{
|
||||
|
||||
if (info == NULL) {
|
||||
|
||||
dbg("HotspotStaLeave:info is null.\r\n");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
unsigned char *mac = info->macAddress;
|
||||
|
||||
dbg("HotspotStaLeave: macAddress=%02X:%02X:%02X:%02X:%02X:%02X, reason=%d.\r\n",
|
||||
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
|
||||
|
||||
info->disconnectedReason);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 热点状态变化回调函数
|
||||
|
||||
static void OnHotspotStateChangedHandler(int state)
|
||||
|
||||
{
|
||||
|
||||
dbg("HotspotStateChanged:state is %d.\r\n", state);
|
||||
|
||||
if (state == WIFI_HOTSPOT_ACTIVE) {
|
||||
|
||||
dbg("wifi hotspot active.\r\n");
|
||||
|
||||
} else {
|
||||
|
||||
dbg("wifi hotspot noactive.\r\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
WifiEvent g_wifiEventHandler = {
|
||||
|
||||
.OnHotspotStaJoin = OnHotspotStaJoinHandler,
|
||||
|
||||
.OnHotspotStaLeave = OnHotspotStaLeaveHandler,
|
||||
|
||||
.OnHotspotStateChanged = OnHotspotStateChangedHandler,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void WifiApEntry(void)
|
||||
|
||||
{
|
||||
|
||||
WifiErrorCode error;
|
||||
|
||||
osDelay(2000);
|
||||
|
||||
|
||||
|
||||
//注册wifi事件的回调函数
|
||||
|
||||
error = RegisterWifiEvent(&g_wifiEventHandler);
|
||||
|
||||
if (error != WIFI_SUCCESS) {
|
||||
|
||||
dbg("RegisterWifiEvent failed, error = %d.\r\n", error);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
dbg("RegisterWifiEvent succeed!\r\n");
|
||||
|
||||
|
||||
|
||||
HotspotConfig config = {0};
|
||||
|
||||
strcpy_s(config.ssid, WIFI_MAX_SSID_LEN, AP_SSID);
|
||||
|
||||
strcpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, AP_PSK);
|
||||
|
||||
config.securityType = WIFI_SEC_TYPE_PSK;
|
||||
|
||||
config.band = HOTSPOT_BAND_TYPE_2G;
|
||||
|
||||
config.channelNum = CHANNEL_NUM;
|
||||
|
||||
|
||||
|
||||
// 设置热点配置信息
|
||||
|
||||
error = SetHotspotConfig(&config);
|
||||
|
||||
if (error != WIFI_SUCCESS) {
|
||||
|
||||
dbg("SetHotspotConfig failed, error = %d.\r\n", error);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
dbg("SetHotspotConfig succeed!\r\n");
|
||||
|
||||
|
||||
|
||||
// 打开热点
|
||||
|
||||
error = EnableHotspot();
|
||||
|
||||
if (error != WIFI_SUCCESS) {
|
||||
|
||||
dbg("EnableHotspot failed, error = %d.\r\n", error);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
dbg("EnableHotspot succeed!\r\n");
|
||||
|
||||
|
||||
|
||||
//检查热点是否已开启
|
||||
|
||||
if (IsHotspotActive() == WIFI_HOTSPOT_NOT_ACTIVE) {
|
||||
|
||||
dbg("Wifi Hotspot is not actived.\r\n");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
dbg("Wifi Hotspot is actived!\r\n");
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## 编译选项
|
||||
|
||||
修改热点信息:
|
||||
|
||||
```c
|
||||
#define AP_SSID "chipsea_test"
|
||||
#define AP_PSK "12345678"
|
||||
#define CHANNEL_NUM 7
|
||||
```
|
||||
|
||||
打开编译选项
|
||||
|
||||
将<u>vendor/chipsea/weblink_demo/app/BUILD.gn</u>文件下的false修改为true以打开编译
|
||||
|
||||
```makefile
|
||||
declare_args() {
|
||||
|
||||
wifi_sta_demo = false
|
||||
|
||||
wifi_ap_demo = false
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## 运行结果
|
||||
|
||||
```
|
||||
wifiDevice: RegisterWifiEvent!
|
||||
RegisterWifiEvent succeed!
|
||||
WifiAp:set akm =10
|
||||
SetHotspotConfig succeed!
|
||||
WPA task started for interface {FVIF-0}
|
||||
WPA network 0: created and configured
|
||||
_ps_disable_cfm:800000
|
||||
_add gtk:1
|
||||
WPA enter FHOST_WPA_STATE_CONNECTED
|
||||
WPA network 0: connected
|
||||
dhcpServerStart 0 0, 0
|
||||
DHCPS init: ip=192.168.88.1
|
||||
HotspotStateChanged:state is 1.
|
||||
wifi hotspot active.
|
||||
EnableHotspot succeed!
|
||||
Wifi Hotspot is actived!
|
||||
_add gtk:1
|
||||
_add ptk:0
|
||||
station join: mac->C2:67:83:F6:B6:9B ip-> 192.168.88.10,cnt= 1
|
||||
HotspotSta[0]: macAddress=C2:67:83:F6:B6:9B
|
||||
dhcps: ack C2:67:83:F6:B6:9B -> 192.168.88.10
|
||||
```
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
# CST85_WBLink开发板Wifi编程开发——热点连接
|
||||
|
||||
本文基于CST85_WBLink开发板,演示了如何使用鸿蒙API进行热点连接功能开发。
|
||||
|
||||
## API介绍:
|
||||
|
||||
### 1.EnableWifi
|
||||
|
||||
```c
|
||||
WifiErrorCode EnableWifi (void)
|
||||
```
|
||||
|
||||
**描述**:使能WIFI设备的STA模式。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 2.IsWifiActive
|
||||
|
||||
```c
|
||||
int IsWifiActive(void);
|
||||
```
|
||||
|
||||
**描述**:检查WIFI设备STA模式是否已启用。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 3.RegisterWifiEvent
|
||||
|
||||
```c
|
||||
WifiErrorCode RegisterWifiEvent (WifiEvent *event)
|
||||
```
|
||||
|
||||
**描述**:设定wifi设备行为的回调函数。例如:热点扫描结果,连接结果回调等。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| ------ | ---------------------- |
|
||||
| event | 需要注册的行为回调函数 |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 4.Scan
|
||||
|
||||
```c
|
||||
WifiErrorCode Scan(void);
|
||||
```
|
||||
|
||||
**描述**:启动设备扫描热点。
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 5.GetScanInfoList
|
||||
|
||||
```c
|
||||
WifiErrorCode GetScanInfoList(WifiScanInfo *result, unsigned int *size);
|
||||
```
|
||||
|
||||
**描述**:获取热点扫描结果。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| ------ | ---------------- |
|
||||
| result | 扫描返回结果列表 |
|
||||
| size | 返回热点个数 |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 6.AddDeviceConfig
|
||||
|
||||
```c
|
||||
WifiErrorCode AddDeviceConfig(const WifiDeviceConfig *config, int *result);
|
||||
```
|
||||
|
||||
**描述**:添加用于连接所需的热点设备信息。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| ------ | ----------------------------------------------- |
|
||||
| config | 热点配置信息 |
|
||||
| result | 系统为该配置项生成的用于后续连接使用的networkid |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
### 7.ConnectTo
|
||||
|
||||
```c
|
||||
WifiErrorCode ConnectTo(int networkId);
|
||||
```
|
||||
|
||||
**描述**:获取热点扫描结果。
|
||||
|
||||
**参数**:
|
||||
|
||||
| 参数名 | 描述 |
|
||||
| --------- | ------------------------------------------ |
|
||||
| networkId | 由AddDeviceConfig接口返回的分配的networkId |
|
||||
|
||||
**返回值**:接口执行结果
|
||||
|
||||
## 流程简介
|
||||
|
||||
1. 调用接口EnableWifi使能wifi设备。
|
||||
2. 通过IsWifiActive检查设备是否工作正常。
|
||||
3. 将扫描结果回调函数注册到系统中,并且在回调函数中释放等待扫描结果的信号量。
|
||||
4. 调用Scan接口开始扫描,并且等待信号量。
|
||||
5. 信号量正常返回则继续调用GetScanInfoList查询扫描结果,否则异常超时退出。
|
||||
6. 调用接口AddDeviceConfig配置一个测试用AP信息,并获取到分配的network ID。
|
||||
7. 配置成功返回后ConnectTo到这个net ID。
|
||||
8. 测试完成
|
||||
|
||||
```c
|
||||
static void OnWifiScanStateChangedHandler(int state, int size)
|
||||
|
||||
{
|
||||
|
||||
(void)state;
|
||||
|
||||
if (state == WIFI_STATE_AVALIABLE) {
|
||||
|
||||
// 接收到扫描结果,释放信号量
|
||||
|
||||
rtos_semaphore_signal(g_scanSemap, false);
|
||||
|
||||
dbg("get wifi scan result %d\r\n", size);
|
||||
|
||||
} else {
|
||||
|
||||
dbg("wifi scan failed\r\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void RegistEvent(void)
|
||||
|
||||
{
|
||||
|
||||
static WifiEvent wifiEventHandler = {
|
||||
|
||||
// 扫描结果回调函数
|
||||
|
||||
.OnWifiScanStateChanged = OnWifiScanStateChangedHandler,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 注册回调函数
|
||||
|
||||
WifiErrorCode error = RegisterWifiEvent(&wifiEventHandler);
|
||||
|
||||
if (error != WIFI_SUCCESS) {
|
||||
|
||||
dbg("register wifi event fail!\r\n");
|
||||
|
||||
} else {
|
||||
|
||||
dbg("register wifi event succeed!\r\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int32_t ScanTest()
|
||||
|
||||
{
|
||||
|
||||
unsigned int rstSize = WIFI_SCAN_HOTSPOT_LIMIT;
|
||||
|
||||
|
||||
|
||||
dbg("start scan test!\r\n");
|
||||
|
||||
// 启动设备扫描
|
||||
|
||||
if (Scan() != WIFI_SUCCESS) {
|
||||
|
||||
dbg("StartScan err!\r\n");
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
dbg("wait scan result...!\r\n");
|
||||
|
||||
// 等待扫描结果
|
||||
|
||||
if (rtos_semaphore_wait(g_scanSemap, 10000) != 0) {
|
||||
|
||||
dbg("StartScan timeout!\r\n");
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
WifiScanInfo *info = (WifiScanInfo *)rtos_malloc(sizeof(WifiScanInfo) * WIFI_SCAN_HOTSPOT_LIMIT);
|
||||
|
||||
if (info == NULL) {
|
||||
|
||||
dbg("malloc failed\r\n");
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取扫描结果
|
||||
|
||||
if (GetScanInfoList(info, &rstSize) != WIFI_SUCCESS) {
|
||||
|
||||
dbg("GetScanInfoList failed\r\n");
|
||||
|
||||
rtos_free(info);
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < rstSize; i++) {
|
||||
|
||||
dbg("no:%03u, ssid:%-30s, rssi:%5d\r\n", i + 1, info[i].ssid, info[i].rssi);
|
||||
|
||||
}
|
||||
|
||||
rtos_free(info);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t ConnectTest()
|
||||
|
||||
{
|
||||
|
||||
int netId;
|
||||
|
||||
// 设定连接热点配置信息
|
||||
|
||||
WifiDeviceConfig demoConfig = {
|
||||
|
||||
.ssid = DEMO_WIFI_SSID,
|
||||
|
||||
.preSharedKey = DEMO_WIFI_PASSWORD,
|
||||
|
||||
.securityType = DEMO_WIFI_SECURITYTYPE,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
dbg("start connect test!\r\n");
|
||||
|
||||
// 添加热点配置信息,获取配置对应的networkId
|
||||
|
||||
if (AddDeviceConfig(&demoConfig, &netId) != WIFI_SUCCESS) {
|
||||
|
||||
printf("AddDeviceConfig failed!\r\n");
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
dbg("Connecting to ssid:[%s],netId:[%d]...\r\n", DEMO_WIFI_SSID, netId);
|
||||
|
||||
|
||||
|
||||
// 连接热点
|
||||
|
||||
return ConnectTo(netId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID WifiEntry(VOID)
|
||||
|
||||
{
|
||||
|
||||
// 延时2s后开始测试
|
||||
|
||||
osDelay(2000);
|
||||
|
||||
unsigned char mac[WIFI_MAC_LEN] = {0};
|
||||
|
||||
|
||||
|
||||
// 使能wifi设备
|
||||
|
||||
if (EnableWifi() != WIFI_SUCCESS) {
|
||||
|
||||
dbg("EnableWifi failed\r\n");
|
||||
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查wifi设备工作是否正常
|
||||
|
||||
if (IsWifiActive() == WIFI_STA_NOT_ACTIVE) {
|
||||
|
||||
dbg("Wifi station is not actived.\n");
|
||||
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 注册回调事件
|
||||
|
||||
RegistEvent();
|
||||
|
||||
|
||||
|
||||
// 获取设备的MAC地址
|
||||
|
||||
if (GetDeviceMacAddress(mac) != 0) {
|
||||
|
||||
dbg("get mac addr\r\n");
|
||||
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
dbg("MAC ADDRESS:%02x:%02x:%02x:%02x:%02x:%02x\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
|
||||
|
||||
// 扫描测试
|
||||
|
||||
if (ScanTest() != 0) {
|
||||
|
||||
dbg("Wifi scan test err.\n");
|
||||
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
dbg("scan test success!\r\n");
|
||||
|
||||
|
||||
|
||||
// 连接测试
|
||||
|
||||
if (ConnectTest() != 0) {
|
||||
|
||||
dbg("Wifi connect test err.\n");
|
||||
|
||||
goto Exit;
|
||||
|
||||
}
|
||||
|
||||
dbg("connect test success!\r\n");
|
||||
|
||||
|
||||
|
||||
Exit:
|
||||
|
||||
// 去使能wifi
|
||||
|
||||
(void)DisableWifi();
|
||||
|
||||
while(1);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## 编译选项
|
||||
|
||||
修改热点信息:
|
||||
|
||||
```c
|
||||
#define DEMO_WIFI_SSID "test"
|
||||
|
||||
#define DEMO_WIFI_PASSWORD "12345678"
|
||||
|
||||
#define DEMO_WIFI_SECURITYTYPE WIFI_SEC_TYPE_PSK
|
||||
```
|
||||
|
||||
打开编译选项
|
||||
|
||||
将<u>vendor/chipsea/weblink_demo/app/BUILD.gn</u>文件下的false修改为true以打开编译
|
||||
|
||||
```makefile
|
||||
declare_args() {
|
||||
|
||||
wifi_sta_demo = false
|
||||
|
||||
wifi_ap_demo = false
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## 运行结果
|
||||
|
||||
```
|
||||
start scan test!
|
||||
vif_name AIC_CC69
|
||||
_scanu_start:0,0,0
|
||||
wait scan result...!
|
||||
_scanu_confirm:0,0,0
|
||||
get wifi scan result 5
|
||||
wifiDevice:(-53 dBm) CH= 1 BSSID=d4:76:a0:3e:16:c0 SSID=chipsea-PC
|
||||
wifiDevice:(-87 dBm) CH= 2 BSSID=08:01:0f:c4:52:19 SSID=ChinaNet-KuSai
|
||||
wifiDevice:(-79 dBm) CH= 4 BSSID=50:33:f0:3e:64:a6 SSID=VPS
|
||||
wifiDevice:(-42 dBm) CH= 6 BSSID=aa:48:2b:61:fb:e5 SSID=Muffin
|
||||
wifiDevice:(-89 dBm) CH= 11 BSSID=7c:b5:9b:56:44:0f SSID=TP-LINK_440F
|
||||
no:001, ssid:chipsea-PC , rssi: -53
|
||||
no:002, ssid:ChinaNet-KuSai , rssi: -87
|
||||
no:003, ssid:VPS , rssi: -79
|
||||
no:004, ssid:Muffin , rssi: -42
|
||||
no:005, ssid:TP-LINK_440F , rssi: -89
|
||||
scan test success!
|
||||
start connect test!
|
||||
wifiDevice:AddDeviceConfig success netid = 0
|
||||
Connecting to ssid:[Muffin],netId:[0]...
|
||||
Connect Wi-Fi: Muffin, 12345678
|
||||
vif_name AIC_CC69
|
||||
WPA task started for interface {FVIF-0}
|
||||
WPA network 0: created and configured
|
||||
_scanu_start:1,0,0
|
||||
_scanu_confirm:1,0,0
|
||||
_scanu_start:1,1,0
|
||||
_scanu_confirm:1,1,0
|
||||
_ps_disable_cfm:800000
|
||||
_sm_auth_send
|
||||
_tx cfm:5,80800000
|
||||
_auth_handler:0
|
||||
_sm_assoc_req_send
|
||||
_tx cfm:7,80800000
|
||||
_assoc_rsp_handler:0
|
||||
_vif state active:0,1,0,0
|
||||
_ps_upm_enter:0,94
|
||||
_connect:1,0,aid=0
|
||||
Connect 0 48aa:612b:e5fb, sta_index 1
|
||||
_curr=0, bss=2
|
||||
_add ptk:0
|
||||
_add gtk:1
|
||||
WPA enter FHOST_WPA_STATE_CONNECTED
|
||||
_ps_enable_cfm:800000
|
||||
WPA network 0: connected
|
||||
_curr=2, bss=0
|
||||
_handle addba_rsp:tid=0, idx=5
|
||||
DHCP completed: ip=172.20.10.6 gw=172.20.10.1
|
||||
fhost_reconnect_dhcp_register
|
||||
connect test success!
|
||||
_disconnct:1,3
|
||||
_delete reources
|
||||
_vif state inactive:0,1
|
||||
_ps_upm_exit
|
||||
Disconnect 0 48aa:612b:e5fb
|
||||
WPA network 0: disconnected
|
||||
wpa_supplicant_main end
|
||||
WPA enter FHOST_WPA_STATE_STOPPED
|
||||
fhost_reconnect_dhcp_registe
|
||||
```
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2022 CHIPSEA Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "wifi_device.h"
|
||||
#include "wifi_error_code.h"
|
||||
#include "wifi_hotspot.h"
|
||||
#include "rtos_al.h"
|
||||
#include "securec.h"
|
||||
#include "dbg.h"
|
||||
#include "ohos_init.h"
|
||||
|
||||
#define AP_SSID "chipsea_test"
|
||||
#define AP_PSK "12345678"
|
||||
#define CHANNEL_NUM 7
|
||||
|
||||
static void OnHotspotStaJoinHandler(StationInfo *info)
|
||||
{
|
||||
if (info == NULL) {
|
||||
dbg("HotspotStaJoin:info is null.\r\n");
|
||||
return;
|
||||
}
|
||||
StationInfo stainfo[WIFI_MAX_STA_NUM] = {0};
|
||||
StationInfo *sta_list_node = NULL;
|
||||
unsigned int size = WIFI_MAX_STA_NUM;
|
||||
|
||||
// 获取当前热点sta列表
|
||||
int error = GetStationList(stainfo, &size);
|
||||
if (error != WIFI_SUCCESS) {
|
||||
dbg("HotspotStaJoin:get list fail, error is %d.\r\n", error);
|
||||
return;
|
||||
}
|
||||
sta_list_node = stainfo;
|
||||
for (uint32_t i = 0; i < size; i++, sta_list_node++) {
|
||||
unsigned char *mac = sta_list_node->macAddress;
|
||||
dbg("HotspotSta[%u]: macAddress=%02X:%02X:%02X:%02X:%02X:%02X\r\n", i,
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
}
|
||||
|
||||
// sta离开回调函数
|
||||
static void OnHotspotStaLeaveHandler(StationInfo *info)
|
||||
{
|
||||
if (info == NULL) {
|
||||
dbg("HotspotStaLeave:info is null.\r\n");
|
||||
return;
|
||||
}
|
||||
unsigned char *mac = info->macAddress;
|
||||
dbg("HotspotStaLeave: macAddress=%02X:%02X:%02X:%02X:%02X:%02X, reason=%d.\r\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
|
||||
info->disconnectedReason);
|
||||
}
|
||||
|
||||
// 热点状态变化回调函数
|
||||
static void OnHotspotStateChangedHandler(int state)
|
||||
{
|
||||
dbg("HotspotStateChanged:state is %d.\r\n", state);
|
||||
if (state == WIFI_HOTSPOT_ACTIVE) {
|
||||
dbg("wifi hotspot active.\r\n");
|
||||
} else {
|
||||
dbg("wifi hotspot noactive.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
WifiEvent g_wifiEventHandler = {
|
||||
.OnHotspotStaJoin = OnHotspotStaJoinHandler,
|
||||
.OnHotspotStaLeave = OnHotspotStaLeaveHandler,
|
||||
.OnHotspotStateChanged = OnHotspotStateChangedHandler,
|
||||
};
|
||||
|
||||
static void WifiApEntry(void)
|
||||
{
|
||||
WifiErrorCode error;
|
||||
osDelay(2000);
|
||||
|
||||
//注册wifi事件的回调函数
|
||||
error = RegisterWifiEvent(&g_wifiEventHandler);
|
||||
if (error != WIFI_SUCCESS) {
|
||||
dbg("RegisterWifiEvent failed, error = %d.\r\n", error);
|
||||
return;
|
||||
}
|
||||
dbg("RegisterWifiEvent succeed!\r\n");
|
||||
|
||||
HotspotConfig config = {0};
|
||||
strcpy_s(config.ssid, WIFI_MAX_SSID_LEN, AP_SSID);
|
||||
strcpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, AP_PSK);
|
||||
config.securityType = WIFI_SEC_TYPE_PSK;
|
||||
config.band = HOTSPOT_BAND_TYPE_2G;
|
||||
config.channelNum = CHANNEL_NUM;
|
||||
|
||||
// 设置热点配置信息
|
||||
error = SetHotspotConfig(&config);
|
||||
if (error != WIFI_SUCCESS) {
|
||||
dbg("SetHotspotConfig failed, error = %d.\r\n", error);
|
||||
return;
|
||||
}
|
||||
dbg("SetHotspotConfig succeed!\r\n");
|
||||
|
||||
// 打开热点
|
||||
error = EnableHotspot();
|
||||
if (error != WIFI_SUCCESS) {
|
||||
dbg("EnableHotspot failed, error = %d.\r\n", error);
|
||||
return;
|
||||
}
|
||||
dbg("EnableHotspot succeed!\r\n");
|
||||
|
||||
//检查热点是否已开启
|
||||
if (IsHotspotActive() == WIFI_HOTSPOT_NOT_ACTIVE) {
|
||||
dbg("Wifi Hotspot is not actived.\r\n");
|
||||
return;
|
||||
}
|
||||
dbg("Wifi Hotspot is actived!\r\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
void WifiApDemo(void)
|
||||
{
|
||||
dbg("[%s:%d]: %s\n", __FILE__, __LINE__, __func__);
|
||||
|
||||
if (rtos_task_create(WifiApEntry, "wifi ap demo task", 0, 0x500, NULL, RTOS_TASK_PRIORITY(1), NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
SYS_RUN(WifiApDemo);
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2022 CHIPSEA Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "rtos_al.h"
|
||||
#include "dbg.h"
|
||||
#include "wifi_device.h"
|
||||
#include "wifi_device_config.h"
|
||||
#include "ohos_init.h"
|
||||
|
||||
#define DEMO_WIFI_SSID "test"
|
||||
#define DEMO_WIFI_PASSWORD "12345678"
|
||||
#define DEMO_WIFI_SECURITYTYPE WIFI_SEC_TYPE_PSK
|
||||
|
||||
rtos_semaphore g_scanSemap;
|
||||
|
||||
static void OnWifiScanStateChangedHandler(int state, int size)
|
||||
{
|
||||
(void)state;
|
||||
if (state == WIFI_STATE_AVALIABLE) {
|
||||
// 接收到扫描结果,释放信号量
|
||||
rtos_semaphore_signal(g_scanSemap, false);
|
||||
dbg("get wifi scan result %d\r\n", size);
|
||||
} else {
|
||||
dbg("wifi scan failed\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void RegistEvent(void)
|
||||
{
|
||||
static WifiEvent wifiEventHandler = {
|
||||
// 扫描结果回调函数
|
||||
.OnWifiScanStateChanged = OnWifiScanStateChangedHandler,
|
||||
};
|
||||
|
||||
// 注册回调函数
|
||||
WifiErrorCode error = RegisterWifiEvent(&wifiEventHandler);
|
||||
if (error != WIFI_SUCCESS) {
|
||||
dbg("register wifi event fail!\r\n");
|
||||
} else {
|
||||
dbg("register wifi event succeed!\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t ScanTest()
|
||||
{
|
||||
unsigned int rstSize = WIFI_SCAN_HOTSPOT_LIMIT;
|
||||
|
||||
dbg("start scan test!\r\n");
|
||||
// 启动设备扫描
|
||||
if (Scan() != WIFI_SUCCESS) {
|
||||
dbg("StartScan err!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dbg("wait scan result...!\r\n");
|
||||
// 等待扫描结果
|
||||
if (rtos_semaphore_wait(g_scanSemap, 10000) != 0) {
|
||||
dbg("StartScan timeout!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WifiScanInfo *info = (WifiScanInfo *)rtos_malloc(sizeof(WifiScanInfo) * WIFI_SCAN_HOTSPOT_LIMIT);
|
||||
if (info == NULL) {
|
||||
dbg("malloc failed\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 获取扫描结果
|
||||
if (GetScanInfoList(info, &rstSize) != WIFI_SUCCESS) {
|
||||
dbg("GetScanInfoList failed\r\n");
|
||||
rtos_free(info);
|
||||
return -1;
|
||||
}
|
||||
for (unsigned int i = 0; i < rstSize; i++) {
|
||||
dbg("no:%03u, ssid:%-30s, rssi:%5d\r\n", i + 1, info[i].ssid, info[i].rssi);
|
||||
}
|
||||
rtos_free(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t AdvanceScanTest()
|
||||
{
|
||||
unsigned int rstSize = WIFI_SCAN_HOTSPOT_LIMIT;
|
||||
WifiScanParams params = {
|
||||
.scanType = WIFI_SSID_SCAN,
|
||||
.ssid = "Muffin",
|
||||
};
|
||||
params.ssidLen = strlen("Muffin");
|
||||
dbg("start scan test!\r\n");
|
||||
// 启动设备扫描
|
||||
if (AdvanceScan(¶ms) != WIFI_SUCCESS) {
|
||||
dbg("StartScan advance err!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dbg("wait scan result...!\r\n");
|
||||
// 等待扫描结果
|
||||
if (rtos_semaphore_wait(g_scanSemap, 10000) != 0) {
|
||||
dbg("StartScan timeout!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WifiScanInfo *info = (WifiScanInfo *)rtos_malloc(sizeof(WifiScanInfo) * WIFI_SCAN_HOTSPOT_LIMIT);
|
||||
if (info == NULL) {
|
||||
dbg("malloc failed\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 获取扫描结果
|
||||
if (GetScanInfoList(info, &rstSize) != WIFI_SUCCESS) {
|
||||
dbg("GetScanInfoList failed\r\n");
|
||||
rtos_free(info);
|
||||
return -1;
|
||||
}
|
||||
for (unsigned int i = 0; i < rstSize; i++) {
|
||||
dbg("no:%03u, ssid:%-30s, rssi:%5d\r\n", i + 1, info[i].ssid, info[i].rssi);
|
||||
}
|
||||
rtos_free(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ConnectTest()
|
||||
{
|
||||
int netId;
|
||||
// 设定连接热点配置信息
|
||||
WifiDeviceConfig demoConfig = {
|
||||
.ssid = DEMO_WIFI_SSID,
|
||||
.preSharedKey = DEMO_WIFI_PASSWORD,
|
||||
.securityType = DEMO_WIFI_SECURITYTYPE,
|
||||
};
|
||||
|
||||
dbg("start connect test!\r\n");
|
||||
// 添加热点配置信息,获取配置对应的networkId
|
||||
if (AddDeviceConfig(&demoConfig, &netId) != WIFI_SUCCESS) {
|
||||
printf("AddDeviceConfig failed!\r\n");
|
||||
return -1;
|
||||
}
|
||||
dbg("Connecting to ssid:[%s],netId:[%d]...\r\n", DEMO_WIFI_SSID, netId);
|
||||
|
||||
// 连接热点
|
||||
return ConnectTo(netId);
|
||||
}
|
||||
|
||||
VOID WifiEntry(VOID)
|
||||
{
|
||||
// 延时2s后开始测试
|
||||
osDelay(2000);
|
||||
unsigned char mac[WIFI_MAC_LEN] = {0};
|
||||
|
||||
// 使能wifi设备
|
||||
if (EnableWifi() != WIFI_SUCCESS) {
|
||||
dbg("EnableWifi failed\r\n");
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// 检查wifi设备工作是否正常
|
||||
if (IsWifiActive() == WIFI_STA_NOT_ACTIVE) {
|
||||
dbg("Wifi station is not actived.\n");
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// 注册回调事件
|
||||
RegistEvent();
|
||||
|
||||
// 获取设备的MAC地址
|
||||
if (GetDeviceMacAddress(mac) != 0) {
|
||||
dbg("get mac addr\r\n");
|
||||
goto Exit;
|
||||
}
|
||||
dbg("MAC ADDRESS:%02x:%02x:%02x:%02x:%02x:%02x\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
// 扫描测试
|
||||
if (ScanTest() != 0) {
|
||||
dbg("Wifi scan test err.\n");
|
||||
goto Exit;
|
||||
}
|
||||
dbg("scan test success!\r\n");
|
||||
|
||||
if (AdvanceScanTest() != 0) {
|
||||
dbg("Wifi scan test err.\n");
|
||||
goto Exit;
|
||||
}
|
||||
dbg("scan test success!\r\n");
|
||||
|
||||
// 连接测试
|
||||
if (ConnectTest() != 0) {
|
||||
dbg("Wifi connect test err.\n");
|
||||
goto Exit;
|
||||
}
|
||||
dbg("connect test success!\r\n");
|
||||
osDelay(10000);
|
||||
|
||||
Exit:
|
||||
Disconnect();
|
||||
// 去使能wifi
|
||||
(void)DisableWifi();
|
||||
while(1);
|
||||
}
|
||||
|
||||
int WifiStaDemo(void)
|
||||
{
|
||||
if (rtos_semaphore_create(&g_scanSemap, 1, 0) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rtos_task_create(WifiEntry, "Example task", 0, 0x500, NULL, RTOS_TASK_PRIORITY(1), NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_RUN(WifiStaDemo);
|
||||
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"product_name": "wblink_demo",
|
||||
"ohos_version": "OpenHarmony 2.3",
|
||||
"version": "3.0",
|
||||
"device_company": "chipsea",
|
||||
"board": "cst85_wblink",
|
||||
"kernel_type": "liteos_m",
|
||||
"kernel_version": "3.0.0",
|
||||
"subsystems": [
|
||||
{
|
||||
"subsystem": "kernel",
|
||||
"components": [
|
||||
{ "component": "liteos_m",
|
||||
"features":[
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "utils",
|
||||
"components": [
|
||||
{
|
||||
"component": "kv_store"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"subsystem": "startup",
|
||||
"components": [
|
||||
{
|
||||
"component": "bootstrap_lite"
|
||||
},
|
||||
{
|
||||
"component": "syspara_lite",
|
||||
"features": [
|
||||
"enable_ohos_startup_syspara_lite_use_posix_file_api = true"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "hiviewdfx",
|
||||
"components": [
|
||||
{
|
||||
"component": "hilog_lite",
|
||||
"optional": "true"
|
||||
},
|
||||
{
|
||||
"component": "hievent_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"subsystem": "distributedschedule",
|
||||
"components": [
|
||||
{
|
||||
"component": "samgr_lite",
|
||||
"features": [
|
||||
"config_ohos_distributedschedule_samgr_lite_shared_task_size = 4096"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
"subsystem": "communication",
|
||||
"components": [
|
||||
{
|
||||
"component": "wifi_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"vendor_adapter_dir": "",
|
||||
"third_party_dir": "//third_party",
|
||||
"product_adapter_dir": "//vendor/chipsea/wblink_demo/hals",
|
||||
"ohos_product_type":"",
|
||||
"ohos_manufacture":"",
|
||||
"ohos_brand":"",
|
||||
"ohos_market_name":"",
|
||||
"ohos_product_series":"",
|
||||
"ohos_product_model":"",
|
||||
"ohos_software_model":"",
|
||||
"ohos_hardware_model":"",
|
||||
"ohos_hardware_profile":"",
|
||||
"ohos_serial":"",
|
||||
"ohos_bootloader_version":"",
|
||||
"ohos_secure_patch_level":"",
|
||||
"ohos_abi_list":""
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2021 chipsea Co., Ltd. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_sysparam") {
|
||||
sources = [ "hal_sys_param.c" ]
|
||||
include_dirs = [ "//base/startup/syspara_lite/hals" ]
|
||||
defines = [
|
||||
"INCREMENTAL_VERSION=\"${ohos_version}\"",
|
||||
"BUILD_TYPE=\"${ohos_build_type}\"",
|
||||
"BUILD_USER=\"${ohos_build_user}\"",
|
||||
"BUILD_TIME=\"${ohos_build_time}\"",
|
||||
"BUILD_HOST=\"${ohos_build_host}\"",
|
||||
"BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2021 chipsea Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_sys_param.h"
|
||||
|
||||
#define OHOS_DEVICE_TYPE "linkiot"
|
||||
#define OHOS_DISPLAY_VERSION "OpenHarmony-2.2-Beta2"
|
||||
#define OHOS_MANUFACTURE "chipsea"
|
||||
#define OHOS_BRAND "chipsea"
|
||||
#define OHOS_MARKET_NAME "****"
|
||||
#define OHOS_PRODUCT_SERIES "****"
|
||||
#define OHOS_PRODUCT_MODEL "****"
|
||||
#define OHOS_SOFTWARE_MODEL "****"
|
||||
#define OHOS_HARDWARE_MODEL "cst85"
|
||||
#define OHOS_HARDWARE_PROFILE "aout:true,display:true"
|
||||
#define OHOS_BOOTLOADER_VERSION "bootloader"
|
||||
#define OHOS_ABI_LIST "****"
|
||||
#define OHOS_SERIAL "1234567890"
|
||||
#define OHOS_FIRST_API_VERSION 1
|
||||
#define ETH_ALEN 6
|
||||
#define MAC_BITS 4
|
||||
#define HEX_A 0xa
|
||||
#define MAC_HIGH_MASK 0xf0
|
||||
#define MAC_LOW_MASK 0x0f
|
||||
#define CHAR_NUM_OFFSET 0x30
|
||||
#define CHAR_CAPITAL_OFFSET 0x37
|
||||
#define STR_END_FLAG '\0'
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
static char serialNumber[2*ETH_ALEN + 1];
|
||||
|
||||
const char* HalGetDeviceType(void)
|
||||
{
|
||||
return OHOS_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetManufacture(void)
|
||||
{
|
||||
return OHOS_MANUFACTURE;
|
||||
}
|
||||
|
||||
const char* HalGetBrand(void)
|
||||
{
|
||||
return OHOS_BRAND;
|
||||
}
|
||||
|
||||
const char* HalGetMarketName(void)
|
||||
{
|
||||
return OHOS_MARKET_NAME;
|
||||
}
|
||||
|
||||
const char* HalGetProductSeries(void)
|
||||
{
|
||||
return OHOS_PRODUCT_SERIES;
|
||||
}
|
||||
|
||||
const char* HalGetProductModel(void)
|
||||
{
|
||||
return OHOS_PRODUCT_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetSoftwareModel(void)
|
||||
{
|
||||
return OHOS_SOFTWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareModel(void)
|
||||
{
|
||||
return OHOS_HARDWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareProfile(void)
|
||||
{
|
||||
return OHOS_HARDWARE_PROFILE;
|
||||
}
|
||||
|
||||
static char Hex2Char(u8 hex)
|
||||
{
|
||||
if (hex < HEX_A) {
|
||||
return hex + CHAR_NUM_OFFSET;
|
||||
} else {
|
||||
return hex + CHAR_CAPITAL_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
const char* HalGetSerial(void)
|
||||
{
|
||||
char macAddr[ETH_ALEN];
|
||||
// as devboard has no production serial number, we just
|
||||
// use wifi mac address as device serial number.
|
||||
if (serialNumber[0] == STR_END_FLAG) {
|
||||
extern int bwifi_get_own_mac(u8 *addr);
|
||||
bwifi_get_own_mac(macAddr);
|
||||
int j = 0;
|
||||
for (int i = 0; i < ETH_ALEN; i++) {
|
||||
u8 lowFour, highFour;
|
||||
highFour = (macAddr[i] & MAC_HIGH_MASK) >> MAC_BITS;
|
||||
serialNumber[j] = Hex2Char(highFour);
|
||||
j++;
|
||||
lowFour = macAddr[i] & MAC_LOW_MASK;
|
||||
serialNumber[j] = Hex2Char(lowFour);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
const char* HalGetBootloaderVersion(void)
|
||||
{
|
||||
return OHOS_BOOTLOADER_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetAbiList(void)
|
||||
{
|
||||
return OHOS_ABI_LIST;
|
||||
}
|
||||
|
||||
const char* HalGetDisplayVersion(void)
|
||||
{
|
||||
return OHOS_DISPLAY_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetIncrementalVersion(void)
|
||||
{
|
||||
return INCREMENTAL_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetBuildType(void)
|
||||
{
|
||||
return BUILD_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetBuildUser(void)
|
||||
{
|
||||
return BUILD_USER;
|
||||
}
|
||||
|
||||
const char* HalGetBuildHost(void)
|
||||
{
|
||||
return BUILD_HOST;
|
||||
}
|
||||
|
||||
const char* HalGetBuildTime(void)
|
||||
{
|
||||
return BUILD_TIME;
|
||||
}
|
||||
|
||||
int HalGetFirstApiVersion(void)
|
||||
{
|
||||
return OHOS_FIRST_API_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief implement for js kvstorekit/filekit
|
||||
*/
|
||||
const char *GetDataPath()
|
||||
{
|
||||
return "/data";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2020 chipsea Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_token_static") {
|
||||
sources = [ "hal_token.c" ]
|
||||
|
||||
include_dirs = [
|
||||
"//base/startup/syspara_lite/hals",
|
||||
"//utils/native/lite/include",
|
||||
]
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2021 chipsea Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_token.h"
|
||||
#include "ohos_errno.h"
|
||||
#include "ohos_types.h"
|
||||
|
||||
static int OEMReadToken(char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, read token from device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, write token to device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get AcKey
|
||||
(void)(acKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdId
|
||||
(void)(productId);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdKey
|
||||
(void)(productKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int HalReadToken(char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMReadToken(token, len);
|
||||
}
|
||||
|
||||
int HalWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMWriteToken(token, len);
|
||||
}
|
||||
|
||||
int HalGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
if (acKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetAcKey(acKey, len);
|
||||
}
|
||||
|
||||
int HalGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
if (productId == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdId(productId, len);
|
||||
}
|
||||
|
||||
int HalGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
if (productKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdKey(productKey, len);
|
||||
}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
# LOSCFG_ARCH_UNALIGNED_EXC is not set
|
||||
LOSCFG_SOC_SERIES_CST85=y
|
||||
LOSCFG_KERNEL_BACKTRACE=y
|
||||
LOSCFG_KERNEL_CPUP=y
|
||||
LOSCFG_PLATFORM_EXC=y
|
||||
LOSCFG_LIBC_NEWLIB=y
|
||||
LOSCFG_DRIVERS_HDF=y
|
||||
LOSCFG_DRIVERS_HDF_PLATFORM=y
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"parts": {
|
||||
"product_wblink_demo": {
|
||||
"module_list": [
|
||||
"//vendor/chipsea/wblink_demo:wblink_demo"
|
||||
]
|
||||
}
|
||||
},
|
||||
"subsystem": "product_wblink_demo"
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
print("CHIPSEA-CST85F01-xts_demo")
|
||||
group("xts_demo") {
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"product_name": "xts_demo",
|
||||
"ohos_version": "OpenHarmony 2.3",
|
||||
"version": "3.0",
|
||||
"device_company": "chipsea",
|
||||
"board": "cst85_wblink",
|
||||
"kernel_type": "liteos_m",
|
||||
"kernel_version": "3.0.0",
|
||||
"subsystems": [
|
||||
{
|
||||
"subsystem": "kernel",
|
||||
"components": [
|
||||
{ "component": "liteos_m",
|
||||
"features":[
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "startup",
|
||||
"components": [
|
||||
{
|
||||
"component": "bootstrap_lite"
|
||||
},
|
||||
{
|
||||
"component": "syspara_lite",
|
||||
"features": [
|
||||
"enable_ohos_startup_syspara_lite_use_posix_file_api = true",
|
||||
"config_ohos_startup_syspara_lite_data_path = \"/data/\""
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "hiviewdfx",
|
||||
"components": [
|
||||
{
|
||||
"component": "hilog_lite",
|
||||
"optional": "true"
|
||||
},
|
||||
{
|
||||
"component": "hievent_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "distributedschedule",
|
||||
"components": [
|
||||
{
|
||||
"component": "samgr_lite"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "communication",
|
||||
"components": [
|
||||
{
|
||||
"component": "wifi_lite",
|
||||
"optional": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "utils",
|
||||
"components": [
|
||||
{
|
||||
"component": "kv_store",
|
||||
"features": [
|
||||
"enable_ohos_utils_native_lite_kv_store_use_posix_kv_api = true"
|
||||
]
|
||||
},
|
||||
{
|
||||
"component": "js_builtin"
|
||||
},
|
||||
{
|
||||
"component": "timer_task"
|
||||
},
|
||||
{
|
||||
"component": "kal_timer",
|
||||
"features": [
|
||||
"enable_histreamer_plugin_ffmpeg_adapter = false",
|
||||
"config_ohos_distributedschedule_samgr_lite_shared_task_size = 4096"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"subsystem": "xts",
|
||||
"components": [
|
||||
{ "component": "xts_acts",
|
||||
"features":[
|
||||
"config_ohos_xts_acts_utils_lite_kv_store_data_path = \"/data\"",
|
||||
"enable_xts_service = true"
|
||||
]
|
||||
},
|
||||
{ "component": "xts_tools", "features":[] }
|
||||
]
|
||||
}
|
||||
],
|
||||
"vendor_adapter_dir": "",
|
||||
"third_party_dir": "//third_party",
|
||||
"product_adapter_dir": "//vendor/chipsea/xts_demo/hals"
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2022 CHIPSEA Co., Ltd. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_sysparam") {
|
||||
sources = [ "hal_sys_param.c" ]
|
||||
include_dirs = [ "//base/startup/syspara_lite/hals" ]
|
||||
defines = [
|
||||
"INCREMENTAL_VERSION=\"${ohos_version}\"",
|
||||
"BUILD_TYPE=\"${ohos_build_type}\"",
|
||||
"BUILD_USER=\"${ohos_build_user}\"",
|
||||
"BUILD_TIME=\"${ohos_build_time}\"",
|
||||
"BUILD_HOST=\"${ohos_build_host}\"",
|
||||
"BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
|
||||
]
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Chipsea Co., Ltd. All rights reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_sys_param.h"
|
||||
|
||||
#define OHOS_DEVICE_TYPE "linkiot"
|
||||
#define OHOS_DISPLAY_VERSION "OpenHarmony-2.2-Beta2"
|
||||
#define OHOS_MANUFACTURE "Chipsea"
|
||||
#define OHOS_BRAND "Chipsea"
|
||||
#define OHOS_MARKET_NAME "****"
|
||||
#define OHOS_PRODUCT_SERIES "****"
|
||||
#define OHOS_PRODUCT_MODEL "****"
|
||||
#define OHOS_SOFTWARE_MODEL "****"
|
||||
#define OHOS_HARDWARE_MODEL "cst85"
|
||||
#define OHOS_HARDWARE_PROFILE "aout:true"
|
||||
#define OHOS_BOOTLOADER_VERSION "bootloader"
|
||||
#define OHOS_ABI_LIST "****"
|
||||
#define OHOS_SERIAL "1234567890"
|
||||
#define OHOS_FIRST_API_VERSION 1
|
||||
|
||||
const char* HalGetDeviceType(void)
|
||||
{
|
||||
return OHOS_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetManufacture(void)
|
||||
{
|
||||
return OHOS_MANUFACTURE;
|
||||
}
|
||||
|
||||
const char* HalGetBrand(void)
|
||||
{
|
||||
return OHOS_BRAND;
|
||||
}
|
||||
|
||||
const char* HalGetMarketName(void)
|
||||
{
|
||||
return OHOS_MARKET_NAME;
|
||||
}
|
||||
|
||||
const char* HalGetProductSeries(void)
|
||||
{
|
||||
return OHOS_PRODUCT_SERIES;
|
||||
}
|
||||
|
||||
const char* HalGetProductModel(void)
|
||||
{
|
||||
return OHOS_PRODUCT_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetSoftwareModel(void)
|
||||
{
|
||||
return OHOS_SOFTWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareModel(void)
|
||||
{
|
||||
return OHOS_HARDWARE_MODEL;
|
||||
}
|
||||
|
||||
const char* HalGetHardwareProfile(void)
|
||||
{
|
||||
return OHOS_HARDWARE_PROFILE;
|
||||
}
|
||||
|
||||
const char* HalGetSerial(void)
|
||||
{
|
||||
return OHOS_SERIAL;
|
||||
}
|
||||
|
||||
const char* HalGetBootloaderVersion(void)
|
||||
{
|
||||
return OHOS_BOOTLOADER_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetAbiList(void)
|
||||
{
|
||||
return OHOS_ABI_LIST;
|
||||
}
|
||||
|
||||
const char* HalGetDisplayVersion(void)
|
||||
{
|
||||
return OHOS_DISPLAY_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetIncrementalVersion(void)
|
||||
{
|
||||
return INCREMENTAL_VERSION;
|
||||
}
|
||||
|
||||
const char* HalGetBuildType(void)
|
||||
{
|
||||
return BUILD_TYPE;
|
||||
}
|
||||
|
||||
const char* HalGetBuildUser(void)
|
||||
{
|
||||
return BUILD_USER;
|
||||
}
|
||||
|
||||
const char* HalGetBuildHost(void)
|
||||
{
|
||||
return BUILD_HOST;
|
||||
}
|
||||
|
||||
const char* HalGetBuildTime(void)
|
||||
{
|
||||
return BUILD_TIME;
|
||||
}
|
||||
|
||||
int HalGetFirstApiVersion(void)
|
||||
{
|
||||
return OHOS_FIRST_API_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief implement for js kvstorekit/filekit
|
||||
*/
|
||||
const char *GetDataPath()
|
||||
{
|
||||
return "/data";
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
static_library("hal_token_static") {
|
||||
sources = [ "hal_token.c" ]
|
||||
|
||||
include_dirs = [
|
||||
"//base/startup/syspara_lite/hals",
|
||||
"//utils/native/lite/include",
|
||||
]
|
||||
deps = []
|
||||
}
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal_token.h"
|
||||
#include "ohos_errno.h"
|
||||
#include "ohos_types.h"
|
||||
|
||||
static int OEMReadToken(char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, read token from device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
// OEM need add here, write token to device
|
||||
(void)(token);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get AcKey
|
||||
(void)(acKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdId
|
||||
(void)(productId);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int OEMGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
// OEM need add here, get ProdKey
|
||||
(void)(productKey);
|
||||
(void)(len);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int HalReadToken(char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMReadToken(token, len);
|
||||
}
|
||||
|
||||
int HalWriteToken(const char *token, unsigned int len)
|
||||
{
|
||||
if (token == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMWriteToken(token, len);
|
||||
}
|
||||
|
||||
int HalGetAcKey(char *acKey, unsigned int len)
|
||||
{
|
||||
if (acKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetAcKey(acKey, len);
|
||||
}
|
||||
|
||||
int HalGetProdId(char *productId, unsigned int len)
|
||||
{
|
||||
if (productId == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdId(productId, len);
|
||||
}
|
||||
|
||||
int HalGetProdKey(char *productKey, unsigned int len)
|
||||
{
|
||||
if (productKey == NULL) {
|
||||
return EC_FAILURE;
|
||||
}
|
||||
|
||||
return OEMGetProdKey(productKey, len);
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
# LOSCFG_ARCH_UNALIGNED_EXC is not set
|
||||
LOSCFG_SOC_SERIES_CST85=y
|
||||
LOSCFG_KERNEL_BACKTRACE=y
|
||||
LOSCFG_KERNEL_CPUP=y
|
||||
LOSCFG_PLATFORM_EXC=y
|
||||
LOSCFG_LIBC_NEWLIB=y
|
||||
LOSCFG_DRIVERS_HDF=y
|
||||
LOSCFG_DRIVERS_HDF_PLATFORM=y
|
||||
LOSCFG_FS_LITTLEFS=y
|
||||
Reference in New Issue
Block a user