add EULA ...

Signed-off-by: wenxing <wenxing.tu@bekencorp.com>
This commit is contained in:
wenxing
2022-10-25 01:29:38 +00:00
parent dc4df43ccd
commit 5a0a1677d6
55 changed files with 473 additions and 3829 deletions
Executable
+71
View File
@@ -0,0 +1,71 @@
## End User License Agreement
THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND【 FULL NAME OF THE LICENSOR 】 (HERE AFTER REFERRED TO AS"【 SHORT NAME OF THE LICENSOR 】") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS AGREEMENT. 【 SHORT NAME OF THE LICENSOR 】 IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY DOWNDOADING OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT,【 SHORT NAME OF THE LICENSOR 】 WILL NOT LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO YOUR SUPPLIER.
“SOFTWARE” means the software in object code provided under the terms of this Agreement.
【favorite District of the licensor】 is the signing place of this Agreement.
### 1.GRANT OF LICENSE
In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of this Agreement, 【 SHORT NAME OF THE LICENSOR 】 hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable, worldwide copyright license (without the right to sublicense) to internally use and copy the SOFTWARE to 【usage mode eg.“set up internal development environment with development boards”】 integrating 【 SHORT NAME OF THE LICENSOR 】 【product type of the licensor,eg.“chips”】, solely for the purpose of【purpose of use for the SOFTWARE,eg.“designing, developing or testing your applications”】 .
All rights to the SOFTWARE and all intellectual property rights contained therein are reserved and shall remain the sole and exclusive property of 【 SHORT NAME OF THE LICENSOR 】. The SOFTWARE is licensed but not sold. Except as expressly licensed in Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to patent rights, copyrights, trademark or trade secret in the SOFTWARE.
No right is granted to YOU under this Agreement to manufacture, have manufactured, or sell, supply or distribute any products which use or embody any of the SOFTWARE or any of the intellectual property rights embodied therein.
### 2.RESTRICTIONS
YOU shall reproduce and not remove or obscure any notice incorporated by 【 SHORT NAME OF THE LICENSOR 】 in the SOFTWARE to protect 【 SHORT NAME OF THE LICENSOR 】’s intellectual property rights embodied therein.
YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
YOU shall not distribute the SOFTWARE under an open source license as listed by the Open Source Initiative (a non-profit corporation whose website is www.opensource.org), or other license which requires the source code or object code of the SOFTWARE to be licensed or otherwise shared with any third party.
### 3.CONFLICT WITH OPEN SOURCE SOFTWARE LICENSE
The SOFTWARE may contain open source software. If the license applied on such open source software has conflict with this Agreement, the license applied on such open source software will prevail and apply to the open source software.
### 4.FEEDBACK
YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in oral or written form) relating to the use of the SOFTWARE ("Feedback") to 【 SHORT NAME OF THE LICENSOR 】 under the terms of this Agreement. YOU hereby grants to 【 SHORT NAME OF THE LICENSOR 】 and its affiliates, under all of you and your affiliates (as applicable) intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design, have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the rights granted in this paragraph to any third party.
### 5.NO WARRANTY
YOU AGREE THAT THE SOFTWARE IS PROVIDED BY 【 SHORT NAME OF THE LICENSOR 】 ON AN "AS IS" BASIS. 【 SHORT NAME OF THE LICENSOR 】 MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
### 6.NO LIABILITY
PLEASE NOTE THAT YOU SHOULD USE THE SOFTWARE AT YOUR OWN RISK.
IN NO EVENT SHALL 【 SHORT NAME OF THE LICENSOR 】 BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF 【 SHORT NAME OF THE LICENSOR 】 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, 【 SHORT NAME OF THE LICENSOR 】 SHALL HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE MAXIMUM LIABILITY OF 【 SHORT NAME OF THE LICENSOR 】 TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST 【 SHORT NAME OF THE LICENSOR 】 IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS RECEIVED BY 【 SHORT NAME OF THE LICENSOR 】 FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
### 7.CONFIDENTIALITY
YOU acknowledge and agree that the SOFTWARE provided under this Agreement contain trade secrets and confidential material of 【 SHORT NAME OF THE LICENSOR 】 and YOU agree to maintain all such information in confidence and apply security measures no less stringent than the measures which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
### 8.TERM AND TERMINATION
This Agreement shall remain in force until terminated. 【 SHORT NAME OF THE LICENSOR 】 may terminate this Agreement at any time with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential information in your possession, together with all documentation and related materials. The provisions of clauses 2, 3, 4, 5, 6, 78 and 9 shall survive termination of this Agreement.
### 9.GENERAL
Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining provisions hereof.
The failure by 【SHORT NAME OF THE LICENSOR】 to enforce any of the provisions of this Agreement, unless waived in writing, shall not constitute a waiver of 【SHORT NAME OF THE LICENSOR】's rights to enforce such provision or any other provision of this Agreement in the future.
This Agreement shall be governed by and construed in accordance with the laws of Peoples Republic of China, without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement shall be submitted to 【favorite court of the licensor】and the parties waive all objections to that jurisdiction and venue.
--------------------------------------------------------------------
Copyright (C) 【starting year of this Agreement】【FULL NAME OF THE LICENSOR】 All rights reserved.
Executable
+177
View File
@@ -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
Executable
+79
View File
@@ -0,0 +1,79 @@
<?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) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved." path=".*" desc="original beken copyright"/>
<policyitem type="copyright" name="Copyright (c) 2013-2018 Arm Limited. All rights reserved." path=".*" desc="original beken copyright"/>
<policyitem type="copyright" name="Copyright (C) 2015-2017 Alibaba Group Holding Limited." path=".*" desc="beken use Alibaba copyright"/>
<policyitem type="copyright" name="Copyright (c) 2020 Huawei Device Co., Ltd." path=".*" desc="beken use Huawei copyright"/>
<policyitem type="copyright" name="Copyright (c) 2021 Huawei Device Co., Ltd." path=".*" desc="beken use Huawei copyright"/>
<policyitem type="copyright" name="Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved." path=".*" desc="beken use Huawei copyright"/>
<policyitem type="copyright" name="Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="beken use Huawei copyright"/>
<policyitem type="copyright" name="Copyright (c) 2009-2020 Arm Limited., Ltd. All rights reserved." path=".*" desc="beken use Huawei copyright"/>
<policyitem type="license" name="Apache" path=".*" desc="beken use apache 2.0 license"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="beken use BSD-3-Clause license"/>
<policyitem type="license" name="MIT" path=".*" desc="beken use MIT license"/>
</policy>
</policylist>
<filefilterlist>
<filefilter name="defaultFilter" desc="beken using MIT files, but invalid copyright">
<filteritem type="filepath" name="EULA" desc="beken using MIT files, but invalid copyright"/>
</filefilter>
<filefilter name="defaultFilter" desc="beken using license files, but invalid copyright">
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/include/oem_auth_config.h" desc="beken using license files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/include/oem_auth_config.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/include/oem_auth_result_storage.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/include/oem_auth_result_storage.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/src/oem_auth_config.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/src/oem_auth_config.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/harmonyos_connect.gni" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/src/oem_auth_result_storage.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/harmonyos_connect.gni" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/src/oem_auth_result_storage.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/hilinksdk/adapter/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/hilinksdk/adapter/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/hilinksdk/adapter/include/hilink_open_ota_adapter.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/hilinksdk/adapter/include/hilink_open_ota_adapter.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/hilinksdk/adapter/include/hilink_open_ota_mcu_adapter.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/hilinksdk/adapter/include/hilink_open_ota_mcu_adapter.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/hilinksdk/adapter/src/hilink_open_ota_adapter.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/utils/sys_param/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/hilinksdk/adapter/src/hilink_open_ota_adapter.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/utils/sys_param/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/hilinksdk/adapter/src/hilink_open_ota_mcu_adapter.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/utils/sys_param/hal_sys_param.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/hilinksdk/adapter/src/hilink_open_ota_mcu_adapter.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/utils/sys_param/hal_sys_param.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/utils/token/hal_token.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/utils/token/hal_token.c" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/BUILD.gn" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="test_xts_part1/hals/harmonyos_connect/kitframework/adapter/include/kitframework_client.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="wifi_bk7235/hals/harmonyos_connect/kitframework/adapter/include/kitframework_client.h" desc="beken using MIT files, but invalid copyright"/>
<filteritem type="filepath" name="EULA" desc="beken using MIT files, but invalid copyright"/>
</filefilter>
</filefilterlist>
</oatconfig>
</configuration>
+13
View File
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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.
group("test_xts_part1") {
deps = [
@@ -1,10 +0,0 @@
harmonyos_connect_package_path = "//vendor/huawei/harmonyos_connect"
if (ohos_kernel_type == "liteos_m") {
ohos_type = "mini"
} else if (ohos_kernel_type == "liteos_a") {
ohos_type = "small"
} else if (ohos_kernel_type == "linux") {
ohos_type = "standard"
}
@@ -1,17 +0,0 @@
import("//build/lite/config/component/lite_component.gni")
import("//applications/iot_solution/device.gni")
static_library("ota_update_adapter") {
sources = [
"src/hilink_open_ota_adapter.c",
"src/hilink_open_ota_mcu_adapter.c",
]
include_dirs = [
"include",
# "//device/asr/asr582x/drivers/ota"
]
deps = [ "$ohos_vendor_adapter_dir/hals/update:hal_update_static" ]
}
@@ -1,196 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved.
* Description: OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_ADAPTER_H
#define HILINK_OPEN_OTA_ADAPTER_H
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* OTA升级分区1 */
#ifndef UPGRADE_FW_BIN1
#define UPGRADE_FW_BIN1 0x00
#endif
/* OTA升级分区2 */
#ifndef UPGRADE_FW_BIN2
#define UPGRADE_FW_BIN2 0x01
#endif
/* 只有MCU升级时立即重启 */
#ifndef RESTART_FLAG_NOW
#define RESTART_FLAG_NOW 0x01
#endif
/* 有模组时切换分区后再重启 */
#ifndef RESTART_FLAG_LATER
#define RESTART_FLAG_LATER 0x02
#endif
/* 模组可以重启 */
#ifndef MODULE_CAN_REBOOT
#define MODULE_CAN_REBOOT 0x01
#endif
/* 模组不能重启 */
#ifndef MODULE_CANNOT_REBOOT
#define MODULE_CANNOT_REBOOT 0x00
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* 返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
typedef void (*GetOtaVerCb)(const char *version);
typedef void (*TrigSelfUpdateCb)(const char *url, const unsigned int size);
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void);
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void);
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是0时,表示擦除成功
* 返回值是-1时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size);
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是0时,表示写入成功
* 返回值是-1时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen);
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是0时,表示读取成功
* 返回值是-1时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen);
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void);
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void);
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag);
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type);
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status);
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void);
/*
* 触发设备的ota新版本检测
* 检测到的版本,sdk将通过cb回调函数上报。如果不需要获取版本号,则可将cb置空。
* 上报的version如果为空,则未成功获取到新版本。
* 注意:1、建议调用频次最多一天一次
* 2、首次通过手机配网成功后不能调用,建议连云成功后至少5s后调用
*/
void HILINK_TrigOtaVersionCheck(GetOtaVerCb cb);
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: MCU OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_MCU_ADAPTER_H
#define HILINK_OPEN_OTA_MCU_ADAPTER_H
#ifdef __cplusplus
extern "C" {
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* MCU返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 开始发送MCU数据 */
#ifndef START_SEND_DATA
#define START_SEND_DATA 0
#endif
/* 发送MCU数据结束 */
#ifndef STOP_SEND_DATA
#define STOP_SEND_DATA 1
#endif
/* 异常终止 */
#ifndef SEND_DATA_ERROR
#define SEND_DATA_ERROR 2
#endif
typedef int (*RptUpgProgressFlagCb)(void);
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen);
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type);
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset);
/*
* 产品OTA升级时下载升级包进度为100%后会重启, APP上显示设备重启中
* 然后等设备起来后上报进度0, APP上才会显示升级成功
* 通过回调函数cb来设置Hilink Sdk被拉起后是否立即向APP上报进度0
* cb返回1时hilink sdk被拉起后不会立即上报进度0,
* 上报时机由产品自己决定,调用hilink_ota_rpt_prg进行上报
* cb返回0时hilink sdk被拉起后会立即上报进度0
* 产品根据自身升级情况判断是否需要注册cb,如不注册则默认hilink sdk被拉起后会立即上报进度0
*/
void HILINK_PowerOnRptUpgProgress(RptUpgProgressFlagCb cb);
#ifdef __cplusplus
}
#endif
#endif /* HILINK_OPEN_OTA_BRIDGE_ADAPTER_H */
@@ -1,211 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
* Description: OTA适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_adapter.h"
#include <stdio.h>
#include <unistd.h>
#include "securec.h"
#define DOWNLOAD_PATITION_ADDR 0x253000 //68+2048+300KB
#define DOWNLOAD_PATITION_LEN 0x187000 //1536KB
static unsigned int write_length = 0;
#define HILINK_OK 0
#define HILINK_ERROR -1
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void)
{
printf("HILINK_OtaAdapterFlashInit start\r\n");
IoTFlashInit();
write_length = 0;
return true;
}
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void)
{
printf("HILINK_OtaAdapterGetUpdateIndex start\r\n");
return UPGRADE_FW_BIN1;
}
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是ILINK_OK时,表示擦除成功
* 返回值是HILINK_ERROR时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size)
{
printf("HILINK_OtaAdapterFlashErase start size=%d\r\n",size);
return IoTFlashErase(DOWNLOAD_PATITION_ADDR,DOWNLOAD_PATITION_LEN);
}
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是HILINK_OK时,表示写入成功
* 返回值是HILINK_ERROR时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashWrite start\r\n");
#if 1
int ret;
if (bufLen == 0)
{
return HILINK_OK;
}
if (buf == NULL)
{
return HILINK_ERROR;
}
ret = IoTFlashWrite(DOWNLOAD_PATITION_ADDR + write_length, bufLen, buf, 0);
write_length += bufLen;
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是HILINK_OK时,表示读取成功
* 返回值是HILINK_ERROR时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashRead start\r\n");
#if 1
int ret;
if ( (buf == NULL) || (bufLen == 0))
{
return HILINK_ERROR;
}
ret = IoTFlashRead(DOWNLOAD_PATITION_ADDR + offset, bufLen, buf);
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void)
{
printf("HILINK_OtaAdapterFlashFinish start\r\n");
IoTFlashDeinit();
return true;
}
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void)
{
printf("HILINK_OtaAdapterFlashMaxSize start\r\n");
return DOWNLOAD_PATITION_LEN;
}
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag)
{
printf("HILINK_OtaAdapterRestart start\r\n");
reboot();
return;
}
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type)
{
printf("HILINK_OtaStartProcess start type =%d\r\n",type);
return RETURN_OK;
}
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status)
{
printf("HILINK_OtaEndProcess start status=%d\r\n",status);
return RETURN_OK;
}
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void)
{
printf("HILINK_GetRebootFlag start\r\n");
return MODULE_CAN_REBOOT;
}
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb)
{
return;
}
@@ -1,63 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: 外挂MCU升级适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_mcu_adapter.h"
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 返回值是RETURN_MCU_NO_NEED_OTA时,表示不需要MCU升级
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
@@ -1,31 +0,0 @@
#import("//applications/iot_solution/device.gni")
oem_common_deps = [
# "//build/lite/config/component/cJSON:cjson_shared",
# "//third_party/mbedtls:mbedtls_shared",
]
config("oem_common_config") {
include_dirs = [
"include",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON/",
"//third_party/mbedtls/include",
"//kernel/liteos_m/components/bounds_checking_function/include",
"//utils/native/lite/include",
# "//device/asr/asr582x/drivers/kv/include/",
]
defines = []
}
static_library("oem_auth_result_storage") {
sources = [ "src/oem_auth_result_storage.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
static_library("oem_auth_config") {
sources = [ "src/oem_auth_config.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
@@ -1,135 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: interface file for kitframework client
* Author: yangzuxun
* Create: 2020-07-20
*/
#ifndef HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#define HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#include <stdint.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
// request auth result
#define ERR_OK 0
#define SERVICE_UNAVAILABLE (-1)
#define INVALID_PARAM (-2)
#define PASS 0
#define FAIL (-1)
#define UNKNOWN (-2)
// define authentication control policy
#define POLICY_ALERT (0x1 << 0) // 警告,kit自行决定
#define POLICY_DENY (0x1 << 1) // 拒绝
#define POLICY_PASS (0x1 << 2) // 放通
#define POLICY_INVISBLE (0x1 << 3) // 设备不可见
// kit id
#define DV_KIT "DvKit"
#define CAST_KIT "CastKit"
#define HI_LINK "HiLinkKit"
#define HI_CAR "HiCarKit"
#define SHARE "ShareKit"
#define MEET_TIME "MeetTimeKit"
#define ONE_HOP "OneHopKit"
#define ONE_TAG "OneTagKit"
// CheckModuleValid return value
#define RET_OK 1
#define RET_FALSE 0
#define RET_INVALID (-1)
typedef enum {
TYPE_AA, // hap or static form
TYPE_DEBUG, // debug version
TYPE_BDREPORT, // big data report module
TYPE_D2D, // D2D module
TYPE_D2C, // D2C module
} CheckType;
typedef struct AuthStatus AuthStatus;
typedef void (*IAuthResultCallback)(const AuthStatus* status);
/**
* @brief The function is used to initial the authtication client and connect to the
* kit server, and return the connect status. The function must be called before
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t CreateKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to trigger device auth, and return the auth result.
* The caller can only call the function without calling CreateKitFrameworkClient(const char* kitId) before.
* @param networkId: the name defined in soft-bus, NULL for local device.
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @param callback: the Auth check result callback.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback);
/**
* @brief The function is used to close the connection of kit server and release the client.
* The function must be called after
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
*/
void CloseKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to check the type whether exists or not
* @param type: the check module type.
* @return error_code: RET_OK or RET_FALSE or RET_INVALID
*/
int32_t CheckModuleValid(CheckType type);
/**
* @brief The function is used to get device auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of device.
*/
int32_t GetDeviceStatus(const AuthStatus* status);
/**
* @brief The function is used to get system auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of system.
*/
int32_t GetSystemStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of kit.
*/
int32_t GetKitStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth policy;
* @param[in] status: The auth status of kit.
* @return The auth policy of kit.
*/
int32_t GetAuthPolicy(const AuthStatus* status);
/**
* @brief The function is used to get ticket;
* @param[in] status: The auth status of kit.
* @return NULL or ticket , max size is 256.
*/
const char* GetTicket(const AuthStatus* status);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif
@@ -1,41 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_CONFIG_H
#define HOS_LITE_OEM_AUTH_CONFIG_H
#include <stdint.h>
#include <stdlib.h>
#include "mbedtls/x509_crt.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief read authentication's server info from device which implemented by OEM.
* format: server1:port1;server2:port2; ...
* @param port: pointer of server info's buffer.
* @param len: length of server info's buffer, max value is 256.
* The max length for signal NV srtuct is 252 Bytes, so please be careful if the server info is save as NV.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthServerInfo(char* buff, uint32_t len);
/**
* @brief load kit's id and verison information from device which implemented by OEM.
* @return char* not NULL means load succeed, NULL is means OEM haven't set kit infos or no others kit to authenticate
* example : NULL means no others kit
* "{\"KitInfos\":[]}" means no others kit
* "{\"KitInfos\":[{\"HiLinkKit\":\"1.0.0\"},{\"DvKit\":\"1.0.1\"}]}" means with HiLink and DvKit
*/
char* OEMLoadKitInfos(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_CONFIG_H */
@@ -1,114 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#define HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief check whether the temperature of the device's flash chip is over limit or not.
* @return true is over limit.
*/
bool OEMIsOverTemperatureLimit(void);
/**
* @brief check reset flag is exist or not which implemented by OEM.
* @return true is reset flag existed, false is not.
*/
bool OEMIsResetFlagExist(void);
/**
* @brief create reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMCreateResetFlag(void);
/**
* @brief delete reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMDeleteResetFlag(void);
/**
* @brief check auth status file is exist or not which implemented by OEM.
* @return true is auth status file existed, false is not.
*/
bool OEMIsAuthStatusExist(void);
/**
* @brief write auth status to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteAuthStatus(const char* data, uint32_t len);
/**
* @brief read auth status from device which implemented by OEM.
* @param buffer: pointer of auth status's buffer.
* @param bufferLen: length of auth status's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen);
/**
* @brief delete auth status file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteAuthStatus(void);
/**
* @brief get auth status's content size from device which implemented by OEM.
* @param len: pointer of auth status's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetAuthStatusFileSize(uint32_t* len);
/**
* @brief check ticket file is exist or not which implemented by OEM.
* @return true is ticket file existed, false is not.
*/
bool OEMIsTicketExist(void);
/**
* @brief write ticket to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteTicket(const char* data, uint32_t len);
/**
* @brief read ticket from device which implemented by OEM.
* @param buffer: pointer of ticket's buffer.
* @param bufferLen: length of ticket's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen);
/**
* @brief delete ticket file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteTicket(void);
/**
* @brief get ticket's content size from device which implemented by OEM.
* @param len: pointer of ticket's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetTicketFileSize(uint32_t* len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_RESULT_STORAGE_H */
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_config.h"
#include <stdio.h>
#include <stdlib.h>
#include "securec.h"
#include "cJSON.h"
#define HCS_HILINKKIT
#define KIT_ID_LEN 40
typedef const char *(*KitGetVerFunc)();
typedef struct KitGetVerInfo
{
char kitId[KIT_ID_LEN + 1];
KitGetVerFunc kitGetVerFunc;
} KitGetVerInfo;
#ifdef HCS_DVKIT
extern const char *DvKit_GetVersion();
#endif
#ifdef HCS_HILINKKIT
// extern const char* HiLinkKit_GetVersion();
const char *HiLinkKit_GetVersion()
{
return "1.0.0";
}
#endif
KitGetVerInfo g_kitGetVerInfo[] = {
#ifdef HCS_DVKIT
{"DvKit", DvKit_GetVersion},
#endif
#ifdef HCS_HILINKKIT
{"HiLinkKit", HiLinkKit_GetVersion},
#endif
{0, NULL}};
#define TOTAL_TIMEOUT 10000
#define KIT_INFO_JSON_KEY "KitInfos"
uint32_t OEMGetTotalTimeout()
{
return TOTAL_TIMEOUT;
}
int32_t OEMReadAuthServerInfo(char *buff, uint32_t len)
{
if (buff == NULL || len == 0)
{
return -1;
}
return -1;
}
char *OEMLoadKitInfos(void)
{
cJSON *root = cJSON_CreateObject();
if (root == NULL)
{
return NULL;
}
cJSON *infos = cJSON_CreateArray();
if (infos == NULL)
{
cJSON_Delete(root);
return NULL;
}
const uint32_t kitCount = sizeof(g_kitGetVerInfo) / sizeof(KitGetVerInfo);
for (uint32_t i = 0; i < kitCount; i++)
{
cJSON *obj = cJSON_CreateObject();
if (obj == NULL)
{
printf("OEM Adapter: Create json object failed\n");
continue;
}
const char *key = g_kitGetVerInfo[i].kitId;
KitGetVerFunc kitGetVerFunc = g_kitGetVerInfo[i].kitGetVerFunc;
if (key == NULL || strlen(key) == 0 || kitGetVerFunc == NULL)
{
cJSON_Delete(obj);
continue;
}
const char *value = (kitGetVerFunc)();
if (value == NULL || strlen(value) == 0 || cJSON_AddStringToObject(obj, key, value) == NULL)
{
printf("OEM Adapter: Add kit info %s to json object failed\n", key);
cJSON_Delete(obj);
continue;
}
if (!cJSON_AddItemToArray(infos, obj))
{
cJSON_Delete(obj);
printf("OEM Adapter: Add kit info %s to json array failed\n", key);
}
}
if (!cJSON_AddItemToObject(root, KIT_INFO_JSON_KEY, infos))
{
printf("OEM Adapter: Add kit infos to json object failed\n");
cJSON_Delete(infos);
cJSON_Delete(root);
return NULL;
}
char *result = cJSON_PrintUnformatted(root);
cJSON_Delete(root);
return result;
}
@@ -1,223 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_result_storage.h"
#include <stdio.h>
#include "securec.h"
#include "utils_file.h"
#define RESET_FILE_NAME "auth_reset"
#define TICKET_FILE_NAME "auth_ticket"
#define AUTH_STATS_FILE_NAME "auth_authstats"
#define WRITE_FLASH_MAX_TEMPERATURE 80
static const uint32_t MAX_FILE_BYTES_LIMIT = 5120;
bool OEMIsOverTemperatureLimit(void)//???¨¨?D?¦Ì?D??
{
return false;
}
static bool IsFileExist(const char* path)
{
printf("IsFileExist start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
return false;
}
(void)UtilsFileClose(fd);
return true;
}
static int32_t CreateFile(const char* path)
{
printf("CreateFile start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_CREAT_FS, 0);
if(fd < 0)
{
return -1;
}
(void)UtilsFileClose(fd);
return 0;
}
static int32_t WriteFile(const char* path,const char* data,uint32_t datalen,int flag)
{
printf("WriteFile start path=%s\r\n",path);
if(path == NULL || data == NULL || datalen == 0)
{
printf("WriteFile data invalid\r\n");
return -1;
}
if(datalen > MAX_FILE_BYTES_LIMIT)
{
printf("WriteFile data over limit\r\n");
return -1;
}
if(OEMIsOverTemperatureLimit())
{
return -1;
}
int32_t fd = UtilsFileOpen(path, flag, 0);
if(fd < 0)
{
printf("WriteFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileWrite(fd, data, datalen) != datalen)
{
printf("WriteFile write failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t ReadFile(const char* path,const char* buffer,uint32_t bufferlen)
{
printf("ReadFile start path=%s\r\n",path);
if(path == NULL || buffer == NULL || bufferlen == 0)
{
printf("ReadFile data invalid\r\n");
return -1;
}
if(!IsFileExist(path))
{
printf("ReadFile file not exsit\r\n");
return -1;
}
int32_t filesize = 0;
if(UtilsFileStat(path,&filesize) != 0)
{
printf("ReadFile stat file failed\r\n");
return -1;
}
if(filesize > bufferlen)
{
printf("ReadFile read data over buffer lenth\r\n");
return -1;
}
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
printf("ReadFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileRead(fd, buffer, filesize) != filesize)
{
printf("ReadFile read data failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t DeleteFile(const char* path)
{
UtilsFileDelete(path);
}
bool OEMIsResetFlagExist(void)
{
return IsFileExist(RESET_FILE_NAME);
}
int32_t OEMCreateResetFlag(void)
{
return CreateFile(RESET_FILE_NAME);
}
int32_t OEMDeleteResetFlag(void)
{
return DeleteFile(RESET_FILE_NAME);
}
bool OEMIsAuthStatusExist(void)
{
return IsFileExist(AUTH_STATS_FILE_NAME);
}
int32_t OEMWriteAuthStatus(const char* data, uint32_t len)
{
if(data == NULL || len == 0)
return -1;
return WriteFile(AUTH_STATS_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen)
{
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(AUTH_STATS_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteAuthStatus(void)
{
return DeleteFile(AUTH_STATS_FILE_NAME);
}
int32_t OEMGetAuthStatusFileSize(uint32_t* len)
{
printf("OEMGetAuthStatusFileSize len=%p\r\n",len);
if(len == NULL)
return -1;
return UtilsFileStat(AUTH_STATS_FILE_NAME,len);
}
bool OEMIsTicketExist(void)
{
return IsFileExist(TICKET_FILE_NAME);
}
int32_t OEMWriteTicket(const char* data, uint32_t len)
{
printf("OEMWriteTicket data=%s -- len=%d\r\n",data,len);
if(data == NULL || len == 0)
return -1;
return WriteFile(TICKET_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen)
{
printf("OEMReadTicket buffer=%s -- bufferLen=%d\r\n",buffer,bufferLen);
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(TICKET_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteTicket(void)
{
return DeleteFile(TICKET_FILE_NAME);
}
int32_t OEMGetTicketFileSize(uint32_t* len)
{
return UtilsFileStat(TICKET_FILE_NAME,len);
}
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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 = [
@@ -1,3 +1,16 @@
// Copyright (C) 2022 BEKEN .
// 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"
+3 -2
View File
@@ -1,15 +1,16 @@
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Copyright (C) 2022 BEKEN .
# 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
# 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.
import("${board_adapter_dir}/hals/sdk_dir.gni")
static_library("hal_token_static") {
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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 "bk_cli.h"
#include "ohos_errno.h"
+13
View File
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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.
group("test_xts_part2") {
deps = [
@@ -1,10 +0,0 @@
harmonyos_connect_package_path = "//vendor/huawei/harmonyos_connect"
if (ohos_kernel_type == "liteos_m") {
ohos_type = "mini"
} else if (ohos_kernel_type == "liteos_a") {
ohos_type = "small"
} else if (ohos_kernel_type == "linux") {
ohos_type = "standard"
}
@@ -1,17 +0,0 @@
import("//build/lite/config/component/lite_component.gni")
import("//applications/iot_solution/device.gni")
static_library("ota_update_adapter") {
sources = [
"src/hilink_open_ota_adapter.c",
"src/hilink_open_ota_mcu_adapter.c",
]
include_dirs = [
"include",
# "//device/asr/asr582x/drivers/ota"
]
deps = [ "$ohos_vendor_adapter_dir/hals/update:hal_update_static" ]
}
@@ -1,196 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved.
* Description: OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_ADAPTER_H
#define HILINK_OPEN_OTA_ADAPTER_H
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* OTA升级分区1 */
#ifndef UPGRADE_FW_BIN1
#define UPGRADE_FW_BIN1 0x00
#endif
/* OTA升级分区2 */
#ifndef UPGRADE_FW_BIN2
#define UPGRADE_FW_BIN2 0x01
#endif
/* 只有MCU升级时立即重启 */
#ifndef RESTART_FLAG_NOW
#define RESTART_FLAG_NOW 0x01
#endif
/* 有模组时切换分区后再重启 */
#ifndef RESTART_FLAG_LATER
#define RESTART_FLAG_LATER 0x02
#endif
/* 模组可以重启 */
#ifndef MODULE_CAN_REBOOT
#define MODULE_CAN_REBOOT 0x01
#endif
/* 模组不能重启 */
#ifndef MODULE_CANNOT_REBOOT
#define MODULE_CANNOT_REBOOT 0x00
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* 返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
typedef void (*GetOtaVerCb)(const char *version);
typedef void (*TrigSelfUpdateCb)(const char *url, const unsigned int size);
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void);
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void);
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是0时,表示擦除成功
* 返回值是-1时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size);
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是0时,表示写入成功
* 返回值是-1时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen);
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是0时,表示读取成功
* 返回值是-1时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen);
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void);
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void);
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag);
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type);
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status);
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void);
/*
* 触发设备的ota新版本检测
* 检测到的版本,sdk将通过cb回调函数上报。如果不需要获取版本号,则可将cb置空。
* 上报的version如果为空,则未成功获取到新版本。
* 注意:1、建议调用频次最多一天一次
* 2、首次通过手机配网成功后不能调用,建议连云成功后至少5s后调用
*/
void HILINK_TrigOtaVersionCheck(GetOtaVerCb cb);
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: MCU OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_MCU_ADAPTER_H
#define HILINK_OPEN_OTA_MCU_ADAPTER_H
#ifdef __cplusplus
extern "C" {
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* MCU返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 开始发送MCU数据 */
#ifndef START_SEND_DATA
#define START_SEND_DATA 0
#endif
/* 发送MCU数据结束 */
#ifndef STOP_SEND_DATA
#define STOP_SEND_DATA 1
#endif
/* 异常终止 */
#ifndef SEND_DATA_ERROR
#define SEND_DATA_ERROR 2
#endif
typedef int (*RptUpgProgressFlagCb)(void);
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen);
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type);
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset);
/*
* 产品OTA升级时下载升级包进度为100%后会重启, APP上显示设备重启中
* 然后等设备起来后上报进度0, APP上才会显示升级成功
* 通过回调函数cb来设置Hilink Sdk被拉起后是否立即向APP上报进度0
* cb返回1时hilink sdk被拉起后不会立即上报进度0,
* 上报时机由产品自己决定,调用hilink_ota_rpt_prg进行上报
* cb返回0时hilink sdk被拉起后会立即上报进度0
* 产品根据自身升级情况判断是否需要注册cb,如不注册则默认hilink sdk被拉起后会立即上报进度0
*/
void HILINK_PowerOnRptUpgProgress(RptUpgProgressFlagCb cb);
#ifdef __cplusplus
}
#endif
#endif /* HILINK_OPEN_OTA_BRIDGE_ADAPTER_H */
@@ -1,211 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
* Description: OTA适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_adapter.h"
#include <stdio.h>
#include <unistd.h>
#include "securec.h"
#define DOWNLOAD_PATITION_ADDR 0x253000 //68+2048+300KB
#define DOWNLOAD_PATITION_LEN 0x187000 //1536KB
static unsigned int write_length = 0;
#define HILINK_OK 0
#define HILINK_ERROR -1
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void)
{
printf("HILINK_OtaAdapterFlashInit start\r\n");
IoTFlashInit();
write_length = 0;
return true;
}
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void)
{
printf("HILINK_OtaAdapterGetUpdateIndex start\r\n");
return UPGRADE_FW_BIN1;
}
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是ILINK_OK时,表示擦除成功
* 返回值是HILINK_ERROR时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size)
{
printf("HILINK_OtaAdapterFlashErase start size=%d\r\n",size);
return IoTFlashErase(DOWNLOAD_PATITION_ADDR,DOWNLOAD_PATITION_LEN);
}
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是HILINK_OK时,表示写入成功
* 返回值是HILINK_ERROR时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashWrite start\r\n");
#if 1
int ret;
if (bufLen == 0)
{
return HILINK_OK;
}
if (buf == NULL)
{
return HILINK_ERROR;
}
ret = IoTFlashWrite(DOWNLOAD_PATITION_ADDR + write_length, bufLen, buf, 0);
write_length += bufLen;
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是HILINK_OK时,表示读取成功
* 返回值是HILINK_ERROR时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashRead start\r\n");
#if 1
int ret;
if ( (buf == NULL) || (bufLen == 0))
{
return HILINK_ERROR;
}
ret = IoTFlashRead(DOWNLOAD_PATITION_ADDR + offset, bufLen, buf);
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void)
{
printf("HILINK_OtaAdapterFlashFinish start\r\n");
IoTFlashDeinit();
return true;
}
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void)
{
printf("HILINK_OtaAdapterFlashMaxSize start\r\n");
return DOWNLOAD_PATITION_LEN;
}
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag)
{
printf("HILINK_OtaAdapterRestart start\r\n");
reboot();
return;
}
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type)
{
printf("HILINK_OtaStartProcess start type =%d\r\n",type);
return RETURN_OK;
}
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status)
{
printf("HILINK_OtaEndProcess start status=%d\r\n",status);
return RETURN_OK;
}
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void)
{
printf("HILINK_GetRebootFlag start\r\n");
return MODULE_CAN_REBOOT;
}
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb)
{
return;
}
@@ -1,63 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: 外挂MCU升级适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_mcu_adapter.h"
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 返回值是RETURN_MCU_NO_NEED_OTA时,表示不需要MCU升级
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
@@ -1,31 +0,0 @@
#import("//applications/iot_solution/device.gni")
oem_common_deps = [
# "//build/lite/config/component/cJSON:cjson_shared",
# "//third_party/mbedtls:mbedtls_shared",
]
config("oem_common_config") {
include_dirs = [
"include",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON/",
"//third_party/mbedtls/include",
"//kernel/liteos_m/components/bounds_checking_function/include",
"//utils/native/lite/include",
# "//device/asr/asr582x/drivers/kv/include/",
]
defines = []
}
static_library("oem_auth_result_storage") {
sources = [ "src/oem_auth_result_storage.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
static_library("oem_auth_config") {
sources = [ "src/oem_auth_config.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
@@ -1,135 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: interface file for kitframework client
* Author: yangzuxun
* Create: 2020-07-20
*/
#ifndef HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#define HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#include <stdint.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
// request auth result
#define ERR_OK 0
#define SERVICE_UNAVAILABLE (-1)
#define INVALID_PARAM (-2)
#define PASS 0
#define FAIL (-1)
#define UNKNOWN (-2)
// define authentication control policy
#define POLICY_ALERT (0x1 << 0) // 警告,kit自行决定
#define POLICY_DENY (0x1 << 1) // 拒绝
#define POLICY_PASS (0x1 << 2) // 放通
#define POLICY_INVISBLE (0x1 << 3) // 设备不可见
// kit id
#define DV_KIT "DvKit"
#define CAST_KIT "CastKit"
#define HI_LINK "HiLinkKit"
#define HI_CAR "HiCarKit"
#define SHARE "ShareKit"
#define MEET_TIME "MeetTimeKit"
#define ONE_HOP "OneHopKit"
#define ONE_TAG "OneTagKit"
// CheckModuleValid return value
#define RET_OK 1
#define RET_FALSE 0
#define RET_INVALID (-1)
typedef enum {
TYPE_AA, // hap or static form
TYPE_DEBUG, // debug version
TYPE_BDREPORT, // big data report module
TYPE_D2D, // D2D module
TYPE_D2C, // D2C module
} CheckType;
typedef struct AuthStatus AuthStatus;
typedef void (*IAuthResultCallback)(const AuthStatus* status);
/**
* @brief The function is used to initial the authtication client and connect to the
* kit server, and return the connect status. The function must be called before
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t CreateKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to trigger device auth, and return the auth result.
* The caller can only call the function without calling CreateKitFrameworkClient(const char* kitId) before.
* @param networkId: the name defined in soft-bus, NULL for local device.
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @param callback: the Auth check result callback.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback);
/**
* @brief The function is used to close the connection of kit server and release the client.
* The function must be called after
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
*/
void CloseKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to check the type whether exists or not
* @param type: the check module type.
* @return error_code: RET_OK or RET_FALSE or RET_INVALID
*/
int32_t CheckModuleValid(CheckType type);
/**
* @brief The function is used to get device auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of device.
*/
int32_t GetDeviceStatus(const AuthStatus* status);
/**
* @brief The function is used to get system auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of system.
*/
int32_t GetSystemStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of kit.
*/
int32_t GetKitStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth policy;
* @param[in] status: The auth status of kit.
* @return The auth policy of kit.
*/
int32_t GetAuthPolicy(const AuthStatus* status);
/**
* @brief The function is used to get ticket;
* @param[in] status: The auth status of kit.
* @return NULL or ticket , max size is 256.
*/
const char* GetTicket(const AuthStatus* status);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif
@@ -1,41 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_CONFIG_H
#define HOS_LITE_OEM_AUTH_CONFIG_H
#include <stdint.h>
#include <stdlib.h>
#include "mbedtls/x509_crt.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief read authentication's server info from device which implemented by OEM.
* format: server1:port1;server2:port2; ...
* @param port: pointer of server info's buffer.
* @param len: length of server info's buffer, max value is 256.
* The max length for signal NV srtuct is 252 Bytes, so please be careful if the server info is save as NV.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthServerInfo(char* buff, uint32_t len);
/**
* @brief load kit's id and verison information from device which implemented by OEM.
* @return char* not NULL means load succeed, NULL is means OEM haven't set kit infos or no others kit to authenticate
* example : NULL means no others kit
* "{\"KitInfos\":[]}" means no others kit
* "{\"KitInfos\":[{\"HiLinkKit\":\"1.0.0\"},{\"DvKit\":\"1.0.1\"}]}" means with HiLink and DvKit
*/
char* OEMLoadKitInfos(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_CONFIG_H */
@@ -1,114 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#define HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief check whether the temperature of the device's flash chip is over limit or not.
* @return true is over limit.
*/
bool OEMIsOverTemperatureLimit(void);
/**
* @brief check reset flag is exist or not which implemented by OEM.
* @return true is reset flag existed, false is not.
*/
bool OEMIsResetFlagExist(void);
/**
* @brief create reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMCreateResetFlag(void);
/**
* @brief delete reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMDeleteResetFlag(void);
/**
* @brief check auth status file is exist or not which implemented by OEM.
* @return true is auth status file existed, false is not.
*/
bool OEMIsAuthStatusExist(void);
/**
* @brief write auth status to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteAuthStatus(const char* data, uint32_t len);
/**
* @brief read auth status from device which implemented by OEM.
* @param buffer: pointer of auth status's buffer.
* @param bufferLen: length of auth status's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen);
/**
* @brief delete auth status file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteAuthStatus(void);
/**
* @brief get auth status's content size from device which implemented by OEM.
* @param len: pointer of auth status's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetAuthStatusFileSize(uint32_t* len);
/**
* @brief check ticket file is exist or not which implemented by OEM.
* @return true is ticket file existed, false is not.
*/
bool OEMIsTicketExist(void);
/**
* @brief write ticket to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteTicket(const char* data, uint32_t len);
/**
* @brief read ticket from device which implemented by OEM.
* @param buffer: pointer of ticket's buffer.
* @param bufferLen: length of ticket's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen);
/**
* @brief delete ticket file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteTicket(void);
/**
* @brief get ticket's content size from device which implemented by OEM.
* @param len: pointer of ticket's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetTicketFileSize(uint32_t* len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_RESULT_STORAGE_H */
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_config.h"
#include <stdio.h>
#include <stdlib.h>
#include "securec.h"
#include "cJSON.h"
#define HCS_HILINKKIT
#define KIT_ID_LEN 40
typedef const char *(*KitGetVerFunc)();
typedef struct KitGetVerInfo
{
char kitId[KIT_ID_LEN + 1];
KitGetVerFunc kitGetVerFunc;
} KitGetVerInfo;
#ifdef HCS_DVKIT
extern const char *DvKit_GetVersion();
#endif
#ifdef HCS_HILINKKIT
// extern const char* HiLinkKit_GetVersion();
const char *HiLinkKit_GetVersion()
{
return "1.0.0";
}
#endif
KitGetVerInfo g_kitGetVerInfo[] = {
#ifdef HCS_DVKIT
{"DvKit", DvKit_GetVersion},
#endif
#ifdef HCS_HILINKKIT
{"HiLinkKit", HiLinkKit_GetVersion},
#endif
{0, NULL}};
#define TOTAL_TIMEOUT 10000
#define KIT_INFO_JSON_KEY "KitInfos"
uint32_t OEMGetTotalTimeout()
{
return TOTAL_TIMEOUT;
}
int32_t OEMReadAuthServerInfo(char *buff, uint32_t len)
{
if (buff == NULL || len == 0)
{
return -1;
}
return -1;
}
char *OEMLoadKitInfos(void)
{
cJSON *root = cJSON_CreateObject();
if (root == NULL)
{
return NULL;
}
cJSON *infos = cJSON_CreateArray();
if (infos == NULL)
{
cJSON_Delete(root);
return NULL;
}
const uint32_t kitCount = sizeof(g_kitGetVerInfo) / sizeof(KitGetVerInfo);
for (uint32_t i = 0; i < kitCount; i++)
{
cJSON *obj = cJSON_CreateObject();
if (obj == NULL)
{
printf("OEM Adapter: Create json object failed\n");
continue;
}
const char *key = g_kitGetVerInfo[i].kitId;
KitGetVerFunc kitGetVerFunc = g_kitGetVerInfo[i].kitGetVerFunc;
if (key == NULL || strlen(key) == 0 || kitGetVerFunc == NULL)
{
cJSON_Delete(obj);
continue;
}
const char *value = (kitGetVerFunc)();
if (value == NULL || strlen(value) == 0 || cJSON_AddStringToObject(obj, key, value) == NULL)
{
printf("OEM Adapter: Add kit info %s to json object failed\n", key);
cJSON_Delete(obj);
continue;
}
if (!cJSON_AddItemToArray(infos, obj))
{
cJSON_Delete(obj);
printf("OEM Adapter: Add kit info %s to json array failed\n", key);
}
}
if (!cJSON_AddItemToObject(root, KIT_INFO_JSON_KEY, infos))
{
printf("OEM Adapter: Add kit infos to json object failed\n");
cJSON_Delete(infos);
cJSON_Delete(root);
return NULL;
}
char *result = cJSON_PrintUnformatted(root);
cJSON_Delete(root);
return result;
}
@@ -1,223 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_result_storage.h"
#include <stdio.h>
#include "securec.h"
#include "utils_file.h"
#define RESET_FILE_NAME "auth_reset"
#define TICKET_FILE_NAME "auth_ticket"
#define AUTH_STATS_FILE_NAME "auth_authstats"
#define WRITE_FLASH_MAX_TEMPERATURE 80
static const uint32_t MAX_FILE_BYTES_LIMIT = 5120;
bool OEMIsOverTemperatureLimit(void)//???¨¨?D?¦Ì?D??
{
return false;
}
static bool IsFileExist(const char* path)
{
printf("IsFileExist start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
return false;
}
(void)UtilsFileClose(fd);
return true;
}
static int32_t CreateFile(const char* path)
{
printf("CreateFile start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_CREAT_FS, 0);
if(fd < 0)
{
return -1;
}
(void)UtilsFileClose(fd);
return 0;
}
static int32_t WriteFile(const char* path,const char* data,uint32_t datalen,int flag)
{
printf("WriteFile start path=%s\r\n",path);
if(path == NULL || data == NULL || datalen == 0)
{
printf("WriteFile data invalid\r\n");
return -1;
}
if(datalen > MAX_FILE_BYTES_LIMIT)
{
printf("WriteFile data over limit\r\n");
return -1;
}
if(OEMIsOverTemperatureLimit())
{
return -1;
}
int32_t fd = UtilsFileOpen(path, flag, 0);
if(fd < 0)
{
printf("WriteFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileWrite(fd, data, datalen) != datalen)
{
printf("WriteFile write failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t ReadFile(const char* path,const char* buffer,uint32_t bufferlen)
{
printf("ReadFile start path=%s\r\n",path);
if(path == NULL || buffer == NULL || bufferlen == 0)
{
printf("ReadFile data invalid\r\n");
return -1;
}
if(!IsFileExist(path))
{
printf("ReadFile file not exsit\r\n");
return -1;
}
int32_t filesize = 0;
if(UtilsFileStat(path,&filesize) != 0)
{
printf("ReadFile stat file failed\r\n");
return -1;
}
if(filesize > bufferlen)
{
printf("ReadFile read data over buffer lenth\r\n");
return -1;
}
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
printf("ReadFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileRead(fd, buffer, filesize) != filesize)
{
printf("ReadFile read data failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t DeleteFile(const char* path)
{
UtilsFileDelete(path);
}
bool OEMIsResetFlagExist(void)
{
return IsFileExist(RESET_FILE_NAME);
}
int32_t OEMCreateResetFlag(void)
{
return CreateFile(RESET_FILE_NAME);
}
int32_t OEMDeleteResetFlag(void)
{
return DeleteFile(RESET_FILE_NAME);
}
bool OEMIsAuthStatusExist(void)
{
return IsFileExist(AUTH_STATS_FILE_NAME);
}
int32_t OEMWriteAuthStatus(const char* data, uint32_t len)
{
if(data == NULL || len == 0)
return -1;
return WriteFile(AUTH_STATS_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen)
{
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(AUTH_STATS_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteAuthStatus(void)
{
return DeleteFile(AUTH_STATS_FILE_NAME);
}
int32_t OEMGetAuthStatusFileSize(uint32_t* len)
{
printf("OEMGetAuthStatusFileSize len=%p\r\n",len);
if(len == NULL)
return -1;
return UtilsFileStat(AUTH_STATS_FILE_NAME,len);
}
bool OEMIsTicketExist(void)
{
return IsFileExist(TICKET_FILE_NAME);
}
int32_t OEMWriteTicket(const char* data, uint32_t len)
{
printf("OEMWriteTicket data=%s -- len=%d\r\n",data,len);
if(data == NULL || len == 0)
return -1;
return WriteFile(TICKET_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen)
{
printf("OEMReadTicket buffer=%s -- bufferLen=%d\r\n",buffer,bufferLen);
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(TICKET_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteTicket(void)
{
return DeleteFile(TICKET_FILE_NAME);
}
int32_t OEMGetTicketFileSize(uint32_t* len)
{
return UtilsFileStat(TICKET_FILE_NAME,len);
}
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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 = [
@@ -1,3 +1,15 @@
// Copyright (C) 2022 BEKEN .
// 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"
+3 -2
View File
@@ -1,15 +1,16 @@
# Copyright (c) 2020 Huawei Device Co., Ltd.
# Copyright (C) 2022 BEKEN .
# 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
# 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.
import("${board_adapter_dir}/hals/sdk_dir.gni")
static_library("hal_token_static") {
@@ -1,3 +1,16 @@
// Copyright (C) 2022 BEKEN .
// 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 "bk_cli.h"
#include "ohos_errno.h"
+13
View File
@@ -1,3 +1,16 @@
# Copyright (C) 2022 BEKEN .
# 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.
group("wifi_bk7235") {
deps = [
@@ -1,10 +0,0 @@
harmonyos_connect_package_path = "//vendor/huawei/harmonyos_connect"
if (ohos_kernel_type == "liteos_m") {
ohos_type = "mini"
} else if (ohos_kernel_type == "liteos_a") {
ohos_type = "small"
} else if (ohos_kernel_type == "linux") {
ohos_type = "standard"
}
@@ -1,17 +0,0 @@
import("//build/lite/config/component/lite_component.gni")
import("//applications/iot_solution/device.gni")
static_library("ota_update_adapter") {
sources = [
"src/hilink_open_ota_adapter.c",
"src/hilink_open_ota_mcu_adapter.c",
]
include_dirs = [
"include",
# "//device/asr/asr582x/drivers/ota"
]
deps = [ "$ohos_vendor_adapter_dir/hals/update:hal_update_static" ]
}
@@ -1,196 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved.
* Description: OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_ADAPTER_H
#define HILINK_OPEN_OTA_ADAPTER_H
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* OTA升级分区1 */
#ifndef UPGRADE_FW_BIN1
#define UPGRADE_FW_BIN1 0x00
#endif
/* OTA升级分区2 */
#ifndef UPGRADE_FW_BIN2
#define UPGRADE_FW_BIN2 0x01
#endif
/* 只有MCU升级时立即重启 */
#ifndef RESTART_FLAG_NOW
#define RESTART_FLAG_NOW 0x01
#endif
/* 有模组时切换分区后再重启 */
#ifndef RESTART_FLAG_LATER
#define RESTART_FLAG_LATER 0x02
#endif
/* 模组可以重启 */
#ifndef MODULE_CAN_REBOOT
#define MODULE_CAN_REBOOT 0x01
#endif
/* 模组不能重启 */
#ifndef MODULE_CANNOT_REBOOT
#define MODULE_CANNOT_REBOOT 0x00
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* 返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
typedef void (*GetOtaVerCb)(const char *version);
typedef void (*TrigSelfUpdateCb)(const char *url, const unsigned int size);
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void);
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void);
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是0时,表示擦除成功
* 返回值是-1时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size);
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是0时,表示写入成功
* 返回值是-1时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen);
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是0时,表示读取成功
* 返回值是-1时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen);
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void);
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void);
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag);
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type);
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status);
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void);
/*
* 触发设备的ota新版本检测
* 检测到的版本,sdk将通过cb回调函数上报。如果不需要获取版本号,则可将cb置空。
* 上报的version如果为空,则未成功获取到新版本。
* 注意:1、建议调用频次最多一天一次
* 2、首次通过手机配网成功后不能调用,建议连云成功后至少5s后调用
*/
void HILINK_TrigOtaVersionCheck(GetOtaVerCb cb);
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: MCU OTA适配层接口(需设备厂商实现)
*/
#ifndef HILINK_OPEN_OTA_MCU_ADAPTER_H
#define HILINK_OPEN_OTA_MCU_ADAPTER_H
#ifdef __cplusplus
extern "C" {
#endif
/* 返回正常 */
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
/* 没有MCU */
#ifndef RETURN_ERROR_NO_MCU
#define RETURN_ERROR_NO_MCU (-1)
#endif
/* MCU返回其他错误 */
#ifndef RETURN_ERROR
#define RETURN_ERROR (-2)
#endif
/* MCU不需要升级 */
#ifndef RETURN_MCU_NO_NEED_OTA
#define RETURN_MCU_NO_NEED_OTA (-3)
#endif
/* 手动升级 */
#ifndef UPDATE_TYPE_MANUAL
#define UPDATE_TYPE_MANUAL 0x00
#endif
/* 自动升级 */
#ifndef UPDATE_TYPE_AUTO
#define UPDATE_TYPE_AUTO 0x01
#endif
/* 开始发送MCU数据 */
#ifndef START_SEND_DATA
#define START_SEND_DATA 0
#endif
/* 发送MCU数据结束 */
#ifndef STOP_SEND_DATA
#define STOP_SEND_DATA 1
#endif
/* 异常终止 */
#ifndef SEND_DATA_ERROR
#define SEND_DATA_ERROR 2
#endif
typedef int (*RptUpgProgressFlagCb)(void);
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen);
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type);
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset);
/*
* 产品OTA升级时下载升级包进度为100%后会重启, APP上显示设备重启中
* 然后等设备起来后上报进度0, APP上才会显示升级成功
* 通过回调函数cb来设置Hilink Sdk被拉起后是否立即向APP上报进度0
* cb返回1时hilink sdk被拉起后不会立即上报进度0,
* 上报时机由产品自己决定,调用hilink_ota_rpt_prg进行上报
* cb返回0时hilink sdk被拉起后会立即上报进度0
* 产品根据自身升级情况判断是否需要注册cb,如不注册则默认hilink sdk被拉起后会立即上报进度0
*/
void HILINK_PowerOnRptUpgProgress(RptUpgProgressFlagCb cb);
#ifdef __cplusplus
}
#endif
#endif /* HILINK_OPEN_OTA_BRIDGE_ADAPTER_H */
@@ -1,211 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
* Description: OTA适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_adapter.h"
#include <stdio.h>
#include <unistd.h>
#include "securec.h"
#define DOWNLOAD_PATITION_ADDR 0x253000 //68+2048+300KB
#define DOWNLOAD_PATITION_LEN 0x187000 //1536KB
static unsigned int write_length = 0;
#define HILINK_OK 0
#define HILINK_ERROR -1
/*
* Flash初始化
* 返回值是true时,表示初始化正常
* 返回值是false时,表示初始化异常
*/
bool HILINK_OtaAdapterFlashInit(void)
{
printf("HILINK_OtaAdapterFlashInit start\r\n");
IoTFlashInit();
write_length = 0;
return true;
}
/*
* 判断需要升级的分区
* 返回值是UPGRADE_FW_BIN1时,表示升级固件到分区1
* 返回值是UPGRADE_FW_BIN2时,表示升级固件到分区2
*/
unsigned int HILINK_OtaAdapterGetUpdateIndex(void)
{
printf("HILINK_OtaAdapterGetUpdateIndex start\r\n");
return UPGRADE_FW_BIN1;
}
/*
* 擦除需要升级的分区
* size表示需要擦除的分区大小
* 返回值是ILINK_OK时,表示擦除成功
* 返回值是HILINK_ERROR时,表示擦除失败
*/
int HILINK_OtaAdapterFlashErase(unsigned int size)
{
printf("HILINK_OtaAdapterFlashErase start size=%d\r\n",size);
return IoTFlashErase(DOWNLOAD_PATITION_ADDR,DOWNLOAD_PATITION_LEN);
}
/*
* 升级数据写入升级的分区
* buf表示待写入数据
* bufLen表示待写入数据的长度
* 返回值是HILINK_OK时,表示写入成功
* 返回值是HILINK_ERROR时,表示写入失败
*/
int HILINK_OtaAdapterFlashWrite(const unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashWrite start\r\n");
#if 1
int ret;
if (bufLen == 0)
{
return HILINK_OK;
}
if (buf == NULL)
{
return HILINK_ERROR;
}
ret = IoTFlashWrite(DOWNLOAD_PATITION_ADDR + write_length, bufLen, buf, 0);
write_length += bufLen;
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 读取升级分区数据
* offset表示读写偏移
* buf表示输出数据的内存地址
* bufLen表示输出数据的内存长度
* 返回值是HILINK_OK时,表示读取成功
* 返回值是HILINK_ERROR时,表示读取失败
*/
int HILINK_OtaAdapterFlashRead(unsigned int offset, unsigned char *buf, unsigned int bufLen)
{
//printf("HILINK_OtaAdapterFlashRead start\r\n");
#if 1
int ret;
if ( (buf == NULL) || (bufLen == 0))
{
return HILINK_ERROR;
}
ret = IoTFlashRead(DOWNLOAD_PATITION_ADDR + offset, bufLen, buf);
if(ret == 0)
return HILINK_OK;
else
return HILINK_ERROR;
#else
return HILINK_OK;
#endif
}
/*
* 分区升级结束
* 返回值是true时,表示结束正常
* 返回值是false时,表示结束异常
*/
bool HILINK_OtaAdapterFlashFinish(void)
{
printf("HILINK_OtaAdapterFlashFinish start\r\n");
IoTFlashDeinit();
return true;
}
/* 获取升级区间最大长度 */
unsigned int HILINK_OtaAdapterFlashMaxSize(void)
{
printf("HILINK_OtaAdapterFlashMaxSize start\r\n");
return DOWNLOAD_PATITION_LEN;
}
/*
* 根据标志重启模组
* flag表示重启标志
* 当flag是RESTART_FLAG_NOW时,表示只有MCU升级时立即重启
* 当flag是RESTART_FLAG_LATER时,表示有模组时切换分区后再重启
*/
void HILINK_OtaAdapterRestart(int flag)
{
printf("HILINK_OtaAdapterRestart start\r\n");
reboot();
return;
}
/*
* 开始模组升级
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将开始启动升级流程
* 返回值是RETURN_ERROR时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:在手动场景场景下,HiLink SDK在接收到用户发出的升级指令后,将直接调用此接口;
* 在自动升级场景下,当HiLink SDK在调用HilinkGetRebootFlag接口返回值是MODULE_CAN_REBOOT时,HiLink SDK将调用此接口。
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_OtaStartProcess(int type)
{
printf("HILINK_OtaStartProcess start type =%d\r\n",type);
return RETURN_OK;
}
/*
* 模组升级结束
* status表示升级结果
* 当status是100时,表示升级成功
* 当status不是100时,表示升级失败
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK将置升级标志或切换运行区标志
* 返回值不是RETURN_OK时,表示处理不成功,HiLink SDK将终止本次升级流程
* 注意:HiLink SDK在将固件写入到OTA升级区后,且完整性校验通过后,将调用厂商适配的此接口;
* 厂商可在此接口中完成和升级流程相关的处理。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等;升级类型是否为自动升级可参考接口HilinkOtaStartProcess的参数type的描述。
*/
int HILINK_OtaEndProcess(int status)
{
printf("HILINK_OtaEndProcess start status=%d\r\n",status);
return RETURN_OK;
}
/*
* 判断模组是否能立即升级并重启
* 返回值是MODULE_CAN_REBOOT时,表示模组可以立即升级并重启,HiLink SDK将开始自动升级流程。
* 返回值是MODULE_CANNOT_REBOOT时,表示模组不能立即升级并重启,HiLink SDK将不进行本次自动升级流程。
* 注意:在用户同意设备可以自动升级的情况下,HiLink SDK调用此接口获取设备当前业务状态下,模组是否可以立即升级并重启的标志。
* 只有当设备处于业务空闲状态时,接口才可以返回MODULE_CAN_REBOOT。
* 当设备处于业务非空闲状态时,接口返回MODULE_CANNOT_REBOOT。
*/
int HILINK_GetRebootFlag(void)
{
printf("HILINK_GetRebootFlag start\r\n");
return MODULE_CAN_REBOOT;
}
/*
* 触发设备的ota新版本升级
* 检测到的版本,sdk将通过cb回调函数触发升级
*/
void HILINK_TrigOtaSelfUpdate(TrigSelfUpdateCb cb)
{
return;
}
@@ -1,63 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: 外挂MCU升级适配实现 (需设备厂商实现)
*/
#include "hilink_open_ota_mcu_adapter.h"
/*
* 获取MCU当前版本
* version表示版本字符串
* inLen表示输入字符串长度
* outLen表示输出字符串长度
* 返回值是RETURN_OK时,表示获取成功
* 返回值是RETURN_ERROR_NO_MCU时,表示没有MCU
* 返回值是RETURN_ERROR时,表示获取失败
* 返回值是RETURN_MCU_NO_NEED_OTA时,表示不需要MCU升级
* 注意:如果获取不到MCU的版本,则不对MCU进行升级。
* 建议厂商在MCU正常启动后,或升级启动后,就将MCU的版本号传递给模组,确保模组可以获取到MCU的版本。
*/
int HILINK_GetMcuVersion(char *version, unsigned int inLen, unsigned int *outLen)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知MCU固件传输的状态
* flag表示升级流程标志
* 当flag是START_SEND_DATA时,表示通知模组即将开始发送MCU固件数据包
* 当flag是STOP_SEND_DATA时,表示通知模组完整的MCU固件包已发送完成
* 当flag是SEND_DATA_ERROR时,表示通知模组本次MCU固件升级异常终止
* len表示MCU固件包的大小
* type表示升级类型
* 当type是UPDATE_TYPE_MANUAL时,表示本次升级流程是由用户主动发起的手动升级
* 当type是UPDATE_TYPE_AUTO时,表示本次升级流程是经过用户同意的自动升级
* 返回值是RETURN_OK时,表示处理成功,HiLink SDK继续正常处理后续流程
* 返回值是RETURN_ERROR时,表示处理失败,HiLink SDK将终止本次MCU升级流程
* 注意:当flag是STOP_SEND_DATA时,此接口需返回MCU侧固件升级的结果;当flag是其它值时,需返回接口接收到此消息后的处理结果。
* 开机后10分钟到1小时内随机时间检测一次是否有新版本,之后以当前时间为起点,23小时加1小时内随机值周期性检测新版本。
* 如果用户打开了自动升级开关,检测到有新版本并且是可以重启的情况下,就进行新版本的下载,下载完成后自动重启。
* 自动升级流程可能在凌晨进行,因此厂商在实现升级流程相关功能时,确保在升级的下载安装固件和重启设备时避免对用户产生
* 影响,比如发出声音,光亮等。
*/
int HILINK_NotifyOtaStatus(int flag, unsigned int len, unsigned int type)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
/*
* HiLink SDK调用厂商适配的此接口通知厂商发送MCU固件文件数据
* data表示发送的数据
* len表示发送的数据的长度
* offset表示发送的数据起始位置相对于完整固件包的偏移量
* 此接口需要返回MCU接收这部分数据的处理结果
* 返回值是RETURN_OK时,模组将通知的数据正确发送给MCU,且MCU正确处理发送的数据,HiLink SDK将继续正常处理后续流程
* 返回值是RETURN_ERROR时,模组或MCU未能正常处理通知的MCU的固件文件数据,HiLink SDK将终止本次MCU固件升级流程
*/
int HILINK_NotifyOtaData(const unsigned char *data, unsigned int len, unsigned int offset)
{
/* 厂商实现此接口 */
return RETURN_OK;
}
@@ -1,31 +0,0 @@
#import("//applications/iot_solution/device.gni")
oem_common_deps = [
# "//build/lite/config/component/cJSON:cjson_shared",
# "//third_party/mbedtls:mbedtls_shared",
]
config("oem_common_config") {
include_dirs = [
"include",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON/",
"//third_party/mbedtls/include",
"//kernel/liteos_m/components/bounds_checking_function/include",
"//utils/native/lite/include",
# "//device/asr/asr582x/drivers/kv/include/",
]
defines = []
}
static_library("oem_auth_result_storage") {
sources = [ "src/oem_auth_result_storage.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
static_library("oem_auth_config") {
sources = [ "src/oem_auth_config.c" ]
configs += [ ":oem_common_config" ]
deps = oem_common_deps
}
@@ -1,135 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: interface file for kitframework client
* Author: yangzuxun
* Create: 2020-07-20
*/
#ifndef HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#define HOS_LITE_KIT_FRAMEWORK_CLIENT_H
#include <stdint.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
// request auth result
#define ERR_OK 0
#define SERVICE_UNAVAILABLE (-1)
#define INVALID_PARAM (-2)
#define PASS 0
#define FAIL (-1)
#define UNKNOWN (-2)
// define authentication control policy
#define POLICY_ALERT (0x1 << 0) // 警告,kit自行决定
#define POLICY_DENY (0x1 << 1) // 拒绝
#define POLICY_PASS (0x1 << 2) // 放通
#define POLICY_INVISBLE (0x1 << 3) // 设备不可见
// kit id
#define DV_KIT "DvKit"
#define CAST_KIT "CastKit"
#define HI_LINK "HiLinkKit"
#define HI_CAR "HiCarKit"
#define SHARE "ShareKit"
#define MEET_TIME "MeetTimeKit"
#define ONE_HOP "OneHopKit"
#define ONE_TAG "OneTagKit"
// CheckModuleValid return value
#define RET_OK 1
#define RET_FALSE 0
#define RET_INVALID (-1)
typedef enum {
TYPE_AA, // hap or static form
TYPE_DEBUG, // debug version
TYPE_BDREPORT, // big data report module
TYPE_D2D, // D2D module
TYPE_D2C, // D2C module
} CheckType;
typedef struct AuthStatus AuthStatus;
typedef void (*IAuthResultCallback)(const AuthStatus* status);
/**
* @brief The function is used to initial the authtication client and connect to the
* kit server, and return the connect status. The function must be called before
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t CreateKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to trigger device auth, and return the auth result.
* The caller can only call the function without calling CreateKitFrameworkClient(const char* kitId) before.
* @param networkId: the name defined in soft-bus, NULL for local device.
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
* @param callback: the Auth check result callback.
* @return error_code: REQ_OK or SERVICE_UNAVAILABLE or INVALID_PARAM
*/
int32_t RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback);
/**
* @brief The function is used to close the connection of kit server and release the client.
* The function must be called after
* RequestAuth(const char* networkId, const char* kitId, IAuthResultCallback callback).
* @param kitId: the Kit identity(package name) which describe the kits to be checked.
*/
void CloseKitFrameworkClient(const char* kitId);
/**
* @brief The function is used to check the type whether exists or not
* @param type: the check module type.
* @return error_code: RET_OK or RET_FALSE or RET_INVALID
*/
int32_t CheckModuleValid(CheckType type);
/**
* @brief The function is used to get device auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of device.
*/
int32_t GetDeviceStatus(const AuthStatus* status);
/**
* @brief The function is used to get system auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of system.
*/
int32_t GetSystemStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth status;
* @param[in] status: The auth status of kit.
* @return The auth status of kit.
*/
int32_t GetKitStatus(const AuthStatus* status);
/**
* @brief The function is used to get kit auth policy;
* @param[in] status: The auth status of kit.
* @return The auth policy of kit.
*/
int32_t GetAuthPolicy(const AuthStatus* status);
/**
* @brief The function is used to get ticket;
* @param[in] status: The auth status of kit.
* @return NULL or ticket , max size is 256.
*/
const char* GetTicket(const AuthStatus* status);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
#endif
@@ -1,41 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_CONFIG_H
#define HOS_LITE_OEM_AUTH_CONFIG_H
#include <stdint.h>
#include <stdlib.h>
#include "mbedtls/x509_crt.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief read authentication's server info from device which implemented by OEM.
* format: server1:port1;server2:port2; ...
* @param port: pointer of server info's buffer.
* @param len: length of server info's buffer, max value is 256.
* The max length for signal NV srtuct is 252 Bytes, so please be careful if the server info is save as NV.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthServerInfo(char* buff, uint32_t len);
/**
* @brief load kit's id and verison information from device which implemented by OEM.
* @return char* not NULL means load succeed, NULL is means OEM haven't set kit infos or no others kit to authenticate
* example : NULL means no others kit
* "{\"KitInfos\":[]}" means no others kit
* "{\"KitInfos\":[{\"HiLinkKit\":\"1.0.0\"},{\"DvKit\":\"1.0.1\"}]}" means with HiLink and DvKit
*/
char* OEMLoadKitInfos(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_CONFIG_H */
@@ -1,114 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: headfile of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#ifndef HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#define HOS_LITE_OEM_AUTH_RESULT_STORAGE_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief check whether the temperature of the device's flash chip is over limit or not.
* @return true is over limit.
*/
bool OEMIsOverTemperatureLimit(void);
/**
* @brief check reset flag is exist or not which implemented by OEM.
* @return true is reset flag existed, false is not.
*/
bool OEMIsResetFlagExist(void);
/**
* @brief create reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMCreateResetFlag(void);
/**
* @brief delete reset flag in device which implemented by OEM.
* @return 0 is create succeed, others is failed.
*/
int32_t OEMDeleteResetFlag(void);
/**
* @brief check auth status file is exist or not which implemented by OEM.
* @return true is auth status file existed, false is not.
*/
bool OEMIsAuthStatusExist(void);
/**
* @brief write auth status to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteAuthStatus(const char* data, uint32_t len);
/**
* @brief read auth status from device which implemented by OEM.
* @param buffer: pointer of auth status's buffer.
* @param bufferLen: length of auth status's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen);
/**
* @brief delete auth status file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteAuthStatus(void);
/**
* @brief get auth status's content size from device which implemented by OEM.
* @param len: pointer of auth status's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetAuthStatusFileSize(uint32_t* len);
/**
* @brief check ticket file is exist or not which implemented by OEM.
* @return true is ticket file existed, false is not.
*/
bool OEMIsTicketExist(void);
/**
* @brief write ticket to device which implemented by OEM.
* @param data: pointer of data which to be written.
* @param len: length of data which to be written.
* @return 0 is written succeed, others is failed.
*/
int32_t OEMWriteTicket(const char* data, uint32_t len);
/**
* @brief read ticket from device which implemented by OEM.
* @param buffer: pointer of ticket's buffer.
* @param bufferLen: length of ticket's buffer.
* @return 0 is read succeed, others is failed.
*/
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen);
/**
* @brief delete ticket file from device which implemented by OEM.
* @return 0 is delete succeed, others is failed.
*/
int32_t OEMDeleteTicket(void);
/**
* @brief get ticket's content size from device which implemented by OEM.
* @param len: pointer of ticket's content size.
* @return 0 is succeed, others is failed.
*/
int32_t OEMGetTicketFileSize(uint32_t* len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HOS_LITE_OEM_AUTH_RESULT_STORAGE_H */
@@ -1,117 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_config
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_config.h"
#include <stdio.h>
#include <stdlib.h>
#include "securec.h"
#include "cJSON.h"
#define HCS_HILINKKIT
#define KIT_ID_LEN 40
typedef const char *(*KitGetVerFunc)();
typedef struct KitGetVerInfo
{
char kitId[KIT_ID_LEN + 1];
KitGetVerFunc kitGetVerFunc;
} KitGetVerInfo;
#ifdef HCS_DVKIT
extern const char *DvKit_GetVersion();
#endif
#ifdef HCS_HILINKKIT
// extern const char* HiLinkKit_GetVersion();
const char *HiLinkKit_GetVersion()
{
return "1.0.0";
}
#endif
KitGetVerInfo g_kitGetVerInfo[] = {
#ifdef HCS_DVKIT
{"DvKit", DvKit_GetVersion},
#endif
#ifdef HCS_HILINKKIT
{"HiLinkKit", HiLinkKit_GetVersion},
#endif
{0, NULL}};
#define TOTAL_TIMEOUT 10000
#define KIT_INFO_JSON_KEY "KitInfos"
uint32_t OEMGetTotalTimeout()
{
return TOTAL_TIMEOUT;
}
int32_t OEMReadAuthServerInfo(char *buff, uint32_t len)
{
if (buff == NULL || len == 0)
{
return -1;
}
return -1;
}
char *OEMLoadKitInfos(void)
{
cJSON *root = cJSON_CreateObject();
if (root == NULL)
{
return NULL;
}
cJSON *infos = cJSON_CreateArray();
if (infos == NULL)
{
cJSON_Delete(root);
return NULL;
}
const uint32_t kitCount = sizeof(g_kitGetVerInfo) / sizeof(KitGetVerInfo);
for (uint32_t i = 0; i < kitCount; i++)
{
cJSON *obj = cJSON_CreateObject();
if (obj == NULL)
{
printf("OEM Adapter: Create json object failed\n");
continue;
}
const char *key = g_kitGetVerInfo[i].kitId;
KitGetVerFunc kitGetVerFunc = g_kitGetVerInfo[i].kitGetVerFunc;
if (key == NULL || strlen(key) == 0 || kitGetVerFunc == NULL)
{
cJSON_Delete(obj);
continue;
}
const char *value = (kitGetVerFunc)();
if (value == NULL || strlen(value) == 0 || cJSON_AddStringToObject(obj, key, value) == NULL)
{
printf("OEM Adapter: Add kit info %s to json object failed\n", key);
cJSON_Delete(obj);
continue;
}
if (!cJSON_AddItemToArray(infos, obj))
{
cJSON_Delete(obj);
printf("OEM Adapter: Add kit info %s to json array failed\n", key);
}
}
if (!cJSON_AddItemToObject(root, KIT_INFO_JSON_KEY, infos))
{
printf("OEM Adapter: Add kit infos to json object failed\n");
cJSON_Delete(infos);
cJSON_Delete(root);
return NULL;
}
char *result = cJSON_PrintUnformatted(root);
cJSON_Delete(root);
return result;
}
@@ -1,223 +0,0 @@
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: implement of oem_auth_result_storage
* Author: Kit Framework group
* Create: 2020-12-26
*/
#include "oem_auth_result_storage.h"
#include <stdio.h>
#include "securec.h"
#include "utils_file.h"
#define RESET_FILE_NAME "auth_reset"
#define TICKET_FILE_NAME "auth_ticket"
#define AUTH_STATS_FILE_NAME "auth_authstats"
#define WRITE_FLASH_MAX_TEMPERATURE 80
static const uint32_t MAX_FILE_BYTES_LIMIT = 5120;
bool OEMIsOverTemperatureLimit(void)//???¨¨?D?¦Ì?D??
{
return false;
}
static bool IsFileExist(const char* path)
{
printf("IsFileExist start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
return false;
}
(void)UtilsFileClose(fd);
return true;
}
static int32_t CreateFile(const char* path)
{
printf("CreateFile start path=%s\r\n",path);
if(path == NULL)
return false;
int32_t fd = UtilsFileOpen(path, O_CREAT_FS, 0);
if(fd < 0)
{
return -1;
}
(void)UtilsFileClose(fd);
return 0;
}
static int32_t WriteFile(const char* path,const char* data,uint32_t datalen,int flag)
{
printf("WriteFile start path=%s\r\n",path);
if(path == NULL || data == NULL || datalen == 0)
{
printf("WriteFile data invalid\r\n");
return -1;
}
if(datalen > MAX_FILE_BYTES_LIMIT)
{
printf("WriteFile data over limit\r\n");
return -1;
}
if(OEMIsOverTemperatureLimit())
{
return -1;
}
int32_t fd = UtilsFileOpen(path, flag, 0);
if(fd < 0)
{
printf("WriteFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileWrite(fd, data, datalen) != datalen)
{
printf("WriteFile write failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t ReadFile(const char* path,const char* buffer,uint32_t bufferlen)
{
printf("ReadFile start path=%s\r\n",path);
if(path == NULL || buffer == NULL || bufferlen == 0)
{
printf("ReadFile data invalid\r\n");
return -1;
}
if(!IsFileExist(path))
{
printf("ReadFile file not exsit\r\n");
return -1;
}
int32_t filesize = 0;
if(UtilsFileStat(path,&filesize) != 0)
{
printf("ReadFile stat file failed\r\n");
return -1;
}
if(filesize > bufferlen)
{
printf("ReadFile read data over buffer lenth\r\n");
return -1;
}
int32_t fd = UtilsFileOpen(path, O_RDONLY_FS, 0);
if(fd < 0)
{
printf("ReadFile open failed\r\n");
return -1;
}
int32_t ret = 0;
if(UtilsFileRead(fd, buffer, filesize) != filesize)
{
printf("ReadFile read data failed\r\n");
return -1;
}
(void)UtilsFileClose(fd);
return ret;
}
static int32_t DeleteFile(const char* path)
{
UtilsFileDelete(path);
}
bool OEMIsResetFlagExist(void)
{
return IsFileExist(RESET_FILE_NAME);
}
int32_t OEMCreateResetFlag(void)
{
return CreateFile(RESET_FILE_NAME);
}
int32_t OEMDeleteResetFlag(void)
{
return DeleteFile(RESET_FILE_NAME);
}
bool OEMIsAuthStatusExist(void)
{
return IsFileExist(AUTH_STATS_FILE_NAME);
}
int32_t OEMWriteAuthStatus(const char* data, uint32_t len)
{
if(data == NULL || len == 0)
return -1;
return WriteFile(AUTH_STATS_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadAuthStatus(char* buffer, uint32_t bufferLen)
{
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(AUTH_STATS_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteAuthStatus(void)
{
return DeleteFile(AUTH_STATS_FILE_NAME);
}
int32_t OEMGetAuthStatusFileSize(uint32_t* len)
{
printf("OEMGetAuthStatusFileSize len=%p\r\n",len);
if(len == NULL)
return -1;
return UtilsFileStat(AUTH_STATS_FILE_NAME,len);
}
bool OEMIsTicketExist(void)
{
return IsFileExist(TICKET_FILE_NAME);
}
int32_t OEMWriteTicket(const char* data, uint32_t len)
{
printf("OEMWriteTicket data=%s -- len=%d\r\n",data,len);
if(data == NULL || len == 0)
return -1;
return WriteFile(TICKET_FILE_NAME,data,len,O_CREAT_FS | O_TRUNC_FS | O_RDWR_FS);
}
int32_t OEMReadTicket(char* buffer, uint32_t bufferLen)
{
printf("OEMReadTicket buffer=%s -- bufferLen=%d\r\n",buffer,bufferLen);
if(buffer == NULL || bufferLen == 0)
return -1;
return ReadFile(TICKET_FILE_NAME,buffer,bufferLen);
}
int32_t OEMDeleteTicket(void)
{
return DeleteFile(TICKET_FILE_NAME);
}
int32_t OEMGetTicketFileSize(uint32_t* len)
{
return UtilsFileStat(TICKET_FILE_NAME,len);
}
+12
View File
@@ -1,3 +1,15 @@
# Copyright (C) 2022 BEKEN .
# 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 = [
@@ -1,3 +1,15 @@
// Copyright (C) 2022 BEKEN .
// 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"