diff --git a/Device/AudioDemo/audio_drivers/codec/rk809_codec/src/rk809_codec_adapter.c b/Device/AudioDemo/audio_drivers/codec/rk809_codec/src/rk809_codec_adapter.c deleted file mode 100644 index 374210f63f3800c0dcd015498fc75f94f4df6adf..0000000000000000000000000000000000000000 --- a/Device/AudioDemo/audio_drivers/codec/rk809_codec/src/rk809_codec_adapter.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2022 Institute of Software, CAS. - * Author : huangji@nj.iscas.ac.cn - * 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 -#include -#include -#include -#include -#include "audio_codec_if.h" -#include "audio_codec_base.h" -#include "audio_driver_log.h" -#include "rk817_codec.h" -#include "rk809_codec_impl.h" - -#define HDF_LOG_TAG "rk809_codec_adapter" - -struct CodecData g_rk809Data = { - .Init = Rk809DeviceInit, - .Read = RK809CodecReadReg, - .Write = Rk809CodecWriteReg, -}; - -struct AudioDaiOps g_rk809DaiDeviceOps = { - .Startup = Rk809DaiStartup, - .HwParams = Rk809DaiHwParams, - .Trigger = Rk809NormalTrigger, -}; - -struct DaiData g_rk809DaiData = { - .DaiInit = Rk809DaiDeviceInit, - .Read = RK809CodecDaiReadReg, - .Write = RK809CodecDaiWriteReg, - .ops = &g_rk809DaiDeviceOps, -}; - -static struct Rk809ChipData *g_chip; -struct Rk809ChipData* GetCodecDevice(void) -{ - return g_chip; -} - -/* HdfDriverEntry implementations */ -static int32_t Rk809DriverBind(struct HdfDeviceObject *device) -{ - struct CodecHost *codecHost; - if (device == NULL) { - AUDIO_DRIVER_LOG_ERR("input para is NULL."); - return HDF_FAILURE; - } - - codecHost = (struct CodecHost *)OsalMemCalloc(sizeof(struct CodecHost)); - if (codecHost == NULL) { - AUDIO_DRIVER_LOG_ERR("malloc codecHost fail!"); - return HDF_FAILURE; - } - codecHost->device = device; - device->service = &codecHost->service; - - return HDF_SUCCESS; -} - -static int32_t Rk809DriverInit(struct HdfDeviceObject *device) -{ - int32_t ret; - struct regmap_config codecRegmapCfg = getCodecRegmap(); - struct platform_device *codeDev = GetCodecPlatformDevice(); - struct rk808 *rk808; - if (!codeDev) { - AUDIO_DEVICE_LOG_ERR("codeDev not ready"); - return HDF_FAILURE; - } - g_chip = devm_kzalloc(&codeDev->dev, sizeof(struct Rk809ChipData), GFP_KERNEL); - if (!g_chip) { - AUDIO_DEVICE_LOG_ERR("devm_kzalloc for g_chip failed!"); - return HDF_ERR_MALLOC_FAIL; - } - g_chip->codec = g_rk809Data; - g_chip->dai = g_rk809DaiData; - platform_set_drvdata(codeDev, g_chip); - g_chip->pdev = codeDev; - rk808 = dev_get_drvdata(g_chip->pdev->dev.parent); - if (!rk808) { - return HDF_FAILURE; - } - g_chip->regmap = devm_regmap_init_i2c(rk808->i2c, &codecRegmapCfg); - if (IS_ERR(g_chip->regmap)) { - AUDIO_DEVICE_LOG_ERR("failed to allocate regmap: %ld\n", PTR_ERR(g_chip->regmap)); - return HDF_FAILURE; - } - - if (CodecGetConfigInfo(device, &g_rk809Data) != HDF_SUCCESS) { - return HDF_FAILURE; - } - if (CodecSetConfigInfoOfControls(&g_rk809Data, &g_rk809DaiData) != HDF_SUCCESS) { - return HDF_FAILURE; - } - ret = CodecGetServiceName(device, &(g_rk809Data.drvCodecName)); - if (ret != HDF_SUCCESS) { - return ret; - } - ret = CodecGetDaiName(device, &(g_rk809DaiData.drvDaiName)); - if (ret != HDF_SUCCESS) { - return HDF_FAILURE; - } - OsalMutexInit(&g_rk809Data.mutex); - OsalMutexInit(&g_rk809DaiData.mutex); - ret = AudioRegisterCodec(device, &g_rk809Data, &g_rk809DaiData); - if (ret != HDF_SUCCESS) { - return ret; - } - return HDF_SUCCESS; -} - -static void RK809DriverRelease(struct HdfDeviceObject *device) -{ - struct CodecHost *codecHost; - if (device == NULL) { - AUDIO_DRIVER_LOG_ERR("device is NULL"); - return; - } - - if (g_chip) { - platform_set_drvdata(g_chip->pdev, NULL); - if (g_chip->regmap) { - regmap_exit(g_chip->regmap); - } - devm_kfree(&g_chip->pdev->dev, g_chip); - } - OsalMutexDestroy(&g_rk809Data.mutex); - OsalMutexDestroy(&g_rk809DaiData.mutex); - - if (device->priv != NULL) { - OsalMemFree(device->priv); - } - codecHost = (struct CodecHost *)device->service; - if (codecHost == NULL) { - HDF_LOGE("CodecDriverRelease: codecHost is NULL"); - return; - } - OsalMemFree(codecHost); - codecHost = NULL; -} - diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/README.md" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/README.md" deleted file mode 100644 index 1ceed9750ac623bfc9c4fbf72efab93276db6a90..0000000000000000000000000000000000000000 --- "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/README.md" +++ /dev/null @@ -1,93 +0,0 @@ -# Linux 下安装 DevEco Device Tool - - - -# 介绍 - -HUAWEI DevEco Device Tool(以下简称DevEco Device Tool)是面向智能设备开发者提供的一站式集成开发环境,支持代码编辑、编译、烧录和调试等功能,支持C/C++语言,以插件的形式部署在Visual Studio Code上,本片文章是基于3.0.0.300版本的DevEco Device Tool来进行安装的。 - -# 环境准备 - -1.准备[ubuntu-20.04.3-desktop-amd64.iso](https://ubuntu.com/download/desktop)镜像。 - -2.准备Virtualbox 6.1.16 ,打开下载[地址](https://download.virtualbox.org/virtualbox/6.1.16/)选择 VirtualBox-6.1.16-140961-Win.exe进行下载。 - -3.Virtualbox 6.1.16 安装 ubuntu-20.04.3-desktop-amd64.iso 镜像可参考以下网址: - -[https://blog.csdn.net/xiangbing911/article/details/108614181](https://blog.csdn.net/xiangbing911/article/details/108614181) - ->![](public_sys-resources/icon-note.gif) **说明:** ->- ubuntu 20.04.3 版本 ->- 系统的用户名不能含有中文字符。 ->- 只能使用普通用户角色搭建开发环境。 - -# 安装 DevEco Device Tool - -DevEco Device Tool基于Visual Studio Code进行扩展,在Visual Studio Code上以插件方式运行,Visual Studio Code版本为1.60及以上。同时,DevEco Device Tool还依赖Python工具,并要求Python为3.8\~3.9版本。 - -在安装过程中,DevEco Device Tool会自动检查Visual Studio Code和Python,如果检测到Visual Studio Code、Python未安装或版本不符合要求,安装程序会自动安装Visual Studio Code和Python。 - -1. 将Ubuntu Shell环境修改为bash。 - 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据步骤2,将Ubuntu shell修改为bash - - ``` - ls -l /bin/sh - ``` - - ![](figures/zh-cn_image_0000001204589378.png) - - 2. 打开终端工具,执行如下命令,输入密码,然后选择No,将Ubuntu shell由dash修改为bash。 - - ``` - sudo dpkg-reconfigure dash - ``` - - ![](figures/zh-cn_image_0000001248709583.png) - -2. 下载最新Linux版本[DevEco Device Tool](https://docs.openharmony.cn/pages/v3.1/zh-cn/device-dev/get-code/gettools-ide.md/#%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7huawei-deveco-device-tool),下载时,请先使用华为开发者帐号进行登录后下载。如未注册华为开发者账号,请先[注册](https://developer.huawei.com/consumer/cn/doc/start/registration-and-verification-0000001053628148)。 -3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.0.0.300.zip为软件包名称,请根据实际进行修改。 - - ``` - unzip devicetool-linux-tool-3.0.0.300.zip - ``` - - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 - - ``` - chmod u+x devicetool-linux-tool-3.0.0.300.sh - ``` - -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.0.0.300.sh请根据实际进行修改。 - - >![](public_sys-resources/icon-note.gif) **说明:** - >安装过程中,会自动检查Visual Studio Code和Python是否安装,且版本符合要求,其中Visual Studio Code为1.60及以上版本,Python为3.8\~3.9版本。如果不满足,则安装过程中会自动安装,提示“Do you want to continue?”,请输入“Y”后继续安装。 - - ``` - sudo ./devicetool-linux-tool-3.0.0.300.sh -- --install-plugins - ``` - - ![](figures/zh-cn_image_0000001204591872.png) - - 按照提示输入命令: - - ``` - sudo apt install python3.8-venv - ``` - - 按照提示请输入“Y”后继续安装: - - ![](figures/zh-cn_image_0000001248832623.png)安装python3.8-venv完成后重新执行命令 - - ``` - sudo ./devicetool-linux-tool-3.0.0.300.sh -- --install-plugins - ``` - - 安装完成后,当界面输出“Deveco Device Tool successfully installed.”时,表示DevEco Device Tool安装成功。 - - ![](figures/zh-cn_image_0000001249113173.png) - -5. 安装完成后,在Ubuntu左下角的![](figures/zh-cn_image_0000001248714253.png)中,启动Visual Studio Code,出现以下界面,至此DevEco Device Tool Ubuntu开发环境安装完成。 - - ![](figures/zh-cn_image_0000001204114680.png) - diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204114680.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204114680.png" deleted file mode 100644 index a9d16244dfd9bc9783896a73a62b6f7141c5711b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204114680.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204589378.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204589378.png" deleted file mode 100644 index 4a318690954621198377187aadf9564ddc2b71b1..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204589378.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204591872.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204591872.png" deleted file mode 100644 index 2322f8754124cadd21afb450a6c93ce4e409421d..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001204591872.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248709583.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248709583.png" deleted file mode 100644 index 6f915dc7a07516effb614ad9d752589fcbc6405b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248709583.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248714253.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248714253.png" deleted file mode 100644 index fbb4eb3c473d7020565f666d594c0f18b3a43f78..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248714253.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248832623.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248832623.png" deleted file mode 100644 index 4f23395b06f66aed09d9b007b56c9ccfd143cd0b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001248832623.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001249113173.png" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001249113173.png" deleted file mode 100644 index 08416d7d6e84ac7847f4e4cbe7cd394a225899e3..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/figures/zh-cn_image_0000001249113173.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-caution.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-caution.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-caution.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-danger.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-danger.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-danger.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-note.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-note.gif" deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-note.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-notice.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-notice.gif" deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-notice.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-tip.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-tip.gif" deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-tip.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-warning.gif" "b/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-warning.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Linux \344\270\213\345\256\211\350\243\205 DevEco Device Tool/public_sys-resources/icon-warning.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/README.md" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/README.md" deleted file mode 100644 index ed49b49c0874607ba5ae7b2803bef082630568ec..0000000000000000000000000000000000000000 --- "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/README.md" +++ /dev/null @@ -1,171 +0,0 @@ -# Windows搭建DevEco Device Tool及烧录 - - - -# 介绍 - -本片文章是基于3.0.0.300版本的DevEco Device Tool来进行烧录的,开发者通过本片文章可快速掌握OpenHarmony标准系统的环境搭建及网口烧录知识。 - -# 系统要求 - -- Windows 10 64位系统。 -- 系统的用户名不能含有中文字符。 - -# 安装DevEco Device Tool - -下载最新Windows版本[DevEco Device Tool](https://docs.openharmony.cn/pages/v3.1/zh-cn/device-dev/get-code/gettools-ide.md/#%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7huawei-deveco-device-tool) - -# 获取烧录文件 - -方式一:文件获取地址:[http://ci.openharmony.cn/dailybuilds](http://ci.openharmony.cn/dailybuilds) - -![](figures/zh-cn_image_0000001193123152.png) - -方式二:获取[标准系统解决方案(二进制)文件](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz) - -# 创建工程 - -1.打开DevEco Device Tool,进入Home页,点击Create Project创建工程,如图所示: - -![](figures/zh-cn_image_0000001192795696.png) - -2.填写工程名称,设置开发板类型,如图所示 - -![](figures/zh-cn_image_0000001192955880.png) - -3.按照图示配置相关选项并完成项目的创建,如图所示: - -![](figures/zh-cn_image_0000001237800813.png) - -# 配置烧录选项 - -1.创建工程后点击Settings设置烧录选项,如图所示: - -![](figures/zh-cn_image_0000001237920903.png) - -2.点击 hi3516dv300\_fastboot标签页配置待烧录的文件,在New Option选项中选择需要修改的项,例如partition\_bin(烧录文件路径)如图所示: - ->![](public_sys-resources/icon-note.gif) **说明:** ->upload\_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。 - -![](figures/zh-cn_image_0000001193121224.png) - -3.配置待烧录的文件可以参考对应的模板配置,如图所示: - -![](figures/zh-cn_image_0000001192801344.png) - -4.配置partition\_bin属性值,如图所示: - -![](figures/zh-cn_image_0000001192961816.png) - -5.选择对应的烧录文件,如图所示: - -![](figures/zh-cn_image_0000001192641910.png) - -6.选择烧录文件成功后,确认是否与模板文件一致。 - -![](figures/zh-cn_image_0000001192802076.png) - -7.设置完后保存配置,点击Save保存配置项,如图所示: - -![](figures/zh-cn_image_0000001237922041.png) - -8.配置boot、updater、userdata 等待烧录的文件参考fastboot 配置即可。 - ->![](public_sys-resources/icon-note.gif) **说明:** ->DevEco Device Tool已预置默认的烧录文件信息fastboot、boot、updater、misc、system、vendor和userdata,可根据实际情况进行调整。 - -# 配置串口及网口协议 - -1.打开“hi3516dv300”标签页,配置串口信息及网口协议,upload\_port:选择已查询的串口号。upload\_protocol:选择烧录协议,固定选择“hiburn-net”。如图所示: - -![](figures/zh-cn_image_0000001192642330.png) - -2.设置完后保存配置。 - -# 设置网口烧录的IP地址信息 - -1.打开控制面板 \> 网络和Internet \> 网络连接,找到连接开发板后出现的网卡。 - -![](figures/zh-cn_image_0000001236734753.png) - -2.点击右键 \> 属性 \> 网络 \> Internet协议版本4(TCP/IPv4),打开IP地址设置页面。 - -3.勾选“使用下面的IP地址“,然后手动输入IP地址、子网验码和默认网关,如图所示: - -![](figures/zh-cn_image_0000001192095156.png) - -4.在“hi3516dv300”标签页中设置网口烧录的IP地址信息,设置如下选项: - -upload\_net\_server\_ip:选择设置的IP地址信息。例如192.168.1.2 - -upload\_net\_client\_mask:设置开发板的子网掩码,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如255.255.255.0 - -upload\_net\_client\_gw:设置开发板的网关,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如192.168.1.1 - -upload\_net\_client\_ip:设置开发板的IP地址,工具会自动根据选择的upload\_net\_server\_ip进行设置。例如192.168.1.3 - -如图所示: - -![](figures/zh-cn_image_0000001237922385.png) - -5.设置完后保存配置。 - -# 开始烧录 - -1.点击![](figures/zh-cn_image_0000001191944830.png)图标,然后在“PROJECT TASKS”中,点击hi3516dv300\_fastboot下的Upload按钮,开始烧录,如图所示: - -![](figures/zh-cn_image_0000001192962610.png)2.启动烧录后,显示如下提示信息时,请重启开发板(下电再上电)。 - -![](figures/zh-cn_image_0000001193122648.png) - -3.重新上电后,界面提示如下信息时,表示烧录成功。 - -![](figures/zh-cn_image_0000001192802756.png) - -# 镜像运行(可选) - -1.烧录完成后若屏幕没有点亮,在DevEco Device Tool中,点击Monitor,打开串口工具。 - -![](figures/zh-cn_image_0000001237762799.png) - -2.重启开发板,在倒计时结束前,按回车键进入系统。 - -![](figures/zh-cn_image_0000001237602841.png) - -3.通过以下两条命令设置启动参数。 - -(1)按照方式一获取烧录文件(Master 版本)执行以下命令: - -``` -setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; -``` - -``` -setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000'; -``` - -(2)按照方式二获取烧录文件(LTS 版本)执行以下命令: - -``` -setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive skip_initramfs rootdelay=5 init=/init root=/dev/mmcblk0p5 rootfstype=ext4 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),1M(misc),3307M(system),256M(vendor),-(userdata)'; -``` - -``` -setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800; bootm 0x80000000"; -``` - -4.保存参数设置。 - -``` -save -``` - -5.重启开发板,完成系统启动。 - -``` -reset -``` - -![](figures/zh-cn_image_0000001237922879.png) - diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001191944830.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001191944830.png" deleted file mode 100644 index fa1f83b309b72048fb8d250db6166a213e7037ac..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001191944830.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192095156.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192095156.png" deleted file mode 100644 index f3a95c2e010b590dfa5d606c60502c1b9e605e08..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192095156.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192641910.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192641910.png" deleted file mode 100644 index d33bc16d82d6db4d00be39cd2b441947b895f8a9..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192641910.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192642330.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192642330.png" deleted file mode 100644 index 3a80aecd33a20b03d9df804e791f06e6c832a58b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192642330.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192795696.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192795696.png" deleted file mode 100644 index 22c88eadf3c4350a61c97db2d6c06cf68d7f386d..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192795696.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192801344.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192801344.png" deleted file mode 100644 index ccba99d41754464c7262dcb62d976f3881f716d0..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192801344.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802076.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802076.png" deleted file mode 100644 index 1a119c1da52749d95fcc06afe9241eb512df1c43..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802076.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802756.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802756.png" deleted file mode 100644 index 3f94b64289f4859253c4c27c3cd7db9db374baaf..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192802756.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192955880.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192955880.png" deleted file mode 100644 index 7cd5ca258ab726db20b963b42ed23d250d89146f..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192955880.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192961816.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192961816.png" deleted file mode 100644 index c17e734df91d6e2557ba4f187a2b76b5186da4c8..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192961816.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192962610.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192962610.png" deleted file mode 100644 index 1c3ad7228fc78cf006e94131885093365f05536b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001192962610.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193121224.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193121224.png" deleted file mode 100644 index aab93cc6aebe39a20b0c460ebaff6ae136ad2a85..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193121224.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193122648.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193122648.png" deleted file mode 100644 index c798f75dca458185154f92c3bf938b9f3b7aef9b..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193122648.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193123152.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193123152.png" deleted file mode 100644 index 44e95ea84bb73ae0a9e5df86f8a4d23978051cce..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001193123152.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001236734753.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001236734753.png" deleted file mode 100644 index aa94df0d1dc3615489e58c55c826cb184e6e1f57..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001236734753.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237602841.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237602841.png" deleted file mode 100644 index 97ca23945c1ad45b17417712a029e38eb54605c9..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237602841.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237762799.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237762799.png" deleted file mode 100644 index 04b79f6443d983a06de77c6fbc90e4d7dc0a3097..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237762799.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237800813.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237800813.png" deleted file mode 100644 index 39aaa239a7e11b48363542a28b2474e5663fbb2e..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237800813.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237920903.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237920903.png" deleted file mode 100644 index 0208c2cd6b6fbd08b637900d0488e9dc571007a7..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237920903.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922041.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922041.png" deleted file mode 100644 index 4e7995a9d9ea3af7a888268f929211554ad3fb7a..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922041.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922385.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922385.png" deleted file mode 100644 index b398637d186dcfe77a9dbff318599035f6432353..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922385.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922879.png" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922879.png" deleted file mode 100644 index e93659d2d178db8e01040f05b77030aebd13f8f7..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/figures/zh-cn_image_0000001237922879.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-caution.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-caution.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-caution.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-danger.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-danger.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-danger.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-note.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-note.gif" deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-note.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-notice.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-notice.gif" deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-notice.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-tip.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-tip.gif" deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-tip.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-warning.gif" "b/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-warning.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/Windows\346\220\255\345\273\272DevEco Device Tool\345\217\212\347\203\247\345\275\225/public_sys-resources/icon-warning.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/README.md" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/README.md" deleted file mode 100644 index fc6b38a7c2a1760cc14a43336b8291b52de3ede6..0000000000000000000000000000000000000000 --- "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/README.md" +++ /dev/null @@ -1,228 +0,0 @@ -# 轻量和小型系统开发指导 - - - -# 介绍 - -DevEco Device Tool支持Hi3861V100开发板的源码一键编译功能,支持Windows和Ubuntu系统。 - -本片文章是基于3.0.0.300版本的DevEco Device Tool来进行编写的,主要介绍的是在Ubuntu系统环境下对小型系统的源码进行编译及烧录。 -下文将以Hi3861V100开发板为例进行介绍,开发板的具体外观和规格可参见附录,开发者可根据需要自行购买。 - -# 开发环境准备 - -以下均为本文开发环境的版本,开发者可以参考本文环境进行配置。 - -**Linux** - -- Ubuntu-20.04.3 - -**Windows** - -- Windows 10 - -**下载并安装DevEco Device Tool(Linux)** - -参考[搭建Ubuntu开发环境](https://gitee.com/openharmony/codelabs/tree/master/Device/DeviceEnvironmentSetupGuide/Linux%20%E4%B8%8B%E5%AE%89%E8%A3%85%20DevEco%20Device%20Tool) - -**下载并安装DevEco Device Tool(Windows)** - -参考[搭建Windows开发环境](https://gitee.com/openharmony/codelabs/tree/master/Device/DeviceEnvironmentSetupGuide/Windows%E6%90%AD%E5%BB%BADevEco%20Device%20Tool%E5%8F%8A%E7%83%A7%E5%BD%95) - -# 获取源码 - -1. 注册码云Gitee账号。 -2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)。 -3. 安装Git并配置用户信息: - -``` -git config --global user.name "yourname" -git config --global user.email "your-email-address" -git config --global credential.helper store -``` - -4. 下载repo工具: - -``` -curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中 -chmod a+x /usr/local/bin/repo -pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests -``` - -5.添加python 软连接: - -``` -sudo ln -s /usr/bin/python3.8 /usr/bin/python -``` - -6.验证输入python 后能正常显示python 版本。 - -7.安装git-lfs: - -``` -sudo apt-get install git-lfs -``` - -8.获取源码: - -``` -repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -# 导入工程 - -1. 打开DevEco Device Tool,进入Home页,点击Import Project打开工程,选择待打开的工程目录,点击Import打开。 - -![](figures/zh-cn_image_0000001242826105.png) - -2.按照图示选择对应的选项。 - -![](figures/zh-cn_image_0000001198155376.png) - -# 配置工具链 - -- [配置gn](#section11258193182315) -- [配置 ninja](#section15585175417298) -- [配置 llvm](#section739632815309) -- [配置 hc-gen](#section4384439203219) -- [配置gcc\_riscv32](#section86961835173411) - -## 配置gn - -1.点击下载[gn工具包](https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz)。 - -2.解压文件,在Tools中设置的路径设置为gn执行文件所在文件夹。 - -![](figures/zh-cn_image_0000001226307048.png) - -## 配置 ninja - -1.点击下载[ninja工具包](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar)。 - -2.解压文件,在Tools中设置的路径设置为ninja执行文件所在文件夹。 - -![](figures/zh-cn_image_0000001271027189.png) - -## 配置 llvm - -1.点击下载[llvm工具包](https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-62608/linux/llvm.tar.gz)。 - -2.解压文件,在Tools中设置的路径设置为llvm\\bin文件夹。 - -![](figures/zh-cn_image_0000001225987164.png) - -## 配置 hc-gen - -1.点击下载[hc-gen工具包](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar)。 - -2.在Tools中设置的路径设置为hc-gen执行文件所在文件夹。 - -![](figures/zh-cn_image_0000001226467048.png) - -## 配置gcc\_riscv32 - -1.下载 [gcc\_riscv32](https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz) 工具包 - -2.在Tools中设置的路径设置为gcc\_riscv32所在文件夹。 - -![](figures/zh-cn_image_0000001226474504.png) - -保存配置 - -![](figures/zh-cn_image_0000001270833525.png) - -# 安装环境依赖 - -执行命令: - -``` -sudo apt-get install mtd-utils -``` - -# 编译运行 - -打开DevEco Device Tool界面,在“PROJECT TASKS”中,点击对应开发板下的Build按钮,执行编译。 - -等待编译完成,在TERMINAL窗口输出“SUCCESS”,编译完成。 - -![](figures/zh-cn_image_0000001235947647.png) - -# 代码烧录 - -烧录时连接好USB,点击Upload 开始烧录,显示如下提示信息时,请按开发板上的RST按钮重启开发板。 - -![](figures/zh-cn_image_0000001243310329.png)重启开发板后,界面提示如下信息时,表示烧录成功。 - -![](figures/zh-cn_image_0000001197830766.png) - -# 附录 - -**Hi3861开发板简介** - -Hi3861开发板是一片大约2cm\*5cm大小的开发板,是一款高度集成的2.4GHz WLAN SoC芯片,集成IEEE 802.11b/g/n基带和RF(Radio Frequency)电路。支持OpenHarmony,并配套提供开放、易用的开发和调试运行环境。 - -![](figures/zh-cn_image_0000001198312824.png) - -另外,Hi3861开发板还可以通过与Hi3861底板连接,扩充自身的外设能力,底板如下图所示。 - -![](figures/zh-cn_image_0000001197992964.png) - -- RF电路包括功率放大器PA(Power Amplifier)、低噪声放大器LNA(Low Noise Amplifier)、RF Balun、天线开关以及电源管理等模块;支持20MHz标准带宽和5MHz/10MHz窄带宽,提供最大72.2Mbit/s物理层速率。 -- Hi3861 WLAN基带支持正交频分复用(OFDM)技术,并向下兼容直接序列扩频(DSSS)和补码键控(CCK)技术,支持IEEE 802.11 b/g/n协议的各种数据速率。 -- Hi3861芯片集成高性能32bit微处理器、硬件安全引擎以及丰富的外设接口,外设接口包括SPI(Synchronous Peripheral Interface)、UART(Universal Asynchronous Receiver & Transmitter)、I2C(The Inter Integrated Circuit)、PWM(Pulse Width Modulation)、GPIO(General Purpose Input/Output)和多路ADC(Analog to Digital Converter),同时支持高速SDIO2.0(Secure Digital Input/Output)接口,最高时钟可达50MHz;芯片内置SRAM(Static Random Access Memory)和Flash,可独立运行,并支持在Flash上运行程序。 -- Hi3861芯片适用于智能家电等物联网智能终端领域。**Hi3861功能框图** - - ![](figures/zh-cn_image_0000001197833116.png) - - -**资源和约束** - -Hi3861开发板,整板共2MB FLASH,352KB RAM。在编写业务代码时,需注意资源使用效率。 - -**开发板规格** - - - - - - - - - - - - - - - - - - - - - - - - - -

规格类型

-

规格清单

-

通用规格

-
  • 1×1 2.4GHz频段(ch1~ch14)
  • PHY支持IEEE 802.11b/g/n
  • MAC支持IEEE802.11 d/e/h/i/k/v/w
-
  • 内置PA和LNA,集成TX/RX Switch、Balun等
  • 支持STA和AP形态,作为AP时最大支持6 个STA接入
  • 支持WFA WPA/WPA2 personal、WPS2.0
  • 支持与BT/BLE芯片共存的2/3/4 线PTA方案
  • 电源电压输入范围:2.3V~3.6V
-
  • IO电源电压支持1.8V和3.3V
-
  • 支持RF自校准方案
  • 低功耗:
    • Ultra Deep Sleep模式:5μA@3.3V
    • DTIM1:1.5mA@3.3V
    • DTIM3:0.8mA@3.3V
    -
-

PHY特性

-
  • 支持IEEE802.11b/g/n单天线所有的数据速率
  • 支持最大速率:72.2Mbps@HT20 MCS7
  • 支持标准20MHz带宽和5M/10M窄带宽
  • 支持STBC
  • 支持Short-GI
-

MAC特性

-
  • 支持A-MPDU,A-MSDU
  • 支持Blk-ACK
  • 支持QoS,满足不同业务服务质量需求
-

CPU子系统

-
  • 高性能 32bit微处理器,最大工作频率160MHz
  • 内嵌SRAM 352KB、ROM 288KB
  • 内嵌 2MB Flash
-

外围接口

-
  • 1个SDIO接口、2个SPI接口、2个I2C接口、3个UART接口、15个GPIO接口、7路ADC输入、6路PWM、1个I2S接口(注:上述接口通过复用实现)
  • 外部主晶体频率40M或24M
-

其他信息

-
  • 封装:QFN-32,5mm×5mm
  • 工作温度:-40℃ ~ +85℃
-
diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197830766.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197830766.png" deleted file mode 100644 index c9bbe023d1f77105348245dde43f89683c8be3ce..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197830766.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197833116.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197833116.png" deleted file mode 100644 index 7de3c25e7ef2abc8d85d8bc945249f571f6bf0c3..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197833116.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197992964.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197992964.png" deleted file mode 100644 index c846be0d2767953df4a3ac78408963f252af040d..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001197992964.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198155376.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198155376.png" deleted file mode 100644 index 9ed30dd3ba3ec085c8d17b9f933e80a5907dba49..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198155376.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198312824.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198312824.png" deleted file mode 100644 index 5086d2b4518cfea4040f3cc243abb2e6087af350..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001198312824.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001225987164.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001225987164.png" deleted file mode 100644 index 91e3130bc848fd1e9ece6b04d7a8095ed813356e..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001225987164.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226307048.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226307048.png" deleted file mode 100644 index 07f2377e0ebaf8d30c061a1d1ec379190ec2ebe1..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226307048.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226467048.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226467048.png" deleted file mode 100644 index 30f7b511b8f07a5081e75afc1f966c38ba95fbf8..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226467048.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226474504.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226474504.png" deleted file mode 100644 index 621c65b7934bd68599a75de3b76c6f7cca52789a..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001226474504.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001235947647.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001235947647.png" deleted file mode 100644 index 669700d73df75d3aae48326e8550fef76bdf05a6..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001235947647.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001242826105.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001242826105.png" deleted file mode 100644 index 8fea8a43b4e1a9dd70352d0986fc5332c0fcc319..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001242826105.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001243310329.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001243310329.png" deleted file mode 100644 index 68695dfd882e0ec697e3a830f19ec63c8dae8075..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001243310329.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001270833525.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001270833525.png" deleted file mode 100644 index b99cd290858d63980889f3f17921e12c0a93dba5..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001270833525.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001271027189.png" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001271027189.png" deleted file mode 100644 index 2b2de8517f2bba0ff35d96aeb96d720c49b2d363..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/figures/zh-cn_image_0000001271027189.png" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-caution.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-caution.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-caution.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-danger.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-danger.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-danger.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-note.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-note.gif" deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-note.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-notice.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-notice.gif" deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-notice.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-tip.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-tip.gif" deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-tip.gif" and /dev/null differ diff --git "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-warning.gif" "b/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-warning.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/DeviceEnvironmentSetupGuide/\350\275\273\351\207\217\345\222\214\345\260\217\345\236\213\347\263\273\347\273\237\345\274\200\345\217\221\346\214\207\345\257\274/public_sys-resources/icon-warning.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/README.md" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/README.md" deleted file mode 100644 index 2288f9ae96c40726221ba70550cec993b4d4e1fa..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/README.md" +++ /dev/null @@ -1,326 +0,0 @@ -# 任务介绍 - -ADC是模拟-数字转换器(Analog to Digital Converter)的缩写。可以将连续变化的模拟信号转换为离散的数字信号,进而使用数字电路进行处理,称之为数字信号处理。I2C\(Inter Integrated Circuit\)总线是一种简单、双向二线制同步串行总线。 - -本篇Codelab将介绍如何使用ADC和I2C API,实现按下Hi3861开发板按键1和按键2,在OLED显示屏上分别显示英文和中文的功能。 - -效果如下: - -![](figures/1_zh-cn_attachment_0000001275840861-00_00_00-00_00_30.gif) - -# 环境准备 - -完成本篇Codelab,我们首先需要完成开发环境搭建、源码编译,可参照如下步骤进行。 - -1. [搭建开发环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-ide-env-win.md)。 -2. 编译源码:建议开发者选择LTS 3.0版本源码进行编译,本篇Codelab是基于此版本开发的。 - - [编译Hi3861V100开发板源码](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md) - -**您需要使用如下设备完成本Codelab:** - -Hi3861V100开发板主板、底板以及OLED显示屏。 - -# API介绍 - -**I2C API** - - - - - - - - - - - - - - - - - - - - - - -

方法

-

说明

-

IoTI2cInit (unsigned int id, unsigned int baudrate)

-

使用指定波特率初始化I2C设备。

-

IoTI2cDeinit (unsigned int id)

-

去初始化I2C设备。

-

IoTI2cWrite (unsigned int id, unsigned short deviceAddr, const unsigned char *data, unsigned int dataLen)

-

向I2C设备写入数据。

-

IoTI2cRead(unsigned int id, unsigned short deviceAddr, unsigned char *data, unsigned int dataLen)

-

从I2C设备读取数据。

-

IoTI2cSetBaudrate(unsigned int id, unsigned int baudrate)

-

设置I2C设备的波特率。

-
- -**ADC API** - - - - - - - - - - -

方法

-

说明

-

AdcRead(WifiIotAdcChannelIndex channel, unsigned short *data, WifiIotAdcEquModelSel equModel, WifiIotAdcCurBais curBais, unsigned short rstCnt)

-

根据输入参数从指定的ADC通道读取一段采样数据

-
- -**Hi3861V100开发板说明** - -实现IOT外设控制,首先需要通过查阅原理图明确接线关系。OLED显示屏与主控芯片(Pegasus)引脚的对应关系如下: - - - - - - - - - - - - - -

按键

-

控制管脚

-

S1

-

GPIO13

-

S2

-

GPIO14

-
- ->![](public_sys-resources/icon-note.gif) **说明:** ->开发板原理图,请开发者联系Hi3861购买渠道客服获取。 - -# 编译烧写&运行 - -1. **确定目录结构**。 - - 开发者编写业务时,务必先在OpenHarmony/applications/sample/wifi-iot/app路径下新建一个目录,用于存放业务源码文件。例如:在app目录下新增目录screen,其中oled\_demo.c为业务代码,BUILD.gn为编译脚本,具体规划目录结构如下: - - ``` - . - └── applications - └── sample - └── wifi-iot - └── app - │── screen - │ │── oled_demo.c - │ │── oled_ssd1306_conf.h - │ │── oled_ssd1306_fonts.c - │ │── oled_ssd1306_fonts.h - │ │── oled_ssd1306.c - │ │── oled_ssd1306.h - │ └── BUILD.gn - └── BUILD.gn - ``` - -2. **设置I2C引脚复用**。 - - 确定I2C引脚,查看原理图,可以看到OLED屏幕使用到的是I2C0,引脚是GPIO13、GPIO14。我们需要修改源码,在OpenHarmony/device/hisilicon/hispark\_pegasus/sdk\_liteos/app/wifiiot\_app/init/app\_io\_init.c文件中,初始化I2C引脚的代码修改成如下: - - ![](figures/1.png) - -3. **开启I2C功能**。 - - 在OpenHarmony/device/hisilicon/hispark\_pegasus/sdk\_liteos/build/config/usr\_config.mk 文件中,增加 CONFIG\_I2C\_SUPPORT=y。 - - ![](figures/2.png) - -4. **编写业务代码**。 - - 在OpenHarmony/applications/sample/wifi-iot/app/screen目录下新建oled\_demo.c文件,在oled\_demo.c中新建业务入口函数OledDemo,并实现业务逻辑。在代码最下方,使用OpenHarmony启动恢复模块接口SYS\_RUN\(\)启动业务。(SYS\_RUN定义在ohos\_init.h文件中) - - ``` - #include - #include - #include "ohos_init.h" - #include "cmsis_os2.h" - #include "hi_io.h" - #include "hi_adc.h" - #include "oled_ssd1306.h" - - #define OLED_I2C_BAUDRATE 400*1000 - - hi_void convert_to_voltage(hi_u32 data_len) - { - ... - // 按键1被按下 - if((vlt_val > 0.4) && (vlt_val < 0.6)) - { - if(key_flg == 0) - { - key_flg = 1; - key_status = KEY_EVENT_S1; - } - } - // 按键2被按下 - if((vlt_val > 0.8) && (vlt_val < 1.1)) - { - if(key_flg == 0) - { - key_flg = 1; - key_status = KEY_EVENT_S2; - } - } - // 没有按键被按下 - if(vlt_val > 3.0) - { - key_flg = 0; - key_status = KEY_EVENT_NONE; - } - } - // 检测电压 - void read_adc(void) - { - ... - for (i = 0; i < ADC_TEST_LENGTH; i++) { - ret = hi_adc_read((hi_adc_channel_index)HI_ADC_CHANNEL_2, &data, HI_ADC_EQU_MODEL_1, HI_ADC_CUR_BAIS_DEFAULT, 0); - if (ret != HI_ERR_SUCCESS) { - printf("ADC Read Fail\n"); - return; - } - g_adc_buf[i] = data; - } - convert_to_voltage(ADC_TEST_LENGTH); - } - - static void OledTask(void *arg) - { - (void)arg; - // 初始化 - IoTI2cInit(0, OLED_I2C_BAUDRATE); // Rate: 100kbps - ... - while(1) - { - // 读取ADC值 - read_adc(); - - switch(get_key_event()) - { - // 没有按键按下,清屏 - case KEY_EVENT_NONE: - { - // Clear screen - ssd1306_Fill(Black); - ssd1306_UpdateScreen(); - } - break; - // 按键1被按下,显示英文字母 - case KEY_EVENT_S1: - { - // Clear screen - ssd1306_Fill(Black); - ssd1306_SetCursor(0,0); - ssd1306_DrawString("**OpenHarmony!**", Font_7x10, White); - ssd1306_UpdateScreen(); - // 显示10s - usleep(10 * 1000 * 1000); - } - break; - // 按键2被按下,显示中文 - case KEY_EVENT_S2: - { - OledDrawChinese(); - // 显示10s - usleep(10 * 1000 * 1000); - } - break; - } - // 轮询时间控制 - usleep(100); - } - } - - static void OledDemo(void) - { - osThreadAttr_t attr; - // 初始化13、14号管脚 - IoTGpioInit(HI_IO_NAME_GPIO_13); - IoTGpioInit(HI_IO_NAME_GPIO_14); - // 将引脚功能设置为I2C引脚 - hi_io_set_func(HI_IO_NAME_GPIO_13, HI_IO_FUNC_GPIO_13_I2C0_SDA); - hi_io_set_func(HI_IO_NAME_GPIO_14, HI_IO_FUNC_GPIO_14_I2C0_SCL); - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = 4096; - attr.priority = osPriorityNormal; - - if (osThreadNew(OledTask, NULL, &attr) == NULL) { - printf("[OledDemo] Falied to create OledTask!\n"); - } - } - SYS_RUN(OledDemo); - ``` - -5. **编写用于将业务构建成静态库的BUILD.gn文件**。 - - 在./applications/sample/wifi-iot/app/screen目录下新建BUILD.gn文件,并完成如下配置。 - - ``` - static_library("oled_example") { - sources = [ - "oled_demo.c", - "oled_ssd1306.c", - "oled_ssd1306_fonts.c" - ] - include_dirs = [ - "//utils/native/lite/include", - "//kernel/liteos_m/components/cmsis", - "//base/iot_hardware/peripheral/interfaces/kits", - "//device/hisilicon/hispark_pegasus/sdk_liteos/include" - ] - } - ``` - - - static\_library中指定业务模块的编译结果,开发者根据实际情况完成填写。 - - sources中指定静态库.a所依赖的.c文件及其路径,若路径中包含"//"则表示绝对路径(此处为代码根路径),若不包含"//"则表示相对路径。 - - include\_dirs中指定source所需要依赖的.h文件路径。 - -6. **编写模块BUILD.gn文件,指定需参与构建的特性模块**。 - - 配置./applications/sample/wifi-iot/app/BUILD.gn文件,在features字段中增加索引,使目标模块参与编译。features字段指定业务模块的路径和目标,features字段配置如下。 - - ``` - import("//build/lite/config/component/lite_component.gni") - - lite_component("app") { - features = [ - "screen:oled_example", - ] - } - ``` - -7. **代码编译和烧录**。 - -代码编译和烧录可以参考: - -[源码编译](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-building.md) - -[烧录](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-burn.md) - -完成烧录后,按下按键1,OLED显示屏上显示英文“\*\*OpenHarmony!\*\*”,按下按键 - -2,OLED显示屏上显示中文“你好世界”。 - -# 恭喜您 - -目前您已经成功完成了本篇Codelab,并且学到了: - -- 如何使用ADC检测电压值,判断Hi3861开发板上哪个按键被按下。 -- 如何使用I2C控制OLED显示屏显示中英文。 - diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1.png" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1.png" deleted file mode 100644 index 6aaf1c1b2d24679783572290074f11b2c62bbdea..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1.png" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1_zh-cn_attachment_0000001275840861-00_00_00-00_00_30.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1_zh-cn_attachment_0000001275840861-00_00_00-00_00_30.gif" deleted file mode 100644 index 210ef8622a17e385bd961b541bd4a9c0d938d365..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/1_zh-cn_attachment_0000001275840861-00_00_00-00_00_30.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/2.png" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/2.png" deleted file mode 100644 index 0b9d20cb4bf23385688784c5c1950cae833bb60a..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/figures/2.png" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-caution.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-caution.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-caution.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-danger.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-danger.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-danger.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-note.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-note.gif" deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-note.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-notice.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-notice.gif" deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-notice.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-tip.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-tip.gif" deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-tip.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-warning.gif" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-warning.gif" deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/public_sys-resources/icon-warning.gif" and /dev/null differ diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/BUILD.gn" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/BUILD.gn" deleted file mode 100644 index 1de119885202883e64d365020d0c9532d7c37451..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/BUILD.gn" +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("oled_example") { - sources = [ - "oled_demo.c", - "oled_ssd1306_fonts.c", - "oled_ssd1306.c", - ] - - include_dirs = [ - "//utils/native/lite/include", - "//kernel/liteos_m/components/cmsis", - "//base/iot_hardware/peripheral/interfaces/kits", - "//device/hisilicon/hispark_pegasus/sdk_liteos/include", - ] -} diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_demo.c" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_demo.c" deleted file mode 100644 index 5d80c60d2150baf03622e34bb7d420f018203b0b..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_demo.c" +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include "ohos_init.h" -#include "cmsis_os2.h" -#include "hi_io.h" -#include "hi_adc.h" -#include "oled_ssd1306.h" - -#define LED_I2C_BARRAGE (400 * 1000) -#define TASK_STACK_SIZE 4096 -void IotShowChinese(void) -{ - const int32_t w = 16; - const int32_t h = 16; - int8_t fonts[][32] = { - { - /* -- ID:0,字符:"你",ASCII编码:C4E3,对应字:宽x高=16x16,画布:宽W=16 高H=16,共32字节 */ - 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x23, 0xFC, 0x22, 0x04, 0x64, 0x08, 0xA8, 0x40, 0x20, 0x40, - 0x21, 0x50, 0x21, 0x48, 0x22, 0x4C, 0x24, 0x44, 0x20, 0x40, 0x20, 0x40, 0x21, 0x40, 0x20, 0x80, - }, - { - /* -- ID:1,字符:"好",ASCII编码:BAC3,对应字:宽x高=16x16,画布:宽W=16 高H=16,共32字节 */ - 0x10, 0x00, 0x11, 0xFC, 0x10, 0x04, 0x10, 0x08, 0xFC, 0x10, 0x24, 0x20, 0x24, 0x24, 0x27, 0xFE, - 0x24, 0x20, 0x44, 0x20, 0x28, 0x20, 0x10, 0x20, 0x28, 0x20, 0x44, 0x20, 0x84, 0xA0, 0x00, 0x40, - }, - { - /* -- ID:2,字符:"世",ASCII编码:CAC0,对应字:宽x高=16x16,画布:宽W=16 高H=16,共32字节 */ - 0x01, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x10, 0x11, 0x14, 0xFF, 0xFE, 0x11, 0x10, 0x11, 0x10, - 0x11, 0x10, 0x11, 0x10, 0x11, 0xF0, 0x11, 0x10, 0x10, 0x00, 0x10, 0x08, 0x1F, 0xFC, 0x00, 0x00, - }, - { - /* -- ID:3,字符:"界",ASCII编码:BDE7,对应字:宽x高=16x16,画布:宽W=16 高H=16,共32字节 */ - 0x00, 0x10, 0x1F, 0xF8, 0x11, 0x10, 0x11, 0x10, 0x1F, 0xF0, 0x11, 0x10, 0x11, 0x10, 0x1F, 0xF0, - 0x02, 0x80, 0x04, 0x60, 0x0C, 0x50, 0x34, 0x4E, 0xC4, 0x44, 0x04, 0x40, 0x08, 0x40, 0x10, 0x40, - } - }; - IotFill(BLACK); - for (size_t i = 0; i < sizeof(fonts) / sizeof(fonts[0]); i++) { - IotShowRegion(i * w, 0, w, h, fonts[i], sizeof(fonts[0]), h); - } - IotChangeScreen(); -} - -hi_u16 g_adc_buf[ADC_TEST_LENGTH] = { 0 }; -int g_keyStatus = KEY_EVENT_NONE; -char g_keyFlg = 0; - -int GetKeyEvent(void) -{ - int tmp = g_keyStatus; - g_keyStatus = KEY_EVENT_NONE; - return tmp; -} - -hi_void convert_to_voltage(hi_u32 data_len) -{ - hi_u32 i; - float vltMax = 0; - float vltMin = 100; - float vltVal; - hi_u16 vlt; - for (i = 0; i < data_len; i++) { - vlt = g_adc_buf[i]; - float voltage = (float)vlt * 1.8 * 4 / 4096.0; /* vlt * 1.8 * 4 / 4096.0: Convert code into voltage */ - vltMax = (voltage > vltMax) ? voltage : vltMax; - vltMin = (voltage < vltMin) ? voltage : vltMin; - } - printf("vltMin:%.3f, vltMax:%.3f \n", vltMin, vltMax); - vltVal = (vltMin + vltMax) / TWO; - // 按键1被按下 - if ((vltVal > FOUR) && (vltVal < SIX)) { - if (g_keyFlg == 0) { - g_keyFlg = 1; - g_keyStatus = KEY_EVENT_S1; - } - } - // 按键2被按下 - if ((vltVal > EIGHT) && (vltVal < ONE)) { - if (g_keyFlg == 0) { - g_keyFlg = 1; - g_keyStatus = KEY_EVENT_S2; - } - } - // 没有按键按下 - if (vltVal > THREE) { - g_keyFlg = 0; - g_keyStatus = KEY_EVENT_NONE; - } -} - -void ReadAdc(void) -{ - hi_u32 ret, i; - hi_u16 data; /* 10 */ - printf("ADC Start\n"); - - memset_s(g_adc_buf, sizeof(g_adc_buf), 0x0, sizeof(g_adc_buf)); - - for (i = 0; i < ADC_TEST_LENGTH; i++) { - ret = hi_adc_read((hi_adc_channel_index)HI_ADC_CHANNEL_2, - &data, HI_ADC_EQU_MODEL_1, HI_ADC_CUR_BAIS_DEFAULT, 0); - if (ret != HI_ERR_SUCCESS) { - printf("ADC Read Fail\n"); - return; - } - g_adc_buf[i] = data; - } - convert_to_voltage(ADC_TEST_LENGTH); -} - -static void OLEDTask(void const *arg) -{ - (void)arg; - - // 指定波特率初始化I2C设备 - IoTI2cInit(0, LED_I2C_BARRAGE); - // 初始化 - IotInit(); - - while (1) { - // 读取ADC值 - ReadAdc(); - switch (GetKeyEvent()) { - case KEY_EVENT_NONE: - { - // Clear screen - IotFill(BLACK); - IotChangeScreen(); - } - break; - - case KEY_EVENT_S1: - { - // 清屏 - IotFill(BLACK); - // 设置光标位置 - IotSetCursor(0, 0); - // 显示内容 - IotShowString("**OpenHarmony!**", g_font710, WHITE); - IotChangeScreen(); - usleep(SLEEP_TIME); - } - break; - - case KEY_EVENT_S2: - { - // 显示中文内容 - IotShowChinese(); - usleep(SLEEP_TIME); - } - break; - - default: - { - } - break; - } - // 轮询时间控制 - usleep(CONTROL_TIME); - } -} - -static void OLEDDemo(void) -{ - osThreadAttr_t attr; - - IoTGpioInit(HI_IO_NAME_GPIO_13); - IoTGpioInit(HI_IO_NAME_GPIO_14); - // 将引脚功能设置为I2C引脚 - hi_io_set_func(HI_IO_NAME_GPIO_13, HI_IO_FUNC_GPIO_13_I2C0_SDA); - hi_io_set_func(HI_IO_NAME_GPIO_14, HI_IO_FUNC_GPIO_14_I2C0_SCL); - - attr.name = "OLEDTask"; - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = TASK_STACK_SIZE; - attr.priority = osPriorityNormal; - - if (osThreadNew(OLEDTask, NULL, &attr) == NULL) { - printf("[OLEDDemo] Failed to create OLEDTask!\n"); - } -} -SYS_RUN(OLEDDemo); diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.c" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.c" deleted file mode 100644 index 164a12ce165aaa0aa52dbe9f7726ad387e73a86e..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.c" +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "oled_ssd1306.h" -#include -#include -#include - -#include -#include - -#include "iot_i2c.h" -#include "iot_errno.h" - -#if defined(IOT_USE_I2C) - -#define IOT_I2C_IDX 0 - -#define IOT_CTRL_CMD 0x00 -#define IOT_CTRL_DATA 0x40 -#define IOT_MASK_CONT (0x1<<7) - -void IotReset(void) { -} - -void HalDelay(int32_t ms) -{ - int32_t msPerTick = 1000 / osKernelGetTickFreq(); - if (ms >= msPerTick) { - osDelay(ms / msPerTick); - } - - int32_t restMs = ms % msPerTick; - if (restMs > 0) { - usleep(restMs * ONE_THOUSAND); - } -} - -static int32_t IotSendData(const int8_t* data, size_t size) -{ - int id = IOT_I2C_IDX; - - return IoTI2cWrite(id, IOT_I2C_ADDER, data, size); -} - -static int32_t IotWriteByte(int8_t regAdder, int8_t byte) -{ - int8_t buffer[] = {regAdder, byte}; - return IotSendData(buffer, sizeof(buffer)); -} - -void IotWriteCmd(int8_t byte) -{ - IotWriteByte(IOT_CTRL_CMD, byte); -} - -void IotWriteData(int8_t* buffer, size_t buffSize) -{ - int8_t data[IOT_WIDTH * TWO] = {0}; - for (size_t i = 0; i < buffSize; i++) { - data[i * TWO] = IOT_CTRL_DATA | IOT_MASK_CONT; - data[i * TWO + 1] = buffer[i]; - } - data[(buffSize - 1) * TWO] = IOT_CTRL_DATA; - IotSendData(data, sizeof(data)); -} -#endif - -static int8_t g_iotBuffer[IOT_BUFFER_SIZE]; - -static IotT g_iot; - -IoTErrorT IotFillBuffer(int8_t* buf, int32_t len) -{ - IoTErrorT ret = IOT_ERR; - if (len <= IOT_BUFFER_SIZE) { - memcpy(g_iotBuffer, buf, len); - ret = IOT_OK; - } - return ret; -} - -void IotInit(void) -{ - // 复位 - IotReset(); - - // 等待屏幕启动 - HalDelay(CONTROL_TIME); - - // 初始化 - IotSetDisplayOn(0); - - IotWriteCmd(MEMORY); - IotWriteCmd(HORIZONTAL); - IotWriteCmd(PAGE); - IotWriteCmd(COM); - IotWriteCmd(HORIZONTAL); - IotWriteCmd(HIGH); - IotWriteCmd(LINE); - - // 设置对比度 - IotSetContrast(CONTRAST); - - IotWriteCmd(SEGMENT); - IotWriteCmd(NORMAL); - IotWriteCmd(MULTIPLEX); - IotWriteCmd(SEEMS); - IotWriteCmd(FOLLOWS); - IotWriteCmd(OFFSET); - IotWriteCmd(HORIZONTAL); - IotWriteCmd(FREQUENCY); - IotWriteCmd(RATIO); - IotWriteCmd(PERIOD); - IotWriteCmd(DEOI); - IotWriteCmd(PINS); - IotWriteCmd(HIS); - IotWriteCmd(VCOMH); - IotWriteCmd(VLSD); - IotWriteCmd(DCDC); - IotWriteCmd(XSDL); - IotSetDisplayOn(1); - - // 清除屏幕显示 - IotFill(BLACK); - - // 将更改后的屏幕缓冲区写入屏幕 - IotChangeScreen(); - - // 设置屏幕 - g_iot.currentX = 0; - g_iot.currentY = 0; - - g_iot.initialized = 1; -} - -// 用给定的颜色填充屏幕 -void IotFill(IOT_COLOR color) -{ - int32_t i; - for (i = 0; i < sizeof(g_iotBuffer); i++) { - g_iotBuffer[i] = (color == BLACK) ? HORIZONTAL : CONTRAST; - } -} - -void IotChangeScreen(void) -{ - const unsigned int two = 2; - int8_t cmd[] = { - 0X21, // 设置列起始和结束地址 - 0X00, // 列起始地址 0 - 0X7F, // 列终止地址 127 - 0X22, // 设置页起始和结束地址 - 0X00, // 页起始地址 0 - 0X07, // 页终止地址 7 - }; - int32_t count = 0; - int8_t data[sizeof(cmd) * TWO + IOT_BUFFER_SIZE + 1] = {}; - - for (int32_t i = 0; i < sizeof(cmd) / sizeof(cmd[0]); i++) { - data[count++] = IOT_CTRL_CMD | IOT_MASK_CONT; - data[count++] = cmd[i]; - } - - data[count++] = IOT_CTRL_DATA; - memcpy(&data[count], g_iotBuffer, sizeof(g_iotBuffer)); - count += sizeof(g_iotBuffer); - - int32_t ret = IotSendData(data, count); - if (ret != IOT_SUCCESS) { - printf("IotChangeScreen send frame data filed: %d!\r\n", ret); - } -} - -void IotShowPixel(int8_t x, int8_t y, IOT_COLOR color) -{ - const unsigned int eight = 8; - if (x >= IOT_WIDTH || y >= IOT_HEIGHT) { - return; - } - - if (g_iot.inverted) { - color = (IOT_COLOR)!color; - } - - if (color == WHITE) { - g_iotBuffer[x + (y / eight) * IOT_WIDTH] |= 1 << (y % eight); - } else { - g_iotBuffer[x + (y / eight) * IOT_WIDTH] &= ~(1 << (y % eight)); - } -} - -char IotShowChar(char ch, FontDef font, IOT_COLOR color) -{ - const unsigned int thirtyTwo = 32; - const unsigned int oHAndTwentySix = 126; - int32_t i, b, j; - - if (ch < thirtyTwo || ch > oHAndTwentySix) { - return 0; - } - - if (IOT_WIDTH < (g_iot.currentX + font.fontWidth) || - IOT_HEIGHT < (g_iot.currentY + font.fontHeight)) { - return 0; - } - - for (i = 0; i < font.fontHeight; i++) { - b = font.data[(ch - thirtyTwo) * font.fontHeight + i]; - for (j = 0; j < font.fontWidth; j++) { - if ((b << j) & QES) { - IotShowPixel(g_iot.currentX + j, (g_iot.currentY + i), (IOT_COLOR) color); - } else { - IotShowPixel(g_iot.currentX + j, (g_iot.currentY + i), (IOT_COLOR)!color); - } - } - } - - g_iot.currentX += font.fontWidth; - - return ch; -} - -char IotShowString(char* str, FontDef font, IOT_COLOR color) -{ - - while (*str) { - if (IotShowChar(*str, font, color) != *str) { - return *str; - } - - str++; - } - - return *str; -} - -void IotSetCursor(int8_t x, int8_t y) -{ - g_iot.currentX = x; - g_iot.currentY = y; -} - -void IotShowRegion(int8_t x, int8_t y, int8_t w, int8_t h, const int8_t* data, int32_t size, int32_t stride) -{ - if (x + w > IOT_WIDTH || y + h > IOT_HEIGHT || w * h == 0) { - printf("%dx%d @ %d,%d out of range or invalid!\r\n", w, h, x, y); - return; - } - - w = (w <= IOT_WIDTH ? w : IOT_WIDTH); - h = (h <= IOT_HEIGHT ? h : IOT_HEIGHT); - stride = (stride == 0 ? w : stride); - - int8_t rows = size * 8 / stride; - for (int8_t i = 0; i < rows; i++) { - int32_t base = i * stride / 8; - for (int8_t j = 0; j < w; j++) { - int32_t idx = base + (j / 8); - int8_t byte = idx < size ? data[idx] : 0; - int8_t bit = byte & (0x80 >> (j % 8)); - IotShowPixel(x + j, y + i, bit ? WHITE : BLACK); - } - } -} - -void IotSetContrast(const int8_t value) -{ - const int8_t kSetContrastControlRegister = 0x81; - IotWriteCmd(kSetContrastControlRegister); - IotWriteCmd(value); -} - -void IotSetDisplayOn(const int8_t on) -{ - int8_t value; - if (on) { - value = FSC; - g_iot.displayOn = 1; - } else { - value = FSD; - g_iot.displayOn = 0; - } - IotWriteCmd(value); -} - -int8_t IotGetDisplayOn() -{ - return g_iot.displayOn; -} diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.h" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.h" deleted file mode 100644 index b739077a0bf0b417cd3a5aa41bcbf7b55c6616ea..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306.h" +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2021-2022 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. - */ - - -#ifndef __SSD1306_H__ -#define __SSD1306_H__ - -#include -#include <_ansi.h> - -_BEGIN_STD_C - -#include "oled_ssd1306_conf.h" -#include "oled_ssd1306_fonts.h" - -#define IOT_USE_I2C -#define IOT_I2C_ADDER (0x3C << 1) - -#define ADC_TEST_LENGTH 64 -#define KEY_EVENT_NONE 0 -#define KEY_EVENT_S1 1 -#define KEY_EVENT_S2 2 -#define SLEEP_TIME (3 * 1000 * 1000) -#define CONTROL_TIME 100 -#define ONE_THOUSAND 1000 -#define TWO 2 -#define FOUR 0.4 -#define SIX 0.6 -#define EIGHT 0.8 -#define ONE 1.1 -#define THREE 3.0 -#define SSD1306_I2C_PORT hi2c1 -#define IOT_HEIGHT 64 -#define IOT_WIDTH 128 -#define IOT_BUFFER_SIZE (IOT_WIDTH * IOT_HEIGHT / 8) -#define MEMORY 0x20 -#define HORIZONTAL 0x00 -#define PAGE 0xB0 - -#define COM 0xC8 -#define HIGH 0x10 -#define LINE 0x40 -#define CONTRAST 0xFF - -#define SEGMENT 0xA1 - -#define NORMAL 0xA6 -#define MULTIPLEX 0xA8 -#define SEEMS 0x3F -#define FOLLOWS 0xA4 -#define OFFSET 0xD3 -#define FREQUENCY 0xD5 -#define RATIO 0xF0 -#define PERIOD 0xD9 -#define DEOI 0x11 -#define PINS 0xDA -#define HIS 0x12 -#define VCOMH 0xDB -#define VLSD 0x30 -#define DCDC 0x8D -#define XSDL 0x14 -#define QES 0x8000 -#define FSC 0xAF -#define FSD 0xAE -typedef enum { - BLACK = 0x00, - WHITE = 0x01 -} IOT_COLOR; - -typedef enum { - IOT_OK = 0x00, - IOT_ERR = 0x01 -} IoTErrorT; - -typedef struct { - int16_t currentX; - int16_t currentY; - int8_t inverted; - int8_t initialized; - int8_t displayOn; -} IotT; - -void IotInit(void); -void IotFill(IOT_COLOR color); -void IotSetCursor(int8_t x, int8_t y); -void IotChangeScreen(void); -char IotShowChar(char ch, FontDef font, IOT_COLOR color); -char IotShowString(char* str, FontDef font, IOT_COLOR color); -void IotShowPixel(int8_t x, int8_t y, IOT_COLOR color); -void IotShowRegion(int8_t x, int8_t y, int8_t w, int8_t h, const int8_t* data, int32_t size, int32_t stride); -void IotSetContrast(const int8_t value); -void IotSetDisplayOn(const int8_t on); -int8_t IotGetDisplayOn(void); -void HalDelay(int32_t ms); -void IotReset(void); -void IotWriteCmd(int8_t byte); -void IotWriteData(int8_t* buffer, size_t buffSize); -IoTErrorT IotFillBuffer(int8_t* buf, int32_t len); - -_END_STD_C - -#endif diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_conf.h" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_conf.h" deleted file mode 100644 index c05e81de1d4f028ea6c395ba509e5b06a09709ba..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_conf.h" +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2021-2022 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. - */ - - -#ifndef __SSD1306_CONF_H__ -#define __SSD1306_CONF_H__ - -#define IOT_INCLUDE_FONT_6X8 -#define IOT_INCLUDE_FONT_7X10 -#define IOT_INCLUDE_FONT_11X18 -#define IOT_INCLUDE_FONT_16X26 - -#endif \ No newline at end of file diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.c" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.c" deleted file mode 100644 index a8573ccff799605d5cbeb7f62c6d36eb9c896b16..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.c" +++ /dev/null @@ -1,714 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "oled_ssd1306_fonts.h" -#include "oled_ssd1306_conf.h" - -#ifdef IOT_INCLUDE_FONT_7X10 -static const int16_t g_font7x10 [] = { -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp -0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x1000, 0x0000, 0x0000, // ! -0x2800, 0x2800, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // " -0x2400, 0x2400, 0x7C00, 0x2400, 0x4800, 0x7C00, 0x4800, 0x4800, 0x0000, 0x0000, // # -0x3800, 0x5400, 0x5000, 0x3800, 0x1400, 0x5400, 0x5400, 0x3800, 0x1000, 0x0000, // $ -0x2000, 0x5400, 0x5800, 0x3000, 0x2800, 0x5400, 0x1400, 0x0800, 0x0000, 0x0000, // % -0x1000, 0x2800, 0x2800, 0x1000, 0x3400, 0x4800, 0x4800, 0x3400, 0x0000, 0x0000, // & -0x1000, 0x1000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ' -0x0800, 0x1000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x1000, 0x0800, // ( -0x2000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x1000, 0x2000, // ) -0x1000, 0x3800, 0x1000, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // * -0x0000, 0x0000, 0x1000, 0x1000, 0x7C00, 0x1000, 0x1000, 0x0000, 0x0000, 0x0000, // + -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, // , -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x0000, 0x0000, 0x0000, 0x0000, // - -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, // . -0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, // / -0x3800, 0x4400, 0x4400, 0x5400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 0 -0x1000, 0x3000, 0x5000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // 1 -0x3800, 0x4400, 0x4400, 0x0400, 0x0800, 0x1000, 0x2000, 0x7C00, 0x0000, 0x0000, // 2 -0x3800, 0x4400, 0x0400, 0x1800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 3 -0x0800, 0x1800, 0x2800, 0x2800, 0x4800, 0x7C00, 0x0800, 0x0800, 0x0000, 0x0000, // 4 -0x7C00, 0x4000, 0x4000, 0x7800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 5 -0x3800, 0x4400, 0x4000, 0x7800, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 6 -0x7C00, 0x0400, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, // 7 -0x3800, 0x4400, 0x4400, 0x3800, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // 8 -0x3800, 0x4400, 0x4400, 0x4400, 0x3C00, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // 9 -0x0000, 0x0000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, // : -0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, // ; -0x0000, 0x0000, 0x0C00, 0x3000, 0x4000, 0x3000, 0x0C00, 0x0000, 0x0000, 0x0000, // < -0x0000, 0x0000, 0x0000, 0x7C00, 0x0000, 0x7C00, 0x0000, 0x0000, 0x0000, 0x0000, // = -0x0000, 0x0000, 0x6000, 0x1800, 0x0400, 0x1800, 0x6000, 0x0000, 0x0000, 0x0000, // > -0x3800, 0x4400, 0x0400, 0x0800, 0x1000, 0x1000, 0x0000, 0x1000, 0x0000, 0x0000, // ? -0x3800, 0x4400, 0x4C00, 0x5400, 0x5C00, 0x4000, 0x4000, 0x3800, 0x0000, 0x0000, // @ -0x1000, 0x2800, 0x2800, 0x2800, 0x2800, 0x7C00, 0x4400, 0x4400, 0x0000, 0x0000, // A -0x7800, 0x4400, 0x4400, 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x0000, 0x0000, // B -0x3800, 0x4400, 0x4000, 0x4000, 0x4000, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // C -0x7000, 0x4800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4800, 0x7000, 0x0000, 0x0000, // D -0x7C00, 0x4000, 0x4000, 0x7C00, 0x4000, 0x4000, 0x4000, 0x7C00, 0x0000, 0x0000, // E -0x7C00, 0x4000, 0x4000, 0x7800, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // F -0x3800, 0x4400, 0x4000, 0x4000, 0x5C00, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // G -0x4400, 0x4400, 0x4400, 0x7C00, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // H -0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3800, 0x0000, 0x0000, // I -0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // J -0x4400, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4800, 0x4400, 0x0000, 0x0000, // K -0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7C00, 0x0000, 0x0000, // L -0x4400, 0x6C00, 0x6C00, 0x5400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // M -0x4400, 0x6400, 0x6400, 0x5400, 0x5400, 0x4C00, 0x4C00, 0x4400, 0x0000, 0x0000, // N -0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // O -0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // P -0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x5400, 0x3800, 0x0400, 0x0000, // Q -0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4800, 0x4800, 0x4400, 0x0000, 0x0000, // R -0x3800, 0x4400, 0x4000, 0x3000, 0x0800, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, // S -0x7C00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // T -0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // U -0x4400, 0x4400, 0x4400, 0x2800, 0x2800, 0x2800, 0x1000, 0x1000, 0x0000, 0x0000, // V -0x4400, 0x4400, 0x5400, 0x5400, 0x5400, 0x6C00, 0x2800, 0x2800, 0x0000, 0x0000, // W -0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x2800, 0x2800, 0x4400, 0x0000, 0x0000, // X -0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // Y -0x7C00, 0x0400, 0x0800, 0x1000, 0x1000, 0x2000, 0x4000, 0x7C00, 0x0000, 0x0000, // Z -0x1800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1800, // [ -0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0000, 0x0000, /* \ */ -0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3000, // ] -0x1000, 0x2800, 0x2800, 0x4400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ^ -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFE00, // _ -0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ` -0x0000, 0x0000, 0x3800, 0x4400, 0x3C00, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // a -0x4000, 0x4000, 0x5800, 0x6400, 0x4400, 0x4400, 0x6400, 0x5800, 0x0000, 0x0000, // b -0x0000, 0x0000, 0x3800, 0x4400, 0x4000, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // c -0x0400, 0x0400, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // d -0x0000, 0x0000, 0x3800, 0x4400, 0x7C00, 0x4000, 0x4400, 0x3800, 0x0000, 0x0000, // e -0x0C00, 0x1000, 0x7C00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // f -0x0000, 0x0000, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0400, 0x7800, // g -0x4000, 0x4000, 0x5800, 0x6400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // h -0x1000, 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // i -0x1000, 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0xE000, // j -0x4000, 0x4000, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4400, 0x0000, 0x0000, // k -0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, // l -0x0000, 0x0000, 0x7800, 0x5400, 0x5400, 0x5400, 0x5400, 0x5400, 0x0000, 0x0000, // m -0x0000, 0x0000, 0x5800, 0x6400, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, // n -0x0000, 0x0000, 0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, // o -0x0000, 0x0000, 0x5800, 0x6400, 0x4400, 0x4400, 0x6400, 0x5800, 0x4000, 0x4000, // p -0x0000, 0x0000, 0x3400, 0x4C00, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0400, 0x0400, // q -0x0000, 0x0000, 0x5800, 0x6400, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, // r -0x0000, 0x0000, 0x3800, 0x4400, 0x3000, 0x0800, 0x4400, 0x3800, 0x0000, 0x0000, // s -0x2000, 0x2000, 0x7800, 0x2000, 0x2000, 0x2000, 0x2000, 0x1800, 0x0000, 0x0000, // t -0x0000, 0x0000, 0x4400, 0x4400, 0x4400, 0x4400, 0x4C00, 0x3400, 0x0000, 0x0000, // u -0x0000, 0x0000, 0x4400, 0x4400, 0x2800, 0x2800, 0x2800, 0x1000, 0x0000, 0x0000, // v -0x0000, 0x0000, 0x5400, 0x5400, 0x5400, 0x6C00, 0x2800, 0x2800, 0x0000, 0x0000, // w -0x0000, 0x0000, 0x4400, 0x2800, 0x1000, 0x1000, 0x2800, 0x4400, 0x0000, 0x0000, // x -0x0000, 0x0000, 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, 0x6000, // y -0x0000, 0x0000, 0x7C00, 0x0800, 0x1000, 0x2000, 0x4000, 0x7C00, 0x0000, 0x0000, // z -0x1800, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1800, // { -0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, // | -0x3000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x3000, // } -0x0000, 0x0000, 0x0000, 0x7400, 0x4C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ~ -}; -#endif - -#ifdef IOT_INCLUDE_FONT_11X18 -static const int16_t g_font11x18 [] = { -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp -0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // ! -0x0000, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // " -0x0000, 0x1980, 0x1980, 0x1980, 0x1980, 0x7FC0, 0x7FC0, 0x1980, 0x3300, -0x7FC0, 0x7FC0, 0x3300, 0x3300, 0x3300, 0x3300, 0x0000, 0x0000, 0x0000, // # -0x0000, 0x1E00, 0x3F00, 0x7580, 0x6580, 0x7400, 0x3C00, 0x1E00, 0x0700, -0x0580, 0x6580, 0x6580, 0x7580, 0x3F00, 0x1E00, 0x0400, 0x0400, 0x0000, // $ -0x0000, 0x7000, 0xD800, 0xD840, 0xD8C0, 0xD980, 0x7300, 0x0600, 0x0C00, -0x1B80, 0x36C0, 0x66C0, 0x46C0, 0x06C0, 0x0380, 0x0000, 0x0000, 0x0000, // % -0x0000, 0x1E00, 0x3F00, 0x3300, 0x3300, 0x3300, 0x1E00, 0x0C00, 0x3CC0, -0x66C0, 0x6380, 0x6180, 0x6380, 0x3EC0, 0x1C80, 0x0000, 0x0000, 0x0000, // & -0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ' -0x0080, 0x0100, 0x0300, 0x0600, 0x0600, 0x0400, 0x0C00, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0400, 0x0600, 0x0600, 0x0300, 0x0100, 0x0080, // ( -0x2000, 0x1000, 0x1800, 0x0C00, 0x0C00, 0x0400, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0400, 0x0C00, 0x0C00, 0x1800, 0x1000, 0x2000, // ) -0x0000, 0x0C00, 0x2D00, 0x3F00, 0x1E00, 0x3300, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // * -0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0xFFC0, 0xFFC0, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // + -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0400, 0x0400, 0x0800, // , -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x1E00, 0x1E00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // - -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // . -0x0000, 0x0300, 0x0300, 0x0300, 0x0600, 0x0600, 0x0600, 0x0600, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x1800, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, // / -0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6D80, 0x6D80, -0x6180, 0x6180, 0x6180, 0x3300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 0 -0x0000, 0x0600, 0x0E00, 0x1E00, 0x3600, 0x2600, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // 1 -0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, 0x6180, 0x0180, 0x0300, 0x0600, -0x0C00, 0x1800, 0x3000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // 2 -0x0000, 0x1C00, 0x3E00, 0x6300, 0x6300, 0x0300, 0x0E00, 0x0E00, 0x0300, -0x0180, 0x0180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 3 -0x0000, 0x0600, 0x0E00, 0x0E00, 0x1E00, 0x1E00, 0x1600, 0x3600, 0x3600, -0x6600, 0x7F80, 0x7F80, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // 4 -0x0000, 0x7F00, 0x7F00, 0x6000, 0x6000, 0x6000, 0x6E00, 0x7F00, 0x6380, -0x0180, 0x0180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 5 -0x0000, 0x1E00, 0x3F00, 0x3380, 0x6180, 0x6000, 0x6E00, 0x7F00, 0x7380, -0x6180, 0x6180, 0x6180, 0x3380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 6 -0x0000, 0x7F80, 0x7F80, 0x0180, 0x0300, 0x0300, 0x0600, 0x0600, 0x0C00, -0x0C00, 0x0C00, 0x0800, 0x1800, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, // 7 -0x0000, 0x1E00, 0x3F00, 0x6380, 0x6180, 0x6180, 0x2100, 0x1E00, 0x3F00, -0x6180, 0x6180, 0x6180, 0x6180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 8 -0x0000, 0x1E00, 0x3F00, 0x7300, 0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, -0x1D80, 0x0180, 0x6180, 0x7300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // 9 -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // : -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0C00, 0x0400, 0x0400, 0x0800, // ; -0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0380, 0x0E00, 0x3800, 0x6000, -0x3800, 0x0E00, 0x0380, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // < -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7F80, 0x7F80, 0x0000, 0x0000, -0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // = -0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x7000, 0x1C00, 0x0700, 0x0180, -0x0700, 0x1C00, 0x7000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // > -0x0000, 0x1F00, 0x3F80, 0x71C0, 0x60C0, 0x00C0, 0x01C0, 0x0380, 0x0700, -0x0E00, 0x0C00, 0x0C00, 0x0000, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // ? -0x0000, 0x1E00, 0x3F00, 0x3180, 0x7180, 0x6380, 0x6F80, 0x6D80, 0x6D80, -0x6F80, 0x6780, 0x6000, 0x3200, 0x3E00, 0x1C00, 0x0000, 0x0000, 0x0000, // @ -0x0000, 0x0E00, 0x0E00, 0x1B00, 0x1B00, 0x1B00, 0x1B00, 0x3180, 0x3180, -0x3F80, 0x3F80, 0x3180, 0x60C0, 0x60C0, 0x60C0, 0x0000, 0x0000, 0x0000, // A -0x0000, 0x7C00, 0x7E00, 0x6300, 0x6300, 0x6300, 0x6300, 0x7E00, 0x7E00, -0x6300, 0x6180, 0x6180, 0x6380, 0x7F00, 0x7E00, 0x0000, 0x0000, 0x0000, // B -0x0000, 0x1E00, 0x3F00, 0x3180, 0x6180, 0x6000, 0x6000, 0x6000, 0x6000, -0x6000, 0x6000, 0x6180, 0x3180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // C -0x0000, 0x7C00, 0x7F00, 0x6300, 0x6380, 0x6180, 0x6180, 0x6180, 0x6180, -0x6180, 0x6180, 0x6300, 0x6300, 0x7E00, 0x7C00, 0x0000, 0x0000, 0x0000, // D -0x0000, 0x7F80, 0x7F80, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F00, 0x7F00, -0x6000, 0x6000, 0x6000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // E -0x0000, 0x7F80, 0x7F80, 0x6000, 0x6000, 0x6000, 0x6000, 0x7F00, 0x7F00, -0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, // F -0x0000, 0x1E00, 0x3F00, 0x3180, 0x6180, 0x6000, 0x6000, 0x6000, 0x6380, -0x6380, 0x6180, 0x6180, 0x3180, 0x3F80, 0x1E00, 0x0000, 0x0000, 0x0000, // G -0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x7F80, 0x7F80, -0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // H -0x0000, 0x3F00, 0x3F00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x3F00, 0x3F00, 0x0000, 0x0000, 0x0000, // I -0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, -0x0180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // J -0x0000, 0x60C0, 0x6180, 0x6300, 0x6600, 0x6600, 0x6C00, 0x7800, 0x7C00, -0x6600, 0x6600, 0x6300, 0x6180, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // K -0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, -0x6000, 0x6000, 0x6000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // L -0x0000, 0x71C0, 0x71C0, 0x7BC0, 0x7AC0, 0x6AC0, 0x6AC0, 0x6EC0, 0x64C0, -0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x60C0, 0x0000, 0x0000, 0x0000, // M -0x0000, 0x7180, 0x7180, 0x7980, 0x7980, 0x7980, 0x6D80, 0x6D80, 0x6D80, -0x6580, 0x6780, 0x6780, 0x6780, 0x6380, 0x6380, 0x0000, 0x0000, 0x0000, // N -0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, -0x6180, 0x6180, 0x6180, 0x3300, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // O -0x0000, 0x7E00, 0x7F00, 0x6380, 0x6180, 0x6180, 0x6180, 0x6380, 0x7F00, -0x7E00, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, // P -0x0000, 0x1E00, 0x3F00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, -0x6180, 0x6580, 0x6780, 0x3300, 0x3F80, 0x1E40, 0x0000, 0x0000, 0x0000, // Q -0x0000, 0x7E00, 0x7F00, 0x6380, 0x6180, 0x6180, 0x6380, 0x7F00, 0x7E00, -0x6600, 0x6300, 0x6300, 0x6180, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // R -0x0000, 0x0E00, 0x1F00, 0x3180, 0x3180, 0x3000, 0x3800, 0x1E00, 0x0700, -0x0380, 0x6180, 0x6180, 0x3180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // S -0x0000, 0xFFC0, 0xFFC0, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // T -0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, -0x6180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // U -0x0000, 0x60C0, 0x60C0, 0x60C0, 0x3180, 0x3180, 0x3180, 0x1B00, 0x1B00, -0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0E00, 0x0400, 0x0000, 0x0000, 0x0000, // V -0x0000, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xC0C0, 0xCCC0, 0x4C80, 0x4C80, -0x5E80, 0x5280, 0x5280, 0x7380, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // W -0x0000, 0xC0C0, 0x6080, 0x6180, 0x3300, 0x3B00, 0x1E00, 0x0C00, 0x0C00, -0x1E00, 0x1F00, 0x3B00, 0x7180, 0x6180, 0xC0C0, 0x0000, 0x0000, 0x0000, // X -0x0000, 0xC0C0, 0x6180, 0x6180, 0x3300, 0x3300, 0x1E00, 0x1E00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // Y -0x0000, 0x3F80, 0x3F80, 0x0180, 0x0300, 0x0300, 0x0600, 0x0C00, 0x0C00, -0x1800, 0x1800, 0x3000, 0x6000, 0x7F80, 0x7F80, 0x0000, 0x0000, 0x0000, // Z -0x0F00, 0x0F00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0F00, 0x0F00, // [ -0x0000, 0x1800, 0x1800, 0x1800, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0600, -0x0600, 0x0600, 0x0600, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, 0x0000, /* \ */ -0x1E00, 0x1E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x1E00, 0x1E00, // ] -0x0000, 0x0C00, 0x0C00, 0x1E00, 0x1200, 0x3300, 0x3300, 0x6180, 0x6180, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ^ -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFE0, 0x0000, // _ -0x0000, 0x3800, 0x1800, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ` -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1F00, 0x3F80, 0x6180, 0x0180, -0x1F80, 0x3F80, 0x6180, 0x6380, 0x7F80, 0x38C0, 0x0000, 0x0000, 0x0000, // a -0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6E00, 0x7F00, 0x7380, 0x6180, -0x6180, 0x6180, 0x6180, 0x7380, 0x7F00, 0x6E00, 0x0000, 0x0000, 0x0000, // b -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, -0x6000, 0x6000, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // c -0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x1D80, 0x3F80, 0x7380, 0x6180, -0x6180, 0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0000, 0x0000, 0x0000, // d -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7300, 0x6180, -0x7F80, 0x7F80, 0x6000, 0x7180, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // e -0x0000, 0x07C0, 0x0FC0, 0x0C00, 0x0C00, 0x7F80, 0x7F80, 0x0C00, 0x0C00, -0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, // f -0x0000, 0x0000, 0x0000, 0x0000, 0x1D80, 0x3F80, 0x7380, 0x6180, 0x6180, -0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0180, 0x6380, 0x7F00, 0x3E00, // g -0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6F00, 0x7F80, 0x7180, 0x6180, -0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // h -0x0000, 0x0600, 0x0600, 0x0000, 0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // i -0x0600, 0x0600, 0x0000, 0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x4600, 0x7E00, 0x3C00, // j -0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6180, 0x6300, 0x6600, 0x6C00, -0x7C00, 0x7600, 0x6300, 0x6300, 0x6180, 0x60C0, 0x0000, 0x0000, 0x0000, // k -0x0000, 0x3E00, 0x3E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, // l -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD80, 0xFFC0, 0xCEC0, 0xCCC0, -0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0xCCC0, 0x0000, 0x0000, 0x0000, // m -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6F00, 0x7F80, 0x7180, 0x6180, -0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x0000, 0x0000, 0x0000, // n -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F00, 0x7380, 0x6180, -0x6180, 0x6180, 0x6180, 0x7380, 0x3F00, 0x1E00, 0x0000, 0x0000, 0x0000, // o -0x0000, 0x0000, 0x0000, 0x0000, 0x6E00, 0x7F00, 0x7380, 0x6180, 0x6180, -0x6180, 0x6180, 0x7380, 0x7F00, 0x6E00, 0x6000, 0x6000, 0x6000, 0x6000, // p -0x0000, 0x0000, 0x0000, 0x0000, 0x1D80, 0x3F80, 0x7380, 0x6180, 0x6180, -0x6180, 0x6180, 0x7380, 0x3F80, 0x1D80, 0x0180, 0x0180, 0x0180, 0x0180, // q -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6700, 0x3F80, 0x3900, 0x3000, -0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, // r -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1E00, 0x3F80, 0x6180, 0x6000, -0x7F00, 0x3F80, 0x0180, 0x6180, 0x7F00, 0x1E00, 0x0000, 0x0000, 0x0000, // s -0x0000, 0x0000, 0x0800, 0x1800, 0x1800, 0x7F00, 0x7F00, 0x1800, 0x1800, -0x1800, 0x1800, 0x1800, 0x1800, 0x1F80, 0x0F80, 0x0000, 0x0000, 0x0000, // t -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x6180, 0x6180, 0x6180, -0x6180, 0x6180, 0x6180, 0x6380, 0x7F80, 0x3D80, 0x0000, 0x0000, 0x0000, // u -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x60C0, 0x3180, 0x3180, 0x3180, -0x1B00, 0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0600, 0x0000, 0x0000, 0x0000, // v -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD80, 0xDD80, 0xDD80, 0x5500, -0x5500, 0x5500, 0x7700, 0x7700, 0x2200, 0x2200, 0x0000, 0x0000, 0x0000, // w -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x3300, 0x3300, 0x1E00, -0x0C00, 0x0C00, 0x1E00, 0x3300, 0x3300, 0x6180, 0x0000, 0x0000, 0x0000, // x -0x0000, 0x0000, 0x0000, 0x0000, 0x6180, 0x6180, 0x3180, 0x3300, 0x3300, -0x1B00, 0x1B00, 0x1B00, 0x0E00, 0x0E00, 0x0E00, 0x1C00, 0x7C00, 0x7000, // y -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7FC0, 0x7FC0, 0x0180, 0x0300, -0x0600, 0x0C00, 0x1800, 0x3000, 0x7FC0, 0x7FC0, 0x0000, 0x0000, 0x0000, // z -0x0380, 0x0780, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0E00, 0x1C00, -0x1C00, 0x0E00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0780, 0x0380, // { -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, -0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, // | -0x3800, 0x3C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0E00, 0x0700, -0x0700, 0x0E00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x0C00, 0x3C00, 0x3800, // } -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3880, 0x7F80, -0x4700, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ~ -}; -#endif -#ifdef IOT_INCLUDE_FONT_16X26 -static const int16_t g_font16x26 [] = { -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [ ] -0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C0, -0x03C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, -0x03E0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [!] -0x1E3C, 0x1E3C, 0x1E3C, 0x1E3C, 0x1E3C, 0x1E3C, 0x1E3C, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = ["] -0x01CE, 0x03CE, 0x03DE, 0x039E, 0x039C, 0x079C, 0x3FFF, 0x7FFF, 0x0738, -0x0F38, 0x0F78, 0x0F78, 0x0E78, 0xFFFF, 0xFFFF, 0x1EF0, 0x1CF0, 0x1CE0, -0x3CE0, 0x3DE0, 0x39E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [#] -0x03FC, 0x0FFE, 0x1FEE, 0x1EE0, 0x1EE0, 0x1EE0, 0x1EE0, 0x1FE0, 0x0FE0, -0x07E0, 0x03F0, 0x01FC, 0x01FE, 0x01FE, 0x01FE, 0x01FE, 0x01FE, 0x01FE, -0x3DFE, 0x3FFC, 0x0FF0, 0x01E0, 0x01E0, 0x0000, 0x0000, 0x0000, // Ascii = [$] -0x3E03, 0xF707, 0xE78F, 0xE78E, 0xE39E, 0xE3BC, 0xE7B8, 0xE7F8, 0xF7F0, -0x3FE0, 0x01C0, 0x03FF, 0x07FF, 0x07F3, 0x0FF3, 0x1EF3, 0x3CF3, 0x38F3, -0x78F3, 0xF07F, 0xE03F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [%] -0x07E0, 0x0FF8, 0x0F78, 0x1F78, 0x1F78, 0x1F78, 0x0F78, 0x0FF0, 0x0FE0, -0x1F80, 0x7FC3, 0xFBC3, 0xF3E7, 0xF1F7, 0xF0F7, 0xF0FF, 0xF07F, 0xF83E, -0x7C7F, 0x3FFF, 0x1FEF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [&] -0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C0, 0x01C0, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = ['] -0x003F, 0x007C, 0x01F0, 0x01E0, 0x03C0, 0x07C0, 0x0780, 0x0780, 0x0F80, -0x0F00, 0x0F00, 0x0F00, 0x0F00, 0x0F00, 0x0F00, 0x0F80, 0x0780, 0x0780, -0x07C0, 0x03C0, 0x01E0, 0x01F0, 0x007C, 0x003F, 0x000F, 0x0000, // Ascii = [(] -0x7E00, 0x1F00, 0x07C0, 0x03C0, 0x01E0, 0x01F0, 0x00F0, 0x00F0, 0x00F8, -0x0078, 0x0078, 0x0078, 0x0078, 0x0078, 0x0078, 0x00F8, 0x00F0, 0x00F0, -0x01F0, 0x01E0, 0x03C0, 0x07C0, 0x1F00, 0x7E00, 0x7800, 0x0000, // Ascii = [)] -0x03E0, 0x03C0, 0x01C0, 0x39CE, 0x3FFF, 0x3F7F, 0x0320, 0x0370, 0x07F8, -0x0F78, 0x1F3C, 0x0638, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [*] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01C0, 0x01C0, 0x01C0, -0x01C0, 0x01C0, 0x01C0, 0x01C0, 0xFFFF, 0xFFFF, 0x01C0, 0x01C0, 0x01C0, -0x01C0, 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [+] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x01E0, 0x01E0, 0x01E0, 0x01C0, 0x0380, // Ascii = [, ] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x3FFE, 0x3FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [-] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [.] -0x000F, 0x000F, 0x001E, 0x001E, 0x003C, 0x003C, 0x0078, 0x0078, 0x00F0, -0x00F0, 0x01E0, 0x01E0, 0x03C0, 0x03C0, 0x0780, 0x0780, 0x0F00, 0x0F00, -0x1E00, 0x1E00, 0x3C00, 0x3C00, 0x7800, 0x7800, 0xF000, 0x0000, // Ascii = [/] -0x07F0, 0x0FF8, 0x1F7C, 0x3E3E, 0x3C1E, 0x7C1F, 0x7C1F, 0x780F, 0x780F, -0x780F, 0x780F, 0x780F, 0x780F, 0x780F, 0x7C1F, 0x7C1F, 0x3C1E, 0x3E3E, -0x1F7C, 0x0FF8, 0x07F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [0] -0x00F0, 0x07F0, 0x3FF0, 0x3FF0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, -0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, -0x01F0, 0x3FFF, 0x3FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [1] -0x0FE0, 0x3FF8, 0x3C7C, 0x003C, 0x003E, 0x003E, 0x003E, 0x003C, 0x003C, -0x007C, 0x00F8, 0x01F0, 0x03E0, 0x07C0, 0x0780, 0x0F00, 0x1E00, 0x3E00, -0x3C00, 0x3FFE, 0x3FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [2] -0x0FF0, 0x1FF8, 0x1C7C, 0x003E, 0x003E, 0x003E, 0x003C, 0x003C, 0x00F8, -0x0FF0, 0x0FF8, 0x007C, 0x003E, 0x001E, 0x001E, 0x001E, 0x001E, 0x003E, -0x1C7C, 0x1FF8, 0x1FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [3] -0x0078, 0x00F8, 0x00F8, 0x01F8, 0x03F8, 0x07F8, 0x07F8, 0x0F78, 0x1E78, -0x1E78, 0x3C78, 0x7878, 0x7878, 0xFFFF, 0xFFFF, 0x0078, 0x0078, 0x0078, -0x0078, 0x0078, 0x0078, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [4] -0x1FFC, 0x1FFC, 0x1FFC, 0x1E00, 0x1E00, 0x1E00, 0x1E00, 0x1E00, 0x1FE0, -0x1FF8, 0x00FC, 0x007C, 0x003E, 0x003E, 0x001E, 0x003E, 0x003E, 0x003C, -0x1C7C, 0x1FF8, 0x1FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [5] -0x01FC, 0x07FE, 0x0F8E, 0x1F00, 0x1E00, 0x3E00, 0x3C00, 0x3C00, 0x3DF8, -0x3FFC, 0x7F3E, 0x7E1F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3E0F, 0x1E1F, -0x1F3E, 0x0FFC, 0x03F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [6] -0x3FFF, 0x3FFF, 0x3FFF, 0x000F, 0x001E, 0x001E, 0x003C, 0x0038, 0x0078, -0x00F0, 0x00F0, 0x01E0, 0x01E0, 0x03C0, 0x03C0, 0x0780, 0x0F80, 0x0F80, -0x0F00, 0x1F00, 0x1F00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [7] -0x07F8, 0x0FFC, 0x1F3E, 0x1E1E, 0x3E1E, 0x3E1E, 0x1E1E, 0x1F3C, 0x0FF8, -0x07F0, 0x0FF8, 0x1EFC, 0x3E3E, 0x3C1F, 0x7C1F, 0x7C0F, 0x7C0F, 0x3C1F, -0x3F3E, 0x1FFC, 0x07F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [8] -0x07F0, 0x0FF8, 0x1E7C, 0x3C3E, 0x3C1E, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, -0x3C1F, 0x3E3F, 0x1FFF, 0x07EF, 0x001F, 0x001E, 0x001E, 0x003E, 0x003C, -0x38F8, 0x3FF0, 0x1FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [9] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [:] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x01E0, 0x01E0, 0x01E0, 0x03C0, 0x0380, // Ascii = [;] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003, 0x000F, 0x003F, -0x00FC, 0x03F0, 0x0FC0, 0x3F00, 0xFE00, 0x3F00, 0x0FC0, 0x03F0, 0x00FC, -0x003F, 0x000F, 0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [<] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [=] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE000, 0xF800, 0x7E00, -0x1F80, 0x07E0, 0x01F8, 0x007E, 0x001F, 0x007E, 0x01F8, 0x07E0, 0x1F80, -0x7E00, 0xF800, 0xE000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [>] -0x1FF0, 0x3FFC, 0x383E, 0x381F, 0x381F, 0x001E, 0x001E, 0x003C, 0x0078, -0x00F0, 0x01E0, 0x03C0, 0x03C0, 0x07C0, 0x07C0, 0x0000, 0x0000, 0x0000, -0x07C0, 0x07C0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [?] -0x03F8, 0x0FFE, 0x1F1E, 0x3E0F, 0x3C7F, 0x78FF, 0x79EF, 0x73C7, 0xF3C7, -0xF38F, 0xF38F, 0xF38F, 0xF39F, 0xF39F, 0x73FF, 0x7BFF, 0x79F7, 0x3C00, -0x1F1C, 0x0FFC, 0x03F8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [@] -0x0000, 0x0000, 0x0000, 0x03E0, 0x03E0, 0x07F0, 0x07F0, 0x07F0, 0x0F78, -0x0F78, 0x0E7C, 0x1E3C, 0x1E3C, 0x3C3E, 0x3FFE, 0x3FFF, 0x781F, 0x780F, -0xF00F, 0xF007, 0xF007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [A] -0x0000, 0x0000, 0x0000, 0x3FF8, 0x3FFC, 0x3C3E, 0x3C1E, 0x3C1E, 0x3C1E, -0x3C3E, 0x3C7C, 0x3FF0, 0x3FF8, 0x3C7E, 0x3C1F, 0x3C1F, 0x3C0F, 0x3C0F, -0x3C1F, 0x3FFE, 0x3FF8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [B] -0x0000, 0x0000, 0x0000, 0x01FF, 0x07FF, 0x1F87, 0x3E00, 0x3C00, 0x7C00, -0x7800, 0x7800, 0x7800, 0x7800, 0x7800, 0x7C00, 0x7C00, 0x3E00, 0x3F00, -0x1F83, 0x07FF, 0x01FF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [C] -0x0000, 0x0000, 0x0000, 0x7FF0, 0x7FFC, 0x787E, 0x781F, 0x781F, 0x780F, -0x780F, 0x780F, 0x780F, 0x780F, 0x780F, 0x780F, 0x780F, 0x781F, 0x781E, -0x787E, 0x7FF8, 0x7FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [D] -0x0000, 0x0000, 0x0000, 0x3FFF, 0x3FFF, 0x3E00, 0x3E00, 0x3E00, 0x3E00, -0x3E00, 0x3E00, 0x3FFE, 0x3FFE, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, -0x3E00, 0x3FFF, 0x3FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [E] -0x0000, 0x0000, 0x0000, 0x1FFF, 0x1FFF, 0x1E00, 0x1E00, 0x1E00, 0x1E00, -0x1E00, 0x1E00, 0x1FFF, 0x1FFF, 0x1E00, 0x1E00, 0x1E00, 0x1E00, 0x1E00, -0x1E00, 0x1E00, 0x1E00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [F] -0x0000, 0x0000, 0x0000, 0x03FE, 0x0FFF, 0x1F87, 0x3E00, 0x7C00, 0x7C00, -0x7800, 0xF800, 0xF800, 0xF87F, 0xF87F, 0x780F, 0x7C0F, 0x7C0F, 0x3E0F, -0x1F8F, 0x0FFF, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [G] -0x0000, 0x0000, 0x0000, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, -0x7C1F, 0x7C1F, 0x7FFF, 0x7FFF, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, 0x7C1F, -0x7C1F, 0x7C1F, 0x7C1F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [H] -0x0000, 0x0000, 0x0000, 0x3FFF, 0x3FFF, 0x03E0, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x3FFF, 0x3FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [I] -0x0000, 0x0000, 0x0000, 0x1FFC, 0x1FFC, 0x007C, 0x007C, 0x007C, 0x007C, -0x007C, 0x007C, 0x007C, 0x007C, 0x007C, 0x007C, 0x007C, 0x0078, 0x0078, -0x38F8, 0x3FF0, 0x3FC0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [J] -0x0000, 0x0000, 0x0000, 0x3C1F, 0x3C1E, 0x3C3C, 0x3C78, 0x3CF0, 0x3DE0, -0x3FE0, 0x3FC0, 0x3F80, 0x3FC0, 0x3FE0, 0x3DF0, 0x3CF0, 0x3C78, 0x3C7C, -0x3C3E, 0x3C1F, 0x3C0F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [K] -0x0000, 0x0000, 0x0000, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, -0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, 0x3E00, -0x3E00, 0x3FFF, 0x3FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [L] -0x0000, 0x0000, 0x0000, 0xF81F, 0xFC1F, 0xFC1F, 0xFE3F, 0xFE3F, 0xFE3F, -0xFF7F, 0xFF77, 0xFF77, 0xF7F7, 0xF7E7, 0xF3E7, 0xF3E7, 0xF3C7, 0xF007, -0xF007, 0xF007, 0xF007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [M] -0x0000, 0x0000, 0x0000, 0x7C0F, 0x7C0F, 0x7E0F, 0x7F0F, 0x7F0F, 0x7F8F, -0x7F8F, 0x7FCF, 0x7BEF, 0x79EF, 0x79FF, 0x78FF, 0x78FF, 0x787F, 0x783F, -0x783F, 0x781F, 0x781F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [N] -0x0000, 0x0000, 0x0000, 0x07F0, 0x1FFC, 0x3E3E, 0x7C1F, 0x780F, 0x780F, -0xF80F, 0xF80F, 0xF80F, 0xF80F, 0xF80F, 0xF80F, 0x780F, 0x780F, 0x7C1F, -0x3E3E, 0x1FFC, 0x07F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [O] -0x0000, 0x0000, 0x0000, 0x3FFC, 0x3FFF, 0x3E1F, 0x3E0F, 0x3E0F, 0x3E0F, -0x3E0F, 0x3E1F, 0x3E3F, 0x3FFC, 0x3FF0, 0x3E00, 0x3E00, 0x3E00, 0x3E00, -0x3E00, 0x3E00, 0x3E00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [P] -0x0000, 0x0000, 0x0000, 0x07F0, 0x1FFC, 0x3E3E, 0x7C1F, 0x780F, 0x780F, -0xF80F, 0xF80F, 0xF80F, 0xF80F, 0xF80F, 0xF80F, 0x780F, 0x780F, 0x7C1F, -0x3E3E, 0x1FFC, 0x07F8, 0x007C, 0x003F, 0x000F, 0x0003, 0x0000, // Ascii = [Q] -0x0000, 0x0000, 0x0000, 0x3FF0, 0x3FFC, 0x3C7E, 0x3C3E, 0x3C1E, 0x3C1E, -0x3C3E, 0x3C3C, 0x3CFC, 0x3FF0, 0x3FE0, 0x3DF0, 0x3CF8, 0x3C7C, 0x3C3E, -0x3C1E, 0x3C1F, 0x3C0F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [R] -0x0000, 0x0000, 0x0000, 0x07FC, 0x1FFE, 0x3E0E, 0x3C00, 0x3C00, 0x3C00, -0x3E00, 0x1FC0, 0x0FF8, 0x03FE, 0x007F, 0x001F, 0x000F, 0x000F, 0x201F, -0x3C3E, 0x3FFC, 0x1FF0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [S] -0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x03E0, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [T] -0x0000, 0x0000, 0x0000, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, -0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x7C0F, 0x3C1E, 0x3C1E, -0x3E3E, 0x1FFC, 0x07F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [U] -0x0000, 0x0000, 0x0000, 0xF007, 0xF007, 0xF807, 0x780F, 0x7C0F, 0x3C1E, -0x3C1E, 0x3E1E, 0x1E3C, 0x1F3C, 0x1F78, 0x0F78, 0x0FF8, 0x07F0, 0x07F0, -0x07F0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [V] -0x0000, 0x0000, 0x0000, 0xE003, 0xF003, 0xF003, 0xF007, 0xF3E7, 0xF3E7, -0xF3E7, 0x73E7, 0x7BF7, 0x7FF7, 0x7FFF, 0x7F7F, 0x7F7F, 0x7F7E, 0x3F7E, -0x3E3E, 0x3E3E, 0x3E3E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [W] -0x0000, 0x0000, 0x0000, 0xF807, 0x7C0F, 0x3E1E, 0x3E3E, 0x1F3C, 0x0FF8, -0x07F0, 0x07E0, 0x03E0, 0x03E0, 0x07F0, 0x0FF8, 0x0F7C, 0x1E7C, 0x3C3E, -0x781F, 0x780F, 0xF00F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [X] -0x0000, 0x0000, 0x0000, 0xF807, 0x7807, 0x7C0F, 0x3C1E, 0x3E1E, 0x1F3C, -0x0F78, 0x0FF8, 0x07F0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, -0x03E0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [Y] -0x0000, 0x0000, 0x0000, 0x7FFF, 0x7FFF, 0x000F, 0x001F, 0x003E, 0x007C, -0x00F8, 0x00F0, 0x01E0, 0x03E0, 0x07C0, 0x0F80, 0x0F00, 0x1E00, 0x3E00, -0x7C00, 0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [Z] -0x07FF, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, -0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, -0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x07FF, 0x07FF, 0x0000, // Ascii = [[] -0x7800, 0x7800, 0x3C00, 0x3C00, 0x1E00, 0x1E00, 0x0F00, 0x0F00, 0x0780, -0x0780, 0x03C0, 0x03C0, 0x01E0, 0x01E0, 0x00F0, 0x00F0, 0x0078, 0x0078, -0x003C, 0x003C, 0x001E, 0x001E, 0x000F, 0x000F, 0x0007, 0x0000, // Ascii = [\] -0x7FF0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, -0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, -0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x7FF0, 0x7FF0, 0x0000, // Ascii = []] -0x00C0, 0x01C0, 0x01C0, 0x03E0, 0x03E0, 0x07F0, 0x07F0, 0x0778, 0x0F78, -0x0F38, 0x1E3C, 0x1E3C, 0x3C1E, 0x3C1E, 0x380F, 0x780F, 0x7807, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [^] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, // Ascii = [_] -0x00F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [`] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0FF8, 0x3FFC, 0x3C7C, -0x003E, 0x003E, 0x003E, 0x07FE, 0x1FFE, 0x3E3E, 0x7C3E, 0x783E, 0x7C3E, -0x7C7E, 0x3FFF, 0x1FCF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [a] -0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3DF8, 0x3FFE, 0x3F3E, -0x3E1F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C1F, 0x3C1E, -0x3F3E, 0x3FFC, 0x3BF0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [b] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03FE, 0x0FFF, 0x1F87, -0x3E00, 0x3E00, 0x3C00, 0x7C00, 0x7C00, 0x7C00, 0x3C00, 0x3E00, 0x3E00, -0x1F87, 0x0FFF, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [c] -0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x07FF, 0x1FFF, 0x3E3F, -0x3C1F, 0x7C1F, 0x7C1F, 0x7C1F, 0x781F, 0x781F, 0x7C1F, 0x7C1F, 0x3C3F, -0x3E7F, 0x1FFF, 0x0FDF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [d] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F8, 0x0FFC, 0x1F3E, -0x3E1E, 0x3C1F, 0x7C1F, 0x7FFF, 0x7FFF, 0x7C00, 0x7C00, 0x3C00, 0x3E00, -0x1F07, 0x0FFF, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [e] -0x01FF, 0x03E1, 0x03C0, 0x07C0, 0x07C0, 0x07C0, 0x7FFF, 0x7FFF, 0x07C0, -0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, -0x07C0, 0x07C0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [f] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07EF, 0x1FFF, 0x3E7F, -0x3C1F, 0x7C1F, 0x7C1F, 0x781F, 0x781F, 0x781F, 0x7C1F, 0x7C1F, 0x3C3F, -0x3E7F, 0x1FFF, 0x0FDF, 0x001E, 0x001E, 0x001E, 0x387C, 0x3FF8, // Ascii = [g] -0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3DFC, 0x3FFE, 0x3F9E, -0x3F1F, 0x3E1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, -0x3C1F, 0x3C1F, 0x3C1F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [h] -0x01F0, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x7FE0, 0x7FE0, 0x01E0, -0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, -0x01E0, 0x01E0, 0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [i] -0x00F8, 0x00F8, 0x0000, 0x0000, 0x0000, 0x0000, 0x3FF8, 0x3FF8, 0x00F8, -0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, -0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F0, 0x71F0, 0x7FE0, // Ascii = [j] -0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C1F, 0x3C3E, 0x3C7C, -0x3CF8, 0x3DF0, 0x3DE0, 0x3FC0, 0x3FC0, 0x3FE0, 0x3DF0, 0x3CF8, 0x3C7C, -0x3C3E, 0x3C1F, 0x3C1F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [k] -0x7FF0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, -0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, -0x01F0, 0x01F0, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [l] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF79E, 0xFFFF, 0xFFFF, -0xFFFF, 0xFBE7, 0xF9E7, 0xF1C7, 0xF1C7, 0xF1C7, 0xF1C7, 0xF1C7, 0xF1C7, -0xF1C7, 0xF1C7, 0xF1C7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [m] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3DFC, 0x3FFE, 0x3F9E, -0x3F1F, 0x3E1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, 0x3C1F, -0x3C1F, 0x3C1F, 0x3C1F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [n] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07F0, 0x1FFC, 0x3E3E, -0x3C1F, 0x7C1F, 0x780F, 0x780F, 0x780F, 0x780F, 0x780F, 0x7C1F, 0x3C1F, -0x3E3E, 0x1FFC, 0x07F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [o] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3DF8, 0x3FFE, 0x3F3E, -0x3E1F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C0F, 0x3C1F, 0x3E1E, -0x3F3E, 0x3FFC, 0x3FF8, 0x3C00, 0x3C00, 0x3C00, 0x3C00, 0x3C00, // Ascii = [p] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07EE, 0x1FFE, 0x3E7E, -0x3C1E, 0x7C1E, 0x781E, 0x781E, 0x781E, 0x781E, 0x781E, 0x7C1E, 0x7C3E, -0x3E7E, 0x1FFE, 0x0FDE, 0x001E, 0x001E, 0x001E, 0x001E, 0x001E, // Ascii = [q] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1F7F, 0x1FFF, 0x1FE7, -0x1FC7, 0x1F87, 0x1F00, 0x1F00, 0x1F00, 0x1F00, 0x1F00, 0x1F00, 0x1F00, -0x1F00, 0x1F00, 0x1F00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [r] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07FC, 0x1FFE, 0x1E0E, -0x3E00, 0x3E00, 0x3F00, 0x1FE0, 0x07FC, 0x00FE, 0x003E, 0x001E, 0x001E, -0x3C3E, 0x3FFC, 0x1FF0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [s] -0x0000, 0x0000, 0x0000, 0x0780, 0x0780, 0x0780, 0x7FFF, 0x7FFF, 0x0780, -0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, 0x0780, -0x07C0, 0x03FF, 0x01FF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [t] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3C1E, 0x3C1E, 0x3C1E, -0x3C1E, 0x3C1E, 0x3C1E, 0x3C1E, 0x3C1E, 0x3C1E, 0x3C1E, 0x3C3E, 0x3C7E, -0x3EFE, 0x1FFE, 0x0FDE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [u] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF007, 0x780F, 0x780F, -0x3C1E, 0x3C1E, 0x3E1E, 0x1E3C, 0x1E3C, 0x0F78, 0x0F78, 0x0FF0, 0x07F0, -0x07F0, 0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [v] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF003, 0xF1E3, 0xF3E3, -0xF3E7, 0xF3F7, 0xF3F7, 0x7FF7, 0x7F77, 0x7F7F, 0x7F7F, 0x7F7F, 0x3E3E, -0x3E3E, 0x3E3E, 0x3E3E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [w] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7C0F, 0x3E1E, 0x3E3C, -0x1F3C, 0x0FF8, 0x07F0, 0x07F0, 0x03E0, 0x07F0, 0x07F8, 0x0FF8, 0x1E7C, -0x3E3E, 0x3C1F, 0x781F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [x] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF807, 0x780F, 0x7C0F, -0x3C1E, 0x3C1E, 0x1E3C, 0x1E3C, 0x1F3C, 0x0F78, 0x0FF8, 0x07F0, 0x07F0, -0x03E0, 0x03E0, 0x03C0, 0x03C0, 0x03C0, 0x0780, 0x0F80, 0x7F00, // Ascii = [y] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3FFF, 0x3FFF, 0x001F, -0x003E, 0x007C, 0x00F8, 0x01F0, 0x03E0, 0x07C0, 0x0F80, 0x1F00, 0x1E00, -0x3C00, 0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [z] -0x01FE, 0x03E0, 0x03C0, 0x03C0, 0x03C0, 0x03C0, 0x01E0, 0x01E0, 0x01E0, -0x01C0, 0x03C0, 0x3F80, 0x3F80, 0x03C0, 0x01C0, 0x01E0, 0x01E0, 0x01E0, -0x03C0, 0x03C0, 0x03C0, 0x03C0, 0x03E0, 0x01FE, 0x007E, 0x0000, // Ascii = [{] -0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, -0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, -0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x0000, // Ascii = [|] -0x3FC0, 0x03E0, 0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x01C0, 0x03C0, 0x03C0, -0x01C0, 0x01E0, 0x00FE, 0x00FE, 0x01E0, 0x01C0, 0x03C0, 0x03C0, 0x01C0, -0x01E0, 0x01E0, 0x01E0, 0x01E0, 0x03E0, 0x3FC0, 0x3F00, 0x0000, // Ascii = [}] -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, -0x0000, 0x0000, 0x3F07, 0x7FC7, 0x73E7, 0xF1FF, 0xF07E, 0x0000, 0x0000, -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // Ascii = [~] -}; -#endif -#ifdef IOT_INCLUDE_FONT_6X8 -static const int16_t g_font6x8 [] = { -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp -0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x2000, 0x0000, // ! -0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // " -0x5000, 0x5000, 0xf800, 0x5000, 0xf800, 0x5000, 0x5000, 0x0000, // # -0x2000, 0x7800, 0xa000, 0x7000, 0x2800, 0xf000, 0x2000, 0x0000, // $ -0xc000, 0xc800, 0x1000, 0x2000, 0x4000, 0x9800, 0x1800, 0x0000, // % -0x4000, 0xa000, 0xa000, 0x4000, 0xa800, 0x9000, 0x6800, 0x0000, // & -0x3000, 0x3000, 0x2000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, // ' -0x1000, 0x2000, 0x4000, 0x4000, 0x4000, 0x2000, 0x1000, 0x0000, // ( -0x4000, 0x2000, 0x1000, 0x1000, 0x1000, 0x2000, 0x4000, 0x0000, // ) -0x2000, 0xa800, 0x7000, 0xf800, 0x7000, 0xa800, 0x2000, 0x0000, // * -0x0000, 0x2000, 0x2000, 0xf800, 0x2000, 0x2000, 0x0000, 0x0000, // + -0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x2000, 0x0000, // , -0x0000, 0x0000, 0x0000, 0xf800, 0x0000, 0x0000, 0x0000, 0x0000, // - -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x0000, // . -0x0000, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x0000, 0x0000, // / -0x7000, 0x8800, 0x9800, 0xa800, 0xc800, 0x8800, 0x7000, 0x0000, // 0 -0x2000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, // 1 -0x7000, 0x8800, 0x0800, 0x7000, 0x8000, 0x8000, 0xf800, 0x0000, // 2 -0xf800, 0x0800, 0x1000, 0x3000, 0x0800, 0x8800, 0x7000, 0x0000, // 3 -0x1000, 0x3000, 0x5000, 0x9000, 0xf800, 0x1000, 0x1000, 0x0000, // 4 -0xf800, 0x8000, 0xf000, 0x0800, 0x0800, 0x8800, 0x7000, 0x0000, // 5 -0x3800, 0x4000, 0x8000, 0xf000, 0x8800, 0x8800, 0x7000, 0x0000, // 6 -0xf800, 0x0800, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x0000, // 7 -0x7000, 0x8800, 0x8800, 0x7000, 0x8800, 0x8800, 0x7000, 0x0000, // 8 -0x7000, 0x8800, 0x8800, 0x7800, 0x0800, 0x1000, 0xe000, 0x0000, // 9 -0x0000, 0x0000, 0x2000, 0x0000, 0x2000, 0x0000, 0x0000, 0x0000, // : -0x0000, 0x0000, 0x2000, 0x0000, 0x2000, 0x2000, 0x4000, 0x0000, // ; -0x0800, 0x1000, 0x2000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0000, // < -0x0000, 0x0000, 0xf800, 0x0000, 0xf800, 0x0000, 0x0000, 0x0000, // = -0x4000, 0x2000, 0x1000, 0x0800, 0x1000, 0x2000, 0x4000, 0x0000, // > -0x7000, 0x8800, 0x0800, 0x3000, 0x2000, 0x0000, 0x2000, 0x0000, // ? -0x7000, 0x8800, 0xa800, 0xb800, 0xb000, 0x8000, 0x7800, 0x0000, // @ -0x2000, 0x5000, 0x8800, 0x8800, 0xf800, 0x8800, 0x8800, 0x0000, // A -0xf000, 0x8800, 0x8800, 0xf000, 0x8800, 0x8800, 0xf000, 0x0000, // B -0x7000, 0x8800, 0x8000, 0x8000, 0x8000, 0x8800, 0x7000, 0x0000, // C -0xf000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0xf000, 0x0000, // D -0xf800, 0x8000, 0x8000, 0xf000, 0x8000, 0x8000, 0xf800, 0x0000, // E -0xf800, 0x8000, 0x8000, 0xf000, 0x8000, 0x8000, 0x8000, 0x0000, // F -0x7800, 0x8800, 0x8000, 0x8000, 0x9800, 0x8800, 0x7800, 0x0000, // G -0x8800, 0x8800, 0x8800, 0xf800, 0x8800, 0x8800, 0x8800, 0x0000, // H -0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, // I -0x3800, 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x6000, 0x0000, // J -0x8800, 0x9000, 0xa000, 0xc000, 0xa000, 0x9000, 0x8800, 0x0000, // K -0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xf800, 0x0000, // L -0x8800, 0xd800, 0xa800, 0xa800, 0xa800, 0x8800, 0x8800, 0x0000, // M -0x8800, 0x8800, 0xc800, 0xa800, 0x9800, 0x8800, 0x8800, 0x0000, // N -0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, // O -0xf000, 0x8800, 0x8800, 0xf000, 0x8000, 0x8000, 0x8000, 0x0000, // P -0x7000, 0x8800, 0x8800, 0x8800, 0xa800, 0x9000, 0x6800, 0x0000, // Q -0xf000, 0x8800, 0x8800, 0xf000, 0xa000, 0x9000, 0x8800, 0x0000, // R -0x7000, 0x8800, 0x8000, 0x7000, 0x0800, 0x8800, 0x7000, 0x0000, // S -0xf800, 0xa800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, // T -0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, // U -0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x5000, 0x2000, 0x0000, // V -0x8800, 0x8800, 0x8800, 0xa800, 0xa800, 0xa800, 0x5000, 0x0000, // W -0x8800, 0x8800, 0x5000, 0x2000, 0x5000, 0x8800, 0x8800, 0x0000, // X -0x8800, 0x8800, 0x5000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, // Y -0xf800, 0x0800, 0x1000, 0x7000, 0x4000, 0x8000, 0xf800, 0x0000, // Z -0x7800, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x0000, // [ -0x0000, 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0000, 0x0000, /* \ */ -0x7800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x7800, 0x0000, // ] -0x2000, 0x5000, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ^ -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xf800, 0x0000, // _ -0x6000, 0x6000, 0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, // ` -0x0000, 0x0000, 0x6000, 0x1000, 0x7000, 0x9000, 0x7800, 0x0000, // a -0x8000, 0x8000, 0xb000, 0xc800, 0x8800, 0xc800, 0xb000, 0x0000, // b -0x0000, 0x0000, 0x7000, 0x8800, 0x8000, 0x8800, 0x7000, 0x0000, // c -0x0800, 0x0800, 0x6800, 0x9800, 0x8800, 0x9800, 0x6800, 0x0000, // d -0x0000, 0x0000, 0x7000, 0x8800, 0xf800, 0x8000, 0x7000, 0x0000, // e -0x1000, 0x2800, 0x2000, 0x7000, 0x2000, 0x2000, 0x2000, 0x0000, // f -0x0000, 0x0000, 0x7000, 0x9800, 0x9800, 0x6800, 0x0800, 0x0000, // g -0x8000, 0x8000, 0xb000, 0xc800, 0x8800, 0x8800, 0x8800, 0x0000, // h -0x2000, 0x0000, 0x6000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, // i -0x1000, 0x0000, 0x1000, 0x1000, 0x1000, 0x9000, 0x6000, 0x0000, // j -0x8000, 0x8000, 0x9000, 0xa000, 0xc000, 0xa000, 0x9000, 0x0000, // k -0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, // l -0x0000, 0x0000, 0xd000, 0xa800, 0xa800, 0xa800, 0xa800, 0x0000, // m -0x0000, 0x0000, 0xb000, 0xc800, 0x8800, 0x8800, 0x8800, 0x0000, // n -0x0000, 0x0000, 0x7000, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, // o -0x0000, 0x0000, 0xb000, 0xc800, 0xc800, 0xb000, 0x8000, 0x0000, // p -0x0000, 0x0000, 0x6800, 0x9800, 0x9800, 0x6800, 0x0800, 0x0000, // q -0x0000, 0x0000, 0xb000, 0xc800, 0x8000, 0x8000, 0x8000, 0x0000, // r -0x0000, 0x0000, 0x7800, 0x8000, 0x7000, 0x0800, 0xf000, 0x0000, // s -0x2000, 0x2000, 0xf800, 0x2000, 0x2000, 0x2800, 0x1000, 0x0000, // t -0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x9800, 0x6800, 0x0000, // u -0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x5000, 0x2000, 0x0000, // v -0x0000, 0x0000, 0x8800, 0x8800, 0xa800, 0xa800, 0x5000, 0x0000, // w -0x0000, 0x0000, 0x8800, 0x5000, 0x2000, 0x5000, 0x8800, 0x0000, // x -0x0000, 0x0000, 0x8800, 0x8800, 0x7800, 0x0800, 0x8800, 0x0000, // y -0x0000, 0x0000, 0xf800, 0x1000, 0x2000, 0x4000, 0xf800, 0x0000, // z -0x1000, 0x2000, 0x2000, 0x4000, 0x2000, 0x2000, 0x1000, 0x0000, // { -0x2000, 0x2000, 0x2000, 0x0000, 0x2000, 0x2000, 0x2000, 0x0000, // | -0x4000, 0x2000, 0x2000, 0x1000, 0x2000, 0x2000, 0x4000, 0x0000, // } -0x4000, 0xa800, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // ~ -}; -#endif - -#ifdef IOT_INCLUDE_FONT_6X8 -FontDef g_font68 = {6, 8, g_font6x8}; -#endif -#ifdef IOT_INCLUDE_FONT_7X10 -FontDef g_font710 = {7, 10, g_font7x10}; -#endif -#ifdef IOT_INCLUDE_FONT_11X18 -FontDef g_font1118 = {11, 18, g_font11x18}; -#endif -#ifdef IOT_INCLUDE_FONT_16X26 -FontDef g_font1626 = {16, 26, g_font16x26}; -#endif diff --git "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.h" "b/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.h" deleted file mode 100644 index e5a4c80fbecadf2d64c2f1efa696f97234cbdd81..0000000000000000000000000000000000000000 --- "a/Device/OLED\345\261\217\345\271\225\347\232\204\346\230\276\347\244\272/screen/oled_ssd1306_fonts.h" +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021-2022 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. - */ - -#ifndef __SSD1306_FONTS_H__ -#define __SSD1306_FONTS_H__ - -#include -#include "oled_ssd1306_conf.h" - -typedef struct { - const int8_t fontWidth; - int8_t fontHeight; - const int16_t *data; -} FontDef; - -#ifdef IOT_INCLUDE_FONT_6X8 -extern FontDef g_font68; -#endif -#ifdef IOT_INCLUDE_FONT_7X10 -extern FontDef g_font710; -#endif -#ifdef IOT_INCLUDE_FONT_11X18 -extern FontDef g_font1118; -#endif -#ifdef IOT_INCLUDE_FONT_16X26 -extern FontDef g_font1626; -#endif -#endif diff --git a/Device/RemoteLamp/LICENSE b/Device/RemoteLamp/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - 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. - -Apache License, Version 2.0 -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: -1.You must give any other recipients of the Work or Derivative Works a copy of this License; and -2.You must cause any modified files to carry prominent notices stating that You changed the files; and -3.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 -4.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 \ No newline at end of file diff --git a/Device/RemoteLamp/README.md b/Device/RemoteLamp/README.md deleted file mode 100644 index 0b1576d94f146d749ad3eb25471515b0aad4cdc4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/README.md +++ /dev/null @@ -1,516 +0,0 @@ -# 简介 - -碰一碰特性是HarmonyOS具备的多终端业务协同技术。通过碰一碰的交互方式,可以将手机和全场景设备连接起来。再通过手机端的原子化服务能力,快速完成配网、远程控制。解决了应用与设备之间接续慢、配网复杂、传输难的问题,为用户带来无缝切换的流畅体验。 - -本篇Codelab将指导大家如何开发一个模拟的“远程台灯”案例。在本案例中,通过手机碰一碰NFC标签,可以从HAG获取到关联意图信息。通过获取到的关联意图信息,可以拉起对应的原子化服务。该原子化服务通过调用hilink接口,并结合设备侧代码实现,可以完成开发板与手机间的配网并建立通信通道。完成此步骤后,即可通过手机控制Hi3861开发版中LED灯的开关了。 - -![](figures/zh-cn_image_0000001204651922.png) - -通过该案例,大家将会学会: - -1. 通过碰一碰能力,拉起手机端原子化服务。 - -2. 快速完成手机与设备的配网。 - -3. 通过手机对设备进行控制。 - - >![](C:/Users/lwx1004741/Desktop/codelabs/【南向】远程台灯_1647257863265/public_sys-resources/icon-note.gif) **说明:** - >本指导仅用于个人开发者体验HarmonyOS碰一碰特性,不能作为商用方案进行碰一碰特性的开发和上架。 - - - -# 实物简介 - -- [手机](#section1089827124516) -- [Hi3861开发板](#section284523516592) - -## 手机 - -华为手机,系统版本为HarmonyOS 2.0.0.168及以上,手机具体型号为Mate 40 Pro。将手机上智慧生活基础服务升级至12.0.0.306及以上版本。具体操作步骤如下: - -- 查看“智慧生活基础服务”版本,打开手机“**设置\>应用服务\>应用管理**”,搜索“智慧生活基础服务”。 -- 升级“智慧生活基础服务”,打开手机“智慧生活”App,点击“**我的 \> 设置 \> 检查应用更新**”,更新“智慧生活基础服务”。 - -## Hi3861开发板 - -本样例基于Hi3861开发板开发,请准备Hi3861开发板(HiSpark Wi-Fi IoT智能家居套件)。包含开发板主板、底板和OLED板。 - -![](figures/zh-cn_image_0000001251198061.png) - - - -# HarmonyOS原子化服务开发 - -- [创建工程](#section12221379216) -- [设备配网原子化服务(entry)](#section68895599506) -- [设备控制原子化服务(control)](#section563615917554) - -本案例将要实现“**碰一碰-拉起原子化服务-设备配网-设备控制**”的完整流程,整个流程都要基于手机端的原子化服务实现。开发原子化服务使用的工具为[DevEco Studio 3.0 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta),关于工具配置请查看官方指导文档[搭建开发环境流程](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/installation_process-0000001071425528)。 - -## 创建工程 - -打开创建工程向导界面,选择“Empty Ability”模板创建原子化服务,用于设备配网。 - -![](figures/zh-cn_image_0000001242968117.png) - -在工程配置中,Project type选择“Atomic Service”,并打开“Show in Service Center”选项,点击Finish按钮即可完成创建设备配网原子化服务。 - -![](figures/zh-cn_image_0000001243462191.png) - -在已创建好的“entry”目录上右击,选择“Empty Ability”模板新建一个Module,用于设备控制。 - -![](figures/zh-cn_image_0000001243467707.png) - -在模块配置界面,“Module type”中选择的“Feature”,点击“Next”。 - -![](figures/zh-cn_image_0000001243470703.png) - -配置Module的“Page ability name”,点击“Finish”完成创建。 - -![](figures/zh-cn_image_0000001198345216.png) - -## 设备配网原子化服务(entry) - -配网过程需要依赖hilink的接口,因此首先需要在entry\\build.gradle中加入对hilink的依赖。 - -``` -dependencies { - ... - ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200' -} -``` - -手机碰一碰nfc标签,将会拉起用于配网的原子化服务(entry模块)。在服务的入口MainAbility中,完成了对nfc中的产品信息的读取,以及将“abilityContext”和从意图中获取的“nanSessionId”注册到用于配网的NetConfigAbility中。 - -``` -// 读取产品信息 -Object productInfo = Objects.requireNonNull(intent.getParams()).getParam("productInfo"); -if (productInfo != null) { - productId = (String) productInfo; -} - -// 从intent中读取的nanSessionId用于配网,同时需要将abilityContext和sessionId注册到NetConfigAbility中 -String sessionId = intent.getStringParam("nanSessionId"); -if ("null".equals(sessionId) || "".equals(sessionId)) { - NetConfigAbility.register(this, null); -} else { - NetConfigAbility.register(this, sessionId); -} -``` - -entry模块的主界面在初始化时,会将产品信息和“nanSessionId”在应用中保存传递。 - -``` -onInit() { - this.deviceName = this.$t('strings.device-name'); - this.deviceImg = '/common/images/LED.png'; - getApp(this).Product.productName = this.productName; - getApp(this).Product.productId = this.productId; - getApp(this).ConfigParams.sessionId = this.sessionId; -} -``` - -点击主界面的“配网”按钮,会默认进行配网操作。主要分为5个步骤,均依赖hilink接口实现,具体代码可查看netconfig.js。 - -1. 通过NAN广播服务搜索设备。 - - ``` - getApp(this).NetConfig.discoveryByNAN(scanInfo, (result) => { - if (result.code == 0) { - // 成功发现设备 - } else { - ... - } - }); - ``` - -2. 连接设备。 - - ``` - getApp(this).NetConfig.connectDevice(connectInfo, (result) => { - if (result.code === 0) { - // 设备连接成功 - } else { - ... - } - }); - ``` - -3. 获取wifi信息。 - - ``` - getApp(this).NetConfig.getWifiList((result) => { - if (result.code == 0 && result.data && result.data.length > 0) { - // 获取wifi信息成功 - } else { - ... - } - }); - ``` - -4. 对设备进行网络配置。 - - ``` - getApp(this).NetConfig.configDeviceNet('deviceInfo', 'accountInfo', netConfigInfo, (result) => { - if (result.code == 0) { - // 设备网络配置成功 - } else { - ... - } - }); - ``` - -5. 配网成功,跳转至设备控制模块。 - - ``` - goToControl() { - let target = { - bundleName: 'com.huawei.smartlamp.hmservice', - abilityName: 'com.huawei.smartlamp.ControlMainAbility', - deviceType: 1,// 从本地设备中拉起原子化服务 - data: { - session_id: getApp(this).ConfigParams.deviceInfo.sessionId, - product_id: getApp(this).Product.productId, - product_name: getApp(this).Product.productName - } - } - FeatureAbility.startAbility(target); - app.terminate() - } - ``` - - -## 设备控制原子化服务(control) - -通过control模块控制开发版led灯的开关,依赖hilink的接口发送指令,因此需要在control\\build.gradle添加对应依赖。 - -``` -dependencies { ... implementation(group: 'com.huawei.hilink', name: 'ailifeability', version: '1.0.0.1', ext: 'har')} -``` - -当成功完成设备配网后,手机会自动拉起设备控制原子化服务(control)。在控制服务界面点击开关按钮时,会利用[FeatureAbility模块\(JS端SDK接口\)](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fa-calls-pa-featureability-0000000000617992)的能力,调用PA向开发板发送指令,NetConfigApi由引入的hilink模块提供。 - -``` -private void sendMessage(String message, HashMap tmpMap) { CommonInfo commonInfo = new CommonInfo(); commonInfo.setSessionId(sessionId); HiLog.error(LABEL_LOG, "sessionId " + sessionId); NetConfigApi.getInstance().sendMessage(commonInfo, message, (code, controlMessage, str) -> { ... });} -``` - - - -# Hi3861开发环境准备 - -Hi3861支持多种开发环境的搭建: - -[搭建Windows开发环境](https://device.harmonyos.com/cn/docs/documentation/guide/ide-install-windows-0000001050164976) - -[搭建Windows+Ubuntu混合开发环境](https://device.harmonyos.com/cn/docs/documentation/guide/ide-install-windows-ubuntu-0000001194073744) - -[搭建Ubuntu开发环境](https://device.harmonyos.com/cn/docs/documentation/guide/ide-install-ubuntu-0000001072959308) - -开发者可以根据自身的情况搭建合适的开发环境。 - - - -# 源码下载与编译前准备 - -- [代码下载](#section14279538198) -- [编译前准备](#section10757135291716) - -本案例将使用Ubuntu开发环境,基于OpenHarmony-3.0-LTS源码进行开发。 - -## 代码下载 - -通过repo工具下载OpenHarmony-3.0-LTS的源码: - -``` -repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -## 编译前准备 - -编译前,需要调整OpenHarmony源码,并添加设备侧代码,以实现设备配网与设备控制的功能。 - -修改device/hisilicon/hispark\_pegasus/sdk\_liteos/build/config/usr\_config.mk文件,开启对I2C的支持。 - -``` -CONFIG_I2C_SUPPORT=y -``` - -修改device/hisilicon/hispark\_pegasus/hi3861\_adapter/hals/communication/wifi\_lite/wifiservice/source/wifi\_hotspot.c文件,在EnableHotspot函数中注释如下代码。 - -``` -//if (SetHotspotIpConfig() != WIFI_SUCCESS) { -// return ERROR_WIFI_UNKNOWN; -//} -``` - -修改device/hisilicon/hispark\_pegasus/hi3861\_adapter/hals/communication/wifi\_lite/wifiservice/source/wifi\_device.c文件,在DispatchConnectEvent函数中注释StaSetWifiNetConfig相关代码。 - -``` -//StaSetWifiNetConfig(HI_WIFI_EVT_CONNECTED); -//StaSetWifiNetConfig(HI_WIFI_EVT_DISCONNECTED); -``` - -修改device/hisilicon/hispark\_pegasus/sdk\_liteos/BUILD.gn文件,在deps中添加如下代码。 - -``` -deps = [ - ... - "//build/lite:product", - ] -``` - -修改base/security/huks/interfaces/innerkits/huks\_lite/BUILD.gn文件,注释如下代码。 - -``` -#sources += [ "hks_tmp_client.c" ] -``` - -在OpenHarmony源码的third\_party目录下,添加IoTDA平台SDK。 - -![](figures/zh-cn_image_0000001199628450.png) - -在vendor目录下,添加设备侧代码team\_x。目录结构如下图所示。 - -![](figures/zh-cn_image_0000001244588393.png) - -“common”中主要包含本样例依赖的头文件和类库文件。“smart\_lamp”中则包含了本样例中设备侧的核心代码。“smart\_lamp”目录结构如下图所示。 - -![](figures/zh-cn_image_0000001199961506.png) - -样例入口文件iot\_main.c位于demo\_smartlamp/src目录下,当启动开发板时,会启动入口线程任务。在该任务中,开发板会完成I2C初始化、OLED初始化,进入配网状态并注册网络监听事件。 - -``` -static void *LampTask(const char *arg) -{ - (void)arg; - WINDBG("LampTask Enter! \n"); - LampInit(); - (void)memset_s(&g_lamp, sizeof(g_lamp), 0x00, sizeof(g_lamp)); - - NetCfgRegister(LampNetEventHandler); // 进入配网状态并注册网络监听事件 - LampShowInfo(); // 显示LED初始状态 -} -``` - -配网成功,并成功注册网络监听事件后,手机端每次发送指令,都会触发监听事件,从而对开发板设备上LED灯进行开关控制。 - -``` -static int LampNetEventHandler(NET_EVENT_TYPE event, void *data) -{ - switch (event) { - case NET_EVENT_RECV_DATA: // 接收到网络信息(FA发送的消息) - LampProcessAppMessage((const char *)data, strlen(data)); // 处理对应的信息 - break; - default: - break; - } - return 0; -} -``` - - - -# 编译和烧录 - -- [编译](#section11934651171) -- [烧录](#section17760192112618) - -## 编译 - -进入源码根目录,首次编译,输入编译命令“hb set”。随后在Input code path命令行中键入“.”,指定OpenHarmony工程编译根目录后回车。 - -![](figures/zh-cn_image_0000001244766309.png) - -选择智能台灯“smart\_lamp”并回车,输入“hb build”命令进行编译,屏幕出现:BUILD SUCCESS字样,说明编译成功。 - -![](figures/zh-cn_image_0000001244886861.png) - -## 烧录 - -1. 将编译生成文件下载至本地Windows环境。 - - ![](figures/zh-cn_image_0000001244769357.png) - -2. 将Hi3861通过TypeC数据线与电脑连接。 - -3. 使用Hiburn工具进行烧录: - -点击“Refresh”按钮,更新com端口信息。在“COM”处选择Hi3861开发板对应的COM口。选择编译生成的二进制文件,勾选“Auto burn”,随后点击“connect”按钮。此时点击Hi3861开发板上的“RST”键,进行烧录。 - -![](figures/zh-cn_image_0000001244690955.png) - -查看烧录进度,等待进度跑完,则烧录完成。可点击“Disconnect”断开连接。 - -![](figures/zh-cn_image_0000001244771101.png) - - - -# 源码下载与编译前准备 - -- [代码下载](#section14279538198) -- [编译前准备](#section10757135291716) - -本案例将使用Ubuntu开发环境,基于OpenHarmony-3.0-LTS源码进行开发。 - -## 代码下载 - -通过repo工具下载OpenHarmony-3.0-LTS的源码: - -``` -repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify -repo sync -c -repo forall -c 'git lfs pull' -``` - -## 编译前准备 - -编译前,需要调整OpenHarmony源码,并添加设备侧代码,以实现设备配网与设备控制的功能。 - -修改device/hisilicon/hispark\_pegasus/sdk\_liteos/build/config/usr\_config.mk文件,开启对I2C的支持。 - -``` -CONFIG_I2C_SUPPORT=y -``` - -修改device/hisilicon/hispark\_pegasus/hi3861\_adapter/hals/communication/wifi\_lite/wifiservice/source/wifi\_hotspot.c文件,在EnableHotspot函数中注释如下代码。 - -``` -//if (SetHotspotIpConfig() != WIFI_SUCCESS) { -// return ERROR_WIFI_UNKNOWN; -//} -``` - -修改device/hisilicon/hispark\_pegasus/hi3861\_adapter/hals/communication/wifi\_lite/wifiservice/source/wifi\_device.c文件,在DispatchConnectEvent函数中注释StaSetWifiNetConfig相关代码。 - -``` -//StaSetWifiNetConfig(HI_WIFI_EVT_CONNECTED); -//StaSetWifiNetConfig(HI_WIFI_EVT_DISCONNECTED); -``` - -修改device/hisilicon/hispark\_pegasus/sdk\_liteos/BUILD.gn文件,在deps中添加如下代码。 - -``` -deps = [ - ... - "//build/lite:product", - ] -``` - -修改base/security/huks/interfaces/innerkits/huks\_lite/BUILD.gn文件,注释如下代码。 - -``` -#sources += [ "hks_tmp_client.c" ] -``` - -在OpenHarmony源码的third\_party目录下,添加IoTDA平台SDK。 - -![](figures/zh-cn_image_0000001199628450.png) - -在vendor目录下,添加设备侧代码team\_x。目录结构如下图所示。 - -![](figures/zh-cn_image_0000001244588393.png) - -“common”中主要包含本样例依赖的头文件和类库文件。“smart\_lamp”中则包含了本样例中设备侧的核心代码。“smart\_lamp”目录结构如下图所示。 - -![](figures/zh-cn_image_0000001199961506.png) - -样例入口文件iot\_main.c位于demo\_smartlamp/src目录下,当启动开发板时,会启动入口线程任务。在该任务中,开发板会完成I2C初始化、OLED初始化,进入配网状态并注册网络监听事件。 - -``` -static void *LampTask(const char *arg) -{ - (void)arg; - WINDBG("LampTask Enter! \n"); - LampInit(); - (void)memset_s(&g_lamp, sizeof(g_lamp), 0x00, sizeof(g_lamp)); - - NetCfgRegister(LampNetEventHandler); // 进入配网状态并注册网络监听事件 - LampShowInfo(); // 显示LED初始状态 -} -``` - -配网成功,并成功注册网络监听事件后,手机端每次发送指令,都会触发监听事件,从而对开发板设备上LED灯进行开关控制。 - -``` -static int LampNetEventHandler(NET_EVENT_TYPE event, void *data) -{ - switch (event) { - case NET_EVENT_RECV_DATA: // 接收到网络信息(FA发送的消息) - LampProcessAppMessage((const char *)data, strlen(data)); // 处理对应的信息 - break; - default: - break; - } - return 0; -} -``` - - - -# 编译和烧录 - -- [编译](#section11934651171) -- [烧录](#section17760192112618) - -## 编译 - -进入源码根目录,首次编译,输入编译命令“hb set”。随后在Input code path命令行中键入“.”,指定OpenHarmony工程编译根目录后回车。 - -![](figures/zh-cn_image_0000001244766309.png) - -选择智能台灯“smart\_lamp”并回车,输入“hb build”命令进行编译,屏幕出现:BUILD SUCCESS字样,说明编译成功。 - -![](figures/zh-cn_image_0000001244886861.png) - -## 烧录 - -1. 将编译生成文件下载至本地Windows环境。 - - ![](figures/zh-cn_image_0000001244769357.png) - -2. 将Hi3861通过TypeC数据线与电脑连接。 - -3. 使用Hiburn工具进行烧录: - -点击“Refresh”按钮,更新com端口信息。在“COM”处选择Hi3861开发板对应的COM口。选择编译生成的二进制文件,勾选“Auto burn”,随后点击“connect”按钮。此时点击Hi3861开发板上的“RST”键,进行烧录。 - -![](figures/zh-cn_image_0000001244690955.png) - -查看烧录进度,等待进度跑完,则烧录完成。可点击“Disconnect”断开连接。 - -![](figures/zh-cn_image_0000001244771101.png) - - - -# 设备配网 - -1. 使用应用调测助手App,在NFC标签中写入对应的标签信息,具体请参考[写入NFC标签信息](https://device.harmonyos.com/cn/docs/documentation/guide/onehop-write-nfc-info-0000001205589971)。 - -2. 通过在HAG上配置原子化关联意图,在手机碰一碰NFC标签后,即可获取需要拉取的原子化服务信息,具体请参考[配置服务关联意图](https://device.harmonyos.com/cn/docs/documentation/guide/onehop-configuration-device-tag-0000001159951466)。 - -3. 在手机上安装开发好的原子化服务。注意该项目包含两个模块,签名需要使用项目级签名。 - - ![](figures/zh-cn_image_0000001200179018.png) - - 打开Run \> Edit Configurations, 勾选entry模块下的“Deploy Multi Hap Packages”选项,表示在运行entry模块(设备配网原子化服务)时,同时会在手机中安装control模块(设备控制原子化服务)。 - - ![](figures/zh-cn_image_0000001200179474.png) - -4. 打开手机NFC功能,确认手机已经接入WLAN无线网络。使用手机背部接触NFC标签,手机会弹出以下页面。 - - ![](figures/zh-cn_image_0000001245648483.png) - -5. 点击Hi3861开发板的RST复位按键,点击手机上的配网按钮,即开始手机与开发板的配网过程。配网成功后,手机应用将自动跳转至控制界面,如下图。 - - ![](figures/zh-cn_image_0000001245448023.png) - - - -# 操作体验 - -配网成功后,即可通过手机对Hi3861开发板LED灯进行开关操作。 - -![](figures/smartlamp.gif) - diff --git a/Device/RemoteLamp/RELEASE-NOTES.MD b/Device/RemoteLamp/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/EntryCard/entry/base/snapshot/widget-2x2.png b/Device/RemoteLamp/SmartLamp/EntryCard/entry/base/snapshot/widget-2x2.png deleted file mode 100644 index 16311262261a7a3cb3195a0e6051beeec5e9ece0..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/EntryCard/entry/base/snapshot/widget-2x2.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/build.gradle b/Device/RemoteLamp/SmartLamp/build.gradle deleted file mode 100644 index 924a888a108e0af16c918e3b049937f48089a7bf..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 -ohos { - compileSdkVersion 7 -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - } - dependencies { - classpath 'com.huawei.ohos:hap:3.0.5.2' - classpath 'com.huawei.ohos:decctest:1.2.7.2' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - } -} diff --git a/Device/RemoteLamp/SmartLamp/control/.gitignore b/Device/RemoteLamp/SmartLamp/control/.gitignore deleted file mode 100644 index 7d5b7a94f4dcf381f03ff21f28f8a2494b58023f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/node_modules diff --git a/Device/RemoteLamp/SmartLamp/control/ailife-view/observed/observed.js b/Device/RemoteLamp/SmartLamp/control/ailife-view/observed/observed.js deleted file mode 100644 index 7e2c2c18bade473734e9a3d051058d1e9364d384..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/ailife-view/observed/observed.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -import utils from '../utils/utils.js'; - -const ACTION_MESSAGE_CODE_SUBSCRIBE = 1001; -const ACTION_MESSAGE_CODE_INIT_DEVICE_DATA = 1005; - -export default { - data: { - observers: {}, - timer: null - }, - async subscribeAbility() { - let action = utils.makeAction(ACTION_MESSAGE_CODE_SUBSCRIBE, {}); - const that = this; - await FeatureAbility.subscribeAbilityEvent(action, async function(callbackData) { - let callbackJson; - if (typeof JSON.parse(callbackData) === 'object' && 'data' in JSON.parse(callbackData)) { - callbackJson = JSON.parse(callbackData)['data']; - } else { - callbackJson = JSON.parse(callbackData); - } - for (const key in callbackJson) { - that.notifyObservers(key, callbackJson[key]); - } - }); - action = utils.makeAction(ACTION_MESSAGE_CODE_INIT_DEVICE_DATA, {}); - await FeatureAbility.callAbility(action); - }, - notifyObservers(key, value) { - if (Object.prototype.hasOwnProperty.call(this.data.observers, key)) { - for (let i = 0; i < this.data.observers[key].length; i++) { - this.data.observers[key][i].callback(key, value); - } - } - } -}; diff --git a/Device/RemoteLamp/SmartLamp/control/ailife-view/utils/utils.js b/Device/RemoteLamp/SmartLamp/control/ailife-view/utils/utils.js deleted file mode 100644 index cac9570b66d55c6e2428515dc6065d89e3519885..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/ailife-view/utils/utils.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -export default { - data: { - bundleName: '', - abilityName: '', - abilityType: '' - }, - setActionParam(bundleName, abilityName, abilityType) { - this.bundleName = bundleName; - this.abilityName = abilityName; - this.abilityType = abilityType; - }, - makeAction(code, data) { - const action = {}; - action.bundleName = this.bundleName; - action.abilityName = this.abilityName; - action.messageCode = code; - action.abilityType = this.abilityType; - action.data = data; - return action; - } -}; \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/build.gradle b/Device/RemoteLamp/SmartLamp/control/build.gradle deleted file mode 100644 index f917a7908e3ebf5ca59a77b805697da31ebc9265..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 -ohos { - compileSdkVersion 7 - defaultConfig { - compatibleSdkVersion 6 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - entryModules "entry" -} - -dependencies { - entryImplementation project(':entry') - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13.1' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200' - implementation(group: 'com.huawei.hilink', name: 'ailifeability', version: '1.0.0.1', ext: 'har') -} -decc { - supportType = ['html','xml'] -} diff --git a/Device/RemoteLamp/SmartLamp/control/package.json b/Device/RemoteLamp/SmartLamp/control/package.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/Device/RemoteLamp/SmartLamp/control/proguard-rules.pro b/Device/RemoteLamp/SmartLamp/control/proguard-rules.pro deleted file mode 100644 index f7666e47561d514b2a76d5a7dfbb43ede86da92a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ -# config module specific ProGuard rules here. \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/config.json b/Device/RemoteLamp/SmartLamp/control/src/main/config.json deleted file mode 100644 index 1989bf7f70174f522ef7267c055712b02d3eca39..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.smartlamp.hmservice", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.smartlamp", - "name": ".MyApplication", - "mainAbility": "com.huawei.smartlamp.ControlMainAbility", - "reqPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ], - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "control", - "moduleType": "feature", - "installationFree": true - }, - "abilities": [ - { - "visible": true, - "name": "com.huawei.smartlamp.ControlMainAbility", - "icon": "$media:icon", - "description": "$string:controlmainability_description", - "label": "$string:control_ControlMainAbility", - "type": "page", - "launchType": "singleton", - "orientation": "portrait" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ] - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/BaseDeviceDataHandler.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/BaseDeviceDataHandler.java deleted file mode 100644 index a34ed7a75f235b10301ea0f1196ccac39481fc38..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/BaseDeviceDataHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import java.util.Map; - -/** - * BaseDeviceDataHandler - * - * @since 2022-01-19 - */ -public abstract class BaseDeviceDataHandler { - // the id of device - String deviceId; - - // used to send data - private final DeviceDataCallback deviceDataCallback; - - BaseDeviceDataHandler(String deviceId, DeviceDataCallback deviceDataCallback) { - this.deviceId = deviceId; - this.deviceDataCallback = deviceDataCallback; - } - - /** - * init profile data when first connecting device - * - * @param dataMap the data to send - */ - final void initProfileData(Map dataMap) { - this.deviceDataCallback.onResult(0, "", dataMap); - } - - /** - * modify device property from UI - * - * @param key key of data - * @param value value of data - */ - public abstract void modifyDeviceProperty(String key, Object value); - - /** - * data changed from device - * - * @param dataMap the data to send - */ - void onDeviceDataChange(Map dataMap) { - this.deviceDataCallback.onResult(0, "", dataMap); - } - - abstract void getData(); -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/ControlMainAbility.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/ControlMainAbility.java deleted file mode 100644 index 6edc46738d4805da07f360fafff705f5206d5d9b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/ControlMainAbility.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; -import ohos.utils.zson.ZSONObject; - -/** - * ControlMainAbility - * - * @since 2022-01-19 - */ -public class ControlMainAbility extends AceAbility { - private static final String START_PARAMS = "__startParams"; - private static final String SESSION_ID = "session_id"; - private static final String FA_DEVICE_ID = "device_id"; - - @Override - public void onStart(Intent intent) { - if (intent.getParams().keySet().contains(START_PARAMS)) { - ZSONObject zsonObject = ZSONObject.stringToZSON((String) intent.getParams().getParam(START_PARAMS)); - String sessionId = zsonObject.getString(SESSION_ID); - NetworkDeviceDataHandler.setSessionId(sessionId); - } - intent.setParam("window_modal", 1); - - String deviceId = intent.getStringParam(FA_DEVICE_ID); - - DataHandlerAbility.register(deviceId); - super.onStart(intent); - } -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DataHandlerAbility.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DataHandlerAbility.java deleted file mode 100644 index cff52067c29fee2b8057272d6d8d241d933a4b7a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DataHandlerAbility.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import ohos.ace.ability.AceInternalAbility; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.rpc.IRemoteObject; -import ohos.rpc.MessageOption; -import ohos.rpc.MessageParcel; -import ohos.rpc.RemoteException; -import ohos.utils.zson.ZSONObject; - -import java.util.Map; - -/** - * DataHandlerAbility - * - * @since 2022-01-19 - */ -public class DataHandlerAbility extends AceInternalAbility { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(HiLog.DEBUG, 0, "DataHandlerAbility"); - private static final String BUNDLE_NAME = "com.huawei.smartlamp.hmservice"; - private static final String ABILITY_NAME = "com.huawei.smartlamp.DataHandlerAbility"; - private static final int ACTION_MESSAGE_CODE_SUBSCRIBE = 1001; - private static final int ACTION_MESSAGE_CODE_DATA_CHANGED = 1004; - private static final int ACTION_MESSAGE_CODE_INIT_DEVICE_DATA = 1005; - private final String deviceId; - private IRemoteObject remoteObjectHandler; - private final DeviceDataCallback deviceDataCallback = new DeviceDataCallback() { - /** - * onResult - * - * @param code errorCode - * @param msg errorMessage - * @param map the data to send - */ - public void onResult(int code, String msg, Map map) { - HiLog.info(LABEL_LOG, "send device data to js: " + map.toString()); - sendData(map); - } - }; - private BaseDeviceDataHandler deviceDataHandler; - - /** - * IDataHandlerAbility. - * - * @param deviceId device id - */ - public DataHandlerAbility(String deviceId) { - super(BUNDLE_NAME, ABILITY_NAME); - this.deviceId = deviceId; - } - - /** - * Internal ability registration. - * - * @param deviceId device id - */ - public static synchronized void register(String deviceId) { - DataHandlerAbility instance = new DataHandlerAbility(deviceId); - instance.onRegister(); - } - - private BaseDeviceDataHandler getDeviceDataHandler() { - return new NetworkDeviceDataHandler(deviceId, deviceDataCallback); - } - - private void sendData(Map dataMap) { - MessageParcel data = MessageParcel.obtain(); - MessageParcel reply = MessageParcel.obtain(); - MessageOption option = new MessageOption(); - data.writeString(ZSONObject.toZSONString(dataMap)); - try { - remoteObjectHandler.sendRequest(0, data, reply, option); - } catch (RemoteException e) { - HiLog.error(LABEL_LOG, "failed to send data to js"); - } - reply.reclaim(); - data.reclaim(); - } - - private boolean onRemoteRequest(int code, MessageParcel data, MessageParcel reply) { - switch (code) { - case ACTION_MESSAGE_CODE_SUBSCRIBE: { - HiLog.info(LABEL_LOG, "ACTION_MESSAGE_CODE_SUBSCRIBE"); - remoteObjectHandler = data.readRemoteObject(); - break; - } - case ACTION_MESSAGE_CODE_INIT_DEVICE_DATA: { - if (deviceDataHandler == null) { - deviceDataHandler = getDeviceDataHandler(); - } - break; - } - case ACTION_MESSAGE_CODE_DATA_CHANGED: { - String zsonStr = data.readString(); - ZSONObject zsonObj = ZSONObject.stringToZSON(zsonStr); - for (Map.Entry entry : zsonObj.entrySet()) { - deviceDataHandler.modifyDeviceProperty(entry.getKey(), entry.getValue()); - } - break; - } - default: { - reply.writeString("service not defined"); - return false; - } - } - return true; - } - - private void onRegister() { - this.setInternalAbilityHandler((code, data, reply, option) -> this.onRemoteRequest(code, data, reply)); - } -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DeviceDataCallback.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DeviceDataCallback.java deleted file mode 100644 index 8ff17d83652cc6d5ecb24424aaa5c96326339428..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/DeviceDataCallback.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import java.util.Map; - -/** - * DeviceDataCallback - * - * @since 2022-01-19 - */ -public interface DeviceDataCallback { - /** - * onResult - * - * @param errorCode errorCode - * @param errorMessage errorMessage - * @param dataMap dataMap - */ - void onResult(int errorCode, String errorMessage, Map dataMap); -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/MyApplication.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/MyApplication.java deleted file mode 100644 index ec75dccb85de7c81a07c80e7d3835af577d3f030..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2022-01-19 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/NetworkDeviceDataHandler.java b/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/NetworkDeviceDataHandler.java deleted file mode 100644 index d5c31ab59ac82262724237c5e031d8899cb8eefd..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/java/com/huawei/smartlamp/NetworkDeviceDataHandler.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import com.huawei.ailifeability.netconfig.api.NetConfigApi; -import com.huawei.ailifeability.netconfig.model.CommonInfo; - -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -import java.util.HashMap; -import java.util.Map; - -/** - * NetworkDeviceDataHandler - * - * @since 2022-01-19 - */ -public class NetworkDeviceDataHandler extends BaseDeviceDataHandler { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(HiLog.DEBUG, 0, "MessageDataHandler"); - private static String sessionId = null; - private final DeviceDataModel dataModel; - private final EventHandler mainHandler; - private final Map dataMap = new HashMap<>(1); - - NetworkDeviceDataHandler(String deviceId, DeviceDataCallback deviceDataCallback) { - super(deviceId, deviceDataCallback); - dataModel = new DeviceDataModel() { - @Override - public Map recoverData() { - dataMap.put("switch/on", 0); - return dataMap; - } - - @Override - public void modifyProperty(String key, Object value) { - Map tmpMap = new HashMap<>(1); - tmpMap.put(key, value); - extracted(key, (int) value, tmpMap); - } - }; - mainHandler = new EventHandler(EventRunner.getMainEventRunner()); - mainHandler.postTask(() -> initProfileData(dataModel.recoverData())); - } - - private void extracted(String key, int value, Map tmpMap) { - if ("switch/on".equals(key)) { - if (value == 0) { - sendMessage("010000", tmpMap); - tmpMap.put("shutdown/mode", 0); - } else { - sendMessage("010100", tmpMap); - } - } - } - - public static void setSessionId(String id) { - sessionId = id; - } - - private void sendMessage(String message, Map tmpMap) { - CommonInfo commonInfo = new CommonInfo(); - commonInfo.setSessionId(sessionId); - HiLog.error(LABEL_LOG, "sessionId " + sessionId); - NetConfigApi.getInstance().sendMessage(commonInfo, message, (code, controlMessage, str) -> { - if (code == 0) { - HiLog.info(LABEL_LOG, "send message success " + message); - dataMap.putAll(tmpMap); - mainHandler.postTask(() -> onDeviceDataChange(dataMap)); - } else { - HiLog.error(LABEL_LOG, "send message fail code = " - + code + " control message = " + controlMessage); - } - }); - } - - @Override - public void modifyDeviceProperty(String key, Object value) { - dataModel.modifyProperty(key, value); - } - - @Override - void getData() { - onDeviceDataChange(dataMap); - } - - /** - * DeviceDataModel - * - * @since 2022-01-19 - */ - private interface DeviceDataModel { - Map recoverData(); - - void modifyProperty(String key, Object value); - } -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/app.js b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/app.js deleted file mode 100644 index 022329245916cde7238f1c93d067918a1d099610..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/app.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -export default { - onCreate() { - }, - onDestroy() { - } -}; diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/LED.png b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/LED.png deleted file mode 100644 index 6e017c183ca3ac3e0131d9da41aa684548c4a197..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/LED.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_off.png b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_off.png deleted file mode 100644 index d1f92fec9057fc5af16c195748efc2556fc054c6..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_off.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_on.png b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_on.png deleted file mode 100644 index 9788f117ff6f9933fbca996748202013e2e33841..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/ic_on.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/logo.png b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/logo.png deleted file mode 100644 index 110d9a5a8cf6886ee0549c2bf6ef8de76b07e6df..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/common/images/logo.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/en-US.json b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/zh-CN.json b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.css b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.css deleted file mode 100644 index b27c205f40b1cd6dbc24dd1e58ec2132d045dc97..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,58 +0,0 @@ -.container { - flex-direction: column; - align-items: center; - padding-left: 12px; - padding-right: 12px; - background-color: #F1F3F5; -} - -.device-info { - flex-direction: column; - align-items: center; -} - -.device-image { - width: 262px; - height: 262px; -} - -.device-logo { - height: 10px; - width: 80px; - margin-top: 4px; - margin-bottom: 20px; -} - -.center-container { - align-items: center; - flex-direction: column; -} -.high-reverse-bar { - flex-direction: row; - border-radius: 16px; - margin: 4px; - height: 88px; - width: 100%; -} - -.high-left-item { - margin-left: 16px; - margin-right: 16px; - height: 100%; - left: 0px; - position: absolute; -} - -.power-text { - height: 100%; - text-align: center; -} - -.high-icon { - right: 4px; - width: 72px; - height: 72px; - margin-top: 8px; - padding: 0px; - position: absolute; -} diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.hml b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.hml deleted file mode 100644 index b7082a276a945718842cd70f90045925ec417ca0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,36 +0,0 @@ - -
-
- -
- -
-
-
-
-
- 开启 -
- -
-
-
- 关闭 -
- -
-
-
\ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.js b/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.js deleted file mode 100644 index e35d8c7eab4999af9be306987b7e45c408a9a09e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -// utils is a utility js that contains some common methods to handle data. -import utils from '../../../../../../ailife-view/utils/utils.js'; -// observed is used to handle data interactions between the JS and Java and used for event notification. -import observed from '../../../../../../ailife-view/observed/observed.js'; - -const ABILITY_TYPE_INTERNAL = 1; -const ACTION_MESSAGE_CODE_DATACHANGED = 1004; - -export default { - data: { - controlData: {}, - imageSrc: '', - logoSrc: '', - isLightOn: true, - deviceName: '' - }, - onInit() { - utils.setActionParam('com.huawei.smartlamp.hmservice', - 'com.huawei.smartlamp.DataHandlerAbility', ABILITY_TYPE_INTERNAL); - }, - async onShow() { - this.deviceName = '智能灯控'; - this.imageSrc = '/common/images/LED.png'; - this.logoSrc = '/common/images/logo.png'; - await observed.subscribeAbility(); - }, - async reverseIconClick() { - const data = {}; - if (this.isLightOn) { - data['switch/on'] = 0; - this.isLightOn = false; - } else { - data['switch/on'] = 1; - this.isLightOn = true; - } - const action = utils.makeAction(ACTION_MESSAGE_CODE_DATACHANGED, data); - await FeatureAbility.callAbility(action); - } -}; diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/element/string.json b/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/element/string.json deleted file mode 100644 index 4168bb33e7faf1693893641bc1fa407c7928555b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "control_ControlMainAbility", - "value": "control_ControlMainAbility" - }, - { - "name": "controlmainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/media/icon.png b/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/control/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/entry/build.gradle b/Device/RemoteLamp/SmartLamp/entry/build.gradle deleted file mode 100644 index de2b3550b6b73c83cbb67c81bffbca08cbd86235..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 -ohos { - compileSdkVersion 7 - defaultConfig { - compatibleSdkVersion 6 - } - showInServiceCenter true - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13.1' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200' - implementation(group: 'com.huawei.hilink', name: 'ailifeability', version: '1.0.0.1', ext: 'har') -} -decc { - supportType = ['html','xml'] -} diff --git a/Device/RemoteLamp/SmartLamp/entry/package.json b/Device/RemoteLamp/SmartLamp/entry/package.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/Device/RemoteLamp/SmartLamp/entry/proguard-rules.pro b/Device/RemoteLamp/SmartLamp/entry/proguard-rules.pro deleted file mode 100644 index f7666e47561d514b2a76d5a7dfbb43ede86da92a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ -# config module specific ProGuard rules here. \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/config.json b/Device/RemoteLamp/SmartLamp/entry/src/main/config.json deleted file mode 100644 index 2cc62f4ed6bd882bbf39e3556b3ad2f2fdfc4ff2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/config.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.smartlamp.hmservice", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.smartlamp", - "name": ".MyApplication", - "mainAbility": "com.huawei.smartlamp.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "portrait", - "visible": true, - "name": "com.huawei.smartlamp.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "formsEnabled": true, - "label": "$string:entry_MainAbility", - "type": "page", - "forms": [ - { - "jsComponentName": "widget", - "isDefault": true, - "scheduledUpdateTime": "10:30", - "defaultDimension": "2*2", - "name": "widget", - "description": "This is a service widget", - "colorMode": "auto", - "type": "JS", - "supportDimensions": [ - "2*2" - ], - "updateEnabled": true, - "updateDuration": 1 - } - ], - "launchType": "singleton" - } - ], - "js": [ - { - "pages": [ - "pages/index/index", - "pages/netconfig/netconfig" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - }, - { - "pages": [ - "pages/index/index" - ], - "name": "widget", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "type": "form" - } - ] - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MainAbility.java b/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MainAbility.java deleted file mode 100644 index 773abfd6a7d1a69cfe1b31c973f0a9d38b00a1f5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MainAbility.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import com.huawei.ailifeability.NetConfigAbility; -import com.huawei.smartlamp.widget.controller.FormController; -import com.huawei.smartlamp.widget.controller.FormControllerManager; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.ability.ProviderFormInfo; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.IntentParams; -import ohos.ace.ability.AceAbility; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -import java.util.Objects; - -/** - * MainAbility - * - * @since 2022-01-19 - */ -public class MainAbility extends AceAbility { - /** - * 默认尺寸 - */ - public static final int DEFAULT_DIMENSION_2X2 = 2; - private static final int HALF_MODEL = 3; - private static final String DEFAULT_MODULE = "default"; - private static final String JS_MODULE = DEFAULT_MODULE; - private static final int INVALID_FORM_ID = -1; - private static final HiLogLabel TAG = new HiLogLabel(HiLog.DEBUG, 0x0, MainAbility.class.getName()); - private static String productId; - private String topWidgetSlice; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - intent.setParam("window_modal", HALF_MODEL); // 1: 半模态(窄), 2: 全屏, 3: 半模态(宽) - setInstanceName(JS_MODULE); - - // 读取产品信息 - Object productInfo = Objects.requireNonNull(intent.getParams()).getParam("productInfo"); - if (productInfo != null) { - productId = (String) productInfo; - } - - // 从intent中读取的nanSessionId用于配网,同时需要将abilityContext和sessionId注册到NetConfigAbility中 - String sessionId = intent.getStringParam("nanSessionId"); - HiLog.info(TAG, "[smart_lamp] MainAbility sessionId: " + sessionId); - if ("null".equals(sessionId) || "".equals(sessionId)) { - NetConfigAbility.register(this, null); - } else { - NetConfigAbility.register(this, sessionId); - } - - IntentParams intentParams = intent.getParams(); - if (intentParams != null) { - intentParams.setParam("productId", productId); - intentParams.setParam("productName", "LED"); - intentParams.setParam("sessionId", sessionId); - setPageParams(null, intentParams); - } - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } - - @Override - protected ProviderFormInfo onCreateForm(Intent intent) { - HiLog.info(TAG, "onCreateForm"); - long formId = intent.getLongParam(AbilitySlice.PARAM_FORM_IDENTITY_KEY, INVALID_FORM_ID); - String formName = intent.getStringParam(AbilitySlice.PARAM_FORM_NAME_KEY); - int dimension = intent.getIntParam(AbilitySlice.PARAM_FORM_DIMENSION_KEY, DEFAULT_DIMENSION_2X2); - HiLog.info(TAG, "onCreateForm: formId=" + formId + ",formName=" + formName); - FormControllerManager formControllerManager = FormControllerManager.getInstance(this); - FormController formController = formControllerManager.getController(formId); - formController = (formController == null) ? formControllerManager.createFormController(formId, - formName, dimension) : formController; - if (formController == null) { - HiLog.error(TAG, "Get null controller. formId: " + formId + ", formName: " + formName); - return null; - } - return formController.bindFormData(formId); - } - - @Override - protected void onUpdateForm(long formId) { - HiLog.info(TAG, "onUpdateForm"); - super.onUpdateForm(formId); - FormControllerManager formControllerManager = FormControllerManager.getInstance(this); - FormController formController = formControllerManager.getController(formId); - formController.onUpdateFormData(formId); - } - - @Override - protected void onDeleteForm(long formId) { - HiLog.info(TAG, "onDeleteForm: formId=" + formId); - super.onDeleteForm(formId); - FormControllerManager formControllerManager = FormControllerManager.getInstance(this); - FormController formController = formControllerManager.getController(formId); - formController.onDeleteForm(formId); - formControllerManager.deleteFormController(formId); - } - - @Override - protected void onTriggerFormEvent(long formId, String message) { - HiLog.info(TAG, "onTriggerFormEvent: " + message); - super.onTriggerFormEvent(formId, message); - FormControllerManager formControllerManager = FormControllerManager.getInstance(this); - FormController formController = formControllerManager.getController(formId); - formController.onTriggerFormEvent(formId, message); - } - - @Override - public void onNewIntent(Intent intent) { - // Only response to it when starting from a service widget. - if (intentFromWidget(intent)) { - String newWidgetSlice = getRoutePageSlice(intent); - if (topWidgetSlice == null || !topWidgetSlice.equals(newWidgetSlice)) { - topWidgetSlice = newWidgetSlice; - restart(); - } - } else { - if (topWidgetSlice != null) { - topWidgetSlice = null; - restart(); - } - } - } - - private boolean intentFromWidget(Intent intent) { - long formId = intent.getLongParam(AbilitySlice.PARAM_FORM_IDENTITY_KEY, INVALID_FORM_ID); - return formId != INVALID_FORM_ID; - } - - private String getRoutePageSlice(Intent intent) { - long formId = intent.getLongParam(AbilitySlice.PARAM_FORM_IDENTITY_KEY, INVALID_FORM_ID); - if (formId == INVALID_FORM_ID) { - return null; - } - FormControllerManager formControllerManager = FormControllerManager.getInstance(this); - FormController formController = formControllerManager.getController(formId); - if (formController == null) { - return null; - } - Class clazz = formController.getRoutePageSlice(intent); - if (clazz == null) { - return null; - } - return clazz.getName(); - } -} diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MyApplication.java b/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MyApplication.java deleted file mode 100644 index 509383e4fe8c6c40a644665dd71f026d6e6600bf..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/MyApplication.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp; - -import com.huawei.ailifeability.NetConfigAbility; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2022-01-19 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } - - @Override - public void onEnd() { - super.onEnd(); - NetConfigAbility.deregister(); - } -} diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormController.java b/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormController.java deleted file mode 100644 index ecfa337694a5da2940b36496be36908f2f1d0783..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormController.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp.widget.controller; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.ability.ProviderFormInfo; -import ohos.aafwk.content.Intent; -import ohos.app.Context; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * FormController - * - * @since 2022-01-19 - */ -public abstract class FormController { - private static final HiLogLabel TAG = new HiLogLabel(HiLog.DEBUG, 0x0, FormController.class.getName()); - /** - * Context of ability - */ - protected final Context context; - - /** - * The name of current form service widget - */ - protected final String formName; - - /** - * The dimension of current form service widget - */ - protected final int dimension; - - /** - * Bind data for a form - * - * @param context context - * @param formName formName - * @param dimension dimension - */ - public FormController(Context context, String formName, int dimension) { - this.context = context; - this.formName = formName; - this.dimension = dimension; - } - - /** - * Bind data for a form - * - * @param formId formId - * @return ProviderFormInfo - */ - public abstract ProviderFormInfo bindFormData(long formId); - - /** - * Update form data on time, this update time is set in config.json by scheduledUpdateTime property - * - * @param formId the id of service widget to be updated - */ - public void onUpdateFormData(long formId) { - HiLog.info(TAG, "deleteForm() formId: " + formId); - } - - /** - * Called when receive service widget message event - * - * @param formId form id - * @param message the message context sent by service widget message event - */ - public abstract void onTriggerFormEvent(long formId, String message); - - /** - * Get the destination ability slice to route - * - * @param intent intent of current page slice - * @return the destination ability slice name to route - */ - public abstract Class getRoutePageSlice(Intent intent); - - /** - * Delete the resource related to current service widget - * - * @param formId form id - */ - public void onDeleteForm(long formId) { - HiLog.info(TAG, "deleteForm() formId: " + formId); - } -} diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormControllerManager.java b/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormControllerManager.java deleted file mode 100644 index 26ebcb0151c3ead33e0a830b260decc74496f6f4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/java/com/huawei/smartlamp/widget/controller/FormControllerManager.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package com.huawei.smartlamp.widget.controller; - -import ohos.app.Context; -import ohos.data.DatabaseHelper; -import ohos.data.preferences.Preferences; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.utils.zson.ZSONObject; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * FormControllerManager - * - * @since 2022-01-19 - */ -public class FormControllerManager { - private static final HiLogLabel TAG = new HiLogLabel(HiLog.DEBUG, 0x0, FormControllerManager.class.getName()); - private static final String PACKAGE_PATH = "com.huawei.smartlamp.widget"; - private static final String SHARED_SP_NAME = "form_info_sp.xml"; - private static final String FORM_NAME = "formName"; - private static final String DIMENSION = "dimension"; - private static final int ACS_NUM = 32; - private static final int DEFAULT_CAPACITY = 32; - private static volatile FormControllerManager managerInstance = null; - private final Map controllerHashMap = new HashMap<>(DEFAULT_CAPACITY); - - private final Context context; - - private final Preferences preferences; - - /** - * Constructor with context. - * - * @param context instance of Context. - */ - private FormControllerManager(Context context) { - this.context = context; - DatabaseHelper databaseHelper = new DatabaseHelper(this.context.getApplicationContext()); - preferences = databaseHelper.getPreferences(SHARED_SP_NAME); - } - - /** - * Singleton mode. - * - * @param context instance of Context. - * @return FormControllerManager instance. - */ - public static synchronized FormControllerManager getInstance(Context context) { - if (managerInstance == null) { - synchronized (FormControllerManager.class) { - if (managerInstance == null) { - managerInstance = new FormControllerManager(context); - } - } - } - return managerInstance; - } - - /** - * Save the form id and form name. - * - * @param formId form id. - * @param formName form name. - * @param dimension form dimension - * @return FormController form controller - */ - public FormController createFormController(long formId, String formName, int dimension) { - synchronized (controllerHashMap) { - if (formId < 0 || formName.isEmpty()) { - return null; - } - HiLog.info(TAG, - "saveFormId() formId: " + formId + ", formName: " + formName + ", preferences: " + preferences); - if (preferences != null) { - ZSONObject formObj = new ZSONObject(); - formObj.put(FORM_NAME, formName); - formObj.put(DIMENSION, dimension); - preferences.putString(Long.toString(formId), ZSONObject.toZSONString(formObj)); - preferences.flushSync(); - } - - // Create controller instance. - FormController controller = newInstance(formName, dimension, context); - - // Cache the controller. - if (controller != null) { - if (!controllerHashMap.containsKey(formId)) { - controllerHashMap.put(formId, controller); - } - } - - return controller; - } - } - - /** - * Get the form controller instance. - * - * @param formId form id. - * @return the instance of form controller. - */ - public FormController getController(long formId) { - synchronized (controllerHashMap) { - if (controllerHashMap.containsKey(formId)) { - return controllerHashMap.get(formId); - } - Map forms = preferences.getAll(); - String formIdString = Long.toString(formId); - if (forms.containsKey(formIdString)) { - ZSONObject formObj = ZSONObject.stringToZSON((String) forms.get(formIdString)); - String formName = formObj.getString(FORM_NAME); - int dimension = formObj.getIntValue(DIMENSION); - FormController controller = newInstance(formName, dimension, context); - controllerHashMap.put(formId, controller); - } - return controllerHashMap.get(formId); - } - } - - private FormController newInstance(String formName, int dimension, Context abilityContext) { - FormController ctrInstance = null; - if (formName == null || formName.isEmpty()) { - HiLog.error(TAG, "newInstance() get empty form name"); - return ctrInstance; - } - try { - String className = PACKAGE_PATH + "." + formName.toLowerCase(Locale.ROOT) + "." - + getClassNameByFormName(formName); - Class clazz = Class.forName(className); - if (clazz != null) { - Object controllerInstance = clazz.getConstructor(Context.class, String.class, Integer.class) - .newInstance(abilityContext, formName, dimension); - if (controllerInstance instanceof FormController) { - ctrInstance = (FormController) controllerInstance; - } - } - } catch (NoSuchMethodException | InstantiationException | IllegalArgumentException | InvocationTargetException - | IllegalAccessException | ClassNotFoundException | SecurityException exception) { - HiLog.error(TAG, "newInstance() get exception: " + exception.getMessage()); - } - return ctrInstance; - } - - /** - * Delete a form controller - * - * @param formId form id - */ - public void deleteFormController(long formId) { - synchronized (controllerHashMap) { - preferences.delete(Long.toString(formId)); - preferences.flushSync(); - controllerHashMap.remove(formId); - } - } - - private String getClassNameByFormName(String formName) { - String[] strings = formName.split("_"); - StringBuilder result = new StringBuilder(DEFAULT_CAPACITY); - for (String string : strings) { - result.append(string); - } - char[] chars = result.toString().toCharArray(); - chars[0] = (chars[0] >= 'a' && chars[0] <= 'z') - ? (char) (chars[0] - ACS_NUM) : chars[0]; - return String.copyValueOf(chars) + "Impl"; - } -} diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/app.js b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/app.js deleted file mode 100644 index ad36856e6ff2c668ee01914043acdb0c73945a0d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/app.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -import netConfig from './fa-netconfig'; - -export default { - NetConfig: netConfig, - Product: { - productId: '', - productName: '' - }, - ConfigParams: { - deviceInfo: {}, - sessionId: '' - }, - onCreate() { - }, - onDestroy() { - } -}; \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common.js b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common.js deleted file mode 100644 index 4b8b06fc7d52c4588d28d6797efdcd170e74d2f3..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -export var getApp = function(appInstance) { - return { - NetConfig: appInstance.$app.$def.NetConfig, - Product: appInstance.$app.$def.Product, - ConfigParams: appInstance.$app.$def.ConfigParams - }; -}; diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common/images/LED.png b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common/images/LED.png deleted file mode 100644 index 6e017c183ca3ac3e0131d9da41aa684548c4a197..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/common/images/LED.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/fa-netconfig.js b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/fa-netconfig.js deleted file mode 100644 index c2f93d8bf6dd224ba94aefd2c992565772dd5a6a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/fa-netconfig.js +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -const CONSTANT = { - BUNDLE_NAME: 'com.huawei.ailifeability', - ABILITY_NAME: 'com.huawei.ailifeability.NetConfigAbility', - DISCOVERY_BY_NAN_CODE: 1001, - CONNECT_DEVICE_CODE: 1003, - GET_WIFI_LIST_CODE: 1004, - CONFIG_DEVICE_NET_CODE: 1006, - DISCONNECT_DEVICE_CODE: 1007, - SUBSCRIBE_EVENT_CODE: 1008, - REGISTER_MSG_RECEIVE: 1010, - REGISTER_DISCONNECT_CALLBACK: 1011 -}; -var EventObserver = { - isInited: false, - callbackMap: new Map(), - register: function(item) { - EventObserver.callbackMap.set(item.messageCode, item.callback); - }, - notify: function(result) { - if (result.messageCode && EventObserver.callbackMap.get(result.messageCode) != undefined) { - EventObserver.callbackMap.get(result.messageCode)(result); - } else { - } - } -}; - -function getSubscribeParam() { - const action = {}; - action.bundleName = CONSTANT.BUNDLE_NAME; - action.abilityName = CONSTANT.ABILITY_NAME; - action.messageCode = CONSTANT.SUBSCRIBE_EVENT_CODE; - action.abilityType = 1; - action.syncOption = 0; - - return action; -} - -function callAbilityFunc(callCode, argsObj, callbackFunc) { - const action = {}; - action.bundleName = CONSTANT.BUNDLE_NAME; - action.abilityName = CONSTANT.ABILITY_NAME; - action.messageCode = callCode; - action.abilityType = 1; - action.data = argsObj; - - if (callbackFunc != undefined) { - EventObserver.register({ - messageCode: callCode, - callback: callbackFunc - }); - } - - return FeatureAbility.callAbility(action); -} - -function callAbility(callCode, argsObj, callbackFunc) { - if (EventObserver.isInited) { - return callAbilityFunc(callCode, argsObj, callbackFunc); - } else { - return FeatureAbility.subscribeAbilityEvent(getSubscribeParam(), (result) => { - const ret = JSON.parse(result); - if (ret.data) { - EventObserver.notify(ret.data); - } else { - } - }).then((result) => { - const ret = JSON.parse(result); - if (ret.code !== 0) { - } - - EventObserver.isInited = true; - return callAbilityFunc(callCode, argsObj, callbackFunc); - }); - } -} - -const FANetConfig = { - discoveryByNAN: function(scanInfo, callbackFunc) { - if (!(typeof scanInfo.duration === 'number' && scanInfo.duration % 1 === 0)) { - return; - } - if (!(typeof scanInfo.lockTime === 'number' && scanInfo.lockTime % 1 === 0)) { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.DISCOVERY_BY_NAN_CODE, { - scanNanInfo: scanInfo - }, callbackFunc); - }, - connectDevice: function(connectInfo, callbackFunc) { - const isConnectInfoNull = connectInfo == null || connectInfo == undefined; - if (isConnectInfoNull) { - return; - } - - if (typeof connectInfo.targetDeviceId !== 'string') { - return; - } - - if (!(typeof connectInfo.type === 'number' && connectInfo.type % 1 === 0)) { - return; - } - - if (typeof connectInfo.pin !== 'string') { - return; - } - - if (typeof connectInfo.password !== 'string') { - return; - } - - if (typeof connectInfo.sessionId !== 'string') { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - - return callAbility(CONSTANT.CONNECT_DEVICE_CODE, { - connectInfo: connectInfo - }, callbackFunc); - }, - getWifiList: function(callbackFunc) { - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.GET_WIFI_LIST_CODE, {}, callbackFunc); - }, - configDeviceNet: function(deviceInfo, accountInfo, netConfigInfo, callbackFunc) { - if (typeof deviceInfo !== 'string') { - return; - } - - if (typeof accountInfo !== 'string') { - return; - } - - const isNetConfigInfoNull = netConfigInfo == null || netConfigInfo == undefined; - if (isNetConfigInfoNull) { - return; - } - - if (typeof netConfigInfo.ssid !== 'string') { - return; - } - - if (typeof netConfigInfo.isDefaultPassword !== 'boolean') { - return; - } - - if (!(typeof netConfigInfo.channel === 'number' && netConfigInfo.channel % 1 === 0)) { - return; - } - - if (typeof netConfigInfo.sessionId !== 'string') { - } - - if (!(typeof netConfigInfo.type === 'number' && netConfigInfo.type % 1 === 0)) { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.CONFIG_DEVICE_NET_CODE, { - deviceInfo: deviceInfo, - accountInfo: accountInfo, - netConfigInfo: netConfigInfo - }, callbackFunc); - }, - disconnectDevice: function(commonInfo, callbackFunc) { - if (commonInfo == null || commonInfo == undefined) { - return; - } - if (typeof commonInfo.sessionId !== 'string') { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.DISCONNECT_DEVICE_CODE, { - commonInfo: commonInfo - }, callbackFunc); - }, - registerMsgReceive: function(commonInfo, callbackFunc) { - if (commonInfo == null || commonInfo == undefined) { - return; - } - if (typeof commonInfo.sessionId !== 'string') { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.REGISTER_MSG_RECEIVE, { - commonInfo: commonInfo - }, callbackFunc); - }, - registerDisconnectCallback: function(commonInfo, callbackFunc) { - if (commonInfo == null || commonInfo == undefined) { - return; - } - if (typeof commonInfo.sessionId !== 'string') { - return; - } - - if (typeof callbackFunc !== 'function') { - return; - } - return callAbility(CONSTANT.REGISTER_DISCONNECT_CALLBACK, { - commonInfo: commonInfo - }, callbackFunc); - } -}; - -export default FANetConfig; \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/en-US.json b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index 07db80fd849422d18a3a55b6dc3efe5fce8f97c1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "strings": { - "cancel": "Cancel", - "net-config": "Net Config", - "progress-0": "0%", - "progress-20": "20%", - "progress-40": "40%", - "progress-60": "60%", - "progress-80": "80%", - "progress-100": "100%", - "desc-20": "Scanning devices.", - "desc-40": "Device scanning completed, establishing connection...", - "desc-60": "Connection established. Obtaining current network information...", - "desc-80": "The current network information has been obtained, and the device is being connected...", - "desc-100": "Device networking is complete.", - "fail-desc-0": "The current phone does not support network distribution.", - "fail-desc-20": "Device scanning failed.", - "fail-desc-40": "Device connection failure.", - "fail-desc-60": "Failed to obtain the current network information.", - "fail-desc-80": "Failed to connect to the network.", - "fail-desc-100": "Device Disconnected", - "device-name": "Intelligent fan" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/zh-CN.json b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index 29ec25e2179ff22018ac209f6692fdf5cfc468ca..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "strings": { - "cancel": "取消", - "net-config": "配网", - "progress-0": "0%", - "progress-20": "20%", - "progress-40": "40%", - "progress-60": "60%", - "progress-80": "80%", - "progress-100": "100%", - "desc-20": "正在扫描设备", - "desc-40": "设备扫描完成,正在建立连接...", - "desc-60": "连接建立完成,正在获取当前网络信息...", - "desc-80": "当前网络信息获取完成,设备联网中...", - "desc-100": "设备联网完成", - "fail-desc-0": "当前手机不支持配网", - "fail-desc-20": "设备扫描失败", - "fail-desc-40": "设备连接失败", - "fail-desc-60": "当前网络信息获取失败", - "fail-desc-80": "设备联网失败", - "fail-desc-100": "设备断开连接", - "device-name": "智能灯控" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.css b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index d05c42071e6757d1f71b2db7682bcfba8cff86f4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,49 +0,0 @@ -.container { - flex-direction: column; - align-content: center; - justify-content: center; - align-items: center; - background-color: rgba(247, 247, 247, 1); -} - -.device-image { - width: 152px; - height: 152px; - margin-top: 24px; -} - -.device-name { - width: 100%; - font-size: 18px; - text-align: center; - margin-top: 16px; - text-color: #FF000000; -} - -.button-container { - flex-direction: row; - margin-left: 16px; - margin-right: 16px; - margin-top: 24px; - margin-bottom: 16px; - align-content: center; - justify-content: center; - align-items: center; -} - -.base-button { - height: 40px; - width: 144px; - text-color: #007DFF; - border-radius: 40px; - font-size: 16px; - background-color: transparent; - margin-left: 4px; - margin-right: 4px; -} - -.vertical-divider { - height: 24px; - width: 1px; - background-color: rgba(0, 0, 0, 0.2); -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.hml b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 10cffeba7568412f872fa8f2b14c32fb1b4201c7..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,23 +0,0 @@ - -
- - {{ deviceName }} -
-
-
\ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.js b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index ff0c2081dbc9a93ef5e02569f425f018c42186a6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -import app from '@system.app'; -import router from '@system.router'; -import {getApp} from '../../common.js'; - -export default { - data: { - deviceName: '', - deviceImg: '', - productName: 'LED', - sessionId: '' - }, - onInit() { - this.deviceName = this.$t('strings.device-name'); - this.deviceImg = '/common/images/LED.png'; - getApp(this).Product.productName = this.productName; - getApp(this).Product.productId = this.productId; - getApp(this).ConfigParams.sessionId = this.sessionId; - }, - cancel() { - app.terminate(); - }, - configNet() { - router.push({ - uri: 'pages/netconfig/netconfig' - }); - } -}; \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.css b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.css deleted file mode 100644 index e270f16d97c2c335be4e40bf78674075403a974d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.css +++ /dev/null @@ -1,38 +0,0 @@ -.container { - flex-direction: column; - align-content: center; - justify-content: center; - align-items: center; - background-color: rgba(247, 247, 247, 1); -} - -.device-image { - width: 152px; - height: 152px; - margin-top: 24px; -} - -.progress { - font-size: 18px; - text-color: #FF000000; - text-align: center; - margin-top: 16px; -} - -.desc { - font-size: 14px; - color: #999999; - text-align: center; - margin-top: 2px; - margin-left: 24px; - margin-right: 24px; -} - -.button { - width: 100%; - height: 22px; - font-size: 16px; - text-color: #358CFD; - background-color: transparent; - margin: 24px; -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.hml b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.hml deleted file mode 100644 index 7506acca76ce601f541d50caa05991830eef290e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.hml +++ /dev/null @@ -1,20 +0,0 @@ - -
- - {{ progress }} - {{ desc }} -
\ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.js b/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.js deleted file mode 100644 index 5d4a5f8aa2ed4c13a21d43afd9cf0ba5aa6a375a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/default/pages/netconfig/netconfig.js +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ -import app from '@system.app'; -import {getApp} from '../../common.js'; - -export default { - data: { - progress: '', - desc: '', - progressStatus: [], - descStatus: [], - failDescStatus: [], - deviceImg: '' - }, - onInit() { - this.deviceImg = '/common/images/LED.png'; - this.progressStatus = [ - this.$t('strings.progress-20'), - this.$t('strings.progress-40'), - this.$t('strings.progress-60'), - this.$t('strings.progress-80'), - this.$t('strings.progress-100') - ]; - this.descStatus = [ - this.$t('strings.desc-20'), - this.$t('strings.desc-40'), - this.$t('strings.desc-60'), - this.$t('strings.desc-80'), - this.$t('strings.desc-100') - ]; - this.failDescStatus = [ - this.$t('strings.fail-desc-0'), - this.$t('strings.fail-desc-20'), - this.$t('strings.fail-desc-40'), - this.$t('strings.fail-desc-60'), - this.$t('strings.fail-desc-80'), - this.$t('strings.fail-desc-100') - ]; - this.progress = this.$t('strings.progress-0'); - this.desc = this.descStatus[0]; - this.discoverDevice(); - }, - discoverDevice() { - const scanInfo = { - duration: 30, - lockTime: 60, - sessionId: getApp(this).ConfigParams.sessionId - }; - // Step1 discover the device through the NaN broadcast service. - getApp(this).NetConfig.discoveryByNAN(scanInfo, (result) => { - if (result.code == 0) { - this.progress = this.progressStatus[1]; - this.desc = this.descStatus[1]; - getApp(this).ConfigParams.deviceInfo = result.data; - this.registerDisconnectCallback(getApp(this).ConfigParams.deviceInfo.sessionId); - this.connectDevice(); - } else { - this.progress = this.progressStatus[4]; - this.desc = this.failDescStatus[1]; - this.disconnectDevice(); - } - }); - }, - connectDevice() { - const connectInfo = { - targetDeviceId: getApp(this).ConfigParams.deviceInfo.productId, - type: 0, - pin: '0123456789012345', - password: getApp(this).ConfigParams.deviceInfo.sn, - sessionId: getApp(this).ConfigParams.deviceInfo.sessionId - }; - // Step2 connect the device. - getApp(this).NetConfig.connectDevice(connectInfo, (result) => { - if (result.code === 0) { - this.progress = this.progressStatus[2]; - this.desc = this.descStatus[2]; - this.getWifiInfo(); - } else { - this.progress = this.progressStatus[4]; - this.desc = this.failDescStatus[2]; - this.disconnectDevice(); - } - }); - }, - getWifiInfo() { - // Step3 get the WiFi information of the current phone connection. - getApp(this).NetConfig.getWifiList((result) => { - if (result.code == 0 && result.data && result.data.length > 0) { - this.progress = this.progressStatus[3]; - this.desc = this.descStatus[3]; - this.configDevice(result.data[0]); - } else { - this.progress = this.progressStatus[4]; - this.desc = this.descStatus[3]; - this.disconnectDevice(); - } - }); - }, - async configDevice(wifiApInfo) { - const netConfigInfo = { - ssid: wifiApInfo.ssid, - ssidPassword: '', - isDefaultPassword: true, - channel: wifiApInfo.channel, - sessionId: getApp(this).ConfigParams.deviceInfo.sessionId, - type: 0, - wifiApId: wifiApInfo.wifiApId, - vendorData: '', - timeout: 30, - paramValid: true - }; - // Step4 config the device net. - getApp(this).NetConfig.configDeviceNet('deviceInfo', 'accountInfo', netConfigInfo, (result) => { - if (result.code == 0) { - this.progress = this.progressStatus[4]; - this.desc = this.descStatus[4]; - this.registerMsgReceive(); - // Step5 config the device net success, go to the control. - this.goToControl(); - } else { - this.progress = this.progressStatus[4]; - this.desc = this.failDescStatus[4]; - this.disconnectDevice(); - } - }); - }, - registerDisconnectCallback(sessionId) { - const commonInfo = { - sessionId: sessionId - }; - getApp(this).NetConfig.registerDisconnectCallback(commonInfo, (result) => { - if (result.code == 0) { - this.desc = this.failDescStatus[5]; - } - }); - }, - registerMsgReceive() { - const commonInfo = { - sessionId: getApp(this).ConfigParams.deviceInfo.sessionId - }; - getApp(this).NetConfig.registerMsgReceive(commonInfo, () => { - }); - }, - disconnectDevice() { - const commonInfo = { - sessionId: getApp(this).ConfigParams.deviceInfo.sessionId - }; - getApp(this).NetConfig.disconnectDevice(commonInfo, (result) => { - }); - }, - goToControl() { - const target = { - bundleName: 'com.huawei.smartlamp.hmservice', - abilityName: 'com.huawei.smartlamp.ControlMainAbility', - deviceType: 1, // 从本地设备中拉起原子化服务 - data: { - session_id: getApp(this).ConfigParams.deviceInfo.sessionId, - product_id: getApp(this).Product.productId, - product_name: getApp(this).Product.productName - } - }; - FeatureAbility.startAbility(target); - app.terminate(); - }, - cancel() { - app.terminate(); - } -}; \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/common/ic_default_image@3x.png b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/common/ic_default_image@3x.png deleted file mode 100644 index 11a9dd87291d31f6e90dd4648ead8429aca1ff54..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/common/ic_default_image@3x.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/en-US.json b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/en-US.json deleted file mode 100644 index dcc22e9fd6f99be642b56d11185d72d998f59ec2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "title": "Lighting Auto Controller", - "detail": "Mobile control Hi3861 development board" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/zh-CN.json b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/zh-CN.json deleted file mode 100644 index 58965331cbddf520eb21a6c585131aa30bb4b397..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "title": "智能灯控", - "detail": "手机控制Hi3861开发板" - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.css b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.css deleted file mode 100644 index 1ecb0d11e8492fe95418eb8bba8fbe22c679fec3..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.css +++ /dev/null @@ -1,64 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.bg-img { - flex-shrink: 0; - height: 100%; -} - -.container-inner { - flex-direction: column; - justify-content: flex-end; - align-items: flex-start; - height: 100%; - width: 100%; - padding: 12px; -} - -.title { - font-size: 19px; - font-weight: bold; - color: white; - text-overflow: ellipsis; - max-lines: 1; -} - -.detail_text { - font-size: 16px; - color: white; - opacity: 0.66; - text-overflow: ellipsis; - max-lines: 1; - margin-top: 6px; -} - -@media (device-type: wearable) { - .container-inner { - justify-content: center; - align-items: center; - margin: 40px 26px; - padding: 0; - } - - .title { - text-align: center; - } - - .detail_text { - max-lines: 2; - text-align: center; - } -} - -@media (device-type: tv) { - .title { - font-size: 16px; - } - - .detail_text { - font-size: 12px; - } -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.hml b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.hml deleted file mode 100644 index e606afc3c70436b19678f525070d3e401c5f4186..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.hml +++ /dev/null @@ -1,25 +0,0 @@ - -
- -
- -
-
- {{ $t('strings.title') }} - {{ $t('strings.detail') }} -
-
-
\ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.json b/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.json deleted file mode 100644 index 05440111a54365f0050e48f66c2f418f6cdbb177..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/js/widget/pages/index/index.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "data": { - "title": "Title", - "detail": "Text", - "iconTitle": "Picture" - }, - "actions": { - "routerEvent": { - "action": "router", - "bundleName": "com.huawei.smartlamp.hmservice", - "abilityName": "com.huawei.smartlamp.MainAbility", - "params": { - "message": "add detail" - } - } - } -} diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/element/string.json b/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/element/string.json deleted file mode 100644 index c767aa51ff12ddbbdbe7052b538266ec01a13d57..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - }, - { - "name": "widget_ability_description", - "value": "This is a WidgetAbility" - } - ] -} \ No newline at end of file diff --git a/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/media/icon.png b/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.jar b/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.properties b/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 63c817f17998697c0097fa6399106b99591c77b9..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-7.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/Device/RemoteLamp/SmartLamp/settings.gradle b/Device/RemoteLamp/SmartLamp/settings.gradle deleted file mode 100644 index 6c41fdbaf841607afc6fb5ecd05af67fe397e197..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/SmartLamp/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry', ':control' diff --git a/Device/RemoteLamp/device/team_x/OAT.xml b/Device/RemoteLamp/device/team_x/OAT.xml deleted file mode 100644 index d7a659e173dd695d4cef7f88b16ad35ae8d03d71..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/OAT.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Device/RemoteLamp/device/team_x/common/hals/BUILD.gn b/Device/RemoteLamp/device/team_x/common/hals/BUILD.gn deleted file mode 100644 index 51811784e8d07ee4fbcde00f86952d6c47961b76..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/hals/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -static_library("hals") { - sources = [ - "src/peripheral_hal.c", - "src/utils_hal.c" - ] - - include_dirs = [ - "../inc", - "//base/iot_hardware/peripheral/interfaces/kits", - ] -} \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/hals/src/peripheral_hal.c b/Device/RemoteLamp/device/team_x/common/hals/src/peripheral_hal.c deleted file mode 100644 index 28488ce9ae10d1f81b01a9515ba238e0fb967d40..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/hals/src/peripheral_hal.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -#include "peripheral_hal.h" -#include "iot_errno.h" -#include "hi_io.h" -#include "hi_adc.h" -#include "hi_types_base.h" -#include "hi_watchdog.h" -#include "hi_pwm.h" - -unsigned int HalIoSetFunc(HalWifiIotIoName id, const char *val) -{ - if (id == HAL_WIFI_IOT_IO_NAME_MAX) { - return IOT_FAILURE; - } - return hi_io_set_func((hi_io_name)id, val); -} - -unsigned int HalAdcRead(HalWifiIotAdcChannelIndex channel, unsigned short *data, HalWifiIotAdcEquModelSel equModel, - HalWifiIotAdcCurBais curBais, unsigned short rstCnt) -{ - return hi_adc_read((hi_adc_channel_index)channel, (hi_u16*)data, (hi_adc_equ_model_sel)equModel, - (hi_adc_cur_bais)curBais, (hi_u16)rstCnt); -} - -void HalSetWatchDogEnable(int enable) -{ - if (enable == 0) { - hi_watchdog_disable(); - } else { - hi_watchdog_enable(); - } -} - -unsigned int HalPwmStart(uint32 id, uint16 duty, uint16 freq) -{ - return hi_pwm_start((hi_pwm_port)id, (hi_u16)duty, (hi_u16)freq); -} \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/hals/src/utils_hal.c b/Device/RemoteLamp/device/team_x/common/hals/src/utils_hal.c deleted file mode 100644 index ef34078b38618fb154a9eee05d30d31ab7026cbd..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/hals/src/utils_hal.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -#include "ohos_types.h" -#include "hi_time.h" -#include "hi_types_base.h" -#include "utils_hal.h" - -void hal_udelay(uint32 us) -{ - hi_udelay((hi_u32)us); -} \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/inc/flower.h b/Device/RemoteLamp/device/team_x/common/inc/flower.h deleted file mode 100644 index cc46dbd60695111aa3e3c0ac545270f08698295e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/flower.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ - -#ifndef __FLOWER_H__ -#define __FLOWER_H__ - - -int FlowerInit(void); - -int FlowerSetMotorStatus(int status); - -int FlowerGetAirStatus(int *temperature, int *humidity); - -int FlowerGetSoilStatus(int *moisture); - -void FlowerDeinit(void); - -#endif // __FLOWER_H__ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_adc.h b/Device/RemoteLamp/device/team_x/common/inc/iot_adc.h deleted file mode 100644 index 6a0f383f4f2e816f68654614a95a697119fb4f40..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_adc.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup IotHardware - * @{ - * - * @brief Provides APIs for operating devices, - * including flash, GPIO, I2C, PWM, UART,ADC, and watchdog APIs. - * - * - * - * @since 2.2 - * @version 2.2 - */ - -/** - * @file iot_adc.h - * - * @brief Declares the ADC interface functions for you to read data. - * - * @since 1.0 - * @version 1.1.0 - */ - -#ifndef IOT_ADC_H -#define IOT_ADC_H - - -/** - * @brief Enumerates analog power control modes. - */ -typedef enum { - /** Automatic control */ - IOT_ADC_CUR_BAIS_DEFAULT, - /** Automatic control */ - IOT_ADC_CUR_BAIS_AUTO, - /** Manual control (AVDD = 1.8 V) */ - IOT_ADC_CUR_BAIS_1P8V, - /** Manual control (AVDD = 3.3 V) */ - IOT_ADC_CUR_BAIS_3P3V, - /** Button value */ - IOT_ADC_CUR_BAIS_BUTT, -} IotAdcCurBais; - -/** - * @brief Enumerates equation models. - */ -typedef enum { - /** One-equation model */ - IOT_ADC_EQU_MODEL_1, - /** Two-equation model */ - IOT_ADC_EQU_MODEL_2, - /** Four-equation model */ - IOT_ADC_EQU_MODEL_4, - /** Eight-equation model */ - IOT_ADC_EQU_MODEL_8, - /** Button value */ - IOT_ADC_EQU_MODEL_BUTT, -} IotAdcEquModelSel; - -/** - * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters. - * - * - * - * @param channel Indicates the ADC channel index. - * @param data Indicates the pointer to the address for storing the read data. - * @param equModel Indicates the equation model. - * @param curBais Indicates the analog power control mode. - * @param rstCnt Indicates the count of the time from reset to conversion start. - * One count is equal to 334 ns. The value must range from 0 to 0xFF0. - * @return Returns {@link IOT_SUCCESS} if the PWM signal output is stopped; - * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTAdcRead(unsigned int channel, unsigned short *data, IotAdcEquModelSel equModel, - IotAdcCurBais curBais, unsigned short rstCnt); - -#endif -/** @} */ \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton.h b/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton.h deleted file mode 100644 index 5f2485f0b9ba928ac196e84cfd465d3f7dd80cd4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 zhangqf1314@163.com . - * 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. - */ - -#ifndef IOT_BOARDBUTTON_H_ -#define IOT_BOARDBUTTON_H_ - -typedef void (*ButtonPressedCallback)(char *arg); - - -/** - * @brief Initialize a button - * - */ -int Board_IsButtonPressedF2(void); -int Board_InitButtonF1(ButtonPressedCallback, char *arg); -int Board_InitButtonF2(ButtonPressedCallback, char *arg); - - -#endif /* IOT_BOARDBUTTON_H_ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton_xradio.h b/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton_xradio.h deleted file mode 100644 index a08612c7399eacc02f60aa96ec34c0090b243c69..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_boardbutton_xradio.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 zhangqf1314@163.com . - * 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. - */ - -#ifndef IOT_BOARDBUTTON_H_ -#define IOT_BOARDBUTTON_H_ - -typedef enum { - BUTTON_INVALID = 0xff, - BUTTON_RELEASE = 0, - BUTTON_PRESS, - BUTTON_LONG_PRESS, - - BUTTON_MAX_TYPE -} BUTTON_VALUE_TYPE; - -typedef struct { - int button_id; - BUTTON_VALUE_TYPE value; -} ButtonEvent; - -typedef void (*ButtonPressedCallback)(ButtonEvent *event); - -/** - * @brief Initialize a button - * - */ -int Board_ButtonInit(ButtonPressedCallback callback); - -int Board_IsButtonPressed(void); - -#endif /* IOT_BOARDBUTTON_H_ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_boardled.h b/Device/RemoteLamp/device/team_x/common/inc/iot_boardled.h deleted file mode 100644 index f0ea44a464e6a9f2aa1ff225168bb5b737126906..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_boardled.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_BOARDLED_H__ -#define __IOT_BOARDLED_H__ - -/** - * @brief Initialize the board pwd led - * @return Returns 0 success while others failed - */ -int BOARD_InitPwmLed(void); - -/** - * @brief Set Pwm led duty cycle - * @param dutyCycle, the duty cycle to set, not max than 40000 - * @return Returns 0 success while others failed - */ -int BOARD_SetPwdLedDutyCycle(int dutyCycle); - - -/** - * @brief Initialize the LED - * @return Returns 0 success while others failed - */ -int BOARD_InitIoLed(void); - -/** - * @brief Control the led status - * @param status Indicates the status to set and value should be CN_BOARD_SWICT_ON/OFF - * @return Returns 0 success while others failed - */ -int BOARD_SetIoLedStatus(int status); - - -/** - * @brief use this function to change the flash cycle; - * @param flashHz indicates the flash frequency - * @return Returns 0 success while others failed - */ - -int LedFlashFrequencySet(float flashHz); - -/** - * @brief use this function to kill the flash task - * @return Returns 0 success while others failed - */ -int LedFlashTaskDeinit(void); - -#endif /* __IOT_BOARDLED_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_boardled_xradio.h b/Device/RemoteLamp/device/team_x/common/inc/iot_boardled_xradio.h deleted file mode 100644 index 8ae3016be04eeb14f939c6dda8d0757679cc1f6e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_boardled_xradio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_BOARDLED_H__ -#define __IOT_BOARDLED_H__ - -typedef enum { - LED_FLASH_FAST_PLUGS, - LED_FLASH_FAST, - LED_FLASH_NORMAL, - LED_FLASH_SLOW, - LED_FLASH_SLOW_PLUGS, - - LED_FLASH_MAX -}LED_FLASH_MODE; - -/** - * @brief use this function to change the flash cycle; - * @param flashHz indicates the flash frequency - * @return Returns 0 success while others failed - */ - -int LedFlashFrequencySet(LED_FLASH_MODE mode); - -/** - * @brief use this function to kill the flash task - * @return Returns 0 success while others failed - */ -int LedFlashTaskDeinit(void); - -/** - * @brief Initialize the LED task - */ -void LedFlashTaskStart(void); - -#endif /* __IOT_BOARDLED_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_cloud.h b/Device/RemoteLamp/device/team_x/common/inc/iot_cloud.h deleted file mode 100644 index 4012a754d7bce966af4b38ba1e57bb93cd1a4154..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_cloud.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology 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. - */ - - -#ifndef __IOT_CLOUD_H__ -#define __IOT_CLOUD_H__ - -#include -#include - -/** - * @brief Initialize the cloud sdk - * @return 0 success while others failed - */ -int CLOUD_Init(void); -/** - * @brief Do deinitialize the cloud sdk - * @return 0 success while others failed - */ -int CLOUD_Deinit(void); - -/** - * @brief Send collected data to Cloud Platform - * @param jsonString, which means this has been formated as the profile defines - * @return Returns 0 success while others failed -*/ -int CLOUD_ReportMsg(const char *jsonString); - -/** - * @brief Connect to the Cloud Platform - * @param deviceID Indicats the deviceID create in the iot platform - * @param devicePwd Indicates the corresponding to the deviceID - * @param serverIP Indicates the ip of the iot platform - * @param serverPort Indicates the port correspond to the ip - * @param cmdCallBack Indicates command callback and will be called if any message comes - * @return Returns 0 success while others failed -*/ -int CLOUD_Connect(const char *deviceID, const char *devicePwd, \ - const char *serverIP, const char *serverPort); - -/** - * @brief Disconnect from the Cloud Platform - * @return 0 success while others failed -*/ -int CLOUD_Disconnect(void); - -/** - * @brief use this is a call back function implemented by the demo - * @param jsonString indicated the jsonString received from the iot_cloud - * @return Returns 0 success while -1 failed - */ -int CLOUD_CommandCallBack(const char *jsonString); - - -/** - * @brief functions and data for the syntax format - * - */ - -// enum all the data type for the oc profile -typedef enum { - IOT_PROFILE_KEY_DATATYPE_INT = 0, - IOT_PROFILE_KEY_DATATYPE_LONG, - IOT_PROFILE_KEY_DATATYPE_FLOAT, - IOT_PROFILE_KEY_DATATYPE_DOUBLE, - IOT_PROFILE_KEY_DATATYPE_STRING, - IOT_PROFILE_KEY_DATATYPE_LAST, -}IotProfileDataType; - - -typedef struct { - void *nxt; ///< ponit to the next key - char *key; - IotProfileDataType type; - void *value; -}IotProfileKV; - - -typedef struct { - void *nxt; - char *serviceID; ///< the service id in the profile, which could not be NULL - char *eventTime; ///< eventtime, which could be NULL means use the platform time - IotProfileKV *propertyLst; ///< the property in the profile, which could not be NULL -} IotProfileService; - - -/** - * @brief Package the profile to json string mode, and you should free it manually - * @param serviceLst, profile services - * @return Returns the formates json string or NULL if failed - * - */ -char *IoTProfilePackage(IotProfileService *serviceLst); - -char *IotNotificationPackage(int type, const char *enString, const char *chString); - -typedef enum { - NOTIFY_TYPE_NORMAL = 0, - NOTIFY_TYPE_SECONDARY, - NOTIFY_TYPE_URGENT, - NOTIFY_TYPE_LAST -} NOTIFY_TYPE; - -int CLOUD_ReportNotification(int type, const char *enString, const char *chString); - -#endif /* __IOT_CLOUD_H__ */ - diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_demo_def.h b/Device/RemoteLamp/device/team_x/common/inc/iot_demo_def.h deleted file mode 100644 index 6c85fc945f902b442e23ecf2a0e6ac88e6cc4d2f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_demo_def.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_DEMO_DEF_H__ -#define __IOT_DEMO_DEF_H__ - -#define CN_BOARD_SWITCH_ON 1 -#define CN_BOARD_SWITCH_OFF 0 -#define CN_HOURS_IN_DAY 24 -#define CN_MINUTES_IN_HOUR 60 -#define CN_SECONDS_IN_MINUTE 60 -#define CN_SECONDS_IN_HOUR (CN_MINUTES_IN_HOUR * CN_SECONDS_IN_MINUTE) -#define CN_MINISECONDS_IN_SECOND 1000 -#define CN_MINUTES_IN_DAY (CN_HOURS_IN_DAY * CN_MINUTES_IN_HOUR) -#define CN_SECONS_IN_DAY (CN_SECONDS_IN_MINUTE * CN_MINUTES_IN_DAY) -#define BASE_YEAR_OF_TIME_CALC 1900 - -#define AFTER_NETCFG_ACTION 2 -#define BUFF_SIZE 256 - -typedef enum { - - LOG_LEVEL_INFO = 0, - LOG_LEVEL_DEBUG, - LOG_LEVEL_WARN, - LOG_LEVEL_ERR, - LOG_LEVEL_EXCEPTION, - LOG_LEVEL_EXIT, -}LogLevelType; - -//we defines a log arise function -#define RAISE_LOG 1 - -#ifdef RAISE_LOG -#define RaiseLog(level,fmt, ...) \ - do \ - { \ - printf("[%s][%u][%d] " fmt "\r\n", \ - __FUNCTION__,__LINE__,level, ##__VA_ARGS__); \ - } while (0) -#else -#define RaiseLog(level,fmt, ...) -#endif - - -#endif /* __IOT_DEMO_DEF_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_gpio_ex.h b/Device/RemoteLamp/device/team_x/common/inc/iot_gpio_ex.h deleted file mode 100644 index 703dcd2aeeb03a88d8bdbfc1c7dafbfa02c8df51..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_gpio_ex.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * @file iot_gpio_ex.h - * - * @brief Declares the extended GPIO interface functions. - * - * These functions are used for settings GPIO pulls and driver strength. \n - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef IOT_GPIO_EX_H -#define IOT_GPIO_EX_H - - -/** - * @brief Enumerates the functions of GPIO hardware pin 0. - */ -typedef enum { - /** GPIO0 function */ - IOT_GPIO_FUNC_GPIO_0_GPIO, - /** Functions of UART1 TXD */ - IOT_GPIO_FUNC_GPIO_0_UART1_TXD = 2, - /** SPI1 CK function */ - IOT_GPIO_FUNC_GPIO_0_SPI1_CK, - /** Functions of JTAG TD0 */ - IOT_GPIO_FUNC_GPIO_0_JTAG_TDO, - /** PWM3 OUT function */ - IOT_GPIO_FUNC_GPIO_0_PWM3_OUT, - /** I2C1 SDA function */ - IOT_GPIO_FUNC_GPIO_0_I2C1_SDA, -} WifiIotIoFuncGpio0; - -/** - * @brief Enumerates the functions of GPIO hardware pin 1. - */ -typedef enum { - /** GPIO1 function */ - IOT_GPIO_FUNC_GPIO_1_GPIO, - /** UART1 RXD function */ - IOT_GPIO_FUNC_GPIO_1_UART1_RXD = 2, - /** SPI1 RXD function */ - IOT_GPIO_FUNC_GPIO_1_SPI1_RXD, - /** JTAG TCKfunction */ - IOT_GPIO_FUNC_GPIO_1_JTAG_TCK, - /** PWM4 OUT function */ - IOT_GPIO_FUNC_GPIO_1_PWM4_OUT, - /** I2C1 SCL function */ - IOT_GPIO_FUNC_GPIO_1_I2C1_SCL, - /** BT FREQ function */ - IOT_GPIO_FUNC_GPIO_1_BT_FREQ, -} WifiiIotIoFuncGpio1; - -/** - * @brief Enumerates the functions of GPIO hardware pin 2. - */ -typedef enum { - /** GPIO2 function */ - IOT_GPIO_FUNC_GPIO_2_GPIO, - /** UART1 RTS function */ - IOT_GPIO_FUNC_GPIO_2_UART1_RTS_N = 2, - /** SPI1 TXD function */ - IOT_GPIO_FUNC_GPIO_2_SPI1_TXD, - /** JTAG TRSTN function */ - IOT_GPIO_FUNC_GPIO_2_JTAG_TRSTN, - /** PWM2 OUT function */ - IOT_GPIO_FUNC_GPIO_2_PWM2_OUT, - /** SSI CLK function */ - IOT_GPIO_FUNC_GPIO_2_SSI_CLK = 7, -} WifiIotIoFuncGpio2; - -/** - * @brief Enumerates the functions of GPIO hardware pin 3. - */ -typedef enum { - /** GPIO3 function */ - IOT_GPIO_FUNC_GPIO_3_GPIO, - /** UART0 TXD function */ - IOT_GPIO_FUNC_GPIO_3_UART0_TXD, - /** UART1 CTS function */ - IOT_GPIO_FUNC_GPIO_3_UART1_CTS_N, - /** SPI CSN function */ - IOT_GPIO_FUNC_GPIO_3_SPI1_CSN, - /** JTAG TDI function */ - IOT_GPIO_FUNC_GPIO_3_JTAG_TDI, - /** PWM5 OUT function */ - IOT_GPIO_FUNC_GPIO_3_PWM5_OUT, - /** I2C1 SDA function */ - IOT_GPIO_FUNC_GPIO_3_I2C1_SDA, - /** SSI DATA function */ - IOT_GPIO_FUNC_GPIO_3_SSI_DATA, -} WifiIotIoFuncGpio3; - -/** - * @brief Enumerates the functions of GPIO hardware pin 4. - */ -typedef enum { - /** GPIO4 function */ - IOT_GPIO_FUNC_GPIO_4_GPIO, - /** UART0 RXD function */ - IOT_GPIO_FUNC_GPIO_4_UART0_RXD = 2, - /** JTAG TMS function */ - IOT_GPIO_FUNC_GPIO_4_JTAG_TMS = 4, - /** PWM1 OUT function */ - IOT_GPIO_FUNC_GPIO_4_PWM1_OUT, - /** I2C1 SCL function */ - IOT_GPIO_FUNC_GPIO_4_I2C1_SCL, -} WifiIotIoFuncGpio4; - -/** - * @brief Enumerates the functions of GPIO hardware pin 5. - */ -typedef enum { - /** GPIO5 function */ - IOT_GPIO_FUNC_GPIO_5_GPIO, - /** UART1 RXD function */ - IOT_GPIO_FUNC_GPIO_5_UART1_RXD = 2, - /** SPI0 CSN function */ - IOT_GPIO_FUNC_GPIO_5_SPI0_CSN, - /** PWM2 OUT function */ - IOT_GPIO_FUNC_GPIO_5_PWM2_OUT = 5, - /** I2C0 MCLK function */ - IOT_GPIO_FUNC_GPIO_5_I2S0_MCLK, - /** BT STATUS function */ - IOT_GPIO_FUNC_GPIO_5_BT_STATUS, -} WifiIotIoFuncGpio5; - -/** - * @brief Enumerates the functions of GPIO hardware pin 6. - */ -typedef enum { - /** GPIO6 function */ - IOT_GPIO_FUNC_GPIO_6_GPIO, - /** UART1 TXD function */ - IOT_GPIO_FUNC_GPIO_6_UART1_TXD = 2, - /** SPI0 CK function */ - IOT_GPIO_FUNC_GPIO_6_SPI0_CK, - /** PWM3 OUT function */ - IOT_GPIO_FUNC_GPIO_6_PWM3_OUT = 5, - /** I2S0 TX function */ - IOT_GPIO_FUNC_GPIO_6_I2S0_TX, - /** COEX switch function */ - IOT_GPIO_FUNC_GPIO_6_COEX_SWITCH, -} WifiIotIoFuncGpio6; - -/** - * @brief Enumerates the functions of GPIO hardware pin 7. - */ -typedef enum { - /** GPIO7 function */ - IOT_GPIO_FUNC_GPIO_7_GPIO, - /** UART1 CTS function */ - IOT_GPIO_FUNC_GPIO_7_UART1_CTS_N = 2, - /** SPI0 RXD function */ - IOT_GPIO_FUNC_GPIO_7_SPI0_RXD, - /** PWM0 OUT function */ - IOT_GPIO_FUNC_GPIO_7_PWM0_OUT = 5, - /** I2S0 BCLK function */ - IOT_GPIO_FUNC_GPIO_7_I2S0_BCLK, - /** BT ACTIVE function */ - IOT_GPIO_FUNC_GPIO_7_BT_ACTIVE, -} WifiIotIoFuncGpio7; - -/** - * @brief Enumerates the functions of GPIO hardware pin 8. - */ -typedef enum { - /** GPIO8 function */ - IOT_GPIO_FUNC_GPIO_8_GPIO, - /** UART1 RTS function */ - IOT_GPIO_FUNC_GPIO_8_UART1_RTS_N = 2, - /** SPI0 TXD function */ - IOT_GPIO_FUNC_GPIO_8_SPI0_TXD, - /** PWM1 OUT function */ - IOT_GPIO_FUNC_GPIO_8_PWM1_OUT = 5, - /** I2S0 WS function */ - IOT_GPIO_FUNC_GPIO_8_I2S0_WS, - /** WLAN ACTIVE function */ - IOT_GPIO_FUNC_GPIO_8_WLAN_ACTIVE, -} WifiIotIoFuncGpio8; - -/** - * @brief Enumerates the functions of GPIO hardware pin 9. - */ -typedef enum { - /** GPIO9 function */ - IOT_GPIO_FUNC_GPIO_9_GPIO, - /** I2C0 SCL function */ - IOT_GPIO_FUNC_GPIO_9_I2C0_SCL, - /** UART2 RTS function */ - IOT_GPIO_FUNC_GPIO_9_UART2_RTS_N, - /** SDIO D2 function */ - IOT_GPIO_FUNC_GPIO_9_SDIO_D2, - /** SPI0 TXD function */ - IOT_GPIO_FUNC_GPIO_9_SPI0_TXD, - /** PWM0 OUT function */ - IOT_GPIO_FUNC_GPIO_9_PWM0_OUT, - /** I2S0 MCLK function */ - IOT_GPIO_FUNC_GPIO_9_I2S0_MCLK = 7, -} WifiIotIoFuncGpio9; - -/** - * @brief Enumerates the functions of GPIO hardware pin 10. - */ -typedef enum { - /** GPIO10 function */ - IOT_GPIO_FUNC_GPIO_10_GPIO, - /** I2C0 SDA function */ - IOT_GPIO_FUNC_GPIO_10_I2C0_SDA, - /** UART2 CTS function */ - IOT_GPIO_FUNC_GPIO_10_UART2_CTS_N, - /** SDIO D3 function */ - IOT_GPIO_FUNC_GPIO_10_SDIO_D3, - /** SPI0 CK function */ - IOT_GPIO_FUNC_GPIO_10_SPI0_CK, - /** PWM1 OUT function */ - IOT_GPIO_FUNC_GPIO_10_PWM1_OUT, - /** I2S0 TX function */ - IOT_GPIO_FUNC_GPIO_10_I2S0_TX = 7, -} WifiIotIoFuncGpio10; - -/** - * @brief Enumerates the functions of GPIO hardware pin 11. - */ -typedef enum { - /** GPIO11 function */ - IOT_GPIO_FUNC_GPIO_11_GPIO, - /** UART2 TXD function */ - IOT_GPIO_FUNC_GPIO_11_UART2_TXD = 2, - /** SDIO CMD function */ - IOT_GPIO_FUNC_GPIO_11_SDIO_CMD, - /** SDIO RXD function */ - IOT_GPIO_FUNC_GPIO_11_SPI0_RXD, - /** PWM2 OUT function */ - IOT_GPIO_FUNC_GPIO_11_PWM2_OUT, - /** RF TX_EN_EXT function */ - IOT_GPIO_FUNC_GPIO_11_RF_TX_EN_EXT, - /** I2S0 RX function */ - IOT_GPIO_FUNC_GPIO_11_I2S0_RX, -} WifiIotIoFuncGpio11; - -/** - * @brief Enumerates the functions of GPIO hardware pin 12. - */ -typedef enum { - /** GPIO12 function */ - IOT_GPIO_FUNC_GPIO_12_GPIO, - /** SUART2 RXD function */ - IOT_GPIO_FUNC_GPIO_12_UART2_RXD = 2, - /** SDIO CLK function */ - IOT_GPIO_FUNC_GPIO_12_SDIO_CLK, - /** SDIO CSN function */ - IOT_GPIO_FUNC_GPIO_12_SPI0_CSN, - /** PWM3 OUT function */ - IOT_GPIO_FUNC_GPIO_12_PWM3_OUT, - /** RF RX_EN_EXT function */ - IOT_GPIO_FUNC_GPIO_12_RF_RX_EN_EXT, - /** I2S0 BCLK function */ - IOT_GPIO_FUNC_GPIO_12_I2S0_BCLK, -} WifiIotIoFuncGpio12; - -/** - * @brief Enumerates the functions of GPIO hardware pin 13. - */ -typedef enum { - /** SSI DATA function */ - IOT_GPIO_FUNC_GPIO_13_SSI_DATA, - /** UART0 TXD function */ - IOT_GPIO_FUNC_GPIO_13_UART0_TXD, - /** UART2 RTS function */ - IOT_GPIO_FUNC_GPIO_13_UART2_RTS_N, - /** SDIO D0 function */ - IOT_GPIO_FUNC_GPIO_13_SDIO_D0, - /** GPIO13 function */ - IOT_GPIO_FUNC_GPIO_13_GPIO, - /** PWM4 OUT function */ - IOT_GPIO_FUNC_GPIO_13_PWM4_OUT, - /** I2C0 SDA function */ - IOT_GPIO_FUNC_GPIO_13_I2C0_SDA, - /** I2S0 WS function */ - IOT_GPIO_FUNC_GPIO_13_I2S0_WS, -} WifiIotIoFuncGpio13; - -/** - * @brief Enumerates the functions of GPIO hardware pin 14. - */ -typedef enum { - /** SSI CLK function */ - IOT_GPIO_FUNC_GPIO_14_SSI_CLK, - /** UART0 RXD function */ - IOT_GPIO_FUNC_GPIO_14_UART0_RXD, - /** UART2 CTS function */ - IOT_GPIO_FUNC_GPIO_14_UART2_CTS_N, - /** SDIO D1 function */ - IOT_GPIO_FUNC_GPIO_14_SDIO_D1, - /** GPIO14 function */ - IOT_GPIO_FUNC_GPIO_14_GPIO, - /** PWM5 OUT function */ - IOT_GPIO_FUNC_GPIO_14_PWM5_OUT, - /** I2C0 SCL function */ - IOT_GPIO_FUNC_GPIO_14_I2C0_SCL, -} WifiIotIoFuncGpio14; - -/** - * @brief Enumerates GPIO pull-up or pull-down settings. - */ -typedef enum { - /** No pull */ - IOT_GPIO_PULL_NONE, - /** Pull-up */ - IOT_GPIO_PULL_UP, - /** Pull-down */ - IOT_GPIO_PULL_DOWN, - /** Maximum value */ - IOT_GPIO_PULL_MAX, -} IotGpioPull; - - -unsigned int IoTGpioSetFunc(unsigned int id, unsigned char val); - -unsigned int IoTGpioSetPull(unsigned int id, IotGpioPull val); - -#endif -/** @} */ \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_i2c_ex.h b/Device/RemoteLamp/device/team_x/common/inc/iot_i2c_ex.h deleted file mode 100644 index e1f09524d32d09d19e4cc87edf1a3106a25347fc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_i2c_ex.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * @addtogroup wifiiot - * @{ - * - * @brief Provides dedicated device operation interfaces on the Wi-Fi module, - * including ADC, AT, flash, GPIO, I2C, I2S, partition, PWM, SDIO, UART, and watchdog. - * - * - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file wifiiot_i2c_ex.h - * - * @brief Declares the extended I2C interface functions. - * - * These functions are used for I2C baud rate setting and device exception callback. \n - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef IOT_I2C_EX_H -#define IOT_I2C_EX_H - - -/** - * @brief Defines I2C data transmission attributes. - */ -typedef struct { - /** Pointer to the buffer storing data to send */ - unsigned char *sendBuf; - /** Length of data to send */ - unsigned int sendLen; - /** Pointer to the buffer for storing data to receive */ - unsigned char *receiveBuf; - /** Length of data received */ - unsigned int receiveLen; -} IotI2cData; - - -/** - * @brief Sends data to and receives data responses from an I2C device. - * - * - * - * @param id Indicates the I2C device ID. - * @param deviceAddr Indicates the I2C device address. - * @param i2cData Indicates the pointer to the device descriptor of the data to receive. - * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link wifiiot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTI2cWriteread(unsigned int id, unsigned short deviceAddr, const IotI2cData *i2cData); - - - -#endif -/** @} */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_list.h b/Device/RemoteLamp/device/team_x/common/inc/iot_list.h deleted file mode 100644 index e5bd8f824c692a37646f1033b9c30315cb8c6439..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_list.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_LIST_H__ -#define __IOT_LIST_H__ - -typedef void* IOT_LIST; - -IOT_LIST IoT_ListCreate(void *data, int size); - -int IoT_ListAppend(IOT_LIST mHandle, void *data, int size); - -int IoT_ListUpdate(IOT_LIST mHandle, int idx, void *data, int size); - -int IoT_ListDelete(IOT_LIST mHandle, void *data); - -int IoT_ListGet(IOT_LIST mHandle, int idx, void *data, int size); - -int IoT_ListGetSize(IOT_LIST mHandle); - -void IoT_ListClear(IOT_LIST mHandle); - -void IoT_ListDestroy(IOT_LIST mHandle); - -#endif /* __IOT_LIST_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg.h b/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg.h deleted file mode 100644 index 9d1f6445d9fabf5eae884a4a603d1488d1ef9ee6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_NETCFG_H__ -#define __IOT_NETCFG_H__ - -/** - * @brief start net config. - * - * @param ap_name: the ap name - * @param ssid: the buff to store the wifi ssid - * @param sLen: the ssid buff size - * @param pwd: the buff to store the wifi password - * @param pLen: the pwd buff size - * - * @since 1.0 - * @version 1.0 - * - * @return 0 success, -1 failed - */ -int BOARD_NetCfgStartConfig(const char *appName, char *ssid, int sLen, char *pwd, int pLen); - -#endif /* __IOT_NETCFG_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg_nan.h b/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg_nan.h deleted file mode 100644 index 9c82eedb137a5f6ba4db380c300a19ae1ab189ae..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_netcfg_nan.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_NETCFG_NAN_H__ -#define __IOT_NETCFG_NAN_H__ - -#define NETCFG_TASK_STACK_SIZE (1024*4) -#define NETCFG_TASK_PRIO 30 -#define NETCFG_LED_INTERVAL_TIME_US 300000 -#define NETCFG_BIZ_SLEEP_TIME_US 1000000 -#define NETCFG_TIME_COUNT 5 -#define DEVICE_INFO_NUM 2 -#define POWER_NUM (-52) -#define MAX_DATA_LEN 4096 -#define FAST_CONNECT_RETRY_NUM 3 - -#define CHANNEL_80211B_ONLY 14 -#define FREQ_OF_CHANNEL_1 2412 -#define FREQ_OF_CHANNEL_80211B_ONLY 2484 -#define WIFI_MIN_CHANNEL 1 -#define WIFI_FREQ_INTERVAL 5 -#define TEST_CONNECT_RETRY_COUNT 5 - -typedef enum { - NET_EVENT_NULL, - NET_EVENT_CONFIG, - NET_EVENT_CONFIG_FAIL, // Connected wifi failed - NET_EVENT_CONFIG_SUCC, // Connected wifi success - NET_EVENT_CONNECTTED, // Wifi connected - NET_EVENT_DISTCONNECT, // Wifi disconnected - NET_EVENT_RECV_DATA, // Recv message from FA - NET_EVENT_SEND_DATA, // Send the message to FA - - NET_EVENT_TYPE_NBR -}NET_EVENT_TYPE; - -/** - * @brief: the network config service callback - * - * @param event reference {@link NET_EVENT_TYPE} - * @param data The data of the event: NET_EVENT_RECV_DATA or NET_EVENT_SEND_DATA - * @since 1.0 - * @version 1.0 - */ -typedef int (*NetCfgEventCallback)(NET_EVENT_TYPE event, void *data); - -/** - * @brief Register the network config task - * - * @param nEventCallback The callback of netcfg module - * @since 1.0 - * @version 1.0 - */ -void NetCfgRegister(NetCfgEventCallback nEventCallback); - -/** - * @brief start net config. - * - * @param ssid: the buff to store the wifi ssid - * @param sLen: the ssid buff size - * @param pwd: the buff to store the wifi password - * @param pLen: the pwd buff size - * - * @since 1.0 - * @version 1.0 - * - * @return 0 success, -1 failed - */ -int BOARD_NAN_NetCfgStartConfig(const char *apName, char *ssid, int sLen, char *pwd, int pLen); -#endif // __IOT_NETCFG_NAN_H__ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_nfc.h b/Device/RemoteLamp/device/team_x/common/inc/iot_nfc.h deleted file mode 100644 index 1f9eca7088f9cf382b90145b39b8f126aa03392c..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_nfc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_NFC_H__ -#define __IOT_NFC_H__ - - -/** - * @brief Initialize the board NFC - * @return Returns 0 success while others failed - */ -int BOARD_InitNfc(void); - -/** - * @brief Defines the nfc information - */ -typedef struct { - const char *deviceID; - const char *devicePWD; - const char *wifiSSID; - const char *wifiPWD; -}NfcInfo; - -/** - * @brief Get the nfc info - * @param info Indicates the buffer to storage the data get from NFC - * @return Returns 0 success while others failed - */ -int BOARD_GetNfcInfo(NfcInfo *info); - - -#endif /* __IOT_NFC_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_schedule.h b/Device/RemoteLamp/device/team_x/common/inc/iot_schedule.h deleted file mode 100644 index 9c50b6e7d38c0ddc4e574b40a4f3336916e8cc40..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_schedule.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_SCHEDULE_H__ -#define __IOT_SCHEDULE_H__ - -int IOT_ScheduleInit(void); - -int IOT_ScheduleAdd(const char *id, int *day, int size, int startTime, int durTime, int cmd, int value); - -int IOT_ScheduleUpdate(const char *id, int *day, int size, int startTime, int durTime, int cmd, int value); - -int IOT_ScheduleDelete(const char *id, int *day, int size, int startTime, int durTime, int cmd, int value); - -int IOT_ScheduleIsUpdate(unsigned int weekday, int curtime); - -void IOT_ScheduleSetUpdate(int update); - -int IOT_ScheduleGetStartTime(void); - -int IOT_ScheduleGetDurationTime(void); - -int IOT_ScheduleGetCommand(int *cmd, int *value); - -void IOT_ScheduleDeinit(void); - -#endif /* __IOT_SCHEDULE_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_sntp.h b/Device/RemoteLamp/device/team_x/common/inc/iot_sntp.h deleted file mode 100644 index 94c48321359fd21130689ca7682b7180892dc391..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_sntp.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_SNTP_H -#define __IOT_SNTP_H - -#include - -/** - * @brief Additional introduction for the key members in struct tm - * struct timeval maybe defines as following - * int tm_sec; seconds (0 - 60) - * int tm_min; minutes (0 - 59) - * int tm_hour; hours (0 - 23) - * int tm_mday; day of month (1 - 31) - * int tm_mon; month of year (0 - 11) - * int tm_year; year - 1900 - * int tm_wday; day of week (Sunday = 0) - * int tm_yday; day of year (0 - 365) - * int tm_isdst; is summer time in effect? - * char *tm_zone; abbreviation of timezone name - * long tm_gmtoff; offset from UTC in seconds - * - */ - -/** - * @brief Get the ntp time from ntp server (local RTC TIME);Could only be used after the - * Network is ok and the tcpip is initialized ok - * - * @param localTimeZone indicates the local timezone, and could be -11 to 11, 0 means the UTC+0, - * positive means east while negative means west, 8 means UTC+8, like China - * @param rtcTime is a pointer to storage the rtc time if the return value is 0, and must not - * be NULL - * @return Returns 0 success while -1 failed; The content in rtcTime Only be valid when returns 0 - * - */ -int SntpGetRtcTime(int localTimeZone, struct tm *rtcTime); - - -#endif /* __IOT_SNTP_H */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_softap.h b/Device/RemoteLamp/device/team_x/common/inc/iot_softap.h deleted file mode 100644 index 606166464ca51f1cc52f22d1f5b6f285f63418f6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_softap.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_SOFTAP_H__ -#define __IOT_SOFTAP_H__ - -/** - * @brief start ap mode. - * - * @param ap_name the ap name - * - * @since 1.0 - * @version 1.0 - * - * @return 0 success, -1 failed - */ -int BOARD_SoftApStart(const char *ap_name); - -/** - * @brief stop ap mode. - * - * @since 1.0 - * @version 1.0 - * - */ -void BOARD_SoftApStop(void); - -#endif /* __IOT_SOFTAP_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_softap_xradio.h b/Device/RemoteLamp/device/team_x/common/inc/iot_softap_xradio.h deleted file mode 100644 index 606166464ca51f1cc52f22d1f5b6f285f63418f6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_softap_xradio.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - */ - -#ifndef __IOT_SOFTAP_H__ -#define __IOT_SOFTAP_H__ - -/** - * @brief start ap mode. - * - * @param ap_name the ap name - * - * @since 1.0 - * @version 1.0 - * - * @return 0 success, -1 failed - */ -int BOARD_SoftApStart(const char *ap_name); - -/** - * @brief stop ap mode. - * - * @since 1.0 - * @version 1.0 - * - */ -void BOARD_SoftApStop(void); - -#endif /* __IOT_SOFTAP_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_spi.h b/Device/RemoteLamp/device/team_x/common/inc/iot_spi.h deleted file mode 100644 index 663c1b8e33071831f1172c38027f2a08535ff3ec..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_spi.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup IotHardware - * @{ - * - * @brief Provides APIs for operating devices, - * including flash, GPIO, I2C, PWM, UART, and watchdog APIs. - * - * - * - * @since 2.2 - * @version 2.2 - */ - -/** - * @file iot_spi.h - * - * @brief Declares flash functions. - * - * These functions are used to initialize or deinitialize a flash device, - * and read data from or write data to a flash memory. \n - * - * @since 2.2 - * @version 2.2 - */ - -#ifndef IOT_SPI_H -#define IOT_SPI_H - -/** - * @brief Indicates the SPI callback, which is used in {@link SpiRegisterUsrFunc}. - */ -typedef void (*SpiIsrFunc)(void); - -/** - * @brief Enumerates SPI channel IDs. - */ -typedef enum { - /** Channel 0 */ - IOT_SPI_ID_0 = 0, - /** Channel 1 */ - IOT_SPI_ID_1, -} IotSpiIdx; - -/** - * @brief Enumerates communication polarities. - */ -typedef enum { - /** Polarity 0 */ - IOT_SPI_CFG_CLOCK_CPOL_0, - /** Polarity 1 */ - IOT_SPI_CFG_CLOCK_CPOL_1, -}IotSpiCfgClockCpol; - -/** - * @brief Enumerates communication phases. - */ -typedef enum { - /** Phase 0 */ - IOT_SPI_CFG_CLOCK_CPHA_0, - /** Phase 1 */ - IOT_SPI_CFG_CLOCK_CPHA_1, -} IotSpiCfgClockCpha; - -/** - * @brief Enumerates communication protocols. - */ -typedef enum { - /** Motorola protocol */ - IOT_SPI_CFG_FRAM_MODE_MOTOROLA, - /** Texas Instruments protocol */ - IOT_SPI_CFG_FRAM_MODE_TI, - /** Microwire protocol */ - IOT_SPI_CFG_FRAM_MODE_MICROWIRE, -} IotSpiCfgFramMode; - -/** - * @brief Enumerates the communication data width, that is, - * the number of valid bits in each frame. - * - */ -typedef enum { - /** 4 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_4BIT = 0x3, - /** 5 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_5BIT, - /** 6 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_6BIT, - /** 7 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_7BIT, - /** 8 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_8BIT, - /** 9 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_9BIT, - /** 10 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_10BIT, - /** 11 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_11BIT, - /** 12 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_12BIT, - /** 13 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_13BIT, - /** 14 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_14BIT, - /** 15 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_15BIT, - /** 16 bits */ - IOT_SPI_CFG_DATA_WIDTH_E_16BIT, -} IotSpiCfgDataWidth; - -/** - * @brief Enumerates the endian mode of each frame. - */ -typedef enum { - /** Little-endian */ - IOT_SPI_CFG_ENDIAN_LITTLE, - /** Big-endian */ - IOT_SPI_CFG_ENDIAN_BIG, -} IotSpiCfgEndian; - -/** - * @brief Defines data communication parameters. - */ -typedef struct { - /** Communication polarity. For details about available values, - * see {@link IotSpiCfgClockCpol}. - */ - unsigned int cpol : 1; - /** Communication phase. - * For details about available values, see {@link IotSpiCfgClockCpha}. - */ - unsigned int cpha : 1; - /** Communication protocol. - * For details about available values, see {@link IotSpiCfgFramMode}. - */ - unsigned int framMode : 2; - /** Communication data width. - * For details about available values, see {@link IotSpiCfgDataWidth}. - */ - unsigned int dataWidth : 4; - /** Endian mode. For details about available values, see {@link IotSpiCfgEndian}. */ - unsigned int endian : 1; - /** Padding bit */ - unsigned int pad : 23; - /** Communication frequency. The value ranges from 2460 Hz to 40 MHz. */ - unsigned int freq; -} IotSpiCfgBasicInfo; - -/** - * @brief Specifies whether a device is a master or slave device. - * - * @since 1.0 - * @version 1.0 - */ -typedef struct { - /** Whether the device is a slave device */ - unsigned int isSlave : 1; - /** Padding bit */ - unsigned int pad : 31; -} IotSpiCfgInitParam; - -/** - * @brief Sends data in SPI slave mode. - * - * In SPI slave mode, this function sends data of the length - * specified by byteLen in writeData through - * the channel specified by spiId within the duration timeOutMs. - * - * @param spiId Indicates the SPI channel ID. - * @param writeData Indicates the pointer to the data to send. - * @param byteLen Indicates the length of the data to send. - * @param timeOutMs Indicates the timeout interval. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSlaveWrite(IotSpiIdx spiId, char *writeData, unsigned int byteLen, unsigned int timeOutMs); - -/** - * @brief Reads data in SPI slave mode. - * - * In SPI slave mode, this function reads data of the length - * specified by byteLen in readData through the channel - * specified by spiId within the duration timeOutMs. - * - * @param spiId Indicates the SPI channel ID. - * @param readData Indicates the pointer to the data to read. - * @param byteLen Indicates the length of the data to read. - * @param timeOutMs Indicates the timeout interval. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSlaveRead(IotSpiIdx spiId, char *readData, unsigned int byteLen, unsigned int timeOutMs); - -/** - * @brief Sends data in half-duplex SPI master mode. - * - * In SPI master mode, this function sends data of the length - * specified by byteLen in writeData - * through the channel specified by spiId. - * - * @param spiId Indicates the SPI channel ID. - * @param writeData Indicates the pointer to the data to send. - * @param byteLen Indicates the length of the data to send. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiHostWrite(IotSpiIdx spiId, char *writeData, unsigned int byteLen); - -/** - * @brief Reads data in half-duplex SPI master mode. - * - * In SPI master mode, this function reads data of the length - * specified by byteLen in readData - * through the channel specified by spiId. - * - * @param spiId Indicates the SPI channel ID. - * @param readData Indicates the pointer to the data to read. - * @param byteLen Indicates the length of the data to read. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiHostRead(IotSpiIdx spiId, char *readData, unsigned int byteLen); - -/** - * @brief Sends and reads data in full-duplex SPI master mode. - * - * In SPI master mode, this function sends data in writeData and - * reads data of the length specified by byteLen in readData - * both through the channel specified by spiId. - * - * @param spiId Indicates the SPI channel ID. - * @param writeData Indicates the pointer to the data to send. - * @param readData Indicates the pointer to the data to read. - * @param byteLen Indicates the length of the data to read. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiHostWriteread(IotSpiIdx spiId, char *writeData, char *readData, unsigned int byteLen); - -/** - * @brief Sets the SPI channel parameter. - * - * - * - * @param spiId Indicates the SPI channel ID. - * @param param Indicates the pointer to the SPI parameter to set. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSetBasicInfo(IotSpiIdx spiId, const IotSpiCfgBasicInfo *param); - -/** - * @brief Initializes an SPI device. - * - * This function initializes the device with the channel ID spiId, - * device type initParam, and device parameter param. - * - * @param spiId Indicates the SPI channel ID. - * @param initParam Specifies whether the device is a slave one. - * @param param Indicates the pointer to the SPI device parameter. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiInit(IotSpiIdx spiId, IotSpiCfgInitParam initParam, const IotSpiCfgBasicInfo *param); - -/** - * @brief Deinitializes an SPI device. - * - * @param spiId Indicates the SPI channel ID. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiDeinit(IotSpiIdx spiId); - -/** - * @brief Sets whether to enable the interrupt request (IRQ) mode for an SPI device. - * - * - * - * @param spiId Indicates the SPI channel ID. - * @param irqEn Specifies whether to enable IRQ. - * The value 1 means to enable IRQ, and 0 means to disable IRQ. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSetIrqMode(IotSpiIdx spiId, unsigned char irqEn); - -/** - * @brief Sets whether to enable DMA to transfer data for an SPI device in slave mode. - * - * - * - * @param spiId Indicates the SPI channel ID. - * @param dmaEn Specifies whether to enable DMA. - * The value 1 means to enable DMA, and 0 means to disable DMA. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSetDmaMode(IotSpiIdx spiId, unsigned char dmaEn); - -/** - * @brief Registers the data TX preparation/recovery function. - * - * This function registers the functions - * registered by prepareF and restoreF for - * an SPI device with a channel specified by spiId. - * - * @param spiId Indicates the SPI channel ID. - * @param prepareF Indicates the function used for data preparation. - * @param restoreF Indicates the function used for data recovery. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiRegisterUsrFunc(IotSpiIdx spiId, SpiIsrFunc prepareF, SpiIsrFunc restoreF); - -/** - * @brief Sets whether to enable loopback test for an SPI device. - * - * - * - * @param spiId Indicates the SPI channel ID. - * @param lbEn Specifies whether to enable loopback test. The value 1 - * means to enable loopback test, and 0 means to disable loopback test. - * @return Returns {@link IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link iot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int IoTSpiSetLoopBackMode(IotSpiIdx spiId, unsigned char lbEn); - -#endif -/** @} */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_store_manager.h b/Device/RemoteLamp/device/team_x/common/inc/iot_store_manager.h deleted file mode 100644 index 447da36ab55df65ebd635035635d01ae914d44f2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_store_manager.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * 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. - */ - -#ifndef __IOT_STORE_MANAGER_H__ -#define __IOT_STORE_MANAGER_H__ - -#define USER_KV_STORE 1 -#if (USER_KV_STORE) -int StoreManagerAddData(const char *data, int length); - -int StoreManagerUpdateData(int idx, const char *data, int length); - -int StoreManagerDeleteDataWithId(int idx); - -int StoreManagerDeleteData(const char *data); - -int StoreManagerGetTotal(void); - -int StoreManagerGetData(char *data, int size, int idx); - -void StoreManagerDelete(void); - -#endif - -#endif /* __IOT_STORE_MANAGER_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_wifi.h b/Device/RemoteLamp/device/team_x/common/inc/iot_wifi.h deleted file mode 100644 index 011ff13ef87b94de6bbe9008408d824a065ecb20..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_wifi.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ - -#ifndef IOT_WIFI_H_ -#define IOT_WIFI_H_ - -/** - * @brief Initialize the board wifi - * @return Returns 0 success while others failed - */ -int BOARD_InitWifi(void); - -/** - * @brief Connect to the wifi - * @param wifiSSID Indicates the ssid of the ap - * @param wifiPWD Indicates the pwd of the ap - * @return Returns 0 success while others failed - */ -int BOARD_ConnectWifi(const char *wifiSSID, const char *wifiPWD); - -/** - * @brief Disconnect from the wifi AP - * @return Returns 0 success while others failed - */ -int BOARD_DisconnectWifi(void); - -#endif /* IOT_WIFI_H_ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/iot_wifi_xradio.h b/Device/RemoteLamp/device/team_x/common/inc/iot_wifi_xradio.h deleted file mode 100644 index 011ff13ef87b94de6bbe9008408d824a065ecb20..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/iot_wifi_xradio.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ - -#ifndef IOT_WIFI_H_ -#define IOT_WIFI_H_ - -/** - * @brief Initialize the board wifi - * @return Returns 0 success while others failed - */ -int BOARD_InitWifi(void); - -/** - * @brief Connect to the wifi - * @param wifiSSID Indicates the ssid of the ap - * @param wifiPWD Indicates the pwd of the ap - * @return Returns 0 success while others failed - */ -int BOARD_ConnectWifi(const char *wifiSSID, const char *wifiPWD); - -/** - * @brief Disconnect from the wifi AP - * @return Returns 0 success while others failed - */ -int BOARD_DisconnectWifi(void); - -#endif /* IOT_WIFI_H_ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/network_config_service.h b/Device/RemoteLamp/device/team_x/common/inc/network_config_service.h deleted file mode 100644 index 2684f9e9497025217dc502aa91e7adb38d06b91c..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/network_config_service.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * 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. - */ - -/** - * @addtogroup NetcfgService - * @{ - * - * @brief Provides the network configuration service. Two network configuration modes are available: - * Neighbor Awareness Networking (NAN) and software enabled access point (SoftAP). - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file network_config_service.h - * - * @brief Defines functions of the NetcfgService module. - * - * You can use the functions to: \n - *
    - *
  • Start the network configuration service.
  • - *
  • Stop the network configuration service.
  • - *
  • Register callbacks for events of the network configuration service.
  • - *
  • Notify the network configuration result.
  • - *
- * - * @since 1.0 - * @version 1.0 - */ - -#ifndef NETWORK_CONFIG_SERVICE_H -#define NETWORK_CONFIG_SERVICE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Represents the maximum length (32 bytes) of a SoftAP hotspot name. - * - */ -#define SSID_MAX_LEN 32 - -/** - * @brief Represents the maximum length (64 bytes) of a SoftAP hotspot password. - * - */ -#define PWD_MAX_LEN 64 - -/** - * @brief Represents the maximum length (32 bytes) of a Wi-Fi Service Set Identifier (SSID). - * - */ -#define WIFI_SSID_MAX_LEN 32 - -/** - * @brief Represents the maximum length (64 bytes) of the password for Wi-Fi configuration. - * - */ -#define WIFI_PWD_MAX_LEN 64 - -/** - * @brief Represents the maximum length (32 bytes) of the pre-shared key for Wi-Fi configuration. - * - */ -#define WIFI_PSK_LEN 32 - -/** - * @brief Represents the maximum length (64 bytes) of the Basic Service Set Identifiers (BSSID) \n - * for Wi-Fi configuration. - * - */ -#define WIFI_BSSID_LEN 6 - -/** - * @brief Enumerates Wi-Fi encryption types. - * - */ -enum WifiPairwise { - /** UNKNOWN */ - WIFI_PARIWISE_UNKNOWN, - /** AES */ - WIFI_PAIRWISE_AES, - /** TKIP */ - WIFI_PAIRWISE_TKIP, - /** TKIP and AES */ - WIFI_PAIRWISE_TKIP_AES_MIX -}; - -/** - * @brief Enumerates Wi-Fi authentication types. - * - */ -enum WifiAuthMode { - /** Open */ - WIFI_SECURITY_OPEN, - /** WEP */ - WIFI_SECURITY_WEP, - /** WPA2-PSK */ - WIFI_SECURITY_WPA2PSK, - /** WPA-PSK and WPA2-PSK */ - WIFI_SECURITY_WPAPSK_WPA2PSK_MIX, - /** WPA-PSK */ - WIFI_SECURITY_WPAPSK, - /** WPA */ - WIFI_SECURITY_WPA, - /** WPA2 */ - WIFI_SECURITY_WPA2, - /** SAE */ - WIFI_SECURITY_SAE, - /** UNKNOWN */ - WIFI_SECURITY_UNKNOWN -}; - -/** - * @brief Enumerates network configuration types. - * - */ -enum NetCfgType { - /** SoftAP */ - NETCFG_SOFTAP = 0, - /** SoftAP and NAN */ - NETCFG_SOFTAP_NAN, - /** Reserved */ - NETCFG_BUTT, -}; - -/** - * @brief Enumerates common error codes of the NetcfgService module. - * - */ -enum NetworkCfgErrorCode { - /** Success */ - NETCFG_OK = 0, - /** Execution failure */ - NETCFG_ERROR = -1, - /** Invalid device information */ - NETCFG_DEV_INFO_INVALID = -2, - /** Invalid SoftAP network configuration parameters */ - NETCFG_SOFTAP_PARAM_INVALID = -3, - /** Incorrect network configuration mode */ - NETCFG_MODE_INVALID = -4, - /** Invalid power for short-distance transmission */ - NETCFG_POWER_INVALID = -5, -}; - -/** - * @brief Enumerates information transmission channels for Wi-Fi configuration. - * - */ -enum WifiInfoSource { - /** Wi-Fi network configuration information is transmitted through NAN channels. */ - WIFI_INFO_FROM_NAN = 0, - /** Wi-Fi network configuration information is transmitted through SoftAP channels. */ - WIFI_INFO_FROM_SOFTAP, -}; - -/** - * @brief Enumerates network configuration service statuses. - * - */ -enum NetCfgStatus { - /** In NAN mode, blinking or buzzing stops when the network configuration is complete or times out. */ - NETCFG_IDENTIFY_DISABLE = 0, - /** In NAN mode, the indicator blinks or the buzzer buzzes when a device is authenticated for access. */ - NETCFG_IDENTIFY_ENABLE = 1, - /** The device is in network configuration. */ - NETCFG_WORKING = 2 -}; - -/** - * @brief Defines SoftAP hotspot parameters. - */ -struct SoftAPParam { - /** (Mandatory) Hotspot name. For details about the maximum length, see {@link SSID_MAX_LEN}. */ - char ssid[SSID_MAX_LEN + 1]; - /** (Optional) Hotspot password. For details about the maximum length, see {@link PWD_MAX_LEN}. - * If the password is empty, the SoftAP is in open mode. - * If the password is not empty, the password length must be less than or equal to the value of PWD_MAX_LEN. - */ - char password[PWD_MAX_LEN + 1]; - /** (Optional) Authentication type - * If the password is empty, the authentication mode must be open. - * If the password is specified, the authentication type can be WEP, WPA2-PSK, or both. - */ - int authType; - /** (Optional) Encryption type. - * Currently, UNKNOWN, AES, TKIP, and TKIP and AES encryption types are supported. - */ - int pairwise; - /** (Optional) Whether to hide the SSID. - * 0 means not to hide the SSID, and 1 means to hide the SSID. - */ - int isHidden; - /** (Optional) Working channel required in the SoftAP mode - * 0: The channel is specified by the system. 1 to 14: The channel is specified by users. - */ - int channelNum; -}; - -/** - * @brief Defines device parameters, which are passed when the application starts the network configuration service. - */ -struct DevInfo { - /** Device parameter name, which contains a maximum of 32 bytes. */ - const char *key; - /** Device parameter value, which contains a maximum of 64 bytes. */ - const char *value; -}; - -/** - * @brief Defines the SSID name, password, and channel used for Wi-Fi configuration. - */ -struct WifiInfo { - /** SSID name. For details about the maximum length, see {@link WIFI_SSID_MAX_LEN}. */ - unsigned char ssid[WIFI_SSID_MAX_LEN + 1]; - /** SSID password. For details about the maximum length, see {@link WIFI_PWD_MAX_LEN}. */ - unsigned char pwd[WIFI_PWD_MAX_LEN + 1]; - /** Pre-shared key. For details about the maximum length, see {@link WIFI_PSK_LEN}. */ - unsigned char psk[WIFI_PSK_LEN + 1]; - /** BSSID. For details about the maximum length, see {@link WIFI_BSSID_LEN}. */ - unsigned char bssid[WIFI_BSSID_LEN + 1]; - /** Length of the SSID name */ - unsigned char ssidLen; - /** Length of the SSID password */ - unsigned char pwdLen; - /** Length of the pre-shared key */ - unsigned char pskLen; - /** Length of the BSSID */ - unsigned char bssidLen; - /** Authentication type used for Wi-Fi configuration - * If the password is empty, the authentication mode must be open. - * If the password is specified, the authentication type can be WEP, WPA2-PSK, or both. - */ - int authMode; - /** Channel for transmitting information. For details about the value, see {@link WifiInfoSource}. */ - int wifiInfoSrc; - /** Working channel used for Wi-Fi configuration. The value ranges from 1 to 14. */ - int channelNumber; -}; - -/** - * @brief Defines callbacks for network configuration registration. - */ -typedef struct { - /** Obtains the PIN code of the device. The maximum length of the PIN code is 16 bytes. */ - int (*GetPinCode)(unsigned char *pinCode, unsigned int size, unsigned int *len); - /** Processes Wi-Fi information and vendor data during network configuration */ - int (*ParseNetCfgData)(const struct WifiInfo *wifiInfo, - const unsigned char *vendorData, unsigned int vendorDataLen); - /** Processes application rapid control data in the rapid control phase. - * The svcId parameter is reserved for device compatibility. The default value is NULL. - * The mode parameter is reserved. The default value is 0. - */ - int (*RecvRawData)(const char *svcId, unsigned int mode, const char *data); - /** Notifies the network configuration service status. \n - * For example, when a device is in NAN mode, this function can be called to control the blinking or buzzer used \n - * for notifications. \n - * status indicates the network configuration status. \n - * The value 0 means to stop buzzing or blinking. \n - * The value 1 means to start buzzing or blinking. \n - * The value 2 means that the device is in the network configuration state. \n - */ - void (*NotifyNetCfgStatus)(enum NetCfgStatus status); - /** Disconnects the network configuration. \n - * This function is used to notify the application when an internal error occurs during network configuration \n - * or a disconnection request is received from the mobile phone. \n - * The errCode values are as follows: \n - * 0: The application fails to receive the network configuration data. \n - * The network configuration service automatically starts. \n - * 1: The application has been notified of the network configuration data and needs to determine \n - * whether to stop or restart the network configuration service. \n - */ - void (*OnDisconnect)(int errCode); -} NetCfgCallback; - -/** - * @brief Sets the transmit channel power for ultra-short-distance transmission \n - * before the network configuration service is started. - * - * @param power Indicates the power for ultra-short-distance transmission. \n - * The value can be -70, -67, -65, -63, -61, -58, -55, \n - * -52, -48, -45, or -42. To prevent a mobile phone far away from the device \n - * from receiving security information, ensure that the wireless transmit power at any point \n - * on the product (including the external antenna) does not exceed -65 dBm. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int SetSafeDistancePower(signed char power); - -/** - * @brief Sets SoftAP hotspot parameters. - * - * @param param Indicates the pointer to the structure of the hotspot parameters. For details, see {@link SoftAPParam}. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int SetSoftAPParameter(const struct SoftAPParam *param); - -/** - * @brief Registers a callback. - * - * Call this function before enabling the network configuration service. - * - * @param callback Indicates the pointer to the structure of the callback function. \n - * For details, see {@link NetCfgCallback}. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int RegNetCfgCallback(const NetCfgCallback *callback); - -/** - * @brief Starts a network configuration. - * - * Packets with the multicast address 238.238.238.238 and port number 5683 are listened by default. - * Note: In NAN mode, call this function after the SoftAP is started successfully. - * - * @param devInfoList Indicates the pointer to the device information list. For details, see {@link DevInfo}. - * @param listSize Indicates the number of devices in the device information list. - * @param mode Indicates the working mode of the network configuration service. For details, see {@link NetcfgPara}. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int StartNetCfg(const struct DevInfo *devInfoList, unsigned int listSize, enum NetCfgType mode); - -/** - * @brief Stops the network configuration. - * - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int StopNetCfg(void); - -/** - * @brief Notifies the network configuration result. - * - * @param result Indicates the network configuration result. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int NotifyNetCfgResult(signed int result); - -/** - * @brief Sends data. - * - * @param data Indicates the pointer to the data to send. The data is a character string. - * @return Returns the operation result. For details, see {@link NetworkCfgErrorCode}. - * @since 1.0 - * @version 1.0 - */ -int SendRawData(const char *data); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Device/RemoteLamp/device/team_x/common/inc/peripheral_hal.h b/Device/RemoteLamp/device/team_x/common/inc/peripheral_hal.h deleted file mode 100644 index 370cd942c8fcd2b155c772b6cc389deb87105d88..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/peripheral_hal.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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. - */ - -#ifndef PERIPHERAL_HAL_H -#define PERIPHERAL_HAL_H - -#include "ohos_types.h" - -/* gpio start */ -typedef enum { - /** GPIO hardware pin 0 */ - HAL_WIFI_IOT_IO_NAME_GPIO_0, - /** GPIO hardware pin 1 */ - HAL_WIFI_IOT_IO_NAME_GPIO_1, - /** GPIO hardware pin 2 */ - HAL_WIFI_IOT_IO_NAME_GPIO_2, - /** GPIO hardware pin 3 */ - HAL_WIFI_IOT_IO_NAME_GPIO_3, - /** GPIO hardware pin 4 */ - HAL_WIFI_IOT_IO_NAME_GPIO_4, - /** GPIO hardware pin 5 */ - HAL_WIFI_IOT_IO_NAME_GPIO_5, - /** GPIO hardware pin 6 */ - HAL_WIFI_IOT_IO_NAME_GPIO_6, - /** GPIO hardware pin 7 */ - HAL_WIFI_IOT_IO_NAME_GPIO_7, - /** GPIO hardware pin 8 */ - HAL_WIFI_IOT_IO_NAME_GPIO_8, - /** GPIO hardware pin 9 */ - HAL_WIFI_IOT_IO_NAME_GPIO_9, - /** GPIO hardware pin 10 */ - HAL_WIFI_IOT_IO_NAME_GPIO_10, - /** GPIO hardware pin 11 */ - HAL_WIFI_IOT_IO_NAME_GPIO_11, - /** GPIO hardware pin 12 */ - HAL_WIFI_IOT_IO_NAME_GPIO_12, - /** GPIO hardware pin 13 */ - HAL_WIFI_IOT_IO_NAME_GPIO_13, - /** GPIO hardware pin 14 */ - HAL_WIFI_IOT_IO_NAME_GPIO_14, - /** Maximum value */ - HAL_WIFI_IOT_IO_NAME_MAX, -} HalWifiIotIoName; - -/** - * @brief set IO function. - * - * @param id -- IO number, reference {@ HalWifiIotIoName}. - * @param val -- the io function value which defined in {@ hi_io.h}. - * - * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link wifiiot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int HalIoSetFunc(HalWifiIotIoName id, const char *val); -/* gpio end */ - - -/* adc start */ - -/** - * @brief Enumerates ADC channel indexes. - * - */ -typedef enum { - /** Channel 0 */ - HAL_WIFI_IOT_ADC_CHANNEL_0, - /** Channel 1 */ - HAL_WIFI_IOT_ADC_CHANNEL_1, - /** Channel 2 */ - HAL_WIFI_IOT_ADC_CHANNEL_2, - /** Channel 3 */ - HAL_WIFI_IOT_ADC_CHANNEL_3, - /** Channel 4 */ - HAL_WIFI_IOT_ADC_CHANNEL_4, - /** Channel 5 */ - HAL_WIFI_IOT_ADC_CHANNEL_5, - /** Channel 6 */ - HAL_WIFI_IOT_ADC_CHANNEL_6, - /** Channel 7 */ - HAL_WIFI_IOT_ADC_CHANNEL_7, - /** Button value */ - HAL_WIFI_IOT_ADC_CHANNEL_BUTT, -} HalWifiIotAdcChannelIndex; - -/** - * @brief Enumerates analog power control modes. - */ -typedef enum { - /** Automatic control */ - HAL_WIFI_IOT_ADC_CUR_BAIS_DEFAULT, - /** Automatic control */ - HAL_WIFI_IOT_ADC_CUR_BAIS_AUTO, - /** Manual control (AVDD = 1.8 V) */ - HAL_WIFI_IOT_ADC_CUR_BAIS_1P8V, - /** Manual control (AVDD = 3.3 V) */ - HAL_WIFI_IOT_ADC_CUR_BAIS_3P3V, - /** Button value */ - HAL_WIFI_IOT_ADC_CUR_BAIS_BUTT, -} HalWifiIotAdcCurBais; - -/** - * @brief Enumerates equation models. - */ -typedef enum { - /** One-equation model */ - HAL_WIFI_IOT_ADC_EQU_MODEL_1, - /** Two-equation model */ - HAL_WIFI_IOT_ADC_EQU_MODEL_2, - /** Four-equation model */ - HAL_WIFI_IOT_ADC_EQU_MODEL_4, - /** Eight-equation model */ - HAL_WIFI_IOT_ADC_EQU_MODEL_8, - /** Button value */ - HAL_WIFI_IOT_ADC_EQU_MODEL_BUTT, -} HalWifiIotAdcEquModelSel; - -/** - * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters. - * - * - * - * @param channel Indicates the ADC channel index. - * @param data Indicates the pointer to the address for storing the read data. - * @param equModel Indicates the equation model. - * @param curBais Indicates the analog power control mode. - * @param rstCnt Indicates the count of the time from reset to conversion start. - * One count is equal to 334 ns. The value must range from 0 to 0xFF0. - * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link wifiiot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int HalAdcRead(HalWifiIotAdcChannelIndex channel, unsigned short *data, HalWifiIotAdcEquModelSel equModel, - HalWifiIotAdcCurBais curBais, unsigned short rstCnt); -/** adc end ****/ - -/** - * @brief set WatchDog enable or disable. - * - * @param enable -- 1 enable, 0 disable. - * - * @since 1.0 - * @version 1.0 - */ -void HalSetWatchDogEnable(int enable); - -/** - * @brief start the pwm. - * - * @param id Port id of PWM - * @param duty The usefull cycles of PWM - * @param freq The total cycles of PWM - * - * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful; - * returns an error code defined in {@link wifiiot_errno.h} otherwise. - * @since 1.0 - * @version 1.0 - */ -unsigned int HalPwmStart(uint32 id, uint16 duty, uint16 freq); - -#endif // PERIPHERAL_HAL_H \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/inc/schedule_list.h b/Device/RemoteLamp/device/team_x/common/inc/schedule_list.h deleted file mode 100644 index 38a0138a3261f2b435a7a195496418482b58bc51..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/schedule_list.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -#ifndef __SCHEDULE_LIST_H__ -#define __SCHEDULE_LIST_H__ - -#include "schedule_store.h" - -#define SCH_DEBUG -#ifdef SCH_DEBUG -#define SCH_DBG(fmt, args...) printf("[DEBUG][%s|%d]" fmt, __func__, __LINE__, ##args) -#define SCH_ERR(fmt, args...) printf("[ERROR][%s|%d]" fmt, __func__, __LINE__, ##args) -#else -#define SCH_DBG(fmt, args...) do{}while(0) -#define SCH_ERR(fmt, args...) do{}while(0) -#endif - -typedef void* SCHEDULE_LIST; - -SCHEDULE_LIST ScheduleListCreate(ScheduleInfo *info); - -int ScheduleListAppend(SCHEDULE_LIST mHandle, ScheduleInfo *info); - -int ScheduleListUpdate(SCHEDULE_LIST mHandle, ScheduleInfo *info); - -int ScheduleListDelete(SCHEDULE_LIST mHandle, ScheduleInfo *info); - -int ScheduleListGetSize(SCHEDULE_LIST mHandle); - -int ScheduleListGet(SCHEDULE_LIST mHandle, int idx, ScheduleInfo *info); - -void ScheduleListDestroy(SCHEDULE_LIST mHandle); - -#endif /* __SCHEDULE_LIST_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/schedule_store.h b/Device/RemoteLamp/device/team_x/common/inc/schedule_store.h deleted file mode 100644 index 5bb84cb149e4162c85895e6c33611cb6e4f29f3a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/schedule_store.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -#ifndef __SCHEDULE_STORE_H__ -#define __SCHEDULE_STORE_H__ - -#define SCHEDULE_ID_LENGTH 40 - -typedef struct { - unsigned char cmd; - unsigned int value; -}ScheduleCommand; - -typedef struct { - unsigned char week; - unsigned int starttime; - unsigned int duration; - unsigned char id[SCHEDULE_ID_LENGTH]; - - ScheduleCommand scheduleCmd; -} ScheduleInfo; - -typedef enum { - SCHEDULE_OPTION_ADD = 0, - SCHEDULE_OPTION_UPDATE, - SCHEDULE_OPTION_DELETE -} SCHEDULE_OPTION; - -int ScheduleStoreUpdate(ScheduleInfo *info, SCHEDULE_OPTION option); - -int ScheduleStoreGetTotal(void); - -int ScheduleStoreGetInfo(ScheduleInfo *info, int idx); - -void ScheduleStoreDelete(void); - -#endif /* __SCHEDULE_STORE_H__ */ diff --git a/Device/RemoteLamp/device/team_x/common/inc/utils_hal.h b/Device/RemoteLamp/device/team_x/common/inc/utils_hal.h deleted file mode 100644 index fb158c285296d1f53a06127802d4137125f91a4e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/inc/utils_hal.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef __UTILS_HAL_H__ -#define __UTILS_HAL_H__ - -void hal_udelay(uint32 us); - -#endif // __UTILS_HAL_H__ \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/BUILD.gn b/Device/RemoteLamp/device/team_x/common/iot_wifi/BUILD.gn deleted file mode 100644 index 7583ce21633b97cc4a5fb008548911583fd951be..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/iot_wifi/BUILD.gn +++ /dev/null @@ -1,49 +0,0 @@ -# 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. - -config_file = [ - "libs/libnetcfgdevicesdk.a", - "libs/libhilinkadapter_3861.a", - "libs/libHwKeystoreSDK.a" -] - -copy("config") { - sources = config_file - outputs = [ "$root_build_dir/libs/{{source_file_part}}" ] -} - -static_library("iot_wifi") { - sources = [ - "iot_wifi.c", - "iot_softap.c", - "iot_netcfg.c", - "iot_netcfg_nan.c" - ] - - cflags = [ "-Wno-unused-variable" ] - cflags += [ "-Wno-unused-but-set-variable" ] - cflags += [ "-Wno-unused-parameter" ] - - include_dirs = [ - "//foundation/communication/wifi_lite/interfaces/wifiservice", - "//third_party/mbedtls/include/mbedtls", - "//kernel/liteos_m/kal/cmsis", - "//third_party/cJSON", - "../inc", - ] - - deps = [ - - ] - -} diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg.c b/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg.c deleted file mode 100644 index e5080a6be9a87e1834e414f6d514c8e2a5ccf2e4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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. - */ - -#include -#include "errno.h" -#include "cmsis_os2.h" -#include "sys/time.h" -#include "sys/socket.h" -#include "netinet/in.h" -#include "lwip/inet.h" -#include "lwip/netdb.h" - -#include "cJSON.h" -#include "ohos_types.h" -#include "iot_softap.h" -#include "iot_netcfg.h" -#include "iot_demo_def.h" - -#define SSID_MAX_LEN 32 -#define PWD_MAX_LEN 32 -#define NET_PORT 8686 -#define RETRY_TIMES 5 -#define CONNECT_TIMEOUT 20 -#define CMD_KEY "cmd" -#define PAR_KEY "param" -#define SID_KEY "wifiName" -#define PWD_KEY "wifiPassword" -#define CMD_CONFIG 0x20 -#define REQUEST_STR "{\"cmd\":32,\"code\":200,\"msg\":\"\"}" - -static int ParseWifiInfo(const char *psr, char *ssid, int sl, char *pwd, int pl) -{ - cJSON *json; - cJSON *sub; - cJSON *obj; - int cmd; - char *ps = NULL; - char *pw = NULL; - - json = cJSON_Parse(psr); - RaiseLog(LOG_LEVEL_ERR, "parse_json: %s\n", psr); - if (json == NULL) { - RaiseLog(LOG_LEVEL_ERR, "parse_json: %s\n", psr); - return -1; - } - - sub = cJSON_GetObjectItem(json, CMD_KEY); - cmd = cJSON_GetNumberValue(sub); - if (cmd != CMD_CONFIG) { - RaiseLog(LOG_LEVEL_ERR, "CMD TYPE FAILED! cmd=%d \n", cmd); - cJSON_Delete(json); - return -1; - } - - sub = cJSON_GetObjectItem(json, PAR_KEY); - if (sub == NULL) { - RaiseLog(LOG_LEVEL_ERR, "get param obj failed! \n"); - cJSON_Delete(json); - return -1; - } - - obj = cJSON_GetObjectItem(sub, SID_KEY); - ps = cJSON_GetStringValue(obj); - if (ps == NULL) { - RaiseLog(LOG_LEVEL_ERR, "get ssid failed! \n"); - cJSON_Delete(json); - return -1; - } - - if (strncpy_s(ssid, sl, ps, strlen(ps)) < 0) { - RaiseLog(LOG_LEVEL_ERR, "strncpy_s failed! \n"); - cJSON_Delete(json); - return -1; - } - - obj = cJSON_GetObjectItem(sub, PWD_KEY); - pw = cJSON_GetStringValue(obj); - if (pw != NULL) { - RaiseLog(LOG_LEVEL_INFO, "pw=%s\n", pw); - if (strncpy_s(pwd, pl, pw, strlen(pw)) < 0) { - RaiseLog(LOG_LEVEL_ERR, "strncpy_s failed! \n"); - cJSON_Delete(json); - return -1; - } - } - - cJSON_Delete(json); - return 0; -} - -static int NetCfgGetSocketValue(int sockfd, char *ssid, int sLen, char *pwd, int pLen) -{ - int result = -1; - - if (sockfd < 0) { - RaiseLog(LOG_LEVEL_ERR, "sockfd invalid!\n"); - return -1; - } - - if (ssid == NULL || sLen < SSID_MAX_LEN || pwd == NULL || pLen < PWD_MAX_LEN) { - RaiseLog(LOG_LEVEL_ERR, "NULL POINT!\n"); - return -1; - } - - while (1) { - int readbytes; - struct sockaddr_in addr; - char recvbuf[BUFF_SIZE] = {0}; - socklen_t len = sizeof(addr); - - readbytes = recvfrom(sockfd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr *)&addr, &len); - if (readbytes <= 0) { - RaiseLog(LOG_LEVEL_ERR, "socket disconnect! \n"); - break; - } - - if (ParseWifiInfo((const char *)recvbuf, ssid, sLen, pwd, pLen) == 0) { - sendto(sockfd, REQUEST_STR, strlen(REQUEST_STR), 0, (struct sockaddr *)&addr, &len); - result = 0; - break; - } - } - - return result; -} - -static int NetCfgGetWifiInfo(char *ssid, int sLen, char *pwd, int pLen) -{ - int sockfd; - struct sockaddr_in servaddr; - - if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - RaiseLog(LOG_LEVEL_ERR, "socket error! \n"); - return -1; - } - - memset_s(&servaddr, sizeof(servaddr), 0, sizeof(servaddr)); - servaddr.sin_family = AF_INET; - servaddr.sin_port = htons(NET_PORT); - servaddr.sin_addr.s_addr = htonl(INADDR_ANY); - - RaiseLog(LOG_LEVEL_INFO, "listen port %d\n", NET_PORT); - if (bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { - RaiseLog(LOG_LEVEL_ERR, "bind socket! \n"); - close(sockfd); - return -1; - } - - if (listen(sockfd, 1) < 0) { - RaiseLog(LOG_LEVEL_ERR,"listen failed! errno = %d \n", errno); - close(sockfd); - return -1; - } - - while (1) { - int newfd, retval; - struct sockaddr_in client_addr; - socklen_t length = sizeof(client_addr); - newfd = accept(sockfd, (struct sockaddr *)&client_addr, &length); - RaiseLog(LOG_LEVEL_INFO, "new socket connect!\n"); - retval = NetCfgGetSocketValue(newfd, ssid, sLen, pwd, pLen); - close(newfd); - - if (retval == 0) { - RaiseLog(LOG_LEVEL_INFO, "config network success! \n"); - break; - } - } - - close(sockfd); - - return 0; -} - -int BOARD_NetCfgStartConfig(const char *appName, char *ssid, int sLen, char *pwd, int pLen) -{ - int retval = 0; - - if (BOARD_SoftApStart(appName) < 0) { - RaiseLog(LOG_LEVEL_ERR, "start softap failed! \n"); - return -1; - } - - if (NetCfgGetWifiInfo(ssid, sLen, pwd, pLen) < 0) { - RaiseLog(LOG_LEVEL_ERR, "start softap failed! \n"); - retval = -1; - } - - BOARD_SoftApStop(); - - return retval; -} \ No newline at end of file diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg_nan.c b/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg_nan.c deleted file mode 100644 index b5bbca4db0b570488815388e93e8da639141af09..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_netcfg_nan.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * 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. - */ - -#include -#include "cmsis_os2.h" -#include "base64.h" -#include "ohos_types.h" -#include "lwip/netif.h" -#include "lwip/netifapi.h" -#include "lwip/ip4_addr.h" -#include "wifi_hotspot.h" -#include "wifi_device_config.h" -#include "iot_netcfg_nan.h" -#include "network_config_service.h" -#include "iot_demo_def.h" - -WifiDeviceConfig g_netCfg = {0}; -WifiEvent g_staEventHandler = {0}; -struct netif *g_staNetif = NULL; - -int g_connectRetryCount = 0; - - -static NetCfgEventCallback g_netCfgEventCallback = NULL; - -#define SET_NET_EVENT(e, d) ({ \ - if (g_netCfgEventCallback != NULL) { \ - g_netCfgEventCallback(e, d); \ - } \ -}) - -const char *g_ssid = "Hi-xxx-Switchs-XXXXX "; -const char *g_pinCode = "11111111"; -const char *g_productId = "1"; -const char *g_sn = "01234567890123450123456789012345"; - -static unsigned int ChannelToFrequency(unsigned int channel) -{ - if (channel <= 0) { - return 0; - } - - if (channel == CHANNEL_80211B_ONLY) { - return FREQ_OF_CHANNEL_80211B_ONLY; - } - - return (((channel - WIFI_MIN_CHANNEL) * WIFI_FREQ_INTERVAL) + FREQ_OF_CHANNEL_1); -} - -static void NetCfgResult(signed char result) -{ - RaiseLog(LOG_LEVEL_INFO, "Network configure done.(result=%d)\n", result); - UnRegisterWifiEvent(&g_staEventHandler); - NotifyNetCfgResult(result); -} - -static void StaResetAddr(struct netif *ptrLwipNetif) -{ - ip4_addr_t staGW; - ip4_addr_t staIpaddr; - ip4_addr_t staNetmask; - - if (ptrLwipNetif == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Null param of netdev\r\n"); - return; - } - - IP4_ADDR(&staGW, 0, 0, 0, 0); - IP4_ADDR(&staIpaddr, 0, 0, 0, 0); - IP4_ADDR(&staNetmask, 0, 0, 0, 0); - - netifapi_netif_set_addr(ptrLwipNetif, &staIpaddr, &staNetmask, &staGW); -} - -static int g_state; - -static void *WifiConnectTask(const char *arg) -{ - (void)arg; - if (g_state == WIFI_STATE_AVALIABLE) { - NetCfgResult(0); - RaiseLog(LOG_LEVEL_INFO, "WiFi: Connected.\n"); - netifapi_dhcp_start(g_staNetif); - } else if (g_state == WIFI_STATE_NOT_AVALIABLE) { - RaiseLog(LOG_LEVEL_INFO, "WiFi: Disconnected retry = %d\n", g_connectRetryCount); - if (g_connectRetryCount < TEST_CONNECT_RETRY_COUNT) { - g_connectRetryCount++; - return NULL; - } - NetCfgResult(-1); - netifapi_dhcp_stop(g_staNetif); - StaResetAddr(g_staNetif); - } - return NULL; -} - -static void WifiConnectionChangedHandler(int state, WifiLinkedInfo *info) -{ - (void)info; - osThreadAttr_t attr; - attr.name = "WifiConnectTask"; - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = NETCFG_TASK_STACK_SIZE; - attr.priority = NETCFG_TASK_PRIO; - g_state = state; - if (osThreadNew((osThreadFunc_t)WifiConnectTask, NULL, &attr) == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Falied to create WifiConnectTask!\n"); - } -} - -static int StaStart(void) -{ - WifiErrorCode error; - error = EnableWifi(); - if (error == ERROR_WIFI_BUSY) { - RaiseLog(LOG_LEVEL_ERR, "Sta had already connnected.\n"); - NetCfgResult(0); - } - if ((error != ERROR_WIFI_BUSY) && (error != WIFI_SUCCESS)) { - RaiseLog(LOG_LEVEL_ERR, "EnableWifi failed, error = %d\n", error); - return -1; - } - - g_staEventHandler.OnWifiConnectionChanged = WifiConnectionChangedHandler; - error = RegisterWifiEvent(&g_staEventHandler); - if (error != WIFI_SUCCESS) { - RaiseLog(LOG_LEVEL_ERR, "RegisterWifiEvent failed, error = %d\n", error); - return -1; - } - - if (IsWifiActive() == 0) { - RaiseLog(LOG_LEVEL_ERR, "Wifi station is not actived.\n"); - return -1; - } - - g_staNetif = netif_find("wlan0"); - if (g_staNetif == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Get netif failed\n"); - return -1; - } - - return 0; -} - -static int WapStaConnect(WifiDeviceConfig *config) -{ - int netId = 0; - WifiErrorCode error; - config->securityType = (config->preSharedKey[0] == '\0') ? WIFI_SEC_TYPE_OPEN : WIFI_SEC_TYPE_PSK; - error = AddDeviceConfig(config, &netId); - if (error != WIFI_SUCCESS) { - RaiseLog(LOG_LEVEL_ERR, "AddDeviceConfig add config failed, error=%d\n", error); - return -1; - } - int count = 0; - while (count < FAST_CONNECT_RETRY_NUM) { - error = ConnectTo(netId); - if (error == WIFI_SUCCESS) { - break; - } - RaiseLog(LOG_LEVEL_INFO, "[sample]continue\n"); - count++; - } - - if (error != WIFI_SUCCESS) { - RaiseLog(LOG_LEVEL_ERR, "ConnectTo conn failed %d\n", error); - return -1; - } - - RaiseLog(LOG_LEVEL_INFO, "WapSta connecting...\n"); - return 0; -} - -static void *CfgNetTask(const char *arg) -{ - (void)arg; - - if (StaStart() != 0) { - SET_NET_EVENT(NET_EVENT_CONFIG_FAIL, NULL); - return NULL; - } - - if (WapStaConnect(&g_netCfg) != 0) { - SET_NET_EVENT(NET_EVENT_CONFIG_FAIL, NULL); - return NULL; - } - - SET_NET_EVENT(NET_EVENT_CONNECTTED, NULL); - - return NULL; -} - -static int CreateCfgNetTask(void) -{ - osThreadAttr_t attr; - attr.name = "CfgNetTask"; - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = NETCFG_TASK_STACK_SIZE; - attr.priority = NETCFG_TASK_PRIO; - - if (osThreadNew((osThreadFunc_t)CfgNetTask, NULL, &attr) == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Falied to create NanCfgNetTask!\n"); - return -1; - } - - return 0; -} - -static void DealSsidPwd(const WifiDeviceConfig *config) -{ - if (config == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Input config is illegal.\n"); - return; - } - - if (memcpy_s(&g_netCfg, sizeof(WifiDeviceConfig), config, sizeof(WifiDeviceConfig)) != 0) { - RaiseLog(LOG_LEVEL_ERR, "memcpy netCfg failed.\n"); - return; - } - RaiseLog(LOG_LEVEL_INFO, "DealSsidPwd\n"); - g_connectRetryCount = 0; - if (CreateCfgNetTask() != 0) { - RaiseLog(LOG_LEVEL_ERR, "Create cfgnet task failed.\n"); - } -} - -int GetPinCode(unsigned char *pinCode, unsigned int size, unsigned int *len) -{ - if (pinCode == NULL) { - return -1; - } - memset_s(pinCode, size, 0, size); - if (strncpy_s((char *)pinCode, size, g_pinCode, strlen(g_pinCode)) != 0) { - RaiseLog(LOG_LEVEL_ERR, "GetPinCode copy pinCode failed\n"); - return -1; - } - *len = strlen((char *)pinCode); - return 0; -} - -int FastConnect(const struct WifiInfo *wifiInfo, WifiDeviceConfig *destCfg) -{ - if (memcpy_s(destCfg->ssid, sizeof(destCfg->ssid), wifiInfo->ssid, wifiInfo->ssidLen) != EOK) { - RaiseLog(LOG_LEVEL_ERR, "FastConnect copy ssid failed\n"); - return -1; - } - if (memcpy_s(destCfg->preSharedKey, sizeof(destCfg->preSharedKey), wifiInfo->psk, wifiInfo->pskLen) != EOK) { - RaiseLog(LOG_LEVEL_ERR, "FastConnect copy pwd failed\n"); - return -1; - } - if (memcpy_s(destCfg->bssid, sizeof(destCfg->bssid), wifiInfo->bssid, wifiInfo->bssidLen) != EOK) { - RaiseLog(LOG_LEVEL_ERR, "FastConnect copy bssid failed\n"); - return -1; - } - destCfg->securityType = wifiInfo->authMode; - destCfg->freq = ChannelToFrequency(wifiInfo->channelNumber); - destCfg->wapiPskType = WIFI_PSK_TYPE_HEX; - return 0; -} - -int ParseNetCfgData(const struct WifiInfo *wifiInfo, const unsigned char *vendorData, unsigned int len) -{ - RaiseLog(LOG_LEVEL_INFO, "ParseWifiData vendorData len:%d\n", len); - if (wifiInfo == NULL) { - RaiseLog(LOG_LEVEL_ERR, "wifiInfo is NULL\n"); - return -1; - } - - WifiDeviceConfig netConfig; - memset_s(&netConfig, sizeof(netConfig), 0, sizeof(netConfig)); - FastConnect(wifiInfo, &netConfig); - - if (vendorData != NULL) { - /* process vendorData */ - } - - DealSsidPwd(&netConfig); - return 0; -} - -int SendRawEncodeData(const unsigned char *data, size_t len) -{ - size_t writeLen = 0; - int ret = mbedtls_base64_encode(NULL, 0, &writeLen, (const unsigned char *)data, len); - if (ret != 0) { - RaiseLog(LOG_LEVEL_ERR, "SendRawEncodeData base64 encode fial\n"); - return -1; - } - size_t encodeBufLen = writeLen; - if (writeLen > MAX_DATA_LEN) { - RaiseLog(LOG_LEVEL_ERR, "SendRawEncodeData dataLen overSize\n"); - return -1; - } - char *buf = malloc(writeLen + 1); - if (buf == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Malloc failed\r\n"); - return -1; - } - (void)memset_s(buf, writeLen + 1, 0, writeLen + 1); - if (mbedtls_base64_encode((unsigned char *)buf, encodeBufLen, &writeLen, (const unsigned char *)data, len) != 0) { - RaiseLog(LOG_LEVEL_ERR, "SendRawEncodeData base64 encode failed\r\n"); - free(buf); - buf = NULL; - return -1; - } - - LOG_I("SendRawEncodeData encode buf = %s\n", buf); - SendRawData((const char*)buf); - if (buf != NULL) { - free(buf); - } - - return 0; -} - -void NotifyNetCfgStatus(enum NetCfgStatus status) -{ - (void)status; - return; -} - -static int RecvRawData(const char *svcId, unsigned int mode, const char *data) -{ - (void)svcId; - (void)mode; - - RaiseLog(LOG_LEVEL_DEBUG, "data : %s \n\n", data); - SET_NET_EVENT(NET_EVENT_RECV_DATA, (void *)data); - return 0; -} - -static void *NetCfgTask(void *arg) -{ - (void)arg; - int ret; - ret = SetSafeDistancePower(POWER_NUM); // Make sure the device discovery distance about 30 cm - if (ret != 0) { - RaiseLog(LOG_LEVEL_ERR, "Set saft distance power failed\n"); - return NULL; - } - - struct SoftAPParam config = {0}; - memset_s(&config, sizeof(struct SoftAPParam), 0, sizeof(struct SoftAPParam)); - strncpy_s(config.ssid, sizeof(config.ssid), g_ssid, strlen(g_ssid)); - config.authType = WIFI_SECURITY_OPEN; - ret = SetSoftAPParameter(&config); - if (ret != 0) { - RaiseLog(LOG_LEVEL_ERR, "Set softAP parameters failed\n"); - return NULL; - } - - NetCfgCallback hook; - memset_s(&hook, sizeof(NetCfgCallback), 0, sizeof(NetCfgCallback)); - hook.GetPinCode = GetPinCode; - hook.ParseNetCfgData = ParseNetCfgData; - hook.RecvRawData = RecvRawData; - hook.NotifyNetCfgStatus = NotifyNetCfgStatus; - ret = RegNetCfgCallback(&hook); - if (ret != 0) { - RaiseLog(LOG_LEVEL_ERR, "Register config callback failed\n"); - return NULL; - } - - struct DevInfo devInfo[DEVICE_INFO_NUM]; - memset_s(&devInfo, sizeof(devInfo), 0, sizeof(devInfo)); - devInfo[0].key = "productId"; - devInfo[1].key = "sn"; - devInfo[0].value = g_productId; - devInfo[1].value = g_sn; - ret = StartNetCfg(devInfo, DEVICE_INFO_NUM, NETCFG_SOFTAP_NAN); - if (ret != 0) { - RaiseLog(LOG_LEVEL_ERR, "Start config wifi fail.\n"); - return NULL; - } - - return NULL; -} - -void NetCfgRegister(NetCfgEventCallback nEventCallback) -{ - RaiseLog(LOG_LEVEL_INFO, "NetCfgRegister enter.\n"); - osThreadAttr_t attr; - - g_netCfgEventCallback = nEventCallback; - - attr.name = "NetCfgTask"; - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = NETCFG_TASK_STACK_SIZE; - attr.priority = NETCFG_TASK_PRIO; - - if (osThreadNew((osThreadFunc_t)NetCfgTask, NULL, &attr) == NULL) { - RaiseLog(LOG_LEVEL_ERR, "Falied to create NetCfgTask!\n"); - } -} diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_softap.c b/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_softap.c deleted file mode 100644 index c29bbf53e8fb27e87c1f5ddde45fdc0ca4ad4ebc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_softap.c +++ /dev/null @@ -1,109 +0,0 @@ - -/* - * 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. - */ - -#include -#include "lwip/ip_addr.h" -#include "lwip/netifapi.h" -#include "wifi_hotspot.h" -#include "wifi_hotspot_config.h" -#include "iot_softap.h" -#include "iot_demo_def.h" - -#define DEFAULT_AP_NAME "TestIotAP" - -static struct netif *g_netif = NULL; - -static void SetAddr(struct netif *pst_lwip_netif) -{ - ip4_addr_t st_gw; - ip4_addr_t st_ipaddr; - ip4_addr_t st_netmask; - - IP4_ADDR(&st_ipaddr, 192, 168, 10, 1); // IP ADDR - IP4_ADDR(&st_gw, 192, 168, 10, 1); // GET WAY ADDR - IP4_ADDR(&st_netmask, 255, 255, 255, 0); // NET MASK CODE - - netifapi_netif_set_addr(pst_lwip_netif, &st_ipaddr, &st_netmask, &st_gw); -} - -static void ResetAddr(struct netif *pst_lwip_netif) -{ - ip4_addr_t st_gw; - ip4_addr_t st_ipaddr; - ip4_addr_t st_netmask; - - IP4_ADDR(&st_ipaddr, 0, 0, 0, 0); - IP4_ADDR(&st_gw, 0, 0, 0, 0); - IP4_ADDR(&st_netmask, 0, 0, 0, 0); - - netifapi_netif_set_addr(pst_lwip_netif, &st_ipaddr, &st_netmask, &st_gw); -} - -int BOARD_SoftApStart(const char *ap_name) -{ - HotspotConfig config = {0}; - ip4_addr_t st_gw; - ip4_addr_t st_ipaddr; - ip4_addr_t st_netmask; - char *apName = ap_name; - char ifname[BUFF_SIZE] = {0}; - int retval; - - if (IsHotspotActive() == WIFI_HOTSPOT_ACTIVE) { - RaiseLog(LOG_LEVEL_ERR, "WIFI_HOTSPOT_ACTIVE \n"); - return -1; - } - if (apName == NULL) { - apName = DEFAULT_AP_NAME; - } - if (strcpy_s(config.ssid, sizeof(config.ssid), apName) != 0) { - RaiseLog(LOG_LEVEL_ERR, "[sample] strcpy ssid fail.\n"); - return -1; - } - config.securityType = WIFI_SEC_TYPE_OPEN; - retval = SetHotspotConfig((const HotspotConfig *)(&config)); - if (retval != WIFI_SUCCESS) { - RaiseLog(LOG_LEVEL_ERR, "SetHotspotConfig \n"); - return -1; - } - - retval = EnableHotspot(); - if (retval != WIFI_SUCCESS) { - RaiseLog(LOG_LEVEL_ERR, "EnableHotspot failed! \n"); - return -1; - } - - g_netif = netifapi_netif_find("ap0"); - if (g_netif != NULL) { - SetAddr(g_netif); - dhcps_start(g_netif, NULL, 0); - } - - return 0; -} - -void BOARD_SoftApStop(void) -{ - if (IsHotspotActive() == WIFI_HOTSPOT_NOT_ACTIVE) { - RaiseLog(LOG_LEVEL_ERR, "WIFI_HOTSPOT_NOT_ACTIVE \n"); - return; - } - - DisableHotspot(); - if (g_netif) { - ResetAddr(g_netif); - } -} diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_wifi.c b/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_wifi.c deleted file mode 100644 index b09654116ee4baffa9f909bf8c9c0ff39b4b5058..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/common/iot_wifi/iot_wifi.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include "lwip/netif.h" -#include "lwip/netifapi.h" -#include "lwip/ip4_addr.h" -#include "lwip/api_shell.h" -#include "cmsis_os2.h" -#include "wifi_device.h" -#include "wifi_error_code.h" -#include "ohos_init.h" -#include "iot_wifi.h" - -#define DEF_TIMEOUT 15 -#define ONE_SECOND 1 -#define SELECT_WIFI_SECURITYTYPE WIFI_SEC_TYPE_PSK - -static void WiFiInit(void); -static void WaitSacnResult(void); -static int WaitConnectResult(void); -static void OnWifiScanStateChangedHandler(int state, int size); -static void OnWifiConnectionChangedHandler(int state, WifiLinkedInfo *info); -static void OnHotspotStaJoinHandler(StationInfo *info); -static void OnHotspotStateChangedHandler(int state); -static void OnHotspotStaLeaveHandler(StationInfo *info); - -static int g_staScanSuccess = 0; -static int g_ConnectSuccess = 0; -static int ssid_count = 0; -WifiEvent g_wifiEventHandler = {0}; -WifiErrorCode error; - -#define SELECT_WLAN_PORT "wlan0" - -int WifiConnect(const char *ssid, const char *psk) -{ - WifiScanInfo *info = NULL; - unsigned int size = WIFI_SCAN_HOTSPOT_LIMIT; - static struct netif *g_lwip_netif = NULL; - - osDelay(200); - printf("<--System Init-->\r\n"); - - // 初始化WIFI - WiFiInit(); - - // 使能WIFI - if (EnableWifi() != WIFI_SUCCESS) { - printf("EnableWifi failed, error = %d\r\n", error); - return -1; - } - - // 判断WIFI是否激活 - if (IsWifiActive() == 0) - { - printf("Wifi station is not actived.\r\n"); - return -1; - } - - // 分配空间,保存WiFi信息 - info = malloc(sizeof(WifiScanInfo) * WIFI_SCAN_HOTSPOT_LIMIT); - if (info == NULL) { - return -1; - } - // 轮询查找WiFi列表 - do { - // 重置标志位 - ssid_count = 0; - g_staScanSuccess = 0; - - // 开始扫描 - Scan(); - - // 等待扫描结果 - WaitSacnResult(); - - // 获取扫描列表 - error = GetScanInfoList(info, &size); - - } while (g_staScanSuccess != 1); - - for (uint8_t i = 0; i < ssid_count; i++) { - printf("no:%03d, ssid:%-30s, rssi:%5d\r\n", i+1, info[i].ssid, info[i].rssi/100); - } - - // 连接指定的WiFi热点 - for (uint8_t i = 0; i < ssid_count; i++) { - if (strcmp(ssid, info[i].ssid) == 0) { - int result; - printf("Select:%3d wireless, Waiting...\r\n", i+1); - // 拷贝要连接的热点信息 - WifiDeviceConfig select_ap_config = {0}; - strcpy(select_ap_config.ssid, info[i].ssid); - strcpy(select_ap_config.preSharedKey, psk); - select_ap_config.securityType = SELECT_WIFI_SECURITYTYPE; - - if (AddDeviceConfig(&select_ap_config, &result) == WIFI_SUCCESS) { - if (ConnectTo(result) == WIFI_SUCCESS && WaitConnectResult() == 1) { - printf("WiFi connect succeed!\r\n"); - g_lwip_netif = netifapi_netif_find(SELECT_WLAN_PORT); - break; - } - } - } - - if (i == ssid_count - 1) { - printf("ERROR: No wifi as expected\r\n"); - while(1) osDelay(100); - } - } - // 启动DHCP - if (g_lwip_netif) { - dhcp_start(g_lwip_netif); - printf("begain to dhcp\r\n"); - } - - // 等待DHCP - for(;;) { - if(dhcp_is_bound(g_lwip_netif) == ERR_OK) { - printf("<-- DHCP state:OK -->\r\n"); - // 打印获取到的IP信息 - netifapi_netif_common(g_lwip_netif, dhcp_clients_info_show, NULL); - break; - } - printf("<-- DHCP state:Inprogress -->\r\n"); - osDelay(100); - } - - osDelay(100); - - return 0; -} - -/**************************************************** -* 初始化WIFI -****************************************************/ -static void WiFiInit(void) -{ - printf("<--Wifi Init-->\r\n"); - g_wifiEventHandler.OnWifiScanStateChanged = OnWifiScanStateChangedHandler; - g_wifiEventHandler.OnWifiConnectionChanged = OnWifiConnectionChangedHandler; - g_wifiEventHandler.OnHotspotStaJoin = OnHotspotStaJoinHandler; - g_wifiEventHandler.OnHotspotStaLeave = OnHotspotStaLeaveHandler; - g_wifiEventHandler.OnHotspotStateChanged = OnHotspotStateChangedHandler; - error = RegisterWifiEvent(&g_wifiEventHandler); - if (error != WIFI_SUCCESS) { - printf("register wifi event fail!\r\n"); - } else { - printf("register wifi event succeed!\r\n"); - } -} - -static void OnWifiScanStateChangedHandler(int state, int size) -{ - if (size > 0) { - ssid_count = size; - g_staScanSuccess = 1; - } - printf("callback function for wifi scan:%d, %d\r\n", state, size); - return; -} - -static void OnWifiConnectionChangedHandler(int state, WifiLinkedInfo *info) -{ - if (info == NULL) { - printf("WifiConnectionChanged:info is null, stat is %d.\n", state); - } else { - if (state == WIFI_STATE_AVALIABLE) { - g_ConnectSuccess = 1; - } else { - g_ConnectSuccess = 0; - } - } -} - -static void OnHotspotStaJoinHandler(StationInfo *info) -{ - (void)info; - printf("STA join AP\n"); - return; -} - -static void OnHotspotStaLeaveHandler(StationInfo *info) -{ - (void)info; - printf("HotspotStaLeave:info is null.\n"); - return; -} - -static void OnHotspotStateChangedHandler(int state) -{ - printf("HotspotStateChanged:state is %d.\n", state); - return; -} - -static void WaitSacnResult(void) -{ - int scanTimeout = DEF_TIMEOUT; - while (scanTimeout > 0) { - sleep(ONE_SECOND); - scanTimeout--; - if (g_staScanSuccess == 1) { - printf("WaitSacnResult:wait success[%d]s\n", (DEF_TIMEOUT - scanTimeout)); - break; - } - } - if (scanTimeout <= 0) { - printf("WaitSacnResult:timeout!\n"); - } -} - -static int WaitConnectResult(void) -{ - int ConnectTimeout = DEF_TIMEOUT; - while (ConnectTimeout > 0) { - sleep(ONE_SECOND); - ConnectTimeout--; - if (g_ConnectSuccess == 1) { - printf("WaitConnectResult:wait success[%d]s\n", (DEF_TIMEOUT - ConnectTimeout)); - break; - } - } - if (ConnectTimeout <= 0) { - printf("WaitConnectResult:timeout!\n"); - return 0; - } - return 1; -} - -int BOARD_InitWifi(void) -{ - return 0; -} - -int BOARD_ConnectWifi(const char *wifiSSID, const char *wifiPWD) -{ - return WifiConnect(wifiSSID, wifiPWD); -} - -int BOARD_DisconnectWifi() -{ - Disconnect(); - return 0; -} diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libHwKeystoreSDK.a b/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libHwKeystoreSDK.a deleted file mode 100644 index 09103aef98c95535f82ebe7d70fd2a4f29ec3352..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libHwKeystoreSDK.a and /dev/null differ diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libhilinkadapter_3861.a b/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libhilinkadapter_3861.a deleted file mode 100644 index 5590f0a020adc05afc40fda24a936127cfec5f9b..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libhilinkadapter_3861.a and /dev/null differ diff --git a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libnetcfgdevicesdk.a b/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libnetcfgdevicesdk.a deleted file mode 100644 index c76f38e6cf26b57aa9f660ea71fd7de66e6a513c..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/device/team_x/common/iot_wifi/libs/libnetcfgdevicesdk.a and /dev/null differ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/BUILD.gn b/Device/RemoteLamp/device/team_x/smart_lamp/BUILD.gn deleted file mode 100644 index 6fcd4b927118a3a449472fb14e196d0cdb3dfe12..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/BUILD.gn +++ /dev/null @@ -1,16 +0,0 @@ -# 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. - -group("smart_lamp") { - deps = ["demo_smartlamp:smart_lamp"] -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/config.json b/Device/RemoteLamp/device/team_x/smart_lamp/config.json deleted file mode 100644 index a2478cf5aa5705f45b1dd914954933146e030209..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "product_name": "smart_lamp", - "ohos_version": "OpenHarmony 3.0.0", - "device_company": "hisilicon", - "board": "hispark_pegasus", - "kernel_type": "liteos_m", - "kernel_version": "", - "subsystems": [ - { - "subsystem": "iot_hardware", - "components": [ - { "component": "iot_controller", "features":[] } - ] - }, - { - "subsystem": "hiviewdfx", - "components": [ - { "component": "hilog_lite", "features":[] }, - { "component": "hievent_lite", "features":[] } - ] - }, - { - "subsystem": "distributed_schedule", - "components": [ - { "component": "samgr_lite", "features":[] } - ] - }, - { - "subsystem": "security", - "components": [ - { "component": "hichainsdk", "features":[] }, - { "component": "huks", "features": - [ - "disable_huks_binary = false", - "disable_authenticate = false", - "huks_use_lite_storage = true", - "huks_use_hardware_root_key = true", - "huks_config_file = \"hks_config_lite.h\"", - "huks_mbedtls_path = \"//device/hisilicon/hispark_pegasus/sdk_liteos/third_party/mbedtls/include/\"" - ] - } - ] - }, - { - "subsystem": "startup", - "components": [ - { "component": "bootstrap_lite", "features":[] }, - { "component": "syspara_lite", "features": - [ - "enable_ohos_startup_syspara_lite_use_thirdparty_mbedtls = false" - ] - } - ] - }, - { - "subsystem": "communication", - "components": [ - { "component": "wifi_lite", "features":[] }, - { "component": "wifi_aware", "features":[]} - ] - }, - { - "subsystem": "update", - "components": [ - { "component": "ota_lite", "features":[] } - ] - }, - { - "subsystem": "utils", - "components": [ - { "component": "file", "features":[] }, - { "component": "kv_store", "features":[] }, - { "component": "os_dump", "features":[] } - ] - }, - { - "subsystem": "vendor", - "components": [ - { "component": "hi3861_sdk", "target": "//device/hisilicon/hispark_pegasus/sdk_liteos:wifiiot_sdk", "features":[] } - ] - } - ], - "vendor_adapter_dir": "//device/hisilicon/hispark_pegasus/hi3861_adapter", - "third_party_dir": "//device/hisilicon/hispark_pegasus/sdk_liteos/third_party", - "product_adapter_dir": "//vendor/team_x/smart_lamp/hals", - "ohos_product_type":"", - "ohos_manufacture":"", - "ohos_brand":"", - "ohos_market_name":"", - "ohos_product_series":"", - "ohos_product_model":"", - "ohos_software_model":"", - "ohos_hardware_model":"", - "ohos_hardware_profile":"", - "ohos_serial":"", - "ohos_bootloader_version":"", - "ohos_secure_patch_level":"", - "ohos_abi_list":"" - } diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/BUILD.gn b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/BUILD.gn deleted file mode 100644 index 69ba4523901b6352ad0a2f18ae217568f339d948..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/BUILD.gn +++ /dev/null @@ -1,34 +0,0 @@ -# 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. - -static_library("smart_lamp") { - sources = [ - "./src/iot_main.c", - "./src/oled.c", - "./src/common.c", - ] - - include_dirs = [ - "./include", - "//kernel/liteos_m/kal/cmsis", - "//base/iot_hardware/peripheral/interfaces/kits", - "../../common/inc", - ] - - deps = [ - "../../common/iot_wifi:iot_wifi", - "../../common/hals:hals" - ] -} - - diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/code_tab.h b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/code_tab.h deleted file mode 100644 index 96d8553ad40b422e06251269620a9efe9fb9eeca..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/code_tab.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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. - */ - -#ifndef __CODE_TAB_H__ -#define __CODE_TAB_H__ - -/* **************************16*16******** */ -const unsigned char F16X16[] = { - 0x10, 0x60, 0x02, 0x8C, 0x00, 0x00, 0xFE, 0x92, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x00, 0x00, 0x00, - 0x04, 0x04, 0x7E, 0x01, 0x40, 0x7E, 0x42, 0x42, 0x7E, 0x42, 0x7E, 0x42, 0x42, 0x7E, 0x40, 0x00, /* "温", 0 */ - 0x10, 0x60, 0x02, 0x8C, 0x00, 0xFE, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0xFE, 0x00, 0x00, 0x00, - 0x04, 0x04, 0x7E, 0x01, 0x44, 0x48, 0x50, 0x7F, 0x40, 0x40, 0x7F, 0x50, 0x48, 0x44, 0x40, 0x00, /* "湿", 1 */ - 0x00, 0x00, 0xFC, 0x24, 0x24, 0x24, 0xFC, 0x25, 0x26, 0x24, 0xFC, 0x24, 0x24, 0x24, 0x04, 0x00, - 0x40, 0x30, 0x8F, 0x80, 0x84, 0x4C, 0x55, 0x25, 0x25, 0x25, 0x55, 0x4C, 0x80, 0x80, 0x80, 0x00, /* "度", 2 */ -}; - -const unsigned char HZ_F16X16[][2][16] = { - { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - }, /* " ", 0 */ - { - {0x80, 0x82, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82, 0x80, 0x00}, - {0x00, 0x80, 0x40, 0x30, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00} - }, /* "开", 1 */ - { - {0x00, 0x20, 0x20, 0x20, 0xA0, 0x60, 0x00, 0xFF, 0x60, 0x80, 0x40, 0x20, 0x18, 0x00, 0x00, 0x00}, - {0x20, 0x10, 0x08, 0x06, 0x01, 0x40, 0x80, 0x7F, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x00} - }, /* "水", 2 */ - { - {0x04, 0x04, 0x04, 0x04, 0x9F, 0x44, 0x24, 0x94, 0x24, 0x44, 0x9F, 0x04, 0x04, 0x04, 0x04, 0x00}, - {0x02, 0x02, 0x21, 0x13, 0x0A, 0x42, 0x82, 0x7F, 0x02, 0x02, 0x0A, 0x13, 0x21, 0x02, 0x02, 0x00} - }, /* "茶", 3 */ - { - {0x40, 0x30, 0x0F, 0x88, 0x28, 0x18, 0x08, 0x40, 0x30, 0x0F, 0xC8, 0x08, 0x28, 0x18, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x7F, 0x20, 0x10, 0x88, 0x40, 0x30, 0x0E, 0x01, 0x0E, 0x30, 0x40, 0x80, 0x00} - }, /* "饮", 4 */ - { - {0x00, 0x02, 0x0C, 0xC0, 0x00, 0xF0, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00}, - {0x02, 0x02, 0x7F, 0x00, 0x00, 0x0F, 0x04, 0x04, 0x04, 0xFF, 0x04, 0x04, 0x04, 0x0F, 0x00, 0x00} - }, /* "冲", 5 */ - { - {0x10, 0x10, 0xF0, 0x1F, 0x10, 0xF0, 0x04, 0x04, 0xFC, 0x04, 0xC4, 0xB4, 0x8C, 0x80, 0x00, 0x00}, - {0x40, 0x22, 0x15, 0x08, 0x16, 0xA1, 0x60, 0x1C, 0x03, 0x00, 0x40, 0x80, 0x40, 0x3F, 0x00, 0x00} - }, /* "奶", 6 */ - { - {0x00, 0x04, 0x04, 0xF4, 0x94, 0x94, 0x94, 0x9F, 0x94, 0x94, 0x94, 0xF4, 0x04, 0x04, 0x00, 0x00}, - {0x40, 0x40, 0x40, 0x7F, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x7F, 0x40, 0x40, 0x40, 0x00} - }, /* "直", 7 */ - { - {0x40, 0x30, 0x0F, 0x88, 0x28, 0x18, 0x08, 0x40, 0x30, 0x0F, 0xC8, 0x08, 0x28, 0x18, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x7F, 0x20, 0x10, 0x88, 0x40, 0x30, 0x0E, 0x01, 0x0E, 0x30, 0x40, 0x80, 0x00} - }, /* "饮", 8 */ -}; - -const unsigned char HZ_F16X16_1[][2][16] = { - { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - }, /* " ", 0 */ - { - {0xFC, 0x04, 0x04, 0xFC, 0x10, 0xFF, 0x10, 0x10, 0xF0, 0x00, 0xF8, 0x08, 0x08, 0xF8, 0x00, 0x00}, - {0x0F, 0x04, 0x84, 0x4F, 0x30, 0x0F, 0x40, 0x80, 0x7F, 0x00, 0x7F, 0x20, 0x20, 0x7F, 0x00, 0x00} - }, /* "咖", 1 */ - { - {0xFC, 0x04, 0x04, 0xFC, 0x00, 0x08, 0x88, 0x88, 0xFF, 0x00, 0x00, 0xFF, 0x88, 0x88, 0x08, 0x00}, - {0x0F, 0x04, 0x04, 0x0F, 0x00, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0xFF, 0x08, 0x08, 0x08, 0x00} - }, /* "啡", 2 */ - { - {0x04, 0x04, 0x04, 0x84, 0x6F, 0x04, 0x04, 0x04, 0xE4, 0x04, 0x8F, 0x44, 0x24, 0x04, 0x04, 0x00}, - {0x04, 0x02, 0x01, 0xFF, 0x00, 0x10, 0x08, 0x04, 0x3F, 0x41, 0x40, 0x40, 0x40, 0x40, 0x78, 0x00} - }, /* "花", 3 */ - { - {0x40, 0x44, 0x54, 0x54, 0x55, 0x56, 0xD4, 0x7C, 0x54, 0x56, 0x55, 0x54, 0x54, 0x44, 0x40, 0x00}, - {0x02, 0x82, 0x82, 0x9A, 0x56, 0x53, 0x22, 0x22, 0x22, 0x52, 0x4E, 0x42, 0x82, 0x02, 0x02, 0x00} - }, /* "姜", 4 */ - { - {0x04, 0x04, 0x04, 0x04, 0x9F, 0x44, 0x24, 0x94, 0x24, 0x44, 0x9F, 0x04, 0x04, 0x04, 0x04, 0x00}, - {0x02, 0x02, 0x21, 0x13, 0x0A, 0x42, 0x82, 0x7F, 0x02, 0x02, 0x0A, 0x13, 0x21, 0x02, 0x02, 0x00} - }, /* "茶", 5 */ -}; - -/* ***********************************6*8*********************************** */ -const unsigned char F6X8[][6] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // sp - {0x00, 0x00, 0x00, 0x2f, 0x00, 0x00}, // ! - {0x00, 0x00, 0x07, 0x00, 0x07, 0x00}, // " - {0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14}, // # - {0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12}, // $ - {0x00, 0x62, 0x64, 0x08, 0x13, 0x23}, // % - {0x00, 0x36, 0x49, 0x55, 0x22, 0x50}, // & - {0x00, 0x00, 0x05, 0x03, 0x00, 0x00}, // ' - {0x00, 0x00, 0x1c, 0x22, 0x41, 0x00}, // ( - {0x00, 0x00, 0x41, 0x22, 0x1c, 0x00}, // ) - {0x00, 0x14, 0x08, 0x3E, 0x08, 0x14}, // * - {0x00, 0x08, 0x08, 0x3E, 0x08, 0x08}, // + - {0x00, 0x00, 0x00, 0xA0, 0x60, 0x00}, // ,1 - {0x00, 0x08, 0x08, 0x08, 0x08, 0x08}, // - - {0x00, 0x00, 0x60, 0x60, 0x00, 0x00}, // . - {0x00, 0x20, 0x10, 0x08, 0x04, 0x02}, // / - {0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E}, // 0 - {0x00, 0x00, 0x42, 0x7F, 0x40, 0x00}, // 1 - {0x00, 0x42, 0x61, 0x51, 0x49, 0x46}, // 2 - {0x00, 0x21, 0x41, 0x45, 0x4B, 0x31}, // 3 - {0x00, 0x18, 0x14, 0x12, 0x7F, 0x10}, // 4 - {0x00, 0x27, 0x45, 0x45, 0x45, 0x39}, // 5 - {0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30}, // 6 - {0x00, 0x01, 0x71, 0x09, 0x05, 0x03}, // 7 - {0x00, 0x36, 0x49, 0x49, 0x49, 0x36}, // 8 - {0x00, 0x06, 0x49, 0x49, 0x29, 0x1E}, // 9 - {0x00, 0x00, 0x36, 0x36, 0x00, 0x00}, // : - {0x00, 0x00, 0x56, 0x36, 0x00, 0x00}, // ; - {0x00, 0x08, 0x14, 0x22, 0x41, 0x00}, // < - {0x00, 0x14, 0x14, 0x14, 0x14, 0x14}, // = - {0x00, 0x00, 0x41, 0x22, 0x14, 0x08}, // > - {0x00, 0x02, 0x01, 0x51, 0x09, 0x06}, // ? - {0x00, 0x32, 0x49, 0x59, 0x51, 0x3E}, // @ - {0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C}, // A - {0x00, 0x7F, 0x49, 0x49, 0x49, 0x36}, // B - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x22}, // C - {0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C}, // D - {0x00, 0x7F, 0x49, 0x49, 0x49, 0x41}, // E - {0x00, 0x7F, 0x09, 0x09, 0x09, 0x01}, // F - {0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A}, // G - {0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F}, // H - {0x00, 0x00, 0x41, 0x7F, 0x41, 0x00}, // I - {0x00, 0x20, 0x40, 0x41, 0x3F, 0x01}, // J - {0x00, 0x7F, 0x08, 0x14, 0x22, 0x41}, // K - {0x00, 0x7F, 0x40, 0x40, 0x40, 0x40}, // L - {0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F}, // M - {0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F}, // N - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E}, // O - {0x00, 0x7F, 0x09, 0x09, 0x09, 0x06}, // P - {0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E}, // Q - {0x00, 0x7F, 0x09, 0x19, 0x29, 0x46}, // R - {0x00, 0x46, 0x49, 0x49, 0x49, 0x31}, // S - {0x00, 0x01, 0x01, 0x7F, 0x01, 0x01}, // T - {0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F}, // U - {0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F}, // V - {0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F}, // W - {0x00, 0x63, 0x14, 0x08, 0x14, 0x63}, // X - {0x00, 0x07, 0x08, 0x70, 0x08, 0x07}, // Y - {0x00, 0x61, 0x51, 0x49, 0x45, 0x43}, // Z - {0x00, 0x00, 0x7F, 0x41, 0x41, 0x00}, // [ - {0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55}, // 55 - {0x00, 0x00, 0x41, 0x41, 0x7F, 0x00}, // ] - {0x00, 0x04, 0x02, 0x01, 0x02, 0x04}, // ^ - {0x00, 0x40, 0x40, 0x40, 0x40, 0x40}, // _ - {0x00, 0x00, 0x01, 0x02, 0x04, 0x00}, // ' - {0x00, 0x20, 0x54, 0x54, 0x54, 0x78}, // a - {0x00, 0x7F, 0x48, 0x44, 0x44, 0x38}, // b - {0x00, 0x38, 0x44, 0x44, 0x44, 0x20}, // c - {0x00, 0x38, 0x44, 0x44, 0x48, 0x7F}, // d - {0x00, 0x38, 0x54, 0x54, 0x54, 0x18}, // e - {0x00, 0x08, 0x7E, 0x09, 0x01, 0x02}, // f - {0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C}, // g - {0x00, 0x7F, 0x08, 0x04, 0x04, 0x78}, // h - {0x00, 0x00, 0x44, 0x7D, 0x40, 0x00}, // i - {0x00, 0x40, 0x80, 0x84, 0x7D, 0x00}, // j - {0x00, 0x7F, 0x10, 0x28, 0x44, 0x00}, // k - {0x00, 0x00, 0x41, 0x7F, 0x40, 0x00}, // l - {0x00, 0x7C, 0x04, 0x18, 0x04, 0x78}, // m - {0x00, 0x7C, 0x08, 0x04, 0x04, 0x78}, // n - {0x00, 0x38, 0x44, 0x44, 0x44, 0x38}, // o - {0x00, 0xFC, 0x24, 0x24, 0x24, 0x18}, // p - {0x00, 0x18, 0x24, 0x24, 0x18, 0xFC}, // q - {0x00, 0x7C, 0x08, 0x04, 0x04, 0x08}, // r - {0x00, 0x48, 0x54, 0x54, 0x54, 0x20}, // s - {0x00, 0x04, 0x3F, 0x44, 0x40, 0x20}, // t - {0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C}, // u - {0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C}, // v - {0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C}, // w - {0x00, 0x44, 0x28, 0x10, 0x28, 0x44}, // x - {0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C}, // y - {0x00, 0x44, 0x64, 0x54, 0x4C, 0x44}, // z - {0x14, 0x14, 0x14, 0x14, 0x14, 0x14}, // horiz lines -}; - -/* ***************************************8*16*********************************** */ -const unsigned char F8X16[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 - 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x30, 0x00, 0x00, 0x00, // !1 - 0x00, 0x10, 0x0C, 0x06, 0x10, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // "2 - 0x40, 0xC0, 0x78, 0x40, 0xC0, 0x78, 0x40, 0x00, 0x04, 0x3F, 0x04, 0x04, 0x3F, 0x04, 0x04, 0x00, // #3 - 0x00, 0x70, 0x88, 0xFC, 0x08, 0x30, 0x00, 0x00, 0x00, 0x18, 0x20, 0xFF, 0x21, 0x1E, 0x00, 0x00, // $4 - 0xF0, 0x08, 0xF0, 0x00, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x21, 0x1C, 0x03, 0x1E, 0x21, 0x1E, 0x00, // %5 - 0x00, 0xF0, 0x08, 0x88, 0x70, 0x00, 0x00, 0x00, 0x1E, 0x21, 0x23, 0x24, 0x19, 0x27, 0x21, 0x10, // &6 - 0x10, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // '7 - 0x00, 0x00, 0x00, 0xE0, 0x18, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x18, 0x20, 0x40, 0x00, // (8 - 0x00, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x18, 0x07, 0x00, 0x00, 0x00, // )9 - 0x40, 0x40, 0x80, 0xF0, 0x80, 0x40, 0x40, 0x00, 0x02, 0x02, 0x01, 0x0F, 0x01, 0x02, 0x02, 0x00, // *10 - 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x1F, 0x01, 0x01, 0x01, 0x00, // +11 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xB0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, // ,12 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // -13 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // .14 - 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x04, 0x00, 0x60, 0x18, 0x06, 0x01, 0x00, 0x00, 0x00, // 15 - 0x00, 0xE0, 0x10, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x00, 0x0F, 0x10, 0x20, 0x20, 0x10, 0x0F, 0x00, // 0 16 - 0x00, 0x10, 0x10, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // 1 17 - 0x00, 0x70, 0x08, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, 0x30, 0x28, 0x24, 0x22, 0x21, 0x30, 0x00, // 2 18 - 0x00, 0x30, 0x08, 0x88, 0x88, 0x48, 0x30, 0x00, 0x00, 0x18, 0x20, 0x20, 0x20, 0x11, 0x0E, 0x00, // 3 19 - 0x00, 0x00, 0xC0, 0x20, 0x10, 0xF8, 0x00, 0x00, 0x00, 0x07, 0x04, 0x24, 0x24, 0x3F, 0x24, 0x00, // 4 20 - 0x00, 0xF8, 0x08, 0x88, 0x88, 0x08, 0x08, 0x00, 0x00, 0x19, 0x21, 0x20, 0x20, 0x11, 0x0E, 0x00, // 5 21 - 0x00, 0xE0, 0x10, 0x88, 0x88, 0x18, 0x00, 0x00, 0x00, 0x0F, 0x11, 0x20, 0x20, 0x11, 0x0E, 0x00, // 6 22 - 0x00, 0x38, 0x08, 0x08, 0xC8, 0x38, 0x08, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, // 7 23 - 0x00, 0x70, 0x88, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, 0x1C, 0x22, 0x21, 0x21, 0x22, 0x1C, 0x00, // 8 24 - 0x00, 0xE0, 0x10, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x00, 0x00, 0x31, 0x22, 0x22, 0x11, 0x0F, 0x00, // 9 25 - 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, // : 26 - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x00, 0x00, // ; 27 - 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, // < 28 - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, // = 29 - 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, // > 30 - 0x00, 0x70, 0x48, 0x08, 0x08, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x36, 0x01, 0x00, 0x00, // ? 31 - 0xC0, 0x30, 0xC8, 0x28, 0xE8, 0x10, 0xE0, 0x00, 0x07, 0x18, 0x27, 0x24, 0x23, 0x14, 0x0B, 0x00, // @ 32 - 0x00, 0x00, 0xC0, 0x38, 0xE0, 0x00, 0x00, 0x00, 0x20, 0x3C, 0x23, 0x02, 0x02, 0x27, 0x38, 0x20, // A 33 - 0x08, 0xF8, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x11, 0x0E, 0x00, // B 34 - 0xC0, 0x30, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x07, 0x18, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, // C 35 - 0x08, 0xF8, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x10, 0x0F, 0x00, // D 36 - 0x08, 0xF8, 0x88, 0x88, 0xE8, 0x08, 0x10, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x23, 0x20, 0x18, 0x00, // E 37 - 0x08, 0xF8, 0x88, 0x88, 0xE8, 0x08, 0x10, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, // F 38 - 0xC0, 0x30, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x07, 0x18, 0x20, 0x20, 0x22, 0x1E, 0x02, 0x00, // G 39 - 0x08, 0xF8, 0x08, 0x00, 0x00, 0x08, 0xF8, 0x08, 0x20, 0x3F, 0x21, 0x01, 0x01, 0x21, 0x3F, 0x20, // H 40 - 0x00, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // I 41 - 0x00, 0x00, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00, 0x00, // J 42 - 0x08, 0xF8, 0x88, 0xC0, 0x28, 0x18, 0x08, 0x00, 0x20, 0x3F, 0x20, 0x01, 0x26, 0x38, 0x20, 0x00, // K 43 - 0x08, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x00, // L 44 - 0x08, 0xF8, 0xF8, 0x00, 0xF8, 0xF8, 0x08, 0x00, 0x20, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x20, 0x00, // M 45 - 0x08, 0xF8, 0x30, 0xC0, 0x00, 0x08, 0xF8, 0x08, 0x20, 0x3F, 0x20, 0x00, 0x07, 0x18, 0x3F, 0x00, // N 46 - 0xE0, 0x10, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x0F, 0x10, 0x20, 0x20, 0x20, 0x10, 0x0F, 0x00, // O 47 - 0x08, 0xF8, 0x08, 0x08, 0x08, 0x08, 0xF0, 0x00, 0x20, 0x3F, 0x21, 0x01, 0x01, 0x01, 0x00, 0x00, // P 48 - 0xE0, 0x10, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x0F, 0x18, 0x24, 0x24, 0x38, 0x50, 0x4F, 0x00, // Q 49 - 0x08, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x03, 0x0C, 0x30, 0x20, // R 50 - 0x00, 0x70, 0x88, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x38, 0x20, 0x21, 0x21, 0x22, 0x1C, 0x00, // S 51 - 0x18, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x18, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x00, 0x00, // T 52 - 0x08, 0xF8, 0x08, 0x00, 0x00, 0x08, 0xF8, 0x08, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, // U 53 - 0x08, 0x78, 0x88, 0x00, 0x00, 0xC8, 0x38, 0x08, 0x00, 0x00, 0x07, 0x38, 0x0E, 0x01, 0x00, 0x00, // V 54 - 0xF8, 0x08, 0x00, 0xF8, 0x00, 0x08, 0xF8, 0x00, 0x03, 0x3C, 0x07, 0x00, 0x07, 0x3C, 0x03, 0x00, // W 55 - 0x08, 0x18, 0x68, 0x80, 0x80, 0x68, 0x18, 0x08, 0x20, 0x30, 0x2C, 0x03, 0x03, 0x2C, 0x30, 0x20, // X 56 - 0x08, 0x38, 0xC8, 0x00, 0xC8, 0x38, 0x08, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x00, 0x00, // Y 57 - 0x10, 0x08, 0x08, 0x08, 0xC8, 0x38, 0x08, 0x00, 0x20, 0x38, 0x26, 0x21, 0x20, 0x20, 0x18, 0x00, // Z 58 - 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x00, // [ 59 - 0x00, 0x0C, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x38, 0xC0, 0x00, // \ 60 - 0x00, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x7F, 0x00, 0x00, 0x00, // ] 61 - 0x00, 0x00, 0x04, 0x02, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ 62 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // _ 63 - 0x00, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` 64 - 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x19, 0x24, 0x22, 0x22, 0x22, 0x3F, 0x20, // a 65 - 0x08, 0xF8, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x11, 0x20, 0x20, 0x11, 0x0E, 0x00, // b 66 - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0x20, 0x11, 0x00, // c 67 - 0x00, 0x00, 0x00, 0x80, 0x80, 0x88, 0xF8, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0x10, 0x3F, 0x20, // d 68 - 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x22, 0x13, 0x00, // e 69 - 0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0x18, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // f 70 - 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x6B, 0x94, 0x94, 0x94, 0x93, 0x60, 0x00, // g 71 - 0x08, 0xF8, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x00, 0x00, 0x20, 0x3F, 0x20, // h 72 - 0x00, 0x80, 0x98, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // i 73 - 0x00, 0x00, 0x00, 0x80, 0x98, 0x98, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00, // j 74 - 0x08, 0xF8, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x20, 0x3F, 0x24, 0x02, 0x2D, 0x30, 0x20, 0x00, // k 75 - 0x00, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // l 76 - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x3F, 0x20, 0x00, 0x3F, // m 77 - 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x00, 0x00, 0x20, 0x3F, 0x20, // n 78 - 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, // o 79 - 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xA1, 0x20, 0x20, 0x11, 0x0E, 0x00, // p 80 - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0xA0, 0xFF, 0x80, // q 81 - 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x20, 0x20, 0x3F, 0x21, 0x20, 0x00, 0x01, 0x00, // r 82 - 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x33, 0x24, 0x24, 0x24, 0x24, 0x19, 0x00, // s 83 - 0x00, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x00, 0x00, // t 84 - 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x10, 0x3F, 0x20, // u 85 - 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0E, 0x30, 0x08, 0x06, 0x01, 0x00, // v 86 - 0x80, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, 0x0F, 0x30, 0x0C, 0x03, 0x0C, 0x30, 0x0F, 0x00, // w 87 - 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x31, 0x2E, 0x0E, 0x31, 0x20, 0x00, // x 88 - 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x81, 0x8E, 0x70, 0x18, 0x06, 0x01, 0x00, // y 89 - 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x21, 0x30, 0x2C, 0x22, 0x21, 0x30, 0x00, // z 90 - 0x00, 0x00, 0x00, 0x00, 0x80, 0x7C, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x40, // { 91 - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, // | 92 - 0x00, 0x02, 0x02, 0x7C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x00, // } 93 - 0x00, 0x06, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ 94 -}; - -const unsigned char BMP1[] = { - 0x00, 0x03, 0x05, 0x09, 0x11, 0xFF, 0x11, 0x89, 0x05, 0xC3, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0xFF, 0x11, 0xAA, 0x44, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x01, 0x38, 0x44, 0x82, 0x92, - 0x92, 0x74, 0x01, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x44, 0xC7, 0x01, 0x7D, - 0x7D, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0x7D, 0x7D, 0x7D, 0x7D, 0x01, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, - 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0x00, 0x00, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD8, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, - 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0xE6, 0x66, 0x20, 0x00, 0x06, 0x06, 0x86, 0x06, - 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x86, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, - 0x00, 0x86, 0x86, 0x86, 0x86, 0x86, 0x80, 0x80, 0x86, 0x86, 0x06, 0x86, 0x86, 0xC0, 0xC0, 0x86, - 0x86, 0x86, 0x06, 0x06, 0xD0, 0x30, 0x76, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1C, 0x00, 0xFE, 0x00, 0x01, - 0x02, 0x00, 0xC4, 0x18, 0x20, 0x02, 0x9E, 0x63, 0xB2, 0x0E, 0x00, 0xFF, 0x81, 0x81, 0xFF, 0x00, - 0x00, 0x80, 0x40, 0x30, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x23, 0xEA, 0xAA, 0xBF, 0xAA, - 0xEA, 0x03, 0x3F, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0C, 0x08, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x81, 0x80, 0x80, 0x81, 0x80, - 0x81, 0x80, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x01, 0x09, 0x0C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, - 0x00, 0x1E, 0x21, 0x40, 0x40, 0x50, 0x21, 0x5E, 0x00, 0x1E, 0x21, 0x40, 0x40, 0x50, 0x21, 0x5E, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC1, 0xC1, 0xFF, - 0xFF, 0xC1, 0xC1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0xFC, 0xF3, 0xEF, 0xF3, 0xFC, - 0x80, 0xFF, 0x80, 0xEE, 0xEE, 0xEE, 0xF5, 0xFB, 0xFF, 0x9C, 0xBE, 0xB6, 0xB6, 0x88, 0xFF, 0x00, - /* MP3_UI.bmp */ -}; -#endif // __KETTLE_CODE_TAB_H__ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/common.h b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/common.h deleted file mode 100644 index 2f6aa9359f851db95434936973af9a731422f3d5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/common.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef __WINDER_COMMON_H__ -#define __WINDER_COMMON_H__ - -void DeviceInit(void); - -#endif /* __WINDER_COMMON_H__ */ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/defines.h b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/defines.h deleted file mode 100644 index 0dfff62d1216aeeee0ed12a4bde3996b48534b8b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/defines.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ -#ifndef __DEFINES_H__ -#define __DEFINES_H__ - -#include -#include - -#include - -#define LOG_E(fmt, arg...) printf("[ERROR][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define LOG_D(fmt, arg...) printf("[DEBUG][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define LOG_I(fmt, arg...) printf("[INFO ][%s|%d]" fmt, __func__, __LINE__, ##arg) - -#define WINDBG(fmt, args...) printf("[WINDER_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##args) -#define WINERR(fmt, args...) printf("[WINDER_ERROR][%s|%d]" fmt, __func__, __LINE__, ##args) -#define WINPRN(fmt, args...) printf("[WINDER_INFO ][%s|%d]" fmt, __func__, __LINE__, ##args) - -#define KEY_ERR(fmt, args...) printf("[KEY_ERROR][%s|%d]" fmt, __func__, __LINE__, ##args) -#define KEY_DBG(fmt, args...) printf("[KEY_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##args) -#define KEY_PRT(fmt, args...) printf("[KEY_INFO ][%s|%d]" fmt, __func__, __LINE__, ##args) - -#define NET_ERR(fmt, args...) printf("[NETCFG_ERROR][%s|%d]" fmt, __func__, __LINE__, ##args) -#define NET_DBG(fmt, args...) printf("[NETCFG_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##args) -#define NET_PRT(fmt, args...) printf("[NETCFG_INFO ][%s|%d]" fmt, __func__, __LINE__, ##args) - -#define OLED_ERR(fmt, arg...) printf("[OLED_ERROR][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define OLED_DBG(fmt, arg...) printf("[OLED_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define OLED_PRT(fmt, arg...) printf("[OLED_INFO ][%s|%d]" fmt, __func__, __LINE__, ##arg) - -#define PWM_ERR(fmt, arg...) printf("[PWM_ERROR][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define PWM_DBG(fmt, arg...) printf("[PWM_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##arg) -#define PWM_PRT(fmt, arg...) printf("[PWM_INFO ][%s|%d]" fmt, __func__, __LINE__, ##arg) - - -#endif /* __DEFINES_H__ */ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/lamp.h b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/lamp.h deleted file mode 100644 index 34573114172351693f13c5ec10fb3e2d272bc54e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/lamp.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -#ifndef __WINDER_H__ -#define __WINDER_H__ - - -#include - -#define LAMP_TASK_STACK_SIZE (1024*4) -#define LAMP_TASK_PRIO (25) - -#define BUF_SIZE 64 - -#define POWER_XPOS 0 -#define POWER_YPOS 0 -#define NETSTA_XPOS 0 -#define NETSTA_YPOS 1 - -#define MESSAGE_LEN 6 -#define MSG_VAL_LEN 2 -typedef enum { - MESSAGE_POWER_OFF = 1, - MESSAGE_POWER_OFF_S = 11, -}MESSAGE_TYPE; -#endif /* __WINDER_H__ */ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/oled.h b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/oled.h deleted file mode 100644 index 35320d5f2d768653ce8c37e85afad417b3d03de9..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/include/oled.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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. - */ - - -#ifndef __WINDER_OLED_H__ -#define __WINDER_OLED_H__ - -#include "ohos_types.h" - -#define WIFI_IOT_OLED_I2C_IDX_0 0 -#define WIFI_IOT_IO_FUNC_GPIO_13_I2C0_SDA 6 -#define WIFI_IOT_IO_FUNC_GPIO_14_I2C0_SCL 6 - -#define I2C_REG_ARRAY_LEN (64) -#define BH_SEND_BUFF (1) -#define OLED_SEND_BUFF_LEN (28) -#define OLED_SEND_BUFF_LEN2 (25) -#define OLED_SEND_BUFF_LEN3 (27) -#define OLED_SEND_BUFF_LEN4 (29) -#define Max_Column (128) -#define OLED_DEMO_TASK_STAK_SIZE (4096) -#define OLED_DEMO_TASK_PRIORITY (25) - -#define OLED_ADDRESS 0x78 -#define OLED_ADDRESS_WRITE_CMD 0x00 -#define OLED_ADDRESS_WRITE_DATA 0x40 - -#define OLED_CLEAN_SCREEN ((uint8)0x00) - -#define SLEEP_20_MS 20000 -#define SLEEP_100_MS 100000 - -#define DELAY_10_MS 1 -#define DELAY_100_MS 10 -#define DELAY_200_MS 20 -#define DELAY_250_MS 25 -#define DELAY_500_MS 50 -/* ssd1306 register cmd */ -#define DISPLAY_OFF 0xAE -#define SET_LOW_COLUMN_ADDRESS 0x00 -#define SET_HIGH_COLUMN_ADDRESS 0x10 -#define SET_START_LINE_ADDRESS 0x40 -#define SET_PAGE_ADDRESS 0xB0 -#define CONTRACT_CONTROL 0x81 -#define FULL_SCREEN 0xFF -#define SET_SEGMENT_REMAP 0xA1 -#define NORMAL 0xA6 -#define SET_MULTIPLEX 0xA8 -#define DUTY 0x3F -#define SCAN_DIRECTION 0xC8 -#define DISPLAY_OFFSET 0xD3 -#define DISPLAY_TYPE 0x00 -#define OSC_DIVISION 0xD5 -#define DIVISION 0x80 -#define COLOR_MODE_OFF 0xD8 -#define COLOR 0x05 -#define PRE_CHARGE_PERIOD 0xD9 -#define PERIOD 0xF1 -#define PIN_CONFIGUARTION 0xDA -#define CONFIGUARTION 0x12 -#define SET_VCOMH 0xDB -#define VCOMH 0x30 -#define SET_CHARGE_PUMP_ENABLE 0x8D -#define PUMP_ENABLE 0x14 -#define TURN_ON_OLED_PANEL 0xAF -#define CMD_LENGTH 27 - -#define OLED_I2C_WRITE_CMD_SEND_LEN 2 - -#define HORIZONTAL_COORDINATE_OF_SLOGANS 2 -#define VERTICAL_COORDINATE_OF_SLOGANS 3 -#define CHAR_SIZE_OF_LANTTICE_8_16 16 -#define HORI_PIXEL_OF_LANTTICE_8_16 8 - -#define CHAR_SIZE_OF_LANTTICE_HZ_16_16 32 -#define HORI_PIXEL_OF_LANTTICE_HZ_16_16 16 - -#define CHAR_SIZE_OF_LANTTICE_HZ_16_16_1 48 -#define HORI_PIXEL_OF_LANTTICE_HZ_16_16_1 16 -#define HORI_PIXEL_OF_LANTTICE_6_8 6 - -#define LIMIT_HORI_PIXEL 120 -#define MAX_LINE_OF_LANTTICE 8 -#define SET_POSITION_OFFSET 4 -#define MAX_OLED_INIT_CYCLE_TIMES 5 - - -/** - * @brief Oled Init Operations - * - * @since 1.0 - * @version 1.0 - */ -int OledInit(void); - -/** - * @brief Oled set oled ON or OFF - * @param value 0 set oled OFF, others set the oled ON - * - * @since 1.0 - * @version 1.0 - */ -void OledSetOnOff(int value); - -/** - * @brief Oled clear - * - * @since 1.0 - * @version 1.0 - */ -void OledClear(void); - - -/** - * @brief Oled Show str - * - * @param - * str The str that you want show - * length The length of the str that you want show - * x The offset of X axis - * y The offset of Y axis - * charSize The CharSize (eg: 8*6) - * @since 1.0 - * @version 1.0 - */ -void OledShowStr(char *str, int length, uint8 x, uint8 y, uint8 charSize); - -#endif /* __OLED_H__ */ diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/common.c b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/common.c deleted file mode 100644 index 8750a5d433b9eea2df0975a94d8634e6e671b115..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/common.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -#include -#include "iot_gpio.h" -#include "iot_errno.h" -#include "peripheral_hal.h" -#include "common.h" - -#define I2C_IDX_BAUDRATE (400000) - -#define WIFI_IOT_IO_FUNC_GPIO_13_I2C0_SDA 6 -#define WIFI_IOT_IO_FUNC_GPIO_14_I2C0_SCL 6 -#define WIFI_IOT_I2C_IDX_0 0 - -static void I2cBusInit(void) -{ - IoTGpioInit(HAL_WIFI_IOT_IO_NAME_GPIO_13); - // Set up the gpio funcion as i2c bus 0 - HalIoSetFunc(HAL_WIFI_IOT_IO_NAME_GPIO_13, WIFI_IOT_IO_FUNC_GPIO_13_I2C0_SDA); - - IoTGpioInit(HAL_WIFI_IOT_IO_NAME_GPIO_14); - HalIoSetFunc(HAL_WIFI_IOT_IO_NAME_GPIO_14, WIFI_IOT_IO_FUNC_GPIO_14_I2C0_SCL); - IoTI2cInit(WIFI_IOT_I2C_IDX_0, I2C_IDX_BAUDRATE); // Rate: 400kbps -} - -void DeviceInit(void) -{ - I2cBusInit(); -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/iot_main.c b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/iot_main.c deleted file mode 100644 index cc066a1f5fe27473b592994f39c3df0bda6acbc5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/iot_main.c +++ /dev/null @@ -1,159 +0,0 @@ -#include "ohos_init.h" -#include "cmsis_os2.h" -#include "common.h" -#include "iot_netcfg_nan.h" -#include "oled.h" -#include "defines.h" -#include "lamp.h" -#include "network_config_service.h" - -#include "iot_gpio.h" - -#define IOT_GPIO_9 9 - - -typedef struct { - uint8 power_off; -}LampInfo; - -static LampInfo g_lamp; - -static void ShowPowerStatus(void) -{ - char power_sta[BUF_SIZE] = {0}; - if (sprintf_s(power_sta, BUF_SIZE, "power %s", g_lamp.power_off == 1 ? "OFF" : "ON") < 0) { - WINERR("sprintf_s failed! \n"); - return; - } - OledShowStr(" ", strlen(" "), POWER_XPOS, POWER_YPOS, 1); - OledShowStr(power_sta, strlen(power_sta), POWER_XPOS, POWER_YPOS, 1); -} - -static void LampShowInfo(void) -{ - ShowPowerStatus(); -} - -static void LampDealPoweroff(int value1, int value2) -{ - (void)value2; - if (value1 == 0) { - g_lamp.power_off = 1; - IoTGpioSetOutputVal(IOT_GPIO_9, 1); - } else { - g_lamp.power_off = 0; - IoTGpioSetOutputVal(IOT_GPIO_9, 0); - } - ShowPowerStatus(); -} - -static int my_atoi(char *str, int length) -{ - char buf[MESSAGE_LEN] = {0}; - if (length >= MESSAGE_LEN) { - WINERR("invliad length! \n"); - return -1; - } - - if (strncpy_s(buf, MESSAGE_LEN, str, length) != 0) { - WINERR("strncpy_s failed! \n"); - return 0; - } - - return atoi(buf); -} - -#define ARRAYSIZE(a) (sizeof((a)) / sizeof((a)[0])) - -typedef union { - char msg[MESSAGE_LEN + 1]; - struct { - char type[MSG_VAL_LEN]; - char value1[MSG_VAL_LEN]; - char value2[MSG_VAL_LEN]; - } msg_segment; -} MsgInfo; - -typedef struct { - int type; - void (*ProcessFunc)(int value1, int value2); -} MsgProcess; - -static MsgInfo g_msgInfo; -static MsgProcess g_msgProcess[] = { - {MESSAGE_POWER_OFF, LampDealPoweroff}, // 灯开关指令 - {MESSAGE_POWER_OFF_S, LampDealPoweroff}, -}; - -static void LampProcessAppMessage(const char *data, int data_len) -{ - if (data_len != MESSAGE_LEN) { - WINERR("data len invalid! \n"); - return; - } - - if (strncpy_s(g_msgInfo.msg, MESSAGE_LEN + 1, data, data_len) != 0) { - WINERR("strncpy_s failed! \n"); - return; - } - - for (uint8 i = 0; i < ARRAYSIZE(g_msgProcess); i++) { - if (g_msgProcess[i].type == my_atoi(g_msgInfo.msg_segment.type, MSG_VAL_LEN)) { - g_msgProcess[i].ProcessFunc(my_atoi(g_msgInfo.msg_segment.value1, MSG_VAL_LEN), - my_atoi(g_msgInfo.msg_segment.value2, MSG_VAL_LEN)); - } - } -} - -static int LampNetEventHandler(NET_EVENT_TYPE event, void *data) -{ - switch (event) { - case NET_EVENT_RECV_DATA: // 接收到网络信息(FA发送的消息) - LampProcessAppMessage((const char *)data, strlen(data)); // 处理对应的信息 - break; - default: - break; - } - return 0; -} - -static void LampInit(void) -{ - DeviceInit(); // 硬件相关初始化(比如I2C的初始化等) - if (OledInit() != 0) { // OLED初始化 - WINERR("OledInit failed! \n"); - } -} - -static void *LampTask(const char *arg) -{ - (void)arg; - WINDBG("LampTask Enter! \n"); - LampInit(); - (void)memset_s(&g_lamp, sizeof(g_lamp), 0x00, sizeof(g_lamp)); - - NetCfgRegister(LampNetEventHandler); // 进入配网状态并注册网络监听事件 - LampShowInfo(); // 显示LED初始状态 -} - -void LampDemoEntry(void) -{ - IoTGpioInit(IOT_GPIO_9); - hi_io_set_func (IOT_GPIO_9,0); - IoTGpioSetDir(IOT_GPIO_9, IOT_GPIO_DIR_OUT); - - osThreadAttr_t attr; - attr.name = "LampTask"; - attr.attr_bits = 0U; - attr.cb_mem = NULL; - attr.cb_size = 0U; - attr.stack_mem = NULL; - attr.stack_size = LAMP_TASK_STACK_SIZE; - attr.priority = LAMP_TASK_PRIO; - - if (osThreadNew((osThreadFunc_t)LampTask, NULL, &attr) == NULL) { - WINERR("Falied to create LampTask!\n"); - } -} - -SYS_RUN(LampDemoEntry); diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/oled.c b/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/oled.c deleted file mode 100644 index 8a32be8250543d2cea4899c65aed834a6db28c2f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/demo_smartlamp/src/oled.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include "kal.h" -#include "iot_errno.h" -#include "iot_i2c.h" - -#include "oled.h" -#include "code_tab.h" - -#include "defines.h" - - -static uint8 OledInitCmd[CMD_LENGTH] = { - DISPLAY_OFF, // Display off - SET_LOW_COLUMN_ADDRESS, // ---set low column address - SET_HIGH_COLUMN_ADDRESS, // ---set high column address - SET_START_LINE_ADDRESS, // --set start line address - SET_PAGE_ADDRESS, // --set page address - CONTRACT_CONTROL, // contract control - FULL_SCREEN, // --128 - SET_SEGMENT_REMAP, // set segment remap - NORMAL, - SET_MULTIPLEX, // --set multiplex ratio(1 to 64) - DUTY, // --1/32 duty - SCAN_DIRECTION, // Com scan direction - DISPLAY_OFFSET, // -set display offset - DISPLAY_TYPE, - OSC_DIVISION, // set osc division - DIVISION, - COLOR_MODE_OFF, // set area color mode off - COLOR, - PRE_CHARGE_PERIOD, // set Pre-Charge Period - PERIOD, - PIN_CONFIGUARTION, // set com pin configuartion - CONFIGUARTION, - SET_VCOMH, // set Vcomh - VCOMH, - SET_CHARGE_PUMP_ENABLE, // set charge pump enable - PUMP_ENABLE, - TURN_ON_OLED_PANEL // --turn on oled panel -}; - - -/* I2C write Byte */ -static uint32 I2cWriteByte(uint8 regAddr, uint8 i2cData) -{ - uint32 status; - uint8 sendBuf[2]; - sendBuf[0] = regAddr; - sendBuf[1] = i2cData; - - status = IoTI2cWrite(WIFI_IOT_OLED_I2C_IDX_0, OLED_ADDRESS, sendBuf, sizeof(sendBuf)); - if (status != IOT_SUCCESS) { - OLED_ERR("===== Error: SSD1306 OLED Screen I2C write status = 0x%x! =====\r\n", status); - } - - return status; -} - -static uint32 WriteCmd(uint8 cmd) -{ - return I2cWriteByte(OLED_ADDRESS_WRITE_CMD, cmd); -} - -static uint32 WriteData(uint8 data) -{ - return I2cWriteByte(OLED_ADDRESS_WRITE_DATA, data); -} - -static void OledSetPosition(uint8 x, uint8 y) -{ - if (IOT_SUCCESS != WriteCmd(0xb0 + y)) { - OLED_ERR("WriteCmd Error \n"); - return; - } - - if (IOT_SUCCESS != WriteCmd(((x&0xf0)>>SET_POSITION_OFFSET) | 0x10)) { - OLED_ERR("WriteCmd Error \n"); - return; - } - - if (IOT_SUCCESS != WriteCmd(x & 0x0f)) { - OLED_ERR("WriteCmd Error \n"); - return; - } -} - -static void OledFillScreen(uint8 fii_data) -{ - for (uint8 m = 0; m < MAX_LINE_OF_LANTTICE; m++) { - if (IOT_SUCCESS != WriteCmd(0xb0 + m)) { - OLED_ERR("WriteCmd Error \n"); - return; - } - - if (IOT_SUCCESS != WriteCmd(0x00)) { - OLED_ERR("WriteCmd Error \n"); - return; - } - - if (IOT_SUCCESS != WriteCmd(0x10)) { - OLED_ERR("WriteCmd Error \n"); - return; - } - - for (uint8 n = 0; n < Max_Column; n++) { - if (IOT_SUCCESS != WriteData(fii_data)) { - OLED_ERR("WriteData Error \n"); - return; - } - } - } -} - -static void OledShowChar(uint8 x, uint8 y, uint8 chr, uint8 charSize) -{ - uint8 i; - uint8 c = chr - ' '; // calc the offset - - if (charSize == CHAR_SIZE_OF_LANTTICE_8_16) { - OledSetPosition(x, y); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_8_16; i++) { - WriteData(F8X16[c*CHAR_SIZE_OF_LANTTICE_8_16 + i ]); - } - OledSetPosition(x, y + 1); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_8_16; i++) { - WriteData(F8X16[c*CHAR_SIZE_OF_LANTTICE_8_16 + i + HORI_PIXEL_OF_LANTTICE_8_16]); - } - } else if (charSize == CHAR_SIZE_OF_LANTTICE_HZ_16_16) { - c = chr - '0'; - OledSetPosition(x, y); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_HZ_16_16; i++) { - WriteData(HZ_F16X16[c][0][i]); - } - - OledSetPosition(x, y + 1); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_HZ_16_16; i++) { - WriteData(HZ_F16X16[c][1][i]); - } - } else if (charSize == CHAR_SIZE_OF_LANTTICE_HZ_16_16_1) { - c = chr - '0'; - OledSetPosition(x, y); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_HZ_16_16_1; i++) { - WriteData(HZ_F16X16_1[c][0][i]); - } - OledSetPosition(x, y + 1); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_HZ_16_16_1; i++) { - WriteData(HZ_F16X16_1[c][1][i]); - } - } else { - OledSetPosition(x, y); - for (i = 0; i < HORI_PIXEL_OF_LANTTICE_6_8; i++) { - WriteData(F6X8[c][i]); - } - } -} - -// oled init -int OledInit(void) -{ - uint32 status; - osDelay(DELAY_100_MS); // 100ms Keep the power supply stable. - - for (int i = 0; i < CMD_LENGTH; i++) { - status = WriteCmd(OledInitCmd[i]); - if (status != IOT_SUCCESS) { - OLED_ERR("Failed to write OledInitCmd: 0x%x \n", OledInitCmd[i]); - return IOT_FAILURE; - } - } - - OledFillScreen(0x00); // The screen off -#if 1 // if no need to show log, can delete this code - osDelay(DELAY_10_MS); // 10ms - OledShowStr("OpenHarmony OS", strlen("OpenHarmony OS"), HORIZONTAL_COORDINATE_OF_SLOGANS, - VERTICAL_COORDINATE_OF_SLOGANS, 1); - osDelay(DELAY_500_MS); // The time of keep display - OledShowStr(" ", strlen(" "), HORIZONTAL_COORDINATE_OF_SLOGANS, - VERTICAL_COORDINATE_OF_SLOGANS, 1); -#endif - OLED_PRT("OledInit succuss\n"); - - return IOT_SUCCESS; -} - -void OledSetOnOff(int value) -{ - (void)value; -} - -void OledClear(void) -{ - OledFillScreen(0x00); // The screen off -} - -void OledShowStr(char *str, int length, uint8 x, uint8 y, uint8 charSize) -{ - uint8 i; - if (str == NULL || length <= 0) { - OLED_ERR("no str to show! \n"); - return; - } - - if (x >= LIMIT_HORI_PIXEL) { - OLED_ERR("please input the correct x coord! \n"); - return; - } - - for (i = 0; i < length; i++) { - OledShowChar(x, y, str[i], charSize); - if (charSize == CHAR_SIZE_OF_LANTTICE_HZ_16_16 || charSize == CHAR_SIZE_OF_LANTTICE_HZ_16_16_1) { - x += HORI_PIXEL_OF_LANTTICE_HZ_16_16; - } else { - x += HORI_PIXEL_OF_LANTTICE_8_16; - } - } -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/BUILD.gn b/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/BUILD.gn deleted file mode 100644 index da7e635996338b5573b1e7e12df269b5cac566dc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("hal_sysparam") { - sources = [ "hal_sys_param.c" ] - include_dirs = [ - "//base/startup/syspara_lite/hals", - ] - defines = [ - "INCREMENTAL_VERSION=\"${ohos_version}\"", - "BUILD_TYPE=\"${ohos_build_type}\"", - "BUILD_USER=\"${ohos_build_user}\"", - "BUILD_TIME=\"${ohos_build_time}\"", - "BUILD_HOST=\"${ohos_build_host}\"", - "BUILD_ROOTHASH=\"${ohos_build_roothash}\"", - ] -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/hal_sys_param.c b/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/hal_sys_param.c deleted file mode 100644 index d2979b759254d7888c73bcc40e5d98ee1952ec68..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/sys_param/hal_sys_param.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hal_sys_param.h" - -static const char OHOS_DEVICE_TYPE[] = {"****"}; -static const char OHOS_DISPLAY_VERSION[] = {"OpenHarmony 3.0 LTS"}; -static const char OHOS_MANUFACTURE[] = {"****"}; -static const char OHOS_BRAND[] = {"****"}; -static const char OHOS_MARKET_NAME[] = {"****"}; -static const char OHOS_PRODUCT_SERIES[] = {"****"}; -static const char OHOS_PRODUCT_MODEL[] = {"****"}; -static const char OHOS_SOFTWARE_MODEL[] = {"****"}; -static const char OHOS_HARDWARE_MODEL[] = {"****"}; -static const char OHOS_HARDWARE_PROFILE[] = {"aout:true,display:true"}; -static const char OHOS_BOOTLOADER_VERSION[] = {"bootloader"}; -static const char OHOS_ABI_LIST[] = {"****"}; -static const char OHOS_SERIAL[] = {"1234567890"}; // provided by OEM. -static const int OHOS_FIRST_API_VERSION = 1; - -static const char EMPTY_STR[] = {""}; - -const char* HalGetDeviceType(void) -{ - return OHOS_DEVICE_TYPE; -} - -const char* HalGetManufacture(void) -{ - return OHOS_MANUFACTURE; -} - -const char* HalGetBrand(void) -{ - return OHOS_BRAND; -} - -const char* HalGetMarketName(void) -{ - return OHOS_MARKET_NAME; -} - -const char* HalGetProductSeries(void) -{ - return OHOS_PRODUCT_SERIES; -} - -const char* HalGetProductModel(void) -{ - return OHOS_PRODUCT_MODEL; -} - -const char* HalGetSoftwareModel(void) -{ - return OHOS_SOFTWARE_MODEL; -} - -const char* HalGetHardwareModel(void) -{ - return OHOS_HARDWARE_MODEL; -} - -const char* HalGetHardwareProfile(void) -{ - return OHOS_HARDWARE_PROFILE; -} - -const char* HalGetSerial(void) -{ - return OHOS_SERIAL; -} - -const char* HalGetBootloaderVersion(void) -{ - return OHOS_BOOTLOADER_VERSION; -} - -const char* HalGetAbiList(void) -{ - return OHOS_ABI_LIST; -} - -const char* HalGetDisplayVersion(void) -{ - return OHOS_DISPLAY_VERSION; -} - -const char* HalGetIncrementalVersion(void) -{ - return INCREMENTAL_VERSION; -} - -const char* HalGetBuildType(void) -{ - return BUILD_TYPE; -} - -const char* HalGetBuildUser(void) -{ - return BUILD_USER; -} - -const char* HalGetBuildHost(void) -{ - return BUILD_HOST; -} - -const char* HalGetBuildTime(void) -{ - return BUILD_TIME; -} - -int HalGetFirstApiVersion(void) -{ - return OHOS_FIRST_API_VERSION; -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/BUILD.gn b/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/BUILD.gn deleted file mode 100644 index 5c43e16f987e2d5c76ed2b4c71e3b713f98d7f86..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("hal_token_static") { - sources = [ "hal_token.c" ] - - include_dirs = [ - "//base/startup/syspara_lite/hals", - "//utils/native/lite/include", - ] - deps = [] -} diff --git a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/hal_token.c b/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/hal_token.c deleted file mode 100644 index b4e0ae61ab4cb4c0c957c430d3a1b1b62d22ce9a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/team_x/smart_lamp/hals/utils/token/hal_token.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hal_token.h" -#include "ohos_errno.h" -#include "ohos_types.h" - -static int OEMReadToken(char *token, unsigned int len) -{ - // OEM need add here, read token from device - (void)(token); - (void)(len); - return EC_SUCCESS; -} - -static int OEMWriteToken(const char *token, unsigned int len) -{ - // OEM need add here, write token to device - (void)(token); - (void)(len); - return EC_SUCCESS; -} - -static int OEMGetAcKey(char *acKey, unsigned int len) -{ - // OEM need add here, get AcKey - (void)(acKey); - (void)(len); - return EC_SUCCESS; -} - -static int OEMGetProdId(char *productId, unsigned int len) -{ - // OEM need add here, get ProdId - (void)(productId); - (void)(len); - return EC_SUCCESS; -} - -static int OEMGetProdKey(char *productKey, unsigned int len) -{ - // OEM need add here, get ProdKey - (void)(productKey); - (void)(len); - return EC_SUCCESS; -} - - -int HalReadToken(char *token, unsigned int len) -{ - if (token == NULL) { - return EC_FAILURE; - } - - return OEMReadToken(token, len); -} - -int HalWriteToken(const char *token, unsigned int len) -{ - if (token == NULL) { - return EC_FAILURE; - } - - return OEMWriteToken(token, len); -} - -int HalGetAcKey(char *acKey, unsigned int len) -{ - if (acKey == NULL) { - return EC_FAILURE; - } - - return OEMGetAcKey(acKey, len); -} - -int HalGetProdId(char *productId, unsigned int len) -{ - if (productId == NULL) { - return EC_FAILURE; - } - - return OEMGetProdId(productId, len); -} - -int HalGetProdKey(char *productKey, unsigned int len) -{ - if (productKey == NULL) { - return EC_FAILURE; - } - - return OEMGetProdKey(productKey, len); -} \ No newline at end of file diff --git a/Device/RemoteLamp/device/third_party/iot_link/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/BUILD.gn deleted file mode 100644 index b285dc5a0f37cbff3289ad861e27e299e5b813cf..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology 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. - -group("iot_link") { - deps = [ - "inc:inc", - "link_log:link_log", - "link_misc:link_misc", - "network/dtls:dtls", - "network/mqtt:mqtt", - "oc_mqtt:oc_mqtt", - "queue:queue" - ] -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/LICENSE b/Device/RemoteLamp/device/third_party/iot_link/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - 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. - -Apache License, Version 2.0 -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: -1.You must give any other recipients of the Work or Derivative Works a copy of this License; and -2.You must cause any modified files to carry prominent notices stating that You changed the files; and -3.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 -4.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 \ No newline at end of file diff --git a/Device/RemoteLamp/device/third_party/iot_link/README.md b/Device/RemoteLamp/device/third_party/iot_link/README.md deleted file mode 100644 index 24b5a0db2ab5410bde1ca7097eb203eeafa17c08..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## SDK简介 -iot_link是连接华为云IoTDA平台的SDK,SDK提供端云协同能力,集成了MQTT、LwM2M、CoAP、mbedtls、LwIP 全套 IoT 互联互通协议栈,且在这些协议栈的基础上,提供了开放 API,用户只需关注自身的应用,而不必关注协议内部实现细节,直接使用SDK封装的API,通过连接、数据上报、命令接收和断开四个步骤就能简单快速地实现与华为IoTDA平台的安全可靠连接。使用SDK,用户可以大大减少开发周期,聚焦自己的业务开发,快速构建自己的产品。 - -## 开源协议 - -* 遵循BSD-3开源许可协议 -* [Huawei LiteOS 知识产权政策](http://developer.huawei.com/ict/cn/site-iot/article/iot-intellectual-property-rights) - diff --git a/Device/RemoteLamp/device/third_party/iot_link/bundle.json b/Device/RemoteLamp/device/third_party/iot_link/bundle.json deleted file mode 100644 index d441d6b00deed3acbac4b92c057e2c98f17b41cc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/bundle.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@bearpi/hm_nano_iot_link", - "version": "1.0.1", - "description": "iot_link", - "publishAs": "code-segment", - "scripts": { - "install": "DEST_PATH=${DEP_BUNDLE_BASE}/third_party/iot_link && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH" - }, - "keywords": [ - "bearpi", - "iotlink" - ], - "author": {}, - "repository": "", - "license": "BSD-3-Clause License", - "tags": [ - "third_party" - ], - "ohos": { - "os": "0.0.1", - "kernel": "", - "board": "" - } -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/inc/BUILD.gn deleted file mode 100644 index deff52d4f36fb5bfaa0eacbffe0549d9318c6169..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/BUILD.gn +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("inc") { - - - cflags = [ "-Wno-unused-variable" ] - cflags += [ "-Wno-unused-but-set-variable" ] - include_dirs = [ - "../inc", - "//kernel/liteos_m/components/cmsis/2.0", - ] -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/atiny_log.h b/Device/RemoteLamp/device/third_party/iot_link/inc/atiny_log.h deleted file mode 100644 index 4a6e9e17b6edfae9fe0d024bf8cf210a6f89b8b0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/atiny_log.h +++ /dev/null @@ -1,77 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -#ifndef ATINY_LOG_H -#define ATINY_LOG_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define LOG_DEBUG EN_LINK_LOG_LEVEL_DEBUG -#define LOG_INFO EN_LINK_LOG_LEVEL_INFO -#define LOG_WARNING EN_LINK_LOG_LEVEL_WARN -#define LOG_ERR EN_LINK_LOG_LEVEL_ERROR -#define LOG_FATAL EN_LINK_LOG_LEVEL_FATAL - -/** - * @brief: you could use this as the main printf for your own log - * - * :the input parameters is just as the printf does, and this function should be deserted - * :this function should not use as advised - * */ - -//#define CONFIG_ATINY_DEUG - -#ifdef CONFIG_ATINY_DEUG - -#define ATINY_LOG LINK_LOG - -#else - -#define ATINY_LOG(level,fmt, ...) - - -#endif - - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/dtls_al.h b/Device/RemoteLamp/device/third_party/iot_link/inc/dtls_al.h deleted file mode 100644 index 1c8ba16366e2db5e9f0c9d39932485152cc4db58..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/dtls_al.h +++ /dev/null @@ -1,146 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-10-17 19:50 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_NETWORK_DTLS_DTLS_AL_DTLS_AL_H_ -#define LITEOS_LAB_IOT_LINK_NETWORK_DTLS_DTLS_AL_DTLS_AL_H_ - - -#include -#include - -typedef enum -{ - EN_DTLS_AL_ERR_OK = 0, - EN_DTLS_AL_ERR_PARA, - EN_DTLS_AL_ERR_SYS, - EN_DTLS_AL_ERR_SYSMEM, - EN_DTLS_AL_ERR_NOCONFIG, - EN_DTLS_AL_ERR_NETWORK, - EN_DTLS_AL_ERR_SERVERCERTPARSE, - EN_DTLS_AL_ERR_CLIENTCERTPARSE, - EN_DTLS_AL_ERR_CLIENTPKPARSE, -}en_dtls_al_err_t; - -/** @brief this enum all the transport encode we support now*/ -typedef enum -{ - EN_DTLS_AL_SECURITY_TYPE_NONE = 0, ///< no encode - EN_DTLS_AL_SECURITY_TYPE_PSK, ///< use the psk mode in transport layer - EN_DTLS_AL_SECURITY_TYPE_CERT, ///< use the ca mode in transport layer,only check the server -}en_dtls_al_security_type_t; - -/** @brief this data defines for the psk mode*/ -typedef struct -{ - uint8_t *psk_id; ///< the psk id - uint8_t *psk_key; ///< the psk key - int psk_id_len; ///< the psk id length - int psk_key_len; ///< the psk key length -}dtls_al_security_psk_t; - - -/** @brief this data defines for the cas mode:only check the server */ -typedef struct -{ - uint8_t *server_ca; - uint8_t *client_ca; - uint8_t *client_pk; - uint8_t *client_pk_pwd; - int server_ca_len; - int client_ca_len; - int client_pk_len; - int client_pk_pwd_len; - char *server_name; -}dtls_al_security_cert_t; - - -/** @brief this data defines for the encode parameter for the connect */ -typedef struct -{ - en_dtls_al_security_type_t type; ///< which security type of the data - union - { - dtls_al_security_psk_t psk; ///< psk data if the type is EN_DTSL_SECURITY_TYPE_PSK - dtls_al_security_cert_t cert; ///< cert data if the type is EN_DTSL_SECURITY_TYPE_CERT - }u; -}dtls_al_security_t; - -typedef struct -{ - int istcp; - int isclient; - dtls_al_security_t security; -}dtls_al_para_t; - -en_dtls_al_err_t dtls_al_new(dtls_al_para_t *para,void **handle); -int dtls_al_connect(void *handle,const char *ip, const char *port, int timeout ); -int dtls_al_write(void *handle, uint8_t *msg, size_t len, int timeout ); -int dtls_al_read(void *handle,uint8_t *buf, size_t len,int timeout ); -en_dtls_al_err_t dtls_al_destroy(void *handle); - -typedef en_dtls_al_err_t (*fn_dtls_al_new)(dtls_al_para_t *para,void **handle); -typedef int (*fn_dtls_al_connect)(void *handle,const char *server_ip, const char *server_port,int timeout); -typedef int (*fn_dtls_al_write)(void *handle,uint8_t *msg, size_t len, int timeout); -typedef int (*fn_dtls_al_read)(void *handle, uint8_t *buf, size_t len, int timeout); -typedef en_dtls_al_err_t (*fn_dtls_al_destroy)(void *handle); - -typedef struct -{ - fn_dtls_al_new io_new; - fn_dtls_al_connect io_connect; - fn_dtls_al_write io_write; - fn_dtls_al_read io_read; - fn_dtls_al_destroy io_destroy; -}dtls_al_io_t; - -typedef struct -{ - const char *name; - dtls_al_io_t io; -}dtls_al_t; - -int dtls_al_install(const dtls_al_t *dtls); -int dtls_al_uninstall(const char*name); - -///< this function should implemented by the developer of the tls -int dtls_imp_init(void); -int dtls_al_init(void) ; ///< this function will call dtls_imp_init() - - - -#endif /* LITEOS_LAB_IOT_LINK_NETWORK_DTLS_DTLS_AL_DTLS_AL_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/link_endian.h b/Device/RemoteLamp/device/third_party/iot_link/inc/link_endian.h deleted file mode 100644 index 0d81ad6deb5a7cf441ee64bc69cfd9b9ee14140b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/link_endian.h +++ /dev/null @@ -1,74 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-07-09 14:28 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_INC_LINK_ENDIAN_H_ -#define LITEOS_LAB_IOT_LINK_INC_LINK_ENDIAN_H_ - - -//define the normal addres function -#define swaps(value) ((((value)&((uint16_t)0xff00))>>8)|(((value)&((uint16_t)0x00ff))<<8)) - -#define swapl(value) ((((value)&((uint32_t)0xff000000))>>24)|(((value)&((uint32_t)0xff0000))>>8)|\ - (((value)&((uint32_t)0xff00))<<8)|(((value)&((uint32_t)0xff))<<24)) - - -#define htoles(value) (value) -#define htolel(value) (value) -#define htobes(value) swaps(value) -#define htobel(value) swapl(value) - - -#ifndef htons -#define htons htobes //translate the host endian to network endian (2 Bytes) -#endif - -#ifndef htonl -#define htonl htobel //translate the host endian to network endian (4 Bytes) -#endif - -#ifndef ntohs -#define ntohs htobes //translate the network endian to host endian (2 Bytes) -#endif - -#ifndef ntohl -#define ntohl htobel //translate the network endian to host endian (4 Bytes) -#endif - - - -#endif /* LITEOS_LAB_IOT_LINK_INC_LINK_ENDIAN_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/link_list.h b/Device/RemoteLamp/device/third_party/iot_link/inc/link_list.h deleted file mode 100644 index 379a00b810a2467c2b37a61f5a949e77cd887236..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/link_list.h +++ /dev/null @@ -1,183 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2020-04-22 17:08 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_INC_LINK_LIST_H_ -#define LITEOS_LAB_IOT_LINK_INC_LINK_LIST_H_ - - -#include -#include - - -///< this is common double-list , and you could implement the one yourself - -/* - * you could add the node to the data entry like - * - * struct { - * - * link_node_t node; - * - * xxx value; - * - * } - * - * - * */ - -typedef struct link_node -{ - struct link_node *nxt, *pre; -}link_node_t; - - -#define LINK_NODE_ENTRY(node, type, member) \ - ((type *)((char *)(node) - (size_t)&((type *)0)->member)) - -typedef void (*fn_link_list_iterate)(link_node_t *node, void *args); - - -typedef struct -{ - link_node_t root; -}link_list_t; - -static inline void link_list_init(link_list_t *list) -{ - list->root.nxt = &list->root; - list->root.pre = &list->root; -} - -static inline int link_list_isempty(link_list_t *list) -{ - return list->root.pre == &list->root?1:0; -} - -static inline int link_list_ishead(link_list_t *list, link_node_t *node) -{ - return list->root.nxt == node?1:0; -} - -static inline int link_list_istail(link_list_t *list, link_node_t *node) -{ - return list->root.pre == node?1:0; -} - -///< insert the new_node before the old_node -static inline void link_list_insert(link_node_t *old_node, link_node_t *new_node) -{ - new_node->pre = old_node->pre; - new_node->nxt = old_node; - new_node->pre->nxt = new_node; - old_node->pre = new_node; -} - -static inline void link_list_addhead(link_list_t *list, link_node_t *node) -{ - link_list_insert(list->root.nxt,node); -} - -static inline void link_list_addtail(link_list_t *list, link_node_t *node) -{ - link_list_insert(&list->root,node); -} - -///< node could not bee root -static inline void link_list_removenode( link_node_t *node) -{ - node->pre->nxt = node->nxt; - node->nxt->pre = node->pre; - -} - -static inline link_node_t *link_list_removehead(link_list_t *list) -{ - link_node_t *node = list->root.nxt; - - link_list_removenode(node); - - return node; -} - -static inline link_node_t *link_list_removetail(link_list_t *list) -{ - link_node_t *node = list->root.pre; - - link_list_removenode(node); - - return node; -} - -static inline void link_list_replace(link_node_t *new_node, link_node_t *old_node) -{ - new_node->nxt = old_node->nxt; - new_node->nxt->pre = new_node; - new_node->pre = old_node->pre; - new_node->pre->nxt = new_node; -} - -#define LINK_LIST_FOREACH(node, list) \ - for(node = (list)->root.nxt; \ - node != &(list)->root; \ - node = (node)->nxt ) - -#define LINK_LIST_FOREACH_SAFE(node, tmp,list) \ - for(node = (list)->root.nxt, tmp = (node)->nxt; \ - node != &(list)->root; \ - node = tmp,tmp = (node)->nxt ) - -static inline void link_list_iterate(link_list_t *list, fn_link_list_iterate fn_iterate, void *args) -{ - link_node_t *node; - LINK_LIST_FOREACH(node, list) - { - fn_iterate(node, args); - } -} - -static inline void link_list_iteratesafe(link_list_t *list, fn_link_list_iterate fn_iterate, void *args) -{ - link_node_t *node; - link_node_t *tmp; - LINK_LIST_FOREACH_SAFE(node, tmp,list) - { - fn_iterate(node, args); - } -} - -#endif /* LITEOS_LAB_IOT_LINK_INC_LINK_LIST_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/link_log.h b/Device/RemoteLamp/device/third_party/iot_link/inc/link_log.h deleted file mode 100644 index 31b78d1145d54adc5db368262ea030f969580cd4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/link_log.h +++ /dev/null @@ -1,154 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -#ifndef LITEOS_LAB_IOT_LINK_LINK_LOG_LINK_LOG_H_ -#define LITEOS_LAB_IOT_LINK_LINK_LOG_LINK_LOG_H_ - -#include -#include -#include -#include -#include "cmsis_os2.h" -// #include -/** - * @brief:this defines for the log module, and LINK_LOG_TRACE/LINK_LOG_DEBUG will not participate the compile in the release version - * - * - * */ -typedef enum -{ - EN_LINK_LOG_LEVEL_TRACE = 0, ///< this is used as the trace function,like the function enter and function out - EN_LINK_LOG_LEVEL_DEBUG, ///< this is used as the debug, you could add any debug as you wish - EN_LINK_LOG_LEVEL_INFO, ///< which means it is import message, and you should known - EN_LINK_LOG_LEVEL_WARN, ///< this is used as the executed result,which means the status is not what we expected,but could accept - EN_LINK_LOG_LEVEL_ERROR, ///< this is used as the executed result,which means the status is not what we expected,could not accepta - EN_LINK_LOG_LEVEL_FATAL, ///< this is used as the parameters input for the api interface, which could not accepted - EN_LINK_LOG_LEVEL_MAX, -}en_link_log_level_t; - -/** - * @brief:use this function to get the current output log - * - * @return: the current output mask log, defined by en_link_log_level_t - * */ -en_link_log_level_t link_log_level_get(void); - -/** - * @brief: use this function to get the debug level name - * - * @parameter[in]:level, the level to get - * - * @return: the mapped level name - * */ -const char *link_log_level_name(en_link_log_level_t level); - -/** - * @brief:use this function to set the current output log - * - *@parameter[in] level:defined by en_link_log_level_t - * - * @return: 0 success while -1 failed - * */ -int link_log_level_set(en_link_log_level_t level); - - -/* - * @brief: this is a weak function ,and you could rewrite one - * - * @param fmt: same use as the fmt for printf - * - * @param unfixed: same use for printf - * - * @return: don't care about it - * - * @attention: and the components should not call this function directly, you'd better - * - * call LINK_LOG groups - * - * */ -//__attribute__((weak)) void link_printf(const char *format, ...); - -#ifndef link_printf -#define link_printf(fmt, ...) \ - do \ - { \ - printf(fmt, ##__VA_ARGS__); \ - \ - }while(0) -#endif - -// #ifdef CONFIG_LINKLOG_ENABLE - -#define osal_sys_time() (osKernelGetTickCount() * (1000 / 100)) -#define LINK_LOG(level,fmt, ...) \ - do \ - { \ - link_printf("[%s][%u][%s] " fmt "\r\n", \ - link_log_level_name((level)), (unsigned int)osal_sys_time(),__FUNCTION__, ##__VA_ARGS__); \ - } while (0) - -#define LINK_LOG_TRACE(fmt, ...) \ - do \ - { \ - if ((EN_LINK_LOG_LEVEL_TRACE) >= link_log_level_get()) \ - { \ - LINK_LOG(EN_LINK_LOG_LEVEL_TRACE,fmt,##__VA_ARGS__); \ - } \ - } while (0) - -#define LINK_LOG_DEBUG(fmt, ...) \ - do \ - { \ - if ((EN_LINK_LOG_LEVEL_DEBUG) >= link_log_level_get()) \ - { \ - LINK_LOG(EN_LINK_LOG_LEVEL_DEBUG,fmt,##__VA_ARGS__); \ - } \ - } while (0) - -// #else - -// #define LINK_LOG(level,fmt, ...) -// #define LINK_LOG_TRACE(fmt, ...) -// #define LINK_LOG_DEBUG(fmt, ...) - -// #endif - - -#define LINK_LOG_INFO(fmt, ...) LINK_LOG(EN_LINK_LOG_LEVEL_INFO,fmt,##__VA_ARGS__) -#define LINK_LOG_WARN(fmt, ...) LINK_LOG(EN_LINK_LOG_LEVEL_WARN,fmt,##__VA_ARGS__) -#define LINK_LOG_ERROR(fmt, ...) LINK_LOG(EN_LINK_LOG_LEVEL_ERROR,fmt,##__VA_ARGS__) -#define LINK_LOG_FATAL(fmt, ...) LINK_LOG(EN_LINK_LOG_LEVEL_FATAL,fmt,##__VA_ARGS__) - - -#endif /* LITEOS_LAB_IOT_LINK_LINK_LOG_LINK_LOG_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/link_version.h b/Device/RemoteLamp/device/third_party/iot_link/inc/link_version.h deleted file mode 100644 index bccd0ffc2974d4d2932c9de75e51a2be9ccc2c5b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/link_version.h +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-11-17 12:09 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_INC_LINK_VERSION_H_ -#define LITEOS_LAB_IOT_LINK_INC_LINK_VERSION_H_ - -const char *linkmain_version(); - -#endif /* LITEOS_LAB_IOT_LINK_INC_LINK_VERSION_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/mqtt_al.h b/Device/RemoteLamp/device/third_party/iot_link/inc/mqtt_al.h deleted file mode 100644 index 56a5735581c07f9d9b1bf928d2eaefad7d3e530c..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/mqtt_al.h +++ /dev/null @@ -1,345 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -#ifndef MQTT_AL_H -#define MQTT_AL_H - -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -/** brief defines for all the ascii or data used in the mqtt engine */ -typedef struct -{ - char *data; ///< buffer to storage the data - int len; ///< buffer data length -}mqtt_al_string_t; //used to represent any type string (maybe not ascii) - -///** @brief this enum all the transport encode we support now*/ -//typedef enum -//{ -// en_mqtt_al_security_none = 0, ///< no encode -// en_mqtt_al_security_psk, ///< use the psk mode in transport layer -// en_mqtt_al_security_cas, ///< use the ca mode in transport layer,only check the server -// en_mqtt_al_security_cacs, ///< use the ca mode in transport layer,both check the server and client -// en_mqtt_al_security_end, ///< the end for the mqtt -//}en_mqtt_al_security_t; -// -///** @brief this data defines for the psk mode*/ -//typedef struct -//{ -// mqtt_al_string_t psk_id; ///< the psk id -// mqtt_al_string_t psk_key; ///< the psk key -//}mqtt_al_security_psk_t; -// -///** @brief this data defines for the cas mode:only check the server */ -//typedef struct -//{ -// mqtt_al_string_t ca_crt; ///< the ca crt -//}mqtt_al_security_cas_t; -// -// -///** @brief this data defines for the cacs mode:both check the server and client */ -//typedef struct -//{ -// mqtt_al_string_t ca_s_crt; ///< the server crt -// mqtt_al_string_t ca_c_crt; ///< the client crt -// mqtt_al_string_t ca_c_key; ///< the client ca key -// mqtt_al_string_t ca_host; ///< for peer certificate, maybe they need this -//}mqtt_al_security_cacs_t; -// -///** @brief this data defines for the encode parameter for the connect */ -//typedef struct -//{ -// en_mqtt_al_security_t type; ///< which security type of the data -// union -// { -// mqtt_al_security_psk_t psk; ///< psk data if the type is en_mqtt_security_psk -// mqtt_al_security_cas_t cas; ///< cas data if the type is en_mqtt_security_cas -// mqtt_al_security_cacs_t cacs; ///< cacs data if the type is en_mqtt_security_cacs -// }u; -//}mqtt_al_security_para_t; - -/** @brief enum all the qos supported for the application */ -typedef enum -{ - en_mqtt_al_qos_0 = 0, ///< mqtt QOS 0 - en_mqtt_al_qos_1, ///< mqtt QOS 1 - en_mqtt_al_qos_2, ///< mqtt QOS 2 - en_mqtt_al_qos_err -}en_mqtt_al_qos_t; - -/** @brief defines the parameter used for the will message used in connect */ -typedef struct -{ - mqtt_al_string_t topic; ///< will topic - mqtt_al_string_t msg; ///< will message - en_mqtt_al_qos_t qos; ///< will message qos - int retain; ///< will message retain or not:1 retain while 0 not -}mqtt_al_willmsg_t; - -/** @brief enum the mqtt version*/ -typedef enum -{ - en_mqtt_al_version_3_1_0 = 0, - en_mqtt_al_version_3_1_1, -}en_mqtt_al_verison; - - - -/** @brief defines the paramter for the mqtt connect */ -typedef struct -{ - mqtt_al_string_t serveraddr; ///< mqtt server:support domain name and dot format - int serverport; ///< mqtt server port - dtls_al_security_t *security; ///< if NULL,will use en_mqtt_security_none - en_mqtt_al_verison version; ///< mqtt version will be used - mqtt_al_string_t clientid; ///< mqtt connect client identifier - mqtt_al_string_t user; ///< mqtt connect user - mqtt_al_string_t passwd; ///< mqtt connect pwd - int cleansession; ///< 1 clean the session while 0 not - mqtt_al_willmsg_t *willmsg; ///< mqtt connect will message - unsigned short keepalivetime;///< keep alive time - char conret; ///< mqtt connect code, return by server - int timeout; ///< how much time will be blocked -}mqtt_al_conpara_t; - -/** @brief defines for the mqtt publish */ -typedef struct -{ - mqtt_al_string_t topic; ///< selected publish topic - mqtt_al_string_t msg; ///< message to be published - en_mqtt_al_qos_t qos; ///< message qos - int retain; ///< message retain :1 retain while 0 not - int timeout; ///< how much time will blocked -}mqtt_al_pubpara_t; - - -/** @brief defines for the message will be passed to the application dealer*/ -typedef struct -{ - mqtt_al_string_t topic; ///< message topic - mqtt_al_string_t msg; ///< the topic message payload - en_mqtt_al_qos_t qos; ///< message qos - int dup; ///< message dup times - int retain;///< retain or not -}mqtt_al_msgrcv_t; - -/** @brief defines the mqtt received message dealer, called by mqtt engine*/ -typedef void (*fn_mqtt_al_msg_dealer)(void *arg,mqtt_al_msgrcv_t *msg); - -/** @brief defines the mqtt subscribe parameter*/ -typedef struct -{ - mqtt_al_string_t topic; ///< topic will be subscribe - en_mqtt_al_qos_t qos; ///< qos requested - fn_mqtt_al_msg_dealer dealer; ///< message dealer:used to deal the received message - void *arg; ///< used for the message dealer - char subret; ///< subscribe result code - int timeout; ///< how much time will be blocked -}mqtt_al_subpara_t; - -/** @brief defines the mqtt unsubscribe parameter*/ -typedef struct -{ - mqtt_al_string_t topic; ///< the unsubscribe topic - uint32_t timeout; ///< how much time will be blocked -}mqtt_al_unsubpara_t; - -/** @brief descript the mqtt engine status */ -typedef enum -{ - en_mqtt_al_connect_ok = 0, ///< which means the mqtt is ok and could supply the service - en_mqtt_al_connect_err, ///< the mqtt no start or connect err -}en_mqtt_al_connect_state; - -/** @brief defines for the mqtt connect code returned by the server */ -#define cn_mqtt_al_con_code_ok 0 ///< has been accepted by the server -#define cn_mqtt_al_con_code_err_version 1 ///< server not support the version -#define cn_mqtt_al_con_code_err_clientID 2 ///< client identifier is error -#define cn_mqtt_al_con_code_err_netrefuse 3 ///< server service not ready yet -#define cn_mqtt_al_con_code_err_u_p 4 ///< bad user name or pwd -#define cn_mqtt_al_con_code_err_auth 5 ///< the client is not authorized -#define cn_mqtt_al_con_code_err_unkown -1 ///< unknown reason -#define cn_mqtt_al_con_code_err_network 0x80 ///< network reason,you could try once more - - -/** @brief defines for the mqtt subscribe code returned by the server */ -#define cn_mqtt_al_sub_code_qos0 0 ///< success and max qos is QOS 0 -#define cn_mqtt_al_sub_code_qos1 1 ///< success and max qos is QOS 1 -#define cn_mqtt_al_sub_code_qos2 2 ///< success and max qos is QOS 2 -#define cn_mqtt_al_sub_code_err 0x80 ///< subscribe failure - -/** - *@brief defines the operation will be registered to the mqtt service - *@brief parameter and return code refere to the corresponding api - * - */ -typedef struct -{ -// ///< the mqtt init function -// int (* init) (void); -// ///< the mqtt deinit function -// int (* deinit) (void ); ---TODO, have a thought if we really need it - ///< connect to the server - void* (* connect) (mqtt_al_conpara_t *param); - ///< disconnect from the server - int (* disconnect)(void *handle ); - ///< publish a message to the server - int (* publish) (void *handle, mqtt_al_pubpara_t *msg); - ///< subscribe a topic to the server - int (* subscribe) (void *handle, mqtt_al_subpara_t *subpara); - ///< unsubscribe a topic to the server - int (* unsubscribe) (void *handle, mqtt_al_unsubpara_t *unsubpara); - ///< check the mqtt engine status - en_mqtt_al_connect_state (* check_status) (void *handle); - -}mqtt_al_op_t; - - -//////////////////////API USED FOR THE MQTT APPLICAITON///////////////////////// - -/** - * @brief maybe the mqtt lib need do some initialize - * - * @return 0 success while -1 failed - * - */ -int mqtt_al_init(void); - -/** - * @brief :when you don't want to use the mqtt service ,please call this function - * - * @return 0 success while -1 failed - */ -int mqtt_al_deinit(void); -/** - *@brief: you could use this function to connect to the mqtt server - * - *@param[in] conparam the parameter we will use in connect, refer to the data mqtt_al_conpara_t - *@ - *@return: first you should check the return value then the return code in conparam - * - *@retval NULL which means you could not get the connect to the server,maybe network reason - *@retval handle, which means you get the context, please check the conparam for more - */ -void * mqtt_al_connect( mqtt_al_conpara_t *conparam); - -/** - * @brief : you could use this function to disconnect from the mqtt server - * - * @param[in] handle the handle we get from mqtt_al_connect - - * @return 0 success -1 failed - - */ -int mqtt_al_disconnect(void *handle); - - -/** - * @brief you could use this function to publish a message to the server - * - * @param[in] handle the handle we get from mqtt_al_connect - * - * @param[in] msg the message we will publish, see the data mqtt_al_pubpara_t - * - * @return 0 success -1 failed - * - */ -int mqtt_al_publish(void *handle, mqtt_al_pubpara_t *pubpara); - -/** - * @brief you could use this function subscribe a topic from the server - * - * @param[in] handle the handle we get from mqtt_al_connect - * - * @param[in] subpara refer to the data mqtt_al_subpara_t - * - * @return 0 success -1 failed - * - */ -int mqtt_al_subscribe(void *handle, mqtt_al_subpara_t *subpara); - -/** - * @brief you could use this function unsubscribe a topic from the server - * - * @param[in] handle the handle we get from mqtt_al_connect - * - * @param[in] unsubpara refer to the data mqtt_al_unsubpara_t - * - * @return 0 success -1 failed - * - */ -int mqtt_al_unsubscribe(void *handle, mqtt_al_unsubpara_t *unsubpara); - -/** - * @brief the mqtt engine state now - * - * @param[in] handle the handle we get from mqtt_al_connect - * - * @return refer to en_mqtt_al_connect_state - */ -en_mqtt_al_connect_state mqtt_al_check_status(void *handle); - -//////////////////////API USED FOR THE MQTT IMPLEMENT///////////////////////// - -/** - *@brief the mqtt lib should call this function to register its implement as a service - * - *@param[in] op refer to the data mqtt_al_op_t - * - *@return 0 success while -1 failed - * - */ -int mqtt_al_install(mqtt_al_op_t *op); -/** - *@brief call this function to unregister the mqtt service - * - *@param[in] op refer to the data mqtt_al_op_t - * - *@return 0 success while -1 failed - * - */ -int mqtt_al_uninstall(void); - - - -#if defined(__cplusplus) -} -#endif - -#endif /* MQTT_AL_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/shell.h b/Device/RemoteLamp/device/third_party/iot_link/inc/shell.h deleted file mode 100644 index 42fbe35ad370ef38279bca161385e74b8d812b0d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/shell.h +++ /dev/null @@ -1,108 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-05-14 17:22 zhangqianfu The first version - * - */ - -#ifndef __OSSHELL_H -#define __OSSHELL_H - - -#include -#include -#include - -#if CONFIG_SHELL_ENABLE - -//this is a shell module designed for the os -//this is a shell type,maybe a command or the data variables -enum en_os_shell_type -{ - EN_OSSHELL_CMD = 0, - EN_OSSHELL_VAR, //up till now, we only support 4 bytes - EN_OSSHELL_LAST, -}; - -#define BUILD_VAR_NAME(A,B) A##B -#define MAX_TAB_MATCHES 16 -struct shell_tab_matches -{ - const char *matches[MAX_TAB_MATCHES]; - unsigned short len; -}; - -//this is the shell function module.the register function must have the same type -//uptils now, we don't care the return value -struct shell_item_t -{ - const char *name; //point to the shell name string - const char *help; //point to the shell description string - void *addr; //point to the shell function or the shell data - unsigned short type; //used to point the shell type:command or a data - unsigned short len; //used to point the shell command or data length -}; -//this define will create a shell command with the specified cmdname -#define OSSHELL_EXPORT_CMD(cmdentry,cmdname,cmdhelp) \ - static const struct shell_item_t BUILD_VAR_NAME(__oshell_,cmdentry) __attribute__((used,section("oshell")))= \ - { \ - .name=cmdname, \ - .help=cmdhelp, \ - .addr=(void *)&cmdentry, \ - .type=EN_OSSHELL_CMD, \ - .len = sizeof(void *), \ - } -//this define will create a create a shell data with the specified name -#define OSSHELL_EXPORT_VAR(var,varname,varhelp) \ - static const struct shell_item_t BUILD_VAR_NAME(__oshell_,var) __attribute__((used,section("oshell")))= \ - { \ - .name=varname, \ - .help=varhelp, \ - .addr=(void *)&var, \ - .type=EN_OSSHELL_VAR, \ - .len =sizeof(var), \ - } - -void shell_init(void); -#else - -#define OSSHELL_EXPORT_CMD(cmdentry,cmdname,cmdhelp) -#define OSSHELL_EXPORT_VAR(var,varname,varhelp) -#define shell_init() - -#endif //end for the shell_config - - -#endif /* __OSSHELL_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/inc/stimer.h b/Device/RemoteLamp/device/third_party/iot_link/inc/stimer.h deleted file mode 100644 index 47b7dd2fda21de789e5a27fdca52f1d71d6d6417..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/inc/stimer.h +++ /dev/null @@ -1,114 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-07-26 18:05 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_STIMER_STIMER_H_ -#define LITEOS_LAB_IOT_LINK_STIMER_STIMER_H_ - -#include -#include - -////////////////DEFINES FOR THE STIMER HEADER/////////////////////////////////// -///< defines for the soft timer operation method,you could use it with the stimer_ioctl function -typedef enum -{ - en_stimer_opt_stop = 0, ///< stop the soft timer - en_stimer_opt_start, ///< start the soft timer - en_stimer_opt_gettime, ///< get the left time - en_stimer_opt_recycle, ///< reset the cycle - en_stimer_opt_reflag, ///< reset the flag -}en_stimer_opt_t; - -///< defines for the soft timer handle returned by the create function and used for ioctl and delete function -///< the user should never supposed any data structure for the handle, you could only use the api supplied -typedef void* stimer_t; - -///< defines for the flag when create the soft timer -#define cn_stimer_flag_once (1<<0) -#define cn_stimer_flag_start (1<<1) -///< define the soft timer interrupt service function -typedef void (*fn_stimer_handler)(void *arg); - - -/** - * @brief: this function used for initialize the timer component, should be called after the os - * - * @return: 0 success while -1 failed - * */ -int32_t stimer_init(); - -/** - * @brief: you could use this function for create a soft timer as you wished - * - * @param[in]:name, the soft timer name - * @param[in]:handler, the soft timer handler when the timer is activated - * @param[in]:arg, the argument will supplied for the handler - * @param[in]:cycle, the soft timer cycle - * @param[in]:flag, you could use cn_stimer_flag_once or cn_stimer_flag_start or both - * - * @return:soft timer handler, you could use it for ioctl or delete;if failed NULL - * will be returned - * - * */ -stimer_t stimer_create(const char *name,fn_stimer_handler handler, \ - void *arg,uint32_t cycle,uint32_t flag); - -/** - * @brief: you could use this function to delete the soft timer you created - * - * @param[in]:timer handler,returned by the create function - * - * @return:0 success while -1 or others failed - * - * */ -int32_t stimer_delete(stimer_t timer); - -/** - * @brief: you could use this function to control the function - * - * @param[in]:timer,returned by the create function - * @param[in]:opt,defined by en_stimer_opt_t, and the arg is corresponding parameters - * @param[in]:arg, corresponding to the opt - * - * @return:0 success while -1 or others failed - * - * */ -int32_t stimer_ioctl(stimer_t timer,en_stimer_opt_t opt, void *arg); - - - -#endif /* LITEOS_LAB_IOT_LINK_STIMER_STIMER_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_log/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/link_log/BUILD.gn deleted file mode 100644 index 4e130f9ea920b2c8b2e73ee053af6bb6e1a04137..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_log/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("link_log") { - sources = [ - "link_log.c", - ] - - cflags = [ "-Wno-unused-variable" ] - cflags += [ "-Wno-unused-but-set-variable" ] - include_dirs = [ - "../link_log", - "../inc", - "//kernel/liteos_m/components/cmsis/2.0", - ] - -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_log/link_log.c b/Device/RemoteLamp/device/third_party/iot_link/link_log/link_log.c deleted file mode 100644 index 6ef8722668fe355070da6f7389e95e0692c01b2e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_log/link_log.c +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-12-19 14:34 zhangqianfu The first version - * - */ - -#include -#include -#include - -static en_link_log_level_t s_link_log_level = EN_LINK_LOG_LEVEL_TRACE; -static const char *s_link_log_names[] = -{ - "TRACE", - "DEBUG", - "INFO ", - "WARN ", - "ERROR", - "FATAL" -}; - -int link_log_level_set(en_link_log_level_t level) -{ - int ret = -1; - if(level < EN_LINK_LOG_LEVEL_MAX ) - { - s_link_log_level = level; - ret = 0; - } - return ret; -} - -en_link_log_level_t link_log_level_get(void) -{ - return s_link_log_level; -} - -const char *link_log_level_name(en_link_log_level_t log_level) -{ - if (log_level >= EN_LINK_LOG_LEVEL_MAX) - { - return "NULL "; - } - else - { - return s_link_log_names[log_level]; - } - -} - -/* - -#ifndef CONFIG_LINK_LOGBUF_LEN -#define CONFIG_LINK_LOGBUF_LEN 256 ///< you could modify it -#endif - -__attribute__((weak)) void link_printf(const char *format, ...) -{ - char str_buf[CONFIG_LINK_LOGBUF_LEN] = {0}; - va_list list; - - (void) (void) memset(str_buf, 0, CONFIG_LINK_LOGBUF_LEN); - - va_start(list, format); - (void) vsnprintf(str_buf, sizeof(str_buf), format, list); - va_end(list); - - (void) printf("%s", str_buf); - - return; -} - -*/ diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/link_misc/BUILD.gn deleted file mode 100644 index cf3f289d8cb921a078ad20beb4e91a7820c08d38..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/BUILD.gn +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -static_library("link_misc") { - sources = [ - "link_random.c", - "link_ring_buffer.c", - "link_string.c", - ] - - cflags = [ "-Wno-unused-variable" ] - cflags += [ "-Wno-unused-but-set-variable" ] - include_dirs = [ - "../link_misc", - "//kernel/liteos_m/components/cmsis/2.0", - ] - -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_misc.h b/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_misc.h deleted file mode 100644 index b28ff21ca7553f17e6f0c97b57edffa345ea40f8..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_misc.h +++ /dev/null @@ -1,255 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-04-29 10:10 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_MISC_H_ -#define LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_MISC_H_ - -#include -#include - -/** - * @brief:use this function to make a string to argc and args mode - * - * @param[in/out]:argc, how many buffer in the argc - * - * @param[in/out]:argv, the buffer for the args - * - * @param[in]:string, the string to be format - * - * - * @return:how many parameters in the string - * - * */ -int string_buffer_to_arg(int *argc, const char *argv[],char *string); - -/** - * - * @brief: use this function to clone a string - * - * @param[in]: source string - * - * @return: the clone string - * - * */ - -char *osal_strdup(const char *ch); - - - -/** - * - * dataoff - * ring buffer map: | ----datalen------- - * | / \ - * |/ \ - * ---------------------------------------------------------- - * | empty space |//////valid data///////| | - * ---------------------------------------------------------- - * | \ / - * | \ / - * | \ / - * | ---------------buflen-------------------------- - * buf - * - * attention that do dump read or write means no data will really write or read, - * it only changed the dataoff or datalen, and you make sure that the dump read - * or write length is legal - * - * */ - -/** - * @brief: this is the ring buffer data structure, implement as the common function - * - * */ -typedef struct -{ - unsigned char *buf; ///< which means the buffer - int buflen; ///< which means the buffer limit - int datalen; ///< which means how many data in the buffer - int dataoff; ///< which means the valid data offset in the buffer -}tag_ring_buffer_t; - -typedef tag_ring_buffer_t ring_buffer_t; - -/** - * @brief:use this function to make a new ring handle - * - * @param[in]:ring,which will be initialized - * - * @param[in]:buf, which will be used as the cache for the ring - * - * @param[in]:buflen, the length of buf - * - * @param[in]:offset, the initialize data offset - * - * @param[in]:datalen, the initialize data length - * - * @return: 0 success while -1 failed - * - * */ - - -int ring_buffer_init(tag_ring_buffer_t *ring,unsigned char *buf, int buflen,int offset,int datalen); - - - -/** - * @brief:use this function to write data to the ring buffer - * - * @param[in]:ring,which will be written - * - * @param[in]:buf, the data buffer - * - * @param[in]:len, the buffer length - * - * @return: how many bytes has been written while -1 means failed - * - * */ -int ring_buffer_write(tag_ring_buffer_t *ring,unsigned char *buf, int len); - -/** - * @brief:use this function to read data from the ring buffer - * - * @param[in]:ring,which will be read - * - * @param[in]:buf, the data buffer - * - * @param[in]:len, the buffer length - * - * @return: how many bytes has been read while -1 failed - * - * */ - -int ring_buffer_read(tag_ring_buffer_t *ring,unsigned char *buf, int len); - -#define ring_buffer_buf(x) (x->buf) -#define ring_buffer_buflen(x) (x->buflen) -#define ring_buffer_data(x) (x->buf + x->dataoff) -//#define ring_buffer_datalen(x) (x->datalen) -//#define ring_buffer_freespace(x) (x->buflen - x->datalen) - -#define ring_buffer_dataoff(x) (x->dataoff) -#define ring_buffer_dumpread(x,y) do{x->dataoff = (x->dataoff + y)%x->buflen; x->datalen -= y;}while(0) -#define ring_buffer_dumpwrite(x,y) do{x->datalen += y;)while(0) - -/** - * @brief:use this function check out how many data in the ring buffer - * - * @param[in]:ring,which will be checked - - * @return: how many data bytes while -1 failed - * - * */ -int ring_buffer_datalen(tag_ring_buffer_t *ring); - -/** - * @brief:use this function check out how many free space in the ring buffer - * - * @param[in]:ring,which will be checked - - * @return: how many free space bytes while -1 failed - * - * */ -int ring_buffer_freespace(tag_ring_buffer_t *ring); - -/** - * @brief:use this function to reset the ring buffer - * - * @param[in]:ring,which will be reset - - * @return: 0 success while -1 failed - * - * */ -int ring_buffer_reset(tag_ring_buffer_t *ring); - -/** - * @brief:use this function to deinit the ring buffer - * - * @param[in]:ring,which will be deinit - - * @return: 0 success while -1 failed - * - * */ -int ring_buffer_deinit(tag_ring_buffer_t *ring); - - -///< random -/** - * @brief: use this function to generate the random ,could be reprogramed by yourelf - * - * @param[in]:output, this is the random data storage buffer - * @param[in]:len, the output buffer length - * - * @retrun:0 success while -1 failed - * - * */ -int link_random(void* output, int len); - - -/** - * @brief: use this function to translate the string to argv mode - * - * @param[in]:string , the string to translate - * @param[inout]:argc, the sizeof argv and how many prarameters has been splited - * @param[inout]:argv, used to storage the parameters splited - * - * @retrun:how many parameters geted - * - * */ -int string_to_arg(int *argc, const char *argv[],char *string); - -/** - * @brief: use this function to add the string list to one string - * - * @param[in]:str[] the array to add, end with NULL - * - * @retrun:the str added, NULL if failed - * - * */ - -char *osal_strcat(char *str[]); - -int hexstr2byte(const char *bufin, int len, char *bufout); - -int byte2hexstr(uint8_t *bufin, int len, char *bufout); - - - - - -#endif /* LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_MISC_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_random.c b/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_random.c deleted file mode 100644 index 509cc6b860734a3493074b24b13af43785070edc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_random.c +++ /dev/null @@ -1,69 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-05-10 10:26 zhangqianfu The first version - * - */ -#include -#include - -#include -#include - -#include "cmsis_os2.h" - -__attribute__((weak)) int link_random(void* output, int len) -{ - int i; - int random_number; - char* pbuf; - - if (NULL == output) - { - return -1; - } - - pbuf = output; - srand(osKernelGetTickCount() * (1000 / 100)); - - for (i = 0; i < len; i += sizeof(int)) - { - random_number = rand(); - (void) memcpy(pbuf + i, &random_number, - sizeof(int) > (unsigned int)(len - i)? (unsigned int)(len - i): sizeof(int)); - } - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_ring_buffer.c b/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_ring_buffer.c deleted file mode 100644 index 59b9d487dbbe5e146775a3b6a4d21b2618b6742a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_ring_buffer.c +++ /dev/null @@ -1,210 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-04-29 10:34 zhangqianfu The first version - * - */ -#include -#include -#include - -#include - - -int ring_buffer_init(tag_ring_buffer_t *ring,unsigned char *buf, int buflen,int offset,int datalen) -{ - int ret = -1; - if((NULL == ring)) - { - return ret; - } - ring->buf = buf; - ring->buflen = buflen; - ring->datalen = datalen; - ring->dataoff = offset; - ret = 0; - return ret; -} - - -int ring_buffer_write(tag_ring_buffer_t *ring,unsigned char *buf, int len) -{ - int ret = -1; - int cpylen; //the current time we should move - int lenleft; //and how many data still left to move - int offset; - unsigned char *src; - unsigned char *dst; - if((NULL == ring)||(NULL == buf)||(0 == len)) - { - return ret;//which means parameters error - } - if((ring->datalen == ring->buflen)|| (ring->buflen <= 0)) - { - ret = 0; - return ret;//which means you could copy nothing here - } - ret = len > (ring->buflen-ring->datalen)?(ring->buflen-ring->datalen):len; - //now let us think the method to fill the data,take care of the roll back - lenleft = ret; - src = buf; - if((ring->dataoff+ring->datalen)>ring->buflen) //which means the data has roll back - { - offset = (ring->dataoff+ring->datalen)%ring->buflen; //we could move it one time - cpylen = lenleft; - dst = ring->buf + offset; - if(cpylen > 0) - { - (void) memcpy(dst,src,cpylen); - ring->datalen += cpylen; - lenleft -= cpylen; - } - } - else if((ring->dataoff+ring->datalen + lenleft)>ring->buflen) //which means the data will be roll back - { - //which means roll back,we should copy some here to the tail - offset = ring->dataoff + ring->datalen; - cpylen = ring->buflen - offset; - dst = ring->buf + offset; - (void) memcpy(dst,src,cpylen); - src += cpylen; - ring->datalen += cpylen; - lenleft -= cpylen; - } - //here means we could move it by one time - if(lenleft > 0) - { - offset = (ring->dataoff+ring->datalen)%ring->buflen; //we could move it one time - cpylen = lenleft; - dst = ring->buf + offset; - (void) memcpy(dst,src,cpylen); - ring->datalen += cpylen; - } - return ret; -} - - -int ring_buffer_read(tag_ring_buffer_t *ring,unsigned char *buf, int len) -{ - int ret = -1; - int cpylen; //the current time we should move - int lenleft; //and how many data still left to move - int offset; - unsigned char *src; - unsigned char *dst; - if((NULL == ring)||(NULL == buf)||(0 == len)) - { - return ret;//which means parameters error - } - if((ring->datalen == 0) || (ring->buflen <= 0)) - { - ret = 0; - return ret;//which means you could copy nothing here - } - ret = len > ring->datalen?ring->datalen:len; - //now let us think the method to fill the data,take care of the roll back - lenleft = ret; - dst = buf; - if(ring->dataoff >= (ring->buflen - lenleft)) //which means the data has roll back - { - offset =ring->dataoff; //we cpy part - cpylen = ring->buflen - ring->dataoff; - src = ring->buf + offset; - - if(cpylen > 0) - { - (void) memcpy(dst,src,cpylen); - ring->dataoff = (ring->dataoff + cpylen)%ring->buflen; - ring->datalen -= cpylen; - lenleft -= cpylen; - dst += cpylen; - } - } - //here means we could move it by one time - if(lenleft > 0) - { - offset =ring->dataoff; //we cpy part - cpylen = lenleft; - src = ring->buf + offset; - (void) memcpy(dst,src,cpylen); - ring->dataoff = ring->dataoff + cpylen; - ring->datalen -= cpylen; - } - return ret; -} - - -int ring_buffer_datalen(tag_ring_buffer_t *ring) -{ - int ret = -1; - if(NULL != ring) - { - ret = ring->datalen; - } - return ret; -} - -int ring_buffer_freespace(tag_ring_buffer_t *ring) -{ - int ret = -1; - if(NULL != ring) - { - ret = ring->buflen-ring->datalen; - } - return ret; -} - -int ring_buffer_reset(tag_ring_buffer_t *ring) -{ - int ret = -1; - if(NULL != ring) - { - ring->datalen = 0; - ring->dataoff = 0; - ret = 0; - } - return ret; -} - -int ring_buffer_deinit(tag_ring_buffer_t *ring) -{ - int ret = -1; - if(NULL != ring) - { - (void) memset(ring,0,sizeof(tag_ring_buffer_t)); - ret = 0; - } - return ret; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_string.c b/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_string.c deleted file mode 100644 index 51997d025bc8059ec8e4cc117bf413cf1cf97c0a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_string.c +++ /dev/null @@ -1,259 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-04-29 09:50 zhangqianfu The first version - * - */ - -#include -#include -#include -#include - -// #include 修改 -//this function is used to format the char string to the argc mode -//this function will changed the original string, used it carefully -//return how many arguments has been -int string_to_arg(int *argc, const char *argv[],char *string) -{ - int argvlen = 0; - int paramnum = 0; - char *tmp = NULL; - char bak; - int len; - - argvlen = *argc; - *argc = paramnum; - if(NULL == string) - { - return paramnum; - } - - //use the '\0' to replace the ' ' - len = strlen(string); - tmp = string; - while(tmp < (string + len)) - { - if(*tmp == ' ') - { - *tmp = '\0'; - } - tmp++; - } - bak = '\0'; - tmp = string; - while(tmp < (string + len)) - { - if((*tmp != '\0')&&(bak =='\0')) - { - if(paramnum < argvlen) - { - argv[paramnum] = tmp; - paramnum++; - } - } - bak = *tmp; - tmp++; - } - *argc = paramnum; - - return paramnum; -} - - -char *osal_strdup(const char *ch) -{ - char *copy; - size_t length; - - if(NULL == ch) - return NULL; - - length = strlen(ch); - copy = (char *)malloc(length + 1); //修改 - if(NULL == copy) - return NULL; - (void) strncpy(copy, ch, length); - copy[length] = '\0'; - - return copy; -} - -char *osal_strcat(char *str[]) -{ - char *ret = NULL; - int str_tnum = 0; - int str_tlen = 0; - int str_off = 0; - int i = 0; - - if(NULL == str) - { - return ret; - } - - while(NULL != str[i]) - { - str_tlen += strlen(str[i]); - str_tnum++; - i++; - } - - ret = malloc(str_tlen); //修改 - if(NULL != ret) - { - for(i =0;i< str_tnum;i++) - { - - (void) memcpy(ret + str_off,str[i],strlen(str[i])); - str_off += strlen(str[i]); - } - ret[str_off] = '\0'; - } - - return ret; -} - -/* -int hexstr2byte(const char *bufin, int len, char *bufout) -{ - int i = 0; - unsigned char tmp2 = 0x0; - unsigned int tmp = 0; - char cc; - - if (NULL == bufin || len <= 0 || NULL == bufout) - { - return -1; - } - for(i = 0; i < len; i = i+2) - { - tmp2 = (unsigned char )bufin[i]; - tmp2 = tmp2 <= '9'?(unsigned char)(unsigned int)(tmp2-0x30):(unsigned char)(unsigned int)(tmp2-0x37); - cc = bufin[i+1]; - tmp = (unsigned int)(unsigned char)cc; - tmp = tmp <= '9'?(unsigned int)(tmp-0x30):(unsigned int)(tmp-0x37); - bufout[i/2] =(tmp2<<4)|(tmp&0x0F); - } - return 0; -} - -*/ - -int hexstr2byte(const char *buf, int len, char *bufout) -{ - int ret = -1; - int i = 0; - uint8_t low; - uint8_t high; - - if (NULL == buf || len <= 0 || NULL == bufout) - { - return ret; - } - - ret = 0; - for(i = 0; i < len; i = i+2) - { - if(((buf[i]) >= '0') && (buf[i] <= '9')) - { - high = (uint8_t)( buf[i] - '0'); - } - else if((buf[i] >= 'A') && (buf[i] <= 'F')) - { - high = (uint8_t)( buf[i] - 'A') + 10; - } - else if((buf[i] >= 'a') && (buf[i] <= 'f')) - { - high = (uint8_t)( buf[i] - 'a') + 10; - } - else - { - ret = -1; - break; - } - - if(((buf[i+1]) >= '0') && (buf[i+1] <= '9')) - { - low = (uint8_t)( buf[i+1] - '0'); - } - else if((buf[i+1] >= 'A') && (buf[i+1] <= 'F')) - { - low = (uint8_t)( buf[i+1] - 'A') + 10; - } - else if((buf[i+1] >= 'a') && (buf[i+1] <= 'f')) - { - low = (uint8_t)( buf[i+1] - 'a') + 10; - } - else - { - ret = -1; - break; - } - - bufout[i/2] = (char)((high<<4)|(low&0x0F)); - } - return ret; -} - - - -//make a byte to 2 ascii hex -int byte2hexstr(uint8_t *bufin, int len, char *bufout) -{ - int i = 0; - uint8_t tmp_l = 0x0; - uint8_t tmp_h = 0; - if ((NULL == bufin )|| (len <= 0 )||( NULL == bufout)) - { - return -1; - } - for(i = 0; i < len; i++) - { - tmp_h = (bufin[i]>>4)&0X0F; - tmp_l = bufin[i] &0x0F; - bufout[2*i] = (tmp_h > 9)? (tmp_h - 10 + 'a'):(tmp_h +'0'); - bufout[2*i + 1] = (tmp_l > 9)? (tmp_l - 10 + 'a'):(tmp_l +'0'); - } - bufout[2*len] = '\0'; - - return 0; -} - - - - - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_time.h b/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_time.h deleted file mode 100644 index a3b55cdd4c1e888e202b153cd61ee37cf20b18dc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/link_misc/link_time.h +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-05-10 14:37 zhangqianfu The first version - * - */ -#ifndef LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_TIME_H_ -#define LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_TIME_H_ - - - - - -#endif /* LITEOS_LAB_IOT_LINK_LINK_MISC_LINK_TIME_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/BUILD.gn deleted file mode 100644 index 5c06fc7dc6d25b4cd8eb4419aa308f838ca74152..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/BUILD.gn +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology 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. - -dtls_inc = [ - "mbedtls/mbedtls_port", - "../../inc", - "../../link_misc", - "//kernel/liteos_m/components/cmsis/2.0", - "//third_party/mbedtls/include/", -] - - -dtls_src = [ - "dtls_al/dtls_al.c", - "mbedtls/mbedtls_port/dtls_interface.c", - "mbedtls/mbedtls_port/mbed_port.c", - "mbedtls/mbedtls_port/timing_alt.c", -] -dtls_def = [ - "WITH_DTLS", - "MBEDTLS_AES_ROM_TABLES", - "MBEDTLS_CONFIG_FILE=\"los_mbedtls_config_dtls.h\"", - "CONFIG_DTLS_MBEDTLS_CERT", - "CONFIG_DTLS_MBEDTLS_PSK", - "CFG_MBEDTLS_MODE=PSK_CERT", - -] - -dtls_cflags = [ - "-Wno-sign-compare", - "-Wno-unused-parameter", -] - -static_library("dtls") { - cflags = dtls_cflags - defines = dtls_def - sources = dtls_src - include_dirs = dtls_inc -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/dtls_al/dtls_al.c b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/dtls_al/dtls_al.c deleted file mode 100644 index 8302ac5ee813a22b3ff6327b49657cad152ca488..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/dtls_al/dtls_al.c +++ /dev/null @@ -1,143 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2019-10-17 19:50 zhangqianfu The first version - * - */ - - -#include -#include -#include -#include -#include -#include - - -static const dtls_al_t *s_dtls_al; - -en_dtls_al_err_t dtls_al_new(dtls_al_para_t *para,void **handle) -{ - en_dtls_al_err_t ret = EN_DTLS_AL_ERR_NOCONFIG; - if( (NULL != s_dtls_al) && (NULL != s_dtls_al->io.io_new) ) - { - ret = s_dtls_al->io.io_new(para, handle); - } - return ret; -} - - -int dtls_al_connect(void *handle,const char *server_ip, const char *server_port, int timeout) -{ - int ret = -1; - if( (NULL != s_dtls_al) && (NULL != s_dtls_al->io.io_connect)) - { - ret = s_dtls_al->io.io_connect(handle, server_ip,server_port, timeout); - } - return ret; -} - -int dtls_al_write(void *handle, uint8_t *msg, size_t len, int timeout) -{ - int ret = 0; - if( (NULL != s_dtls_al) && (NULL != s_dtls_al->io.io_write)) - { - ret = s_dtls_al->io.io_write(handle, msg, len, timeout ); - } - return ret; -} - -int dtls_al_read(void *handle, uint8_t *buf, size_t len, int timeout) -{ - int ret = 0; - if( (NULL != s_dtls_al) && (NULL != s_dtls_al->io.io_read)) - { - ret = s_dtls_al->io.io_read(handle, buf, len, timeout ); - } - return ret; -} - -en_dtls_al_err_t dtls_al_destroy(void *handle) -{ - en_dtls_al_err_t ret = EN_DTLS_AL_ERR_NOCONFIG; - if( (NULL != s_dtls_al) && (NULL != s_dtls_al->io.io_destroy)) - { - ret = s_dtls_al->io.io_destroy( handle ); - } - return ret; -} - - -int dtls_al_install(const dtls_al_t *dtls) -{ - int ret = -1; - if (NULL == s_dtls_al ) - { - s_dtls_al = dtls; - ret = 0; - } - - return ret; -} - -int dtls_al_uninstall(const char*name) -{ - int ret = -1; - - if((NULL != s_dtls_al) && (0 == strcmp(name,s_dtls_al->name))) - { - s_dtls_al = NULL; - } - - return ret; -} - -__attribute__((weak)) int dtls_imp_init(void) -{ - LINK_LOG_DEBUG("%s:###please implement dtls by yourself####",__FUNCTION__); - return -1; -} - -int dtls_al_init(void) -{ - int ret; - - ret = dtls_imp_init(); - LINK_LOG_DEBUG("IOT_LINK:DO DTLS LOAD-IMPLEMENT RET:%d",ret); - - return ret; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.c b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.c deleted file mode 100644 index 8b330cf13af17dbea925d78e653a768c2acfe3a2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.c +++ /dev/null @@ -1,552 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Simple DTLS client demonstration program - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ - -#include "dtls_interface.h" -#include "mbedtls/net_sockets.h" -#include "mbedtls/ssl_internal.h" -#include "cmsis_os2.h" -#include "string.h" - -#define MBEDTLS_LOG LINK_LOG_DEBUG - -mbedtls_ssl_context *dtls_ssl_new(dtls_establish_info_s *info, char plat_type) -{ - int ret = -1; - mbedtls_ssl_context *ssl = NULL; - mbedtls_ssl_config *conf = NULL; - mbedtls_entropy_context *entropy = NULL; - mbedtls_ctr_drbg_context *ctr_drbg = NULL; - mbedtls_timing_delay_context *timer = NULL; -#if defined(MBEDTLS_X509_CRT_PARSE_C) - mbedtls_x509_crt *cacert; - mbedtls_x509_crt *client_ca = NULL; - mbedtls_pk_context *client_pk = NULL; -#endif - - const char *pers = "ssl_client"; - int transport; - ssl = mbedtls_calloc(1, sizeof(mbedtls_ssl_context)); - conf = mbedtls_calloc(1, sizeof(mbedtls_ssl_config)); - entropy = mbedtls_calloc(1, sizeof(mbedtls_entropy_context)); - ctr_drbg = mbedtls_calloc(1, sizeof(mbedtls_ctr_drbg_context)); -#if defined(MBEDTLS_X509_CRT_PARSE_C) - cacert = mbedtls_calloc(1, sizeof(mbedtls_x509_crt)); -#endif - - if (NULL == info || NULL == ssl - || NULL == conf || NULL == entropy - || NULL == ctr_drbg -#if defined(MBEDTLS_X509_CRT_PARSE_C) - || NULL == cacert -#endif - ) - { - goto exit_fail; - } - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if(NULL != info->v.c.client_ca) /// we'd better to make the client ca and key - { - client_ca = mbedtls_calloc(1, sizeof(mbedtls_x509_crt)); - client_pk = mbedtls_calloc(1, sizeof(mbedtls_pk_context)); - if((NULL == client_ca) || (NULL == client_pk)) - { - goto exit_fail; - } - mbedtls_x509_crt_init(client_ca); - mbedtls_pk_init(client_pk); - } -#endif - - if (info->udp_or_tcp == MBEDTLS_NET_PROTO_UDP) - { - transport = MBEDTLS_SSL_TRANSPORT_DATAGRAM; - timer = mbedtls_calloc(1, sizeof(mbedtls_timing_delay_context)); - if (NULL == timer) - goto exit_fail; - } - else - { - transport = MBEDTLS_SSL_TRANSPORT_STREAM; - } - - mbedtls_ssl_init(ssl); - mbedtls_ssl_config_init(conf); - mbedtls_ctr_drbg_init(ctr_drbg); - mbedtls_entropy_init(entropy); - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if (info->psk_or_cert == VERIFY_WITH_CERT) - { - mbedtls_x509_crt_init(cacert); - } -#endif - - if ((ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func, entropy, - (const unsigned char *) pers, - strlen(pers))) != 0) - { - MBEDTLS_LOG("mbedtls_ctr_drbg_seed failed: -0x%x", -ret); - goto exit_fail; - } - - MBEDTLS_LOG("setting up the SSL structure"); - - (void) mbedtls_ssl_config_defaults(conf,plat_type,transport,MBEDTLS_SSL_PRESET_DEFAULT); - - mbedtls_ssl_conf_authmode(conf, MBEDTLS_SSL_VERIFY_REQUIRED); - mbedtls_ssl_conf_rng(conf, mbedtls_ctr_drbg_random, ctr_drbg); - - if (info->udp_or_tcp == MBEDTLS_NET_PROTO_TCP) - { - mbedtls_ssl_conf_read_timeout(conf, TLS_SHAKEHAND_TIMEOUT); - } - -#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) - if (info->psk_or_cert == VERIFY_WITH_PSK) - { - if ((ret = mbedtls_ssl_conf_psk(conf, - info->v.p.psk, - info->v.p.psk_len, - info->v.p.psk_identity, - strlen((const char *)info->v.p.psk_identity))) != 0) - { - MBEDTLS_LOG("mbedtls_ssl_conf_psk failed: -0x%x", -ret); - goto exit_fail; - } - } -#endif - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if (info->psk_or_cert == VERIFY_WITH_CERT) - { - ret = mbedtls_x509_crt_parse(cacert, info->v.c.ca_cert, info->v.c.cert_len); - if(ret < 0) - { - MBEDTLS_LOG("mbedtls_x509_crt_parse failed -0x%x", -ret); - goto exit_fail; - } - mbedtls_ssl_conf_authmode(conf, MBEDTLS_SSL_VERIFY_REQUIRED); - mbedtls_ssl_conf_ca_chain(conf, cacert, NULL); - - if(NULL != info->v.c.client_ca) ///< setup the client key and ca - { - ret = mbedtls_x509_crt_parse(client_ca,info->v.c.client_ca,info->v.c.client_ca_len); - if(ret <0) - { - goto exit_fail; - } - - ret = mbedtls_pk_parse_key(client_pk,info->v.c.client_pk,info->v.c.client_pk_len,\ - info->v.c.client_pk_pwd,info->v.c.client_pk_pwd_len); - if(ret < 0) - { - goto exit_fail; - } - - ret = mbedtls_ssl_conf_own_cert( conf, client_ca, client_pk ); - if(ret != 0) - { - goto exit_fail; - } - } - } -#endif - - mbedtls_ssl_conf_authmode(conf, MBEDTLS_SSL_VERIFY_REQUIRED); //TODO--test for no check the ca_rt--only for the debug - - if ((ret = mbedtls_ssl_setup(ssl, conf)) != 0) - { - MBEDTLS_LOG("mbedtls_ssl_setup failed: -0x%x", -ret); - goto exit_fail; - } - - if (info->udp_or_tcp == MBEDTLS_NET_PROTO_UDP) - { - mbedtls_ssl_set_timer_cb(ssl, timer, mbedtls_timing_set_delay, - mbedtls_timing_get_delay); - } - - MBEDTLS_LOG("set SSL structure succeed"); - - return ssl; - -exit_fail: - - if (conf) - { - mbedtls_ssl_config_free(conf); - mbedtls_free(conf); - } - - if (ctr_drbg) - { - mbedtls_ctr_drbg_free(ctr_drbg); - mbedtls_free(ctr_drbg); - } - - if (entropy) - { - mbedtls_entropy_free(entropy); - mbedtls_free(entropy); - } - - if (timer) - { - mbedtls_free(timer); - } - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if (cacert) - { - mbedtls_x509_crt_free(cacert); - mbedtls_free(cacert); - } - - if(client_ca) - { - mbedtls_x509_crt_free(client_ca); - mbedtls_free(client_ca); - } - - if(client_pk) - { - mbedtls_pk_free(client_pk); - mbedtls_free(client_pk); - } -#endif - - if (ssl) - { - mbedtls_ssl_free(ssl); - mbedtls_free(ssl); - } - return NULL; -} - -static inline uint32_t dtls_gettime(void) -{ - return ((uint32_t)osKernelGetTickCount() * (1000 / 100) ); -} - -int dtls_shakehand(mbedtls_ssl_context *ssl, const dtls_shakehand_info_s *info) -{ - int ret = MBEDTLS_ERR_NET_CONNECT_FAILED; - uint32_t change_value = 0; - mbedtls_net_context *server_fd = NULL; - uint32_t max_value; -#if defined(MBEDTLS_X509_CRT_PARSE_C) - unsigned int flags; -#endif - - MBEDTLS_LOG("connecting to server"); - - server_fd = (mbedtls_net_context *)malloc(sizeof(mbedtls_net_context)); - if (server_fd == NULL) - { - MBEDTLS_LOG("connect failed! mode %d", info->client_or_server); - ret = MBEDTLS_ERR_NET_CONNECT_FAILED; - goto exit_fail; - } - - if (MBEDTLS_SSL_IS_CLIENT == info->client_or_server) - { - ret = mbedtls_net_connect(server_fd, info->u.c.host, info->u.c.port, info->udp_or_tcp); - if( 0 != ret) - { - ret = MBEDTLS_ERR_NET_CONNECT_FAILED; - goto exit_fail; - } - } - else - { - //server_fd = (mbedtls_net_context*)atiny_net_bind(NULL, info->u.s.local_port, MBEDTLS_NET_PROTO_UDP); - ///< --TODO ,not implement yet - } - - mbedtls_ssl_set_bio(ssl, server_fd, - mbedtls_net_send, mbedtls_net_recv, mbedtls_net_recv_timeout); - - MBEDTLS_LOG("performing the SSL/TLS handshake"); - - max_value = ((MBEDTLS_SSL_IS_SERVER == info->client_or_server || info->udp_or_tcp == MBEDTLS_NET_PROTO_UDP) ? - (dtls_gettime() + info->timeout) : 50); - - do - { - ret = mbedtls_ssl_handshake(ssl); - - if (MBEDTLS_SSL_IS_CLIENT == info->client_or_server && info->udp_or_tcp == MBEDTLS_NET_PROTO_TCP) - { - change_value++; - } - else - { - change_value = dtls_gettime(); - } - - if (info->step_notify) - { - info->step_notify(info->param); - } - } - while ((ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE || - (ret == MBEDTLS_ERR_SSL_TIMEOUT && - info->udp_or_tcp == MBEDTLS_NET_PROTO_TCP)) && - (change_value < max_value)); - - if (info->finish_notify) - { - info->finish_notify(info->param); - } - - if (ret != 0) - { - MBEDTLS_LOG("mbedtls_ssl_handshake failed: -0x%x", -ret); - goto exit_fail; - } - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if (info->psk_or_cert == VERIFY_WITH_CERT) - { - if((flags = mbedtls_ssl_get_verify_result(ssl)) != 0) - { - char vrfy_buf[512]; - (void) mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), " ! ", flags); - MBEDTLS_LOG("cert verify failed: %s", vrfy_buf); - goto exit_fail; - } - else - MBEDTLS_LOG("cert verify succeed"); - } -#endif - - MBEDTLS_LOG("handshake succeed"); - - return 0; - -exit_fail: - - if (server_fd) - { - mbedtls_net_free(server_fd); - ssl->p_bio = NULL; - } - - return ret; - -} -void dtls_ssl_destroy(mbedtls_ssl_context *ssl) -{ - int ret; - mbedtls_ssl_config *conf = NULL; - mbedtls_ctr_drbg_context *ctr_drbg = NULL; - mbedtls_entropy_context *entropy = NULL; - mbedtls_net_context *server_fd = NULL; - mbedtls_timing_delay_context *timer = NULL; -#if defined(MBEDTLS_X509_CRT_PARSE_C) - mbedtls_x509_crt *cacert = NULL; - mbedtls_x509_crt *client_ca = NULL; - mbedtls_pk_context *client_pk = NULL; - mbedtls_ssl_key_cert *key_cert = NULL; -#endif - - if (ssl == NULL) - { - return; - } - - conf = (mbedtls_ssl_config *)ssl->conf; - server_fd = (mbedtls_net_context *)ssl->p_bio; - timer = (mbedtls_timing_delay_context *)ssl->p_timer; - - - do ret = mbedtls_ssl_close_notify( ssl ); - while( ret == MBEDTLS_ERR_SSL_WANT_WRITE ); - - - if (NULL != conf) - { - ctr_drbg = conf->p_rng; - - if (NULL !=ctr_drbg) - { - entropy = ctr_drbg->p_entropy; - } - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - cacert = (mbedtls_x509_crt *)conf->ca_chain; - - key_cert = conf->key_cert; - if(NULL != key_cert) - { - client_ca = (mbedtls_x509_crt *) key_cert->cert; - client_pk = key_cert->key; - } - -#endif - } - - if (NULL != server_fd) - { - mbedtls_net_free(server_fd); - } - - if (NULL != conf) - { - mbedtls_ssl_config_free(conf); - mbedtls_free(conf); - ssl->conf = NULL; // need by mbedtls_debug_print_msg(), see mbedtls_ssl_free(ssl) - } - - if (ctr_drbg) - { - mbedtls_ctr_drbg_free(ctr_drbg); - mbedtls_free(ctr_drbg); - } - - if (entropy) - { - mbedtls_entropy_free(entropy); - mbedtls_free(entropy); - } - - if (timer) - { - mbedtls_free(timer); - } - -#if defined(MBEDTLS_X509_CRT_PARSE_C) - if (cacert) - { - mbedtls_x509_crt_free(cacert); - mbedtls_free(cacert); - } - if( client_ca ) - { - mbedtls_x509_crt_free(client_ca); - mbedtls_free(client_ca); - } - - if( client_pk ) - { - mbedtls_pk_free(client_pk); - mbedtls_free(client_pk); - } - -#endif - - mbedtls_ssl_free(ssl); - mbedtls_free(ssl); -} - -int dtls_write(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len) -{ - - int ret; - - ret = mbedtls_ssl_write(ssl, (unsigned char *) buf, len); - - if ((ret == MBEDTLS_ERR_SSL_WANT_WRITE) ||(ret == MBEDTLS_ERR_SSL_TIMEOUT)) - { - ret = -1; - } - else if (ret <= 0) - { - ret = 0; - } - - return ret; -} - - -///< make it return as normal socket return -int dtls_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len, uint32_t timeout) -{ - int ret; - - - mbedtls_ssl_conf_read_timeout((mbedtls_ssl_config *)ssl->conf, timeout); - - ret = mbedtls_ssl_read(ssl, buf, len); - - if ((ret == MBEDTLS_ERR_SSL_WANT_READ) ||(ret == MBEDTLS_ERR_SSL_TIMEOUT)) - { - ret = -1; - } - else if (ret <= 0) - { - ret = 0; - } - - return ret; -} - - - -int dtls_accept( mbedtls_net_context *bind_ctx, - mbedtls_net_context *client_ctx, - void *client_ip, size_t buf_size, size_t *ip_len ) -{ - return mbedtls_net_accept(bind_ctx, client_ctx, client_ip, buf_size, ip_len); -} - -void dtls_init(void) -{ - (void)mbedtls_platform_set_calloc_free(calloc, free); - (void)mbedtls_platform_set_snprintf(snprintf); - (void)mbedtls_platform_set_printf(printf); -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.h deleted file mode 100644 index 01210dd3f3cf3f87a4b3e451890618a3e7bbc6c5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.h +++ /dev/null @@ -1,169 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Simple DTLS client demonstration program - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -#ifndef DTLS_INTERFACE_H -#define DTLS_INTERFACE_H - - -#include - - -#if !defined(MBEDTLS_CONFIG_FILE) -#include "los_mbedtls_config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#define mbedtls_printf LINK_LOG_DEBUG -#endif - -#include "mbedtls/net_sockets.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/error.h" -#include "mbedtls/timing.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef TLS_SHAKEHAND_TIMEOUT -#define TLS_SHAKEHAND_TIMEOUT 1000 -#endif - -typedef enum -{ - VERIFY_WITH_PSK = 0, - VERIFY_WITH_CERT, -}verify_type_e; - -typedef struct -{ - union - { - struct - { - const char *host; - const char *port; - }c; - struct - { - const char *local_port; - }s; - }u; - uint32_t timeout; - int client_or_server; - int udp_or_tcp; - verify_type_e psk_or_cert; - void (*step_notify)(void *param); - void (*finish_notify)(void *param); - void *param; -}dtls_shakehand_info_s; - -typedef struct -{ - union - { - struct - { - const unsigned char *psk; - uint32_t psk_len; - const unsigned char *psk_identity; - }p; - struct - { - const unsigned char *ca_cert; - uint32_t cert_len; - - const unsigned char *client_ca; - uint32_t client_ca_len; - - const unsigned char *client_pk; - uint32_t client_pk_len; - - const unsigned char *client_pk_pwd; - uint32_t client_pk_pwd_len; - - }c; - }v; - verify_type_e psk_or_cert; - int udp_or_tcp; -}dtls_establish_info_s; - -void dtls_init(void); - -mbedtls_ssl_context *dtls_ssl_new(dtls_establish_info_s *info, char plat_type); - -int dtls_shakehand(mbedtls_ssl_context *ssl, const dtls_shakehand_info_s *info); - -void dtls_ssl_destroy(mbedtls_ssl_context* ssl); - -int dtls_write(mbedtls_ssl_context* ssl, const unsigned char* buf, size_t len); - -int dtls_read(mbedtls_ssl_context* ssl, unsigned char* buf, size_t len, uint32_t timeout); - -int dtls_accept( mbedtls_net_context *bind_ctx, - mbedtls_net_context *client_ctx, - void *client_ip, size_t buf_size, size_t *ip_len ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config.h deleted file mode 100644 index a7c58a35ec92c8c752f7c299b8188b4887a1a499..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config.h +++ /dev/null @@ -1,159 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * Distinguishing features: - * - no bignum, no PK, no X509 - * - fully modern and secure (provided the pre-shared keys have high entropy) - * - very low record overhead with CCM-8 - * - optimized for low RAM usage - * - * See README.txt for usage instructions. - */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -/* System support */ -//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ -/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ - -/* mbed TLS feature support */ -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_SSL_PROTO_TLS1_2 -#define MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY - -/* mbed TLS modules */ -#define MBEDTLS_AES_C -#define MBEDTLS_CCM_C -#define MBEDTLS_CIPHER_C -#define MBEDTLS_CTR_DRBG_C -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_MD_C -//#define MBEDTLS_NET_C -#define MBEDTLS_SHA256_C -#define MBEDTLS_SSL_CLI_C -#define MBEDTLS_SSL_SRV_C -#define MBEDTLS_SSL_TLS_C -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_DEBUG_C -#endif - -#ifdef USE_MRVL_SDIO_WIFI -#define MBEDTLS_ARC4_C -#define MBEDTLS_MD5_C -#define MBEDTLS_SHA1_C -#endif - -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_ENTROPY_HARDWARE_ALT -#define MBEDTLS_NO_PLATFORM_ENTROPY -#define MBEDTLS_PLATFORM_PRINTF_ALT -#define MBEDTLS_PLATFORM_SNPRINTF_ALT - -#define MBEDTLS_PLATFORM_MEMORY -//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ - -/* Save RAM at the expense of ROM */ -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_AES_ROM_TABLES -#endif - -/* Save some RAM by adjusting to your exact needs */ -#define MBEDTLS_PSK_MAX_LEN 32 /* 128-bits keys are generally enough */ - -/* - * You should adjust this to the exact number of sources you're using: default - * is the "platform_entropy_poll" source, but you may want to add other ones - * Minimum is 2 for the entropy test suite. - */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 - -/* - * Save RAM at the expense of interoperability: do this only if you control - * both ends of the connection! (See comments in "mbedtls/ssl.h".) - * The optimal size here depends on the typical size of records. - */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 5000 -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES -#define MBEDTLS_SSL_RENEGOTIATION -#define MBEDTLS_SSL_CACHE_C -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#if 0 // We should support two encryption algorithm -#define MBEDTLS_CCM_C -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 -#define MBEDTLS_WITH_ONLY_AEAD_CHIPERS -#define MBEDTLS_ONLY_CCM_8_CHIPERS -#else -#define MBEDTLS_CIPHER_MODE_CBC -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 -#endif - -#if defined(CONFIG_FEATURE_FOTA) || defined(WITH_SOTA) -#define MBEDTLS_RSA_C -#define MBEDTLS_BIGNUM_C -#define MBEDTLS_OID_C -#define MBEDTLS_PKCS1_V21 -#define MBEDTLS_ASN1_PARSE_C -#endif - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_cert.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_cert.h deleted file mode 100644 index 6c2a94e4d654d5eeaad2ca7b6ba939b8c4dc5a1f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_cert.h +++ /dev/null @@ -1,250 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * Distinguishing features: - * - no bignum, no PK, no X509 - * - fully modern and secure (provided the pre-shared keys have high entropy) - * - very low record overhead with CCM-8 - * - optimized for low RAM usage - * - * See README.txt for usage instructions. - */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -/* System support */ -//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ -/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ - -/* mbed TLS feature support */ -//#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_SSL_PROTO_TLS1_2 -//#define MBEDTLS_SSL_PROTO_DTLS -//#define MBEDTLS_SSL_DTLS_HELLO_VERIFY - -/* mbed TLS modules */ -#define MBEDTLS_AES_C -//#define MBEDTLS_CCM_C -#define MBEDTLS_CIPHER_C -#define MBEDTLS_CTR_DRBG_C -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_MD_C -//#define MBEDTLS_NET_C -#define MBEDTLS_SHA256_C -#define MBEDTLS_SSL_CLI_C -//#define MBEDTLS_SSL_SRV_C -#define MBEDTLS_SSL_TLS_C -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_DEBUG_C -#endif - -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_ENTROPY_HARDWARE_ALT -#define MBEDTLS_NO_PLATFORM_ENTROPY -#define MBEDTLS_PLATFORM_PRINTF_ALT -#define MBEDTLS_PLATFORM_SNPRINTF_ALT - -#define MBEDTLS_PLATFORM_MEMORY -//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ - -/* Save RAM at the expense of ROM */ -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_AES_ROM_TABLES -#endif - -/* Save some RAM by adjusting to your exact needs */ -#define MBEDTLS_PSK_MAX_LEN 32 /* 128-bits keys are generally enough */ - -/* - * You should adjust this to the exact number of sources you're using: default - * is the "platform_entropy_poll" source, but you may want to add other ones - * Minimum is 2 for the entropy test suite. - */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 - -/* - * Save RAM at the expense of interoperability: do this only if you control - * both ends of the connection! (See comments in "mbedtls/ssl.h".) - * The optimal size here depends on the typical size of records. - */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 16000 -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH -//#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES -#define MBEDTLS_SSL_RENEGOTIATION -#define MBEDTLS_SSL_CACHE_C -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#if 0 // We should support two encryption algorithm -#define MBEDTLS_CCM_C -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 -#define MBEDTLS_WITH_ONLY_AEAD_CHIPERS -#define MBEDTLS_ONLY_CCM_8_CHIPERS -#else - -#define MBEDTLS_CIPHER_MODE_CBC -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 -#endif - - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -// #define MBEDTLS_HAVE_ASM -// #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED - -//#define MBEDTLS_CIPHER_MODE_CFB -//#define MBEDTLS_CIPHER_MODE_CTR -//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -#define MBEDTLS_CIPHER_PADDING_ZEROS -//#define MBEDTLS_ECDSA_DETERMINISTIC -//#define MBEDTLS_ECP_NIST_OPTIM -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -//#define MBEDTLS_ECP_DP_BP256R1_ENABLED -//#define MBEDTLS_ECP_DP_BP384R1_ENABLED -//#define MBEDTLS_ECP_DP_BP512R1_ENABLED -//#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -#define MBEDTLS_PK_PARSE_EC_EXTENDED -#define MBEDTLS_ERROR_STRERROR_DUMMY -//#define MBEDTLS_GENPRIME -#define MBEDTLS_PK_RSA_ALT_SUPPORT -#define MBEDTLS_PKCS1_V15 -#define MBEDTLS_PKCS1_V21 -//#define MBEDTLS_SELF_TEST -//#define MBEDTLS_SSL_ENCRYPT_THEN_MAC -#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET -#define MBEDTLS_SSL_FALLBACK_SCSV -//#define MBEDTLS_SSL_CBC_RECORD_SPLITTING -//#define MBEDTLS_SSL_PROTO_TLS1 -//#define MBEDTLS_SSL_PROTO_TLS1_1 -//#define MBEDTLS_SSL_ALPN -//#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT -#define MBEDTLS_SSL_SESSION_TICKETS -#define MBEDTLS_SSL_EXPORT_KEYS -// #define MBEDTLS_SSL_SERVER_NAME_INDICATION -//#define MBEDTLS_SSL_TRUNCATED_HMAC -#define MBEDTLS_VERSION_FEATURES -#define MBEDTLS_VERSION_C -// #define MBEDTLS_AESNI_C -//#define MBEDTLS_ARC4_C -#define MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_WRITE_C -#define MBEDTLS_BASE64_C -#define MBEDTLS_BIGNUM_C -//#define MBEDTLS_BLOWFISH_C -//#define MBEDTLS_CAMELLIA_C -#define MBEDTLS_CERTS_C -//#define MBEDTLS_DES_C -//#define MBEDTLS_DHM_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_ECP_C -#define MBEDTLS_ERROR_C -#define MBEDTLS_GCM_C -//#define MBEDTLS_HMAC_DRBG_C -//#define MBEDTLS_MD5_C -#define MBEDTLS_OID_C -// #define MBEDTLS_PADLOCK_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_PEM_WRITE_C -#define MBEDTLS_PK_C -#define MBEDTLS_PK_PARSE_C -#define MBEDTLS_PK_WRITE_C -#define MBEDTLS_PKCS5_C -#define MBEDTLS_PKCS12_C -//#define MBEDTLS_RIPEMD160_C -#define MBEDTLS_RSA_C -//#define MBEDTLS_SHA512_C -#define MBEDTLS_SSL_COOKIE_C -//#define MBEDTLS_SSL_TICKET_C - #define MBEDTLS_X509_CHECK_KEY_USAGE - #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - #define MBEDTLS_X509_RSASSA_PSS_SUPPORT - #define MBEDTLS_X509_USE_C - #define MBEDTLS_X509_CRT_PARSE_C - #define MBEDTLS_X509_CRL_PARSE_C - #define MBEDTLS_X509_CSR_PARSE_C - #define MBEDTLS_X509_CREATE_C - #define MBEDTLS_X509_CRT_WRITE_C - #define MBEDTLS_X509_CSR_WRITE_C -//#define MBEDTLS_XTEA_C -//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE -#define MBEDTLS_SHA1_C - - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_dtls.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_dtls.h deleted file mode 100644 index 444873c88e167c490ed8f348afe0acf6216aad02..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_dtls.h +++ /dev/null @@ -1,293 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * Distinguishing features: - * - no bignum, no PK, no X509 - * - fully modern and secure (provided the pre-shared keys have high entropy) - * - very low record overhead with CCM-8 - * - optimized for low RAM usage - * - * See README.txt for usage instructions. - */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -/* System support */ -//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ -/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ - -/* mbed TLS feature support */ -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_SSL_PROTO_TLS1_2 - -#ifdef CONFIG_DTLS_MBEDTLS_PSK -#define MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY -#endif - -/* mbed TLS modules */ -#define MBEDTLS_AES_C -#define MBEDTLS_CCM_C -#define MBEDTLS_CIPHER_C -#define MBEDTLS_CTR_DRBG_C -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_MD_C -//#define MBEDTLS_NET_C -#define MBEDTLS_SHA256_C -#define MBEDTLS_SSL_CLI_C - -#ifdef CONFIG_DTLS_MBEDTLS_PSK -#define MBEDTLS_SSL_SRV_C -#endif - -#define MBEDTLS_SSL_TLS_C -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_DEBUG_C -#endif - -#ifdef CONFIG_DTLS_MBEDTLS_PSK -#ifdef USE_MRVL_SDIO_WIFI -#define MBEDTLS_ARC4_C -#define MBEDTLS_MD5_C -#define MBEDTLS_SHA1_C -#endif -#endif - -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_ENTROPY_HARDWARE_ALT -#define MBEDTLS_NO_PLATFORM_ENTROPY -#define MBEDTLS_PLATFORM_PRINTF_ALT -#define MBEDTLS_PLATFORM_SNPRINTF_ALT - -#define MBEDTLS_PLATFORM_MEMORY -//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ - -/* Save RAM at the expense of ROM */ -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_AES_ROM_TABLES -#endif - -/* Save some RAM by adjusting to your exact needs */ -#define MBEDTLS_PSK_MAX_LEN 32 /* 128-bits keys are generally enough */ - -/* - * You should adjust this to the exact number of sources you're using: default - * is the "platform_entropy_poll" source, but you may want to add other ones - * Minimum is 2 for the entropy test suite. - */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 - -/* - * Save RAM at the expense of interoperability: do this only if you control - * both ends of the connection! (See comments in "mbedtls/ssl.h".) - * The optimal size here depends on the typical size of records. - */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 5000 -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH - -#ifdef CONFIG_DTLS_MBEDTLS_PSK -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#endif - -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES -#define MBEDTLS_SSL_RENEGOTIATION -#define MBEDTLS_SSL_CACHE_C -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#if 0 // We should support two encryption algorithm -#define MBEDTLS_CCM_C -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 -#define MBEDTLS_WITH_ONLY_AEAD_CHIPERS -#define MBEDTLS_ONLY_CCM_8_CHIPERS -#else -#define MBEDTLS_CIPHER_MODE_CBC -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256,MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256,MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 -#endif - -#ifdef CONFIG_DTLS_MBEDTLS_CERT -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -// #define MBEDTLS_HAVE_ASM - #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED - #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED - -#define MBEDTLS_CIPHER_MODE_CFB -#define MBEDTLS_CIPHER_MODE_CTR -#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -#define MBEDTLS_CIPHER_PADDING_ZEROS -#define MBEDTLS_ECDSA_DETERMINISTIC -#define MBEDTLS_ECP_NIST_OPTIM -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -#define MBEDTLS_ECP_DP_BP256R1_ENABLED -#define MBEDTLS_ECP_DP_BP384R1_ENABLED -#define MBEDTLS_ECP_DP_BP512R1_ENABLED -#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -#define MBEDTLS_PK_PARSE_EC_EXTENDED -#define MBEDTLS_ERROR_STRERROR_DUMMY -#define MBEDTLS_GENPRIME -#define MBEDTLS_PK_RSA_ALT_SUPPORT -#define MBEDTLS_PKCS1_V15 -#define MBEDTLS_PKCS1_V21 -#define MBEDTLS_SELF_TEST -#define MBEDTLS_SSL_ENCRYPT_THEN_MAC -#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET -#define MBEDTLS_SSL_FALLBACK_SCSV -#define MBEDTLS_SSL_CBC_RECORD_SPLITTING -#define MBEDTLS_SSL_PROTO_TLS1 -#define MBEDTLS_SSL_PROTO_TLS1_1 -#define MBEDTLS_SSL_ALPN -//#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT -#define MBEDTLS_SSL_SESSION_TICKETS -#define MBEDTLS_SSL_EXPORT_KEYS -// #define MBEDTLS_SSL_SERVER_NAME_INDICATION -#define MBEDTLS_SSL_TRUNCATED_HMAC -#define MBEDTLS_VERSION_FEATURES -#define MBEDTLS_VERSION_C -// #define MBEDTLS_AESNI_C -#define MBEDTLS_ARC4_C -#define MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_WRITE_C -#define MBEDTLS_BASE64_C -#define MBEDTLS_BIGNUM_C -#define MBEDTLS_BLOWFISH_C -#define MBEDTLS_CAMELLIA_C -#define MBEDTLS_CERTS_C -#define MBEDTLS_DES_C -#define MBEDTLS_DHM_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_ECP_C -#define MBEDTLS_ERROR_C -#define MBEDTLS_GCM_C -#define MBEDTLS_HMAC_DRBG_C -#define MBEDTLS_MD5_C -#define MBEDTLS_OID_C -// #define MBEDTLS_PADLOCK_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_PEM_WRITE_C -#define MBEDTLS_PK_C -#define MBEDTLS_PK_PARSE_C -#define MBEDTLS_PK_WRITE_C -#define MBEDTLS_PKCS5_C -#define MBEDTLS_PKCS12_C -#define MBEDTLS_RIPEMD160_C -#define MBEDTLS_RSA_C -#define MBEDTLS_SHA512_C -#define MBEDTLS_SSL_COOKIE_C -#define MBEDTLS_SSL_TICKET_C - #define MBEDTLS_X509_CHECK_KEY_USAGE - #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - #define MBEDTLS_X509_RSASSA_PSS_SUPPORT - #define MBEDTLS_X509_USE_C - #define MBEDTLS_X509_CRT_PARSE_C - #define MBEDTLS_X509_CRL_PARSE_C - #define MBEDTLS_X509_CSR_PARSE_C - #define MBEDTLS_X509_CREATE_C - #define MBEDTLS_X509_CRT_WRITE_C - #define MBEDTLS_X509_CSR_WRITE_C -#define MBEDTLS_XTEA_C -#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE -#define MBEDTLS_SHA1_C -#endif - - -#ifdef CONFIG_DTLS_MBEDTLS_PSK -#if defined(CONFIG_FEATURE_FOTA) || defined(WITH_SOTA) -#ifndef MBEDTLS_RSA_C -#define MBEDTLS_RSA_C -#endif - -#ifndef MBEDTLS_BIGNUM_C -#define MBEDTLS_BIGNUM_C -#endif - -#ifndef MBEDTLS_OID_C -#define MBEDTLS_OID_C -#endif - -#ifndef MBEDTLS_PKCS1_V21 -#define MBEDTLS_PKCS1_V21 -#endif - -#ifndef MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_PARSE_C -#endif -#endif -#endif - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_psk.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_psk.h deleted file mode 100644 index 102e62c2427028950517c7900d56961751a74081..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/los_mbedtls_config_psk.h +++ /dev/null @@ -1,246 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -/* - * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites - * Distinguishing features: - * - no bignum, no PK, no X509 - * - fully modern and secure (provided the pre-shared keys have high entropy) - * - very low record overhead with CCM-8 - * - optimized for low RAM usage - * - * See README.txt for usage instructions. - */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -/* System support */ -//#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ -/* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ - -/* mbed TLS feature support */ -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_SSL_PROTO_TLS1_2 -#define MBEDTLS_SSL_PROTO_DTLS -#define MBEDTLS_SSL_DTLS_HELLO_VERIFY - -/* mbed TLS modules */ -#define MBEDTLS_AES_C -#define MBEDTLS_CCM_C -#define MBEDTLS_CIPHER_C -#define MBEDTLS_CTR_DRBG_C -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_MD_C -//#define MBEDTLS_NET_C -#define MBEDTLS_SHA256_C -#define MBEDTLS_SSL_CLI_C -//#define MBEDTLS_SSL_SRV_C -#define MBEDTLS_SSL_TLS_C -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_DEBUG_C -#endif - -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_ENTROPY_HARDWARE_ALT -#define MBEDTLS_NO_PLATFORM_ENTROPY -#define MBEDTLS_PLATFORM_PRINTF_ALT -#define MBEDTLS_PLATFORM_SNPRINTF_ALT - -#define MBEDTLS_PLATFORM_MEMORY -//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ - -/* Save RAM at the expense of ROM */ -#if !defined ( __GNUC__ ) /* GCC*/ -#define MBEDTLS_AES_ROM_TABLES -#endif - -/* Save some RAM by adjusting to your exact needs */ -#define MBEDTLS_PSK_MAX_LEN 32 /* 128-bits keys are generally enough */ - -/* - * You should adjust this to the exact number of sources you're using: default - * is the "platform_entropy_poll" source, but you may want to add other ones - * Minimum is 2 for the entropy test suite. - */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 - -/* - * Save RAM at the expense of interoperability: do this only if you control - * both ends of the connection! (See comments in "mbedtls/ssl.h".) - * The optimal size here depends on the typical size of records. - */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 5000 -#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH -#define MBEDTLS_SSL_DTLS_ANTI_REPLAY -#define MBEDTLS_SSL_ALL_ALERT_MESSAGES -#define MBEDTLS_SSL_RENEGOTIATION -#define MBEDTLS_SSL_CACHE_C -#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -#if 0 // We should support two encryption algorithm -#define MBEDTLS_CCM_C -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 -#define MBEDTLS_WITH_ONLY_AEAD_CHIPERS -#define MBEDTLS_ONLY_CCM_8_CHIPERS -#else -#define MBEDTLS_CIPHER_MODE_CBC -#define MBEDTLS_SSL_CIPHERSUITES \ - MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256,MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA,MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA -#endif - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -// #define MBEDTLS_HAVE_ASM -// #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED -#define MBEDTLS_CIPHER_MODE_CFB -#define MBEDTLS_CIPHER_MODE_CTR -#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -#define MBEDTLS_CIPHER_PADDING_ZEROS -#define MBEDTLS_ECDSA_DETERMINISTIC -#define MBEDTLS_ECP_NIST_OPTIM -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -#define MBEDTLS_ECP_DP_BP256R1_ENABLED -#define MBEDTLS_ECP_DP_BP384R1_ENABLED -#define MBEDTLS_ECP_DP_BP512R1_ENABLED -#define MBEDTLS_ECP_DP_CURVE25519_ENABLED -#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -// #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -#define MBEDTLS_PK_PARSE_EC_EXTENDED -#define MBEDTLS_ERROR_STRERROR_DUMMY -#define MBEDTLS_GENPRIME -#define MBEDTLS_PK_RSA_ALT_SUPPORT -#define MBEDTLS_PKCS1_V15 -#define MBEDTLS_PKCS1_V21 -#define MBEDTLS_SELF_TEST -#define MBEDTLS_SSL_ENCRYPT_THEN_MAC -#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET -#define MBEDTLS_SSL_FALLBACK_SCSV -#define MBEDTLS_SSL_CBC_RECORD_SPLITTING -#define MBEDTLS_SSL_PROTO_TLS1 -#define MBEDTLS_SSL_PROTO_TLS1_1 -#define MBEDTLS_SSL_ALPN -#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT -#define MBEDTLS_SSL_SESSION_TICKETS -#define MBEDTLS_SSL_EXPORT_KEYS -// #define MBEDTLS_SSL_SERVER_NAME_INDICATION -#define MBEDTLS_SSL_TRUNCATED_HMAC -#define MBEDTLS_VERSION_FEATURES -#define MBEDTLS_VERSION_C -// #define MBEDTLS_AESNI_C -#define MBEDTLS_ARC4_C -#define MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_WRITE_C -#define MBEDTLS_BASE64_C -#define MBEDTLS_BIGNUM_C -#define MBEDTLS_BLOWFISH_C -#define MBEDTLS_CAMELLIA_C -#define MBEDTLS_CERTS_C -#define MBEDTLS_DES_C -#define MBEDTLS_DHM_C -#define MBEDTLS_ECDH_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_ECP_C -#define MBEDTLS_ERROR_C -#define MBEDTLS_GCM_C -#define MBEDTLS_HMAC_DRBG_C -#define MBEDTLS_MD5_C -#define MBEDTLS_OID_C -// #define MBEDTLS_PADLOCK_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_PEM_WRITE_C -#define MBEDTLS_PK_C -#define MBEDTLS_PK_PARSE_C -#define MBEDTLS_PK_WRITE_C -#define MBEDTLS_PKCS5_C -#define MBEDTLS_PKCS12_C -#define MBEDTLS_RIPEMD160_C -#define MBEDTLS_RSA_C -#define MBEDTLS_SHA512_C -#define MBEDTLS_SSL_COOKIE_C -#define MBEDTLS_SSL_TICKET_C -// #define MBEDTLS_X509_CHECK_KEY_USAGE -// #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE -// #define MBEDTLS_X509_RSASSA_PSS_SUPPORT -// #define MBEDTLS_X509_USE_C -// #define MBEDTLS_X509_CRT_PARSE_C -// #define MBEDTLS_X509_CRL_PARSE_C -// #define MBEDTLS_X509_CSR_PARSE_C -// #define MBEDTLS_X509_CREATE_C -// #define MBEDTLS_X509_CRT_WRITE_C -// #define MBEDTLS_X509_CSR_WRITE_C -#define MBEDTLS_XTEA_C -#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE -#define MBEDTLS_SHA1_C - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/mbed_port.c b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/mbed_port.c deleted file mode 100644 index 890375e1065d1c50e7a55ac372827a2ce4a05b00..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/mbed_port.c +++ /dev/null @@ -1,209 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ -/** - * DATE AUTHOR INSTRUCTION - * 2020-02-18 09:00 zhangqianfu The first version - * - */ - -#include -#include -#include -#include "mbedtls/platform.h" - -#if defined(MBEDTLS_DEBUG_C) -static void mbed_port_debug( void *ctx, int level, - const char *file, int line, - const char *str ) -{ - const char *p, *basename; - - /* Extract basename from file */ - for( p = basename = file; *p != '\0'; p++ ) - if( *p == '/' || *p == '\\' ) - basename = p + 1; - - printf("%s:%04d: |%d| %s", basename, line, level, str ); -} -#endif - -en_dtls_al_err_t mbed_new(dtls_al_para_t *para, void **handle) -{ - - en_dtls_al_err_t ret = EN_DTLS_AL_ERR_PARA; - mbedtls_ssl_context *ssl; - dtls_establish_info_s einfo; - char plat_type; - - if(para->security.type == EN_DTLS_AL_SECURITY_TYPE_CERT) - { - einfo.psk_or_cert = VERIFY_WITH_CERT; - - einfo.v.c.ca_cert = para->security.u.cert.server_ca; - einfo.v.c.cert_len = para->security.u.cert.server_ca_len; - einfo.v.c.client_ca = para->security.u.cert.client_ca; - einfo.v.c.client_ca_len = para->security.u.cert.client_ca_len; - einfo.v.c.client_pk = para->security.u.cert.client_pk; - einfo.v.c.client_pk_len = para->security.u.cert.client_pk_len; - einfo.v.c.client_pk_pwd = para->security.u.cert.client_pk_pwd; - einfo.v.c.client_pk_pwd_len = para->security.u.cert.client_pk_pwd_len; - } - else - { - einfo.psk_or_cert = VERIFY_WITH_PSK; - einfo.v.p.psk = para->security.u.psk.psk_key; - einfo.v.p.psk_len = para->security.u.psk.psk_key_len; - einfo.v.p.psk_identity = para->security.u.psk.psk_id; - } - - if(para->istcp) - { - einfo.udp_or_tcp = MBEDTLS_NET_PROTO_TCP; - } - else - { - einfo.udp_or_tcp = MBEDTLS_NET_PROTO_UDP; - } - - - if(para->isclient) - { - plat_type = MBEDTLS_SSL_IS_CLIENT; - } - else - { - plat_type = MBEDTLS_SSL_IS_SERVER; - } - - ssl = dtls_ssl_new(&einfo, plat_type); - - if(NULL != ssl) - { - *handle = ssl; - ret = EN_DTLS_AL_ERR_OK; - - #if defined(MBEDTLS_DEBUG_C) - mbedtls_debug_set_threshold(10); - mbedtls_ssl_conf_dbg (ssl->conf,mbed_port_debug,NULL); - #endif - } - - return ret; -} - - -en_dtls_al_err_t mbed_destroy(void *handle) -{ - en_dtls_al_err_t ret = EN_DTLS_AL_ERR_PARA; - if(NULL != handle) - { - dtls_ssl_destroy(handle); - ret = EN_DTLS_AL_ERR_OK; - } - return ret; -} - - -///< make it return as normal socket return - -int mbed_write(void *handle, uint8_t *buf, size_t len,int timeout) -{ - - int ret; - - ret = dtls_write(handle, buf,len); - - return ret; -} - - -int mbed_read( void *handle, unsigned char *buf, size_t len, int timeout) -{ - int ret; - - ret = dtls_read(handle, buf,len,timeout); - - return ret; -} - -int dtls_shakehand(mbedtls_ssl_context *ssl, const dtls_shakehand_info_s *info); - - -int mbed_connect(void *handle,const char *server_ip, const char *server_port,int timeout) -{ - int ret = -1; - dtls_shakehand_info_s sinfo; - - - (void) memset(&sinfo, 0, sizeof(sinfo)); - - - sinfo.u.c.host = server_ip; - sinfo.u.c.port = server_port; - - sinfo.client_or_server = MBEDTLS_SSL_IS_CLIENT; - sinfo.udp_or_tcp = MBEDTLS_NET_PROTO_TCP; - sinfo.timeout = timeout; - - ret = dtls_shakehand( handle,&sinfo); - - return ret; -} - -static const dtls_al_t s_mbedtls_io = -{ - .name = "mbed", - .io = { - .io_new = mbed_new, - .io_connect = mbed_connect, - .io_read = mbed_read, - .io_write = mbed_write, - .io_destroy = mbed_destroy, - }, -}; - - - -int dtls_imp_init(void) -{ - int ret =-1; - - (void)mbedtls_platform_set_calloc_free(calloc, free); - // (void)mbedtls_platform_set_snprintf(snprintf); - // (void)mbedtls_platform_set_printf(printf); - ret = dtls_al_install(&s_mbedtls_io); - - return ret; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.c b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.c deleted file mode 100644 index 4162d97f39def4e0e02850be8cc5c84a0fe51d00..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.c +++ /dev/null @@ -1,101 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2016-2018>, - * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulations, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulations. - *---------------------------------------------------------------------------*/ - -#if !defined(MBEDTLS_CONFIG_FILE) -#include "mbedtls/config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - - -#include "cmsis_os2.h" -#include - -unsigned long mbedtls_timing_get_timer(struct mbedtls_timing_hr_time *val, int reset) -{ - struct mbedtls_timing_hr_time now; - now.timer_ms = osKernelGetTickCount() * (1000 / 1000);; - - if (reset) - { - val->timer_ms = now.timer_ms; - } - - return (unsigned long)(now.timer_ms - val->timer_ms); -} - -/* - * Set delays to watch - */ -void mbedtls_timing_set_delay(void *data, uint32_t int_ms, uint32_t fin_ms) -{ - mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data; - - ctx->int_ms = int_ms; - ctx->fin_ms = fin_ms; - - if (fin_ms != 0) - { - (void)mbedtls_timing_get_timer(&ctx->timer, 1); - } -} - -/* - * Get number of delays expired - */ -int mbedtls_timing_get_delay(void *data) -{ - mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *)data; - unsigned long elapsed_ms; - - if (ctx->fin_ms == 0) - { - return -1; - } - - elapsed_ms = mbedtls_timing_get_timer(&ctx->timer, 0); - - if (elapsed_ms >= ctx->fin_ms) - { - return 2; - } - - if (elapsed_ms >= ctx->int_ms) - { - return 1; - } - - return 0; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.h b/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.h deleted file mode 100644 index aedfa095f179ffb8cdd2559ceaa6b767dedbd46f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/dtls/mbedtls/mbedtls_port/timing_alt.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * \file timing_alt.h - * - * \brief Portable interface to the CPU cycle counter - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * 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 file is part of mbed TLS (https://tls.mbed.org) - */ -#ifndef MBEDTLS_TIMING_ALT_H -#define MBEDTLS_TIMING_ALT_H - -#if !defined(MBEDTLS_CONFIG_FILE) -#include "config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief timer structure - */ -struct mbedtls_timing_hr_time -{ - uint64_t timer_ms; -}; - -/** - * \brief Context for mbedtls_timing_set/get_delay() - */ -typedef struct -{ - struct mbedtls_timing_hr_time timer; - uint32_t int_ms; - uint32_t fin_ms; -} mbedtls_timing_delay_context; - -/** - * \brief Return the elapsed time in milliseconds - * - * \param val points to a timer structure - * \param reset if set to 1, the timer is restarted - */ -unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ); - -/** - * \brief Set a pair of delays to watch - * (See \c mbedtls_timing_get_delay().) - * - * \param data Pointer to timing data - * Must point to a valid \c mbedtls_timing_delay_context struct. - * \param int_ms First (intermediate) delay in milliseconds. - * \param fin_ms Second (final) delay in milliseconds. - * Pass 0 to cancel the current delay. - */ -void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); - -/** - * \brief Get the status of delays - * (Memory helper: number of delays passed.) - * - * \param data Pointer to timing data - * Must point to a valid \c mbedtls_timing_delay_context struct. - * - * \return -1 if cancelled (fin_ms = 0) - * 0 if none of the delays are passed, - * 1 if only the intermediate delay is passed, - * 2 if the final delay is passed. - */ -int mbedtls_timing_get_delay( void *data ); - -#ifdef __cplusplus -} -#endif - - -#endif /* timing_alt.h */ - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/BUILD.gn b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/BUILD.gn deleted file mode 100644 index fcae5148fc9da0a92d585c42cca0b0d01b167306..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology 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. - -mqtt_paho_inc = [ - "paho_mqtt/paho/MQTTClient-C/src", - "paho_mqtt/paho/MQTTPacket/src", - "paho_mqtt/port", - "../../inc", - "//kernel/liteos_m/components/cmsis/2.0", - "//vendor/hisi/hi3861/hi3861/third_party/lwip_sack/include/", -] - - -mqtt_paho_src = [ - "mqtt_al/mqtt_al.c", - "paho_mqtt/port/paho_mqtt_port.c", - "paho_mqtt/port/paho_osdepends.c", - "paho_mqtt/paho/MQTTClient-C/src/MQTTClient.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTConnectClient.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTConnectServer.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTDeserializePublish.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTFormat.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTPacket.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTSerializePublish.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeClient.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeServer.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeClient.c", - "paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeServer.c", - - -] -mqtt_paho_defs = [ - "MQTTCLIENT_PLATFORM_HEADER=paho_osdepends.h", - -] - -mqtt_cflags = [ - "-Wno-sign-compare", - "-Wno-unused-parameter", - "-Wno-unused-function", -] - -static_library("mqtt") { - cflags = mqtt_cflags - defines = mqtt_paho_defs - sources = mqtt_paho_src - include_dirs = mqtt_paho_inc -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/mqtt_al/mqtt_al.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/mqtt_al/mqtt_al.c deleted file mode 100644 index a25ad7f4ea4717c5cd114b28519da11c0ded4379..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/mqtt_al/mqtt_al.c +++ /dev/null @@ -1,213 +0,0 @@ -/*---------------------------------------------------------------------------- - * Copyright (c) <2018>, - * All rights reserved. - * Redistributopsn and use in source and binary forms, with or without modificatopsn, - * are permitted provided that the following conditopsns are met: - * 1. Redistributopsns of source code must retain the above copyright notice, this list of - * conditopsns and the following disclaimer. - * 2. Redistributopsns in binary form must reproduce the above copyright notice, this list - * of conditopsns and the following disclaimer in the documentatopsn and/or other materials - * provided with the distributopsn. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific propsr written - * permissopsn. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTopsN) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *---------------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------- - * Notice of Export Control Law - * =============================================== - * Huawei LiteOS may be subject to applicable export control laws and regulatopsns, which might - * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. - * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such - * applicable export control laws and regulatopsns. - *---------------------------------------------------------------------------*/ - -#include -#include -#include - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -#include - - -typedef struct -{ - mqtt_al_op_t *ops; - mqtt_al_op_t mem; -}mqtt_al_op_cb_t; - -static mqtt_al_op_cb_t s_mqtt_al_op_cb; - - -/////////////////CREATE THE API FOR THE MQTT LIB//////////////////////////////// -int mqtt_al_install(mqtt_al_op_t *op) -{ - int ret = -1; - if((NULL != op)&&(NULL == s_mqtt_al_op_cb.ops)) - { - s_mqtt_al_op_cb.mem = *op; - s_mqtt_al_op_cb.ops = &s_mqtt_al_op_cb.mem; - - ret = 0; - } - - return ret; -} - -int mqtt_al_uninstall() -{ - int ret = -1; - if(NULL != s_mqtt_al_op_cb.ops) - { - s_mqtt_al_op_cb.ops = NULL; - - ret = 0; - } - - return ret; -} - -//////////////////////////CREATE THE API FOR THE MQTT APPLICATopsN/////////////// - -__attribute__((weak)) int mqtt_imp_init(void) -{ - LINK_LOG_DEBUG("%s:###please implement mqtt by yourself####",__FUNCTION__); - return -1; -} - -int mqtt_al_init(void) -{ - int ret; - - ret = mqtt_imp_init(); - LINK_LOG_DEBUG("IOT_LINK:DO MQTT LOAD-IMPLEMENT RET:%d",ret); - - return ret; -} - -int mqtt_al_deinit() -{ - - int ret = 0; - - //maybe need special code here - - return ret; -} - -void * mqtt_al_connect( mqtt_al_conpara_t *conpara) -{ - - void *ret = NULL; - - if((NULL != conpara) && (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->connect)) - { - ret = s_mqtt_al_op_cb.ops->connect(conpara); - } - - return ret; - -} - - -int mqtt_al_disconnect(void *handle) -{ - - int ret = -1; - - if((NULL != handle) && (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->disconnect)) - { - ret = s_mqtt_al_op_cb.ops->disconnect(handle); - } - - return ret; - -} - - -int mqtt_al_publish(void *handle, mqtt_al_pubpara_t *pubpara) -{ - - int ret = -1; - - if((NULL != handle) && (NULL != pubpara) &&\ - (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->publish)) - { - ret = s_mqtt_al_op_cb.ops->publish(handle,pubpara); - } - - return ret; - -} - - -int mqtt_al_subscribe(void *handle, mqtt_al_subpara_t *subpara) -{ - - int ret = -1; - - if((NULL != handle) && (NULL != subpara) &&\ - (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->subscribe)) - { - ret = s_mqtt_al_op_cb.ops->subscribe(handle,subpara); - } - - return ret; - -} - - -int mqtt_al_unsubscribe(void *handle, mqtt_al_unsubpara_t *unsubpara) -{ - - int ret = -1; - - if((NULL != handle) && (NULL != unsubpara) && \ - (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->unsubscribe)) - { - ret = s_mqtt_al_op_cb.ops->unsubscribe(handle,unsubpara); - } - - return ret; - -} - -en_mqtt_al_connect_state mqtt_al_check_status(void *handle) -{ - - en_mqtt_al_connect_state ret = en_mqtt_al_connect_err; - - if((NULL != handle) && (NULL != s_mqtt_al_op_cb.ops) && (NULL != s_mqtt_al_op_cb.ops->check_status)) - { - ret = s_mqtt_al_op_cb.ops->check_status(handle); - } - - return ret; -} - - - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/Readme.md b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/Readme.md deleted file mode 100644 index 4413e12e7e7e7e0832cb70c132f9999e686b96d1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/Readme.md +++ /dev/null @@ -1,22 +0,0 @@ -#### PAHO库修改说明 - -在PAHO v1.1.0版本上修改,修改的主要点如下: - -| 修改级别 | 修改内容 | -| :------- | ------------------------------------------------------------ | -| 修复 | 原库定义的SUCCESS会引起冲突,C50版本重新命 | -| 修复 | MQTTClientInit原库没有返回值,C50版本修改为有返回值,并增加了MQTTClientDeinit函数 | -| 修复 | MQTTClientInit原库没有检查互斥锁返回值,C50版本修改为检查返回值 | -| 优化 | C50版本修改了TOPIC匹配函数(用于收到消息时投递消息),应该是引用了某个库的API函数,暂时未查阅到 | -| 修复 | C50在CYCLE中增加了UNSUBACK的处理 | -| 修改 | 原库版本的KEEPALIVE逻辑为上次发送和上次接收为或逻辑,C50版本修改为与逻辑 | -| 修改 | C50版本修改了超时重传逻辑(QOS2) | -| 修复 | C50版本的MQTTYield函数使用互斥锁进行互斥,避免数据冲突 | -| 修改 | 原库版本订阅函数的回调函数不支持ARG参数,修改为带参数模式 | - -修复:原版本或者库存在显性或者隐性BUG,进行修复 - -修改:原版本不满足现有需求或者功能,需要修改 - -优化:对某些实现做了更合适的修改 - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.cproject b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.cproject deleted file mode 100644 index 8fdc3d34971d8c43407da81d44089971b886009d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.cproject +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.gitignore b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.gitignore deleted file mode 100644 index c9fa4f9514ee8ca8dbfdc499dc4885e2beae32f9..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/dep/ -/build/ -/build.paho/ -*.swp -*.pyc -/doc/MQTTClient/ -/doc/MQTTPacket/ -/doc/MQTTClient-C/ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.project b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.project deleted file mode 100644 index 88aa3838d4e0b14a553bdb85e0d28064a860555c..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - embedded-C - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.core.prefs b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index 8d41bca80871a5e733f20fbc3a559df03a22d3f4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,163 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.cdt.core.formatter.alignment_for_assignment=16 -org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80 -org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.cdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34 -org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18 -org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0 -org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16 -org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48 -org.eclipse.cdt.core.formatter.alignment_for_expression_list=0 -org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.cdt.core.formatter.alignment_for_member_access=0 -org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16 -org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=next_line -org.eclipse.cdt.core.formatter.brace_position_for_block=next_line -org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=next_line -org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=next_line -org.eclipse.cdt.core.formatter.brace_position_for_switch=next_line -org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=next_line -org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1 -org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true -org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true -org.eclipse.cdt.core.formatter.compact_else_if=true -org.eclipse.cdt.core.formatter.continuation_indentation=2 -org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false -org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0 -org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true -org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false -org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false -org.eclipse.cdt.core.formatter.indent_empty_lines=false -org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.cdt.core.formatter.indentation.size=4 -org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.join_wrapped_lines=true -org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.cdt.core.formatter.lineSplit=80 -org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.cdt.core.formatter.tabulation.char=tab -org.eclipse.cdt.core.formatter.tabulation.size=4 -org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.ui.prefs b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.ui.prefs deleted file mode 100644 index 48a50c7083a32362084e6e9f12f744f33cbc33bb..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.settings/org.eclipse.cdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -formatter_profile=org.eclipse.cdt.ui.default.allman_profile -formatter_settings_version=1 diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.travis.yml b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.travis.yml deleted file mode 100644 index da7be02680298e7c591204979826d5c61e7561dc..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -sudo: true -language: c - -compiler: - - gcc - -os: - - linux - -sudo: required - -before_install: - - ./travis-install.sh - -script: - - if [[ "$COVERITY_SCAN_BRANCH" != 1 ]]; then ./travis-build.sh; fi - -addons: - apt: - sources: - - george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3 - - sourceline: 'ppa:mosquitto-dev/mosquitto-ppa' - packages: - - cmake - - cmake-data - - mosquitto - - doxygen - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CMakeLists.txt deleted file mode 100644 index ec59f63ceea8fe483bed163c09ced9b80ec09cbe..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -cmake_minimum_required(VERSION 2.8) -project (embedded-mqtt) -set(CMAKE_BUILD_TYPE Debug) - -message(STATUS "CMake version: " ${CMAKE_VERSION}) -message(STATUS "CMake system name: " ${CMAKE_SYSTEM_NAME}) - -set(CMAKE_SCRIPTS "${CMAKE_SOURCE_DIR}/cmake") -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") - -## build settings -set(PAHO_VERSION_MAJOR 1) -set(PAHO_VERSION_MINOR 0) -set(PAHO_VERSION_PATCH 0) -set(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH}) - -string(TIMESTAMP BUILD_TIMESTAMP UTC) -message(STATUS "Timestamp is ${BUILD_TIMESTAMP}") - -set(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH}) -include(CPack) - -include_directories(MQTTPacket/src) - -enable_testing() -ADD_SUBDIRECTORY(MQTTPacket) -ADD_SUBDIRECTORY(MQTTClient) -ADD_SUBDIRECTORY(MQTTClient-C) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CONTRIBUTING.md b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CONTRIBUTING.md deleted file mode 100644 index 0837fdf83f6f80fbfa5b147c363af22047a3eab5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/CONTRIBUTING.md +++ /dev/null @@ -1,66 +0,0 @@ -# Contributing to Paho - -Thanks for your interest in this project! - -You can contribute bugfixes and new features by sending pull requests through GitHub. - -## Legal - -In order for your contribution to be accepted, it must comply with the Eclipse Foundation IP policy. - -Please read the [Eclipse Foundation policy on accepting contributions via Git](http://wiki.eclipse.org/Development_Resources/Contributing_via_Git). - -1. Sign the [Eclipse CLA](http://www.eclipse.org/legal/CLA.php) - 1. Register for an Eclipse Foundation User ID. You can register [here](https://dev.eclipse.org/site_login/createaccount.php). - 2. Log into the [Projects Portal](https://projects.eclipse.org/), and click on the '[Eclipse CLA](https://projects.eclipse.org/user/sign/cla)' link. -2. Go to your [account settings](https://dev.eclipse.org/site_login/myaccount.php#open_tab_accountsettings) and add your GitHub username to your account. -3. Make sure that you _sign-off_ your Git commits in the following format: - ``` Signed-off-by: John Smith ``` This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. ```git commit -s -m "Adding a cool feature"``` -4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with. - -## Contributing a change - -1. [Fork the repository on GitHub](https://github.com/eclipse/paho.mqtt.embedded-c/fork) -2. Clone the forked repository onto your computer: ``` git clone https://github.com//paho.mqtt.embedded-c.git ``` -3. Create a new branch from the latest ```develop``` branch with ```git checkout -b YOUR_BRANCH_NAME origin/develop``` -4. Make your changes -5. If developing a new feature, make sure to include JUnit tests. -6. Ensure that all new and existing tests pass. -7. Commit the changes into the branch: ``` git commit -s ``` Make sure that your commit message is meaningful and describes your changes correctly. -8. If you have a lot of commits for the change, squash them into a single / few commits. -9. Push the changes in your branch to your forked repository. -10. Finally, go to [https://github.com/eclipse/paho.mqtt.embedded-c](https://github.com/eclipse/paho.mqtt.embedded-c) and create a pull request from your "YOUR_BRANCH_NAME" branch to the ```develop``` one to request review and merge of the commits in your pushed branch. - - -What happens next depends on the content of the patch. If it is 100% authored -by the contributor and is less than 1000 lines (and meets the needs of the -project), then it can be pulled into the main repository. If not, more steps -are required. These are detailed in the -[legal process poster](http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf). - - - -## Developer resources: - - -Information regarding source code management, builds, coding standards, and more. - -- [https://projects.eclipse.org/projects/iot.paho/developer](https://projects.eclipse.org/projects/iot.paho/developer) - -Contact: --------- - -Contact the project developers via the project's development -[mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev). - -Search for bugs: ----------------- - -This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.embedded-c/issues](https://github.com/eclipse/paho.mqtt.embedded-c/issues) to track ongoing development and issues. - -Create a new bug: ------------------ - -Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome! - -- [Create new Paho bug](https://github.com/eclipse/paho.mqtt.embedded-c/issues) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/makefile b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/makefile deleted file mode 100644 index e0c8341a38bb6bf4ae1be3f3e46f0d7eb676b343..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/makefile +++ /dev/null @@ -1,45 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - --include ../makefile.init - -RM := rm -rf - -# All of the sources participating in the build are defined here --include sources.mk --include MQTTPacket/src/subdir.mk --include MQTTPacket/samples/subdir.mk --include subdir.mk --include objects.mk - -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(strip $(C_DEPS)),) --include $(C_DEPS) -endif -endif - --include ../makefile.defs - -# Add inputs and outputs from these tool invocations to the build variables - -# All Target -all: libembedded-C.so - -# Tool invocations -libembedded-C.so: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: GCC C Linker' - gcc -shared -o "libembedded-C.so" $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' - -# Other Targets -clean: - -$(RM) $(C_DEPS)$(LIBRARIES)$(OBJS) libembedded-C.so - -@echo ' ' - -.PHONY: all clean dependents -.SECONDARY: - --include ../makefile.targets diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/objects.mk b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/objects.mk deleted file mode 100644 index 742c2da043f4f5d93c414dca3a725ab2204d9817..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/objects.mk +++ /dev/null @@ -1,8 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -USER_OBJS := - -LIBS := - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/sources.mk b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/sources.mk deleted file mode 100644 index 00b705830f37562199ddebdfed9bae1e9091df84..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/sources.mk +++ /dev/null @@ -1,18 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -ASM_SRCS := -OBJ_SRCS := -S_UPPER_SRCS := -C_SRCS := -O_SRCS := -C_DEPS := -LIBRARIES := -OBJS := - -# Every subdirectory with source files must be described here -SUBDIRS := \ -MQTTPacket/src \ -MQTTPacket/samples \ - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/MQTTDeserializeConnect.d b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/MQTTDeserializeConnect.d deleted file mode 100644 index 5ca53ed99e5d72eff374e3e5b2f432da1f0b1416..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/MQTTDeserializeConnect.d +++ /dev/null @@ -1,4 +0,0 @@ -src/MQTTDeserializeConnect.d src/MQTTDeserializeConnect.o: \ - ../src/MQTTDeserializeConnect.c ../src/StackTrace.h - -../src/StackTrace.h: diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/subdir.mk b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/subdir.mk deleted file mode 100644 index cbae0e4ea99b8215b9851ed0080046840419809b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Debug/src/subdir.mk +++ /dev/null @@ -1,48 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -C_SRCS += \ -../src/MQTTConnectClient.c \ -../src/MQTTConnectServer.c \ -../src/MQTTDeserializePublish.c \ -../src/MQTTPacket.c \ -../src/MQTTSerializePublish.c \ -../src/MQTTSubscribeClient.c \ -../src/MQTTSubscribeServer.c \ -../src/MQTTUnsubscribeClient.c \ -../src/MQTTUnsubscribeServer.c - -C_DEPS += \ -./src/MQTTConnectClient.d \ -./src/MQTTConnectServer.d \ -./src/MQTTDeserializePublish.d \ -./src/MQTTPacket.d \ -./src/MQTTSerializePublish.d \ -./src/MQTTSubscribeClient.d \ -./src/MQTTSubscribeServer.d \ -./src/MQTTUnsubscribeClient.d \ -./src/MQTTUnsubscribeServer.d - -OBJS += \ -./src/MQTTConnectClient.o \ -./src/MQTTConnectServer.o \ -./src/MQTTDeserializePublish.o \ -./src/MQTTPacket.o \ -./src/MQTTSerializePublish.o \ -./src/MQTTSubscribeClient.o \ -./src/MQTTSubscribeServer.o \ -./src/MQTTUnsubscribeClient.o \ -./src/MQTTUnsubscribeServer.o - - -# Each subdirectory must supply rules for building sources it contributes -src/%.o: ../src/%.c - @echo 'Building file: $<' - @echo 'Invoking: GCC C Compiler' - gcc -I"/home/icraggs/work/paho/org.eclipse.paho.mqtt.embedded-c/src" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/CMakeLists.txt deleted file mode 100644 index c8242dd842d52e48208bdd2d88fe8f3603d18af0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -project("paho-mqttclient" C) - -ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(samples) -ADD_SUBDIRECTORY(test) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/CMakeLists.txt deleted file mode 100644 index d3697be8fa9c80b3be156b29878b211deaa6f09a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -add_subdirectory(linux) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/FreeRTOS/MQTTEcho.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/FreeRTOS/MQTTEcho.c deleted file mode 100644 index a9b6c393f4b7ccfdbfdc8c4bb816f628d8597996..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/FreeRTOS/MQTTEcho.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" - -/* FreeRTOS+TCP includes. */ -#include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" - -#define MQTT_TASK 1 -#include "MQTTClient.h" - - -void messageArrived(MessageData* data) -{ - printf("Message arrived on topic %.*s: %.*s\n", data->topicName->lenstring.len, data->topicName->lenstring.data, - data->message->payloadlen, data->message->payload); -} - -static void prvMQTTEchoTask(void *pvParameters) -{ - /* connect to m2m.eclipse.org, subscribe to a topic, send and receive messages regularly every 1 sec */ - MQTTClient client; - Network network; - unsigned char sendbuf[80], readbuf[80]; - int rc = 0, - count = 0; - MQTTPacket_connectData connectData = MQTTPacket_connectData_initializer; - - pvParameters = 0; - NetworkInit(&network); - MQTTClientInit(&client, &network, 30000, sendbuf, sizeof(sendbuf), readbuf, sizeof(readbuf)); - - char* address = "iot.eclipse.org"; - if ((rc = NetworkConnect(&network, address, 1883)) != 0) - printf("Return code from network connect is %d\n", rc); - -#if defined(MQTT_TASK) - if ((rc = MQTTStartTask(&client)) != pdPASS) - printf("Return code from start tasks is %d\n", rc); -#endif - - connectData.MQTTVersion = 3; - connectData.clientID.cstring = "FreeRTOS_sample"; - - if ((rc = MQTTConnect(&client, &connectData)) != 0) - printf("Return code from MQTT connect is %d\n", rc); - else - printf("MQTT Connected\n"); - - if ((rc = MQTTSubscribe(&client, "FreeRTOS/sample/#", 2, messageArrived)) != 0) - printf("Return code from MQTT subscribe is %d\n", rc); - - while (++count) - { - MQTTMessage message; - char payload[30]; - - message.qos = 1; - message.retained = 0; - message.payload = payload; - sprintf(payload, "message number %d", count); - message.payloadlen = strlen(payload); - - if ((rc = MQTTPublish(&client, "FreeRTOS/sample/a", &message)) != 0) - printf("Return code from MQTT publish is %d\n", rc); -#if !defined(MQTT_TASK) - if ((rc = MQTTYield(&client, 1000)) != 0) - printf("Return code from yield is %d\n", rc); -#endif - } - - /* do not return */ -} - - -void vStartMQTTTasks(uint16_t usTaskStackSize, UBaseType_t uxTaskPriority) -{ - BaseType_t x = 0L; - - xTaskCreate(prvMQTTEchoTask, /* The function that implements the task. */ - "MQTTEcho0", /* Just a text name for the task to aid debugging. */ - usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */ - (void *)x, /* The task parameter, not used in this case. */ - uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */ - NULL); /* The task handle is not used. */ -} -/*-----------------------------------------------------------*/ - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/CMakeLists.txt deleted file mode 100644 index 6ca474d40f1c2cad930548e590edd6291626ec81..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - - -add_executable( - stdoutsubc - stdoutsub.c -) -target_link_libraries(stdoutsubc paho-embed-mqtt3cc paho-embed-mqtt3c) -target_include_directories(stdoutsubc PRIVATE "../../src" "../../src/linux") -target_compile_definitions(stdoutsubc PRIVATE MQTTCLIENT_PLATFORM_HEADER=MQTTLinux.h) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/build.sh b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/build.sh deleted file mode 100644 index 767eb5774d02bd591809579d72ba7e56596c6860..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -cp ../../src/MQTTClient.c . -sed -e 's/""/"MQTTLinux.h"/g' ../../src/MQTTClient.h > MQTTClient.h -gcc stdoutsub.c -I ../../src -I ../../src/linux -I ../../../MQTTPacket/src MQTTClient.c ../../src/linux/MQTTLinux.c ../../../MQTTPacket/src/MQTTFormat.c ../../../MQTTPacket/src/MQTTPacket.c ../../../MQTTPacket/src/MQTTDeserializePublish.c ../../../MQTTPacket/src/MQTTConnectClient.c ../../../MQTTPacket/src/MQTTSubscribeClient.c ../../../MQTTPacket/src/MQTTSerializePublish.c -o stdoutsub ../../../MQTTPacket/src/MQTTConnectServer.c ../../../MQTTPacket/src/MQTTSubscribeServer.c ../../../MQTTPacket/src/MQTTUnsubscribeServer.c ../../../MQTTPacket/src/MQTTUnsubscribeClient.c -DMQTTCLIENT_PLATFORM_HEADER=MQTTLinux.h diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/stdoutsub.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/stdoutsub.c deleted file mode 100644 index f57506e746e2eca33e6d0e5df2d8e471b5f1ad9a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/samples/linux/stdoutsub.c +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2016 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial contribution - * Ian Craggs - change delimiter option from char to string - * Al Stockdill-Mander - Version using the embedded C client - * Ian Craggs - update MQTTClient function names - *******************************************************************************/ - -/* - - stdout subscriber - - compulsory parameters: - - topic to subscribe to - - defaulted parameters: - - --host localhost - --port 1883 - --qos 2 - --delimiter \n - --clientid stdout_subscriber - - --userid none - --password none - - for example: - - stdoutsub topic/of/interest --host iot.eclipse.org - -*/ -#include -#include -#include "MQTTClient.h" - -#include -#include - -#include - - -volatile int toStop = 0; - - -void usage() -{ - printf("MQTT stdout subscriber\n"); - printf("Usage: stdoutsub topicname , where options are:\n"); - printf(" --host (default is localhost)\n"); - printf(" --port (default is 1883)\n"); - printf(" --qos (default is 2)\n"); - printf(" --delimiter (default is \\n)\n"); - printf(" --clientid (default is hostname+timestamp)\n"); - printf(" --username none\n"); - printf(" --password none\n"); - printf(" --showtopics (default is on if the topic has a wildcard, else off)\n"); - exit(-1); -} - - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - - -struct opts_struct -{ - char* clientid; - int nodelimiter; - char* delimiter; - enum QoS qos; - char* username; - char* password; - char* host; - int port; - int showtopics; -} opts = -{ - (char*)"stdout-subscriber", 0, (char*)"\n", QOS2, NULL, NULL, (char*)"localhost", 1883, 0 -}; - - -void getopts(int argc, char** argv) -{ - int count = 2; - - while (count < argc) - { - if (strcmp(argv[count], "--qos") == 0) - { - if (++count < argc) - { - if (strcmp(argv[count], "0") == 0) - opts.qos = QOS0; - else if (strcmp(argv[count], "1") == 0) - opts.qos = QOS1; - else if (strcmp(argv[count], "2") == 0) - opts.qos = QOS2; - else - usage(); - } - else - usage(); - } - else if (strcmp(argv[count], "--host") == 0) - { - if (++count < argc) - opts.host = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--port") == 0) - { - if (++count < argc) - opts.port = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--clientid") == 0) - { - if (++count < argc) - opts.clientid = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--username") == 0) - { - if (++count < argc) - opts.username = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--password") == 0) - { - if (++count < argc) - opts.password = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--delimiter") == 0) - { - if (++count < argc) - opts.delimiter = argv[count]; - else - opts.nodelimiter = 1; - } - else if (strcmp(argv[count], "--showtopics") == 0) - { - if (++count < argc) - { - if (strcmp(argv[count], "on") == 0) - opts.showtopics = 1; - else if (strcmp(argv[count], "off") == 0) - opts.showtopics = 0; - else - usage(); - } - else - usage(); - } - count++; - } - -} - - -void messageArrived(MessageData* md) -{ - MQTTMessage* message = md->message; - - if (opts.showtopics) - printf("%.*s\t", md->topicName->lenstring.len, md->topicName->lenstring.data); - if (opts.nodelimiter) - printf("%.*s", (int)message->payloadlen, (char*)message->payload); - else - printf("%.*s%s", (int)message->payloadlen, (char*)message->payload, opts.delimiter); - //fflush(stdout); -} - - -int main(int argc, char** argv) -{ - int rc = 0; - unsigned char buf[100]; - unsigned char readbuf[100]; - - if (argc < 2) - usage(); - - char* topic = argv[1]; - - if (strchr(topic, '#') || strchr(topic, '+')) - opts.showtopics = 1; - if (opts.showtopics) - printf("topic is %s\n", topic); - - getopts(argc, argv); - - Network n; - MQTTClient c; - - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); - - NetworkInit(&n); - NetworkConnect(&n, opts.host, opts.port); - MQTTClientInit(&c, &n, 1000, buf, 100, readbuf, 100); - - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.willFlag = 0; - data.MQTTVersion = 3; - data.clientID.cstring = opts.clientid; - data.username.cstring = opts.username; - data.password.cstring = opts.password; - - data.keepAliveInterval = 10; - data.cleansession = 1; - printf("Connecting to %s %d\n", opts.host, opts.port); - - rc = MQTTConnect(&c, &data); - printf("Connected %d\n", rc); - - printf("Subscribing to %s\n", topic); - rc = MQTTSubscribe(&c, topic, opts.qos, messageArrived); - printf("Subscribed %d\n", rc); - - while (!toStop) - { - MQTTYield(&c, 1000); - } - - printf("Stopping\n"); - - MQTTDisconnect(&c); - NetworkDisconnect(&n); - - return 0; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/CMakeLists.txt deleted file mode 100644 index a2327ea9fae4395a3afa0bf676b76ad76a628c02..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -# MQTTClient Library - C - - -file(GLOB SOURCES "*.c" "linux/*.c") - -add_library( - paho-embed-mqtt3cc SHARED - ${SOURCES} -) -install(TARGETS paho-embed-mqtt3cc DESTINATION /usr/lib) -target_include_directories(paho-embed-mqtt3cc PRIVATE "linux") -target_link_libraries(paho-embed-mqtt3cc paho-embed-mqtt3c) -target_compile_definitions(paho-embed-mqtt3cc PRIVATE - MQTTCLIENT_PLATFORM_HEADER=MQTTLinux.h MQTTCLIENT_QOS2=1) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.c deleted file mode 100644 index 21cce692cea86dde42145297134edbc17788b272..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.c +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2015 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - * Ian Craggs - convert to FreeRTOS - *******************************************************************************/ - -#include "MQTTFreeRTOS.h" - - -int ThreadStart(Thread* thread, void (*fn)(void*), void* arg) -{ - int rc = 0; - uint16_t usTaskStackSize = (configMINIMAL_STACK_SIZE * 5); - UBaseType_t uxTaskPriority = uxTaskPriorityGet(NULL); /* set the priority as the same as the calling task*/ - - rc = xTaskCreate(fn, /* The function that implements the task. */ - "MQTTTask", /* Just a text name for the task to aid debugging. */ - usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */ - arg, /* The task parameter, not used in this case. */ - uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */ - &thread->task); /* The task handle is not used. */ - - return rc; -} - - -void MutexInit(Mutex* mutex) -{ - mutex->sem = xSemaphoreCreateMutex(); -} - -int MutexLock(Mutex* mutex) -{ - return xSemaphoreTake(mutex->sem, portMAX_DELAY); - -} - -int MutexUnlock(Mutex* mutex) -{ - return xSemaphoreGive(mutex->sem); -} - - -void TimerCountdownMS(Timer* timer, unsigned int timeout_ms) -{ - timer->xTicksToWait = timeout_ms / portTICK_PERIOD_MS; /* convert milliseconds to ticks */ - vTaskSetTimeOutState(&timer->xTimeOut); /* Record the time at which this function was entered. */ -} - - -void TimerCountdown(Timer* timer, unsigned int timeout) -{ - TimerCountdownMS(timer, timeout * 1000); -} - - -int TimerLeftMS(Timer* timer) -{ - xTaskCheckForTimeOut(&timer->xTimeOut, &timer->xTicksToWait); /* updates xTicksToWait to the number left */ - return (timer->xTicksToWait < 0) ? 0 : (timer->xTicksToWait * portTICK_PERIOD_MS); -} - - -char TimerIsExpired(Timer* timer) -{ - return xTaskCheckForTimeOut(&timer->xTimeOut, &timer->xTicksToWait) == pdTRUE; -} - - -void TimerInit(Timer* timer) -{ - timer->xTicksToWait = 0; - memset(&timer->xTimeOut, '\0', sizeof(timer->xTimeOut)); -} - - -int FreeRTOS_read(Network* n, unsigned char* buffer, int len, int timeout_ms) -{ - TickType_t xTicksToWait = timeout_ms / portTICK_PERIOD_MS; /* convert milliseconds to ticks */ - TimeOut_t xTimeOut; - int recvLen = 0; - - vTaskSetTimeOutState(&xTimeOut); /* Record the time at which this function was entered. */ - do - { - int rc = 0; - - FreeRTOS_setsockopt(n->my_socket, 0, FREERTOS_SO_RCVTIMEO, &xTicksToWait, sizeof(xTicksToWait)); - rc = FreeRTOS_recv(n->my_socket, buffer + recvLen, len - recvLen, 0); - if (rc > 0) - recvLen += rc; - else if (rc < 0) - { - recvLen = rc; - break; - } - } while (recvLen < len && xTaskCheckForTimeOut(&xTimeOut, &xTicksToWait) == pdFALSE); - - return recvLen; -} - - -int FreeRTOS_write(Network* n, unsigned char* buffer, int len, int timeout_ms) -{ - TickType_t xTicksToWait = timeout_ms / portTICK_PERIOD_MS; /* convert milliseconds to ticks */ - TimeOut_t xTimeOut; - int sentLen = 0; - - vTaskSetTimeOutState(&xTimeOut); /* Record the time at which this function was entered. */ - do - { - int rc = 0; - - FreeRTOS_setsockopt(n->my_socket, 0, FREERTOS_SO_RCVTIMEO, &xTicksToWait, sizeof(xTicksToWait)); - rc = FreeRTOS_send(n->my_socket, buffer + sentLen, len - sentLen, 0); - if (rc > 0) - sentLen += rc; - else if (rc < 0) - { - sentLen = rc; - break; - } - } while (sentLen < len && xTaskCheckForTimeOut(&xTimeOut, &xTicksToWait) == pdFALSE); - - return sentLen; -} - - -void FreeRTOS_disconnect(Network* n) -{ - FreeRTOS_closesocket(n->my_socket); -} - - -void NetworkInit(Network* n) -{ - n->my_socket = 0; - n->mqttread = FreeRTOS_read; - n->mqttwrite = FreeRTOS_write; - n->disconnect = FreeRTOS_disconnect; -} - - -int NetworkConnect(Network* n, char* addr, int port) -{ - struct freertos_sockaddr sAddr; - int retVal = -1; - uint32_t ipAddress; - - if ((ipAddress = FreeRTOS_gethostbyname(addr)) == 0) - goto exit; - - sAddr.sin_port = FreeRTOS_htons(port); - sAddr.sin_addr = ipAddress; - - if ((n->my_socket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP)) < 0) - goto exit; - - if ((retVal = FreeRTOS_connect(n->my_socket, &sAddr, sizeof(sAddr))) < 0) - { - FreeRTOS_closesocket(n->my_socket); - goto exit; - } - -exit: - return retVal; -} - - -#if 0 -int NetworkConnectTLS(Network *n, char* addr, int port, SlSockSecureFiles_t* certificates, unsigned char sec_method, unsigned int cipher, char server_verify) -{ - SlSockAddrIn_t sAddr; - int addrSize; - int retVal; - unsigned long ipAddress; - - retVal = sl_NetAppDnsGetHostByName(addr, strlen(addr), &ipAddress, AF_INET); - if (retVal < 0) { - return -1; - } - - sAddr.sin_family = AF_INET; - sAddr.sin_port = sl_Htons((unsigned short)port); - sAddr.sin_addr.s_addr = sl_Htonl(ipAddress); - - addrSize = sizeof(SlSockAddrIn_t); - - n->my_socket = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, SL_SEC_SOCKET); - if (n->my_socket < 0) { - return -1; - } - - SlSockSecureMethod method; - method.secureMethod = sec_method; - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECMETHOD, &method, sizeof(method)); - if (retVal < 0) { - return retVal; - } - - SlSockSecureMask mask; - mask.secureMask = cipher; - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_MASK, &mask, sizeof(mask)); - if (retVal < 0) { - return retVal; - } - - if (certificates != NULL) { - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_FILES, certificates->secureFiles, sizeof(SlSockSecureFiles_t)); - if (retVal < 0) - { - return retVal; - } - } - - retVal = sl_Connect(n->my_socket, (SlSockAddr_t *)&sAddr, addrSize); - if (retVal < 0) { - if (server_verify || retVal != -453) { - sl_Close(n->my_socket); - return retVal; - } - } - - SysTickIntRegister(SysTickIntHandler); - SysTickPeriodSet(80000); - SysTickEnable(); - - return retVal; -} -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.h deleted file mode 100644 index 0e42180d1b2f36a617e07a0307402420619e1d1e..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.h +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2015 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(MQTTFreeRTOS_H) -#define MQTTFreeRTOS_H - -#include "FreeRTOS.h" -#include "FreeRTOS_Sockets.h" -#include "FreeRTOS_IP.h" -#include "semphr.h" -#include "task.h" - -typedef struct Timer -{ - TickType_t xTicksToWait; - TimeOut_t xTimeOut; -} Timer; - -typedef struct Network Network; - -struct Network -{ - xSocket_t my_socket; - int (*mqttread) (Network*, unsigned char*, int, int); - int (*mqttwrite) (Network*, unsigned char*, int, int); - void (*disconnect) (Network*); -}; - -void TimerInit(Timer*); -char TimerIsExpired(Timer*); -void TimerCountdownMS(Timer*, unsigned int); -void TimerCountdown(Timer*, unsigned int); -int TimerLeftMS(Timer*); - -typedef struct Mutex -{ - SemaphoreHandle_t sem; -} Mutex; - -void MutexInit(Mutex*); -int MutexLock(Mutex*); -int MutexUnlock(Mutex*); - -typedef struct Thread -{ - TaskHandle_t task; -} Thread; - -int ThreadStart(Thread*, void (*fn)(void*), void* arg); - -int FreeRTOS_read(Network*, unsigned char*, int, int); -int FreeRTOS_write(Network*, unsigned char*, int, int); -void FreeRTOS_disconnect(Network*); - -void NetworkInit(Network*); -int NetworkConnect(Network*, char*, int); -/*int NetworkConnectTLS(Network*, char*, int, SlSockSecureFiles_t*, unsigned char, unsigned int, char);*/ - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.c deleted file mode 100644 index cf16ee024b99ae27995f2685221ece78da2e08f6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.c +++ /dev/null @@ -1,952 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander/Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - fix for #96 - check rem_len in readPacket - * Ian Craggs - add ability to set message handler separately #6 - *******************************************************************************/ -#include "MQTTClient.h" - -static void NewMessageData(MessageData* md, MQTTString* aTopicName, MQTTMessage* aMessage) { - md->topicName = aTopicName; - md->message = aMessage; -} - - -static int getNextPacketId(MQTTClient *c) { - return c->next_packetid = (c->next_packetid == MAX_PACKET_ID) ? 1 : c->next_packetid + 1; -} - - -static int sendPacket(MQTTClient* c, int length, Timer* timer) -{ - int rc = FAILURE, - sent = 0; - - while (sent < length && !TimerIsExpired(timer)) - { - rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer)); - if (rc < 0) // there was an error writing the data - break; - sent += rc; - } - if (sent == length) - { - TimerCountdown(&c->last_sent, c->keepAliveInterval); // record the fact that we have successfully sent the packet - rc = MQTT_SUCCESS; - } - else - rc = FAILURE; - return rc; -} - - -int MQTTClientInit(MQTTClient* c, Network* network, unsigned int command_timeout_ms, - unsigned char *sendbuf, size_t sendbuf_size, unsigned char *readbuf, size_t readbuf_size) -{ - int i; - c->ipstack = network; - - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - c->messageHandlers[i].topicFilter = 0; - c->command_timeout_ms = command_timeout_ms; - c->buf = sendbuf; - c->buf_size = sendbuf_size; - c->readbuf = readbuf; - c->readbuf_size = readbuf_size; - c->isconnected = 0; - c->cleansession = 0; - c->ping_outstanding = 0; - c->defaultMessageHandler = NULL; - c->next_packetid = 1; - TimerInit(&c->last_sent); - TimerInit(&c->last_received); -#if defined(MQTT_TASK) - if (MutexInit(&c->mutex) != 0) - { - return FAILURE; - } -#endif - return MQTT_SUCCESS; -} - -void MQTTClientDeInit(MQTTClient *c) -{ - if(!c) - return; -#if defined(MQTT_TASK) - MutexDestory(&c->mutex); -#endif - return; -} - -static int decodePacket(MQTTClient* c, int* value, int timeout) -{ - unsigned char i; - int multiplier = 1; - int len = 0; - const int MAX_NO_OF_REMAINING_LENGTH_BYTES = 4; - - *value = 0; - do - { - int rc = MQTTPACKET_READ_ERROR; - - if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES) - { - rc = MQTTPACKET_READ_ERROR; /* bad data */ - goto exit; - } - rc = c->ipstack->mqttread(c->ipstack, &i, 1, timeout); - if (rc != 1) - goto exit; - *value += (i & 127) * multiplier; - multiplier *= 128; - } while ((i & 128) != 0); -exit: - return len; -} - - -static int readPacket(MQTTClient* c, Timer* timer) -{ - MQTTHeader header = {0}; - int len = 0; - int rem_len = 0; - - /* 1. read the header byte. This has the packet type in it */ - int rc = c->ipstack->mqttread(c->ipstack, c->readbuf, 1, TimerLeftMS(timer)); - if (rc != 1) - goto exit; - - len = 1; - /* 2. read the remaining length. This is variable in itself */ - decodePacket(c, &rem_len, TimerLeftMS(timer)); - len += MQTTPacket_encode(c->readbuf + 1, rem_len); /* put the original remaining length back into the buffer */ - - if (rem_len > (c->readbuf_size - len)) - { - rc = BUFFER_OVERFLOW; - goto exit; - } - - /* 3. read the rest of the buffer using a callback to supply the rest of the data */ - if (rem_len > 0 && (rc = c->ipstack->mqttread(c->ipstack, c->readbuf + len, rem_len, TimerLeftMS(timer)) != rem_len)) { - rc = 0; - goto exit; - } - - header.byte = c->readbuf[0]; - rc = header.bits.type; - if (c->keepAliveInterval > 0) - TimerCountdown(&c->last_received, c->keepAliveInterval); // record the fact that we have successfully received a packet -exit: - return rc; -} - -/** - * Copyright (c) 2009-2018 Roger Light - * licensed under the Eclipse Public License 1.0 and the Eclipse Distribution License 1.0 - */ -static int MQTTTopicMatched(const char *sub, MQTTString *topic_name, char *result) -{ - int sublen, topiclen; - int spos, tpos; - char multilevel_wildcard = 0; - char *topic; - - if(!result) - return -1; - *result = 0; - - if(!sub || !topic_name) - { - return -1; - } - - sublen = strlen(sub); - - if(topic_name->cstring) - { - topic = topic_name->cstring; - topiclen = strlen(topic_name->cstring); - } - else - { - topic = topic_name->lenstring.data; - topiclen = topic_name->lenstring.len; - } - - if(!sublen || !topiclen) - { - *result = 0; - return -1; - } - - if(sublen && topiclen) - { - if((sub[0] == '$' && topic[0] != '$') - || (topic[0] == '$' && sub[0] != '$')) - { - return 0; - } - } - - spos = 0; - tpos = 0; - - while(spos < sublen && tpos <= topiclen) - { - if(sub[spos] == topic[tpos]) - { - if(tpos == topiclen - 1) - { - /* Check for e.g. foo matching foo/# */ - if(spos == sublen - 3 && sub[spos + 1] == '/' && sub[spos + 2] == '#') - { - *result = 1; - multilevel_wildcard = 1; - return 0; - } - } - spos++; - tpos++; - if(spos == sublen && tpos == topiclen) - { - *result = 1; - return 0; - } - else if(tpos == topiclen && spos == sublen - 1 && sub[spos] == '+') - { - if(spos > 0 && sub[spos - 1] != '/') - { - return -1; - } - spos++; - *result = 1; - return 0; - } - } - else - { - if(sub[spos] == '+') - { - /* Check for bad "+foo" or "a/+foo" subscription */ - if(spos > 0 && sub[spos - 1] != '/') - { - return -1; - } - /* Check for bad "foo+" or "foo+/a" subscription */ - if(spos < sublen - 1 && sub[spos + 1] != '/') - { - return -1; - } - spos++; - while(tpos < topiclen && topic[tpos] != '/') - { - tpos++; - } - if(tpos == topiclen && spos == sublen) - { - *result = 1; - return 0; - } - } - else if(sub[spos] == '#') - { - if(spos > 0 && sub[spos - 1] != '/') - { - return -1; - } - multilevel_wildcard = 1; - if(spos + 1 != sublen) - { - return -1; - } - else - { - *result = 1; - return 0; - } - } - else - { - /* Check for e.g. foo/bar matching foo/+/# */ - if(spos > 0 && spos + 2 == sublen && tpos == topiclen - && sub[spos - 1] == '+' && sub[spos] == '/' && sub[spos + 1] == '#') - { - *result = 1; - multilevel_wildcard = 1; - return 0; - } - return 0; - } - } - } - if(multilevel_wildcard == 0 && (tpos < topiclen || spos < sublen)) - { - *result = 0; - } - - return 0; -} - - -int deliverMessage(MQTTClient* c, MQTTString* topicName, MQTTMessage* message) -{ - int i; - int rc = FAILURE; - char match_rst = 0; - - // we have to find the right message handler - indexed by topic - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (c->messageHandlers[i].topicFilter != 0) - { - (void)MQTTTopicMatched((const char *)c->messageHandlers[i].topicFilter, topicName, &match_rst); - if (1 == match_rst && c->messageHandlers[i].fp != NULL) - { - MessageData md; - NewMessageData(&md, topicName, message); - - md.arg = c->messageHandlers[i].arg; ///< --modified,we need a args for the handler - c->messageHandlers[i].fp(&md); - rc = MQTT_SUCCESS; - } - } - } - - if (rc == FAILURE && c->defaultMessageHandler != NULL) - { - MessageData md; - NewMessageData(&md, topicName, message); - c->defaultMessageHandler(&md); - rc = MQTT_SUCCESS; - } - - return rc; -} - - -int keepalive(MQTTClient* c) -{ - int rc = MQTT_SUCCESS; - - if (c->keepAliveInterval == 0) - goto exit; - - ///last_sent)) - { - if (c->ping_outstanding) - rc = FAILURE; /* PINGRESP not received in keepalive interval */ - else - { - Timer timer; - TimerInit(&timer); - TimerCountdownMS(&timer, 1000); - int len = MQTTSerialize_pingreq(c->buf, c->buf_size); - if (len > 0 && (rc = sendPacket(c, len, &timer)) == MQTT_SUCCESS) // send the ping packet - c->ping_outstanding = 1; - } - } - -exit: - return rc; -} - - -void MQTTCleanSession(MQTTClient* c) -{ - int i = 0; - - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - c->messageHandlers[i].topicFilter = NULL; -} - - -void MQTTCloseSession(MQTTClient* c) -{ - c->ping_outstanding = 0; - c->isconnected = 0; - if (c->cleansession) - MQTTCleanSession(c); -} - - -int cycle(MQTTClient* c, Timer* timer) -{ - int len = 0, - rc = MQTT_SUCCESS; - Timer send_timer; - - int packet_type = readPacket(c, timer); /* read the socket, see what work is due */ - - switch (packet_type) - { - default: - /* no more data to read, unrecoverable. Or read packet fails due to unexpected network error */ - rc = packet_type; - goto exit; - case 0: /* timed out reading packet */ - break; - case CONNACK: - case PUBACK: - case SUBACK: - case UNSUBACK: - break; - case PUBLISH: - { - MQTTString topicName; - MQTTMessage msg; - int intQoS; - msg.payloadlen = 0; /* this is a size_t, but deserialize publish sets this as int */ - if (MQTTDeserialize_publish(&msg.dup, &intQoS, &msg.retained, &msg.id, &topicName, - (unsigned char **)&msg.payload, (int *)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1) - goto exit; - msg.qos = (enum QoS)intQoS; - deliverMessage(c, &topicName, &msg); - if (msg.qos != QOS0) - { - if (msg.qos == QOS1) - len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id); - else if (msg.qos == QOS2) - len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id); - if (len <= 0) - rc = FAILURE; - else - { - TimerInit(&send_timer); - TimerCountdownMS(&send_timer, 1000); - rc = sendPacket(c, len, &send_timer); - } - if (rc == FAILURE) - goto exit; // there was a problem - } - break; - } - case PUBREC: - case PUBREL: - { - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) - rc = FAILURE; - else if ((len = MQTTSerialize_ack(c->buf, c->buf_size, - (packet_type == PUBREC) ? PUBREL : PUBCOMP, 0, mypacketid)) <= 0) - rc = FAILURE; - else - { - TimerInit(&send_timer); - TimerCountdownMS(&send_timer, 1000); - rc = sendPacket(c, len, &send_timer); - if(rc != MQTT_SUCCESS) - rc = FAILURE; // there was a problem - } - if (rc == FAILURE) - goto exit; // there was a problem - break; - } - - case PUBCOMP: - break; - case PINGRESP: - c->ping_outstanding = 0; - break; - } - - if (keepalive(c) != MQTT_SUCCESS) - { - //check only keepalive FAILURE status so that previous FAILURE status can be considered as FAULT - rc = FAILURE; - } - -exit: - if (rc == MQTT_SUCCESS) - rc = packet_type; - else if (c->isconnected) - MQTTCloseSession(c); - return rc; -} - - -int MQTTYield(MQTTClient* c, int timeout_ms) -{ - int rc = MQTT_SUCCESS; - Timer timer; - - TimerInit(&timer); - TimerCountdownMS(&timer, timeout_ms); - - do - { -#if defined(MQTT_TASK) - (void)MutexLock(&c->mutex); -#endif - if ( (rc = cycle(c, &timer) ) < 0) - { - rc = FAILURE; -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - break; - } -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - } - while (!TimerIsExpired(&timer)); - - return rc; -} - - -void MQTTRun(void* parm) -{ - Timer timer; - MQTTClient* c = (MQTTClient*)parm; - - TimerInit(&timer); - - while (1) - { -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - TimerCountdownMS(&timer, 500); /* Don't wait too long if no traffic is incoming */ - cycle(c, &timer); -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - } -} - - -//#if defined(MQTT_TASK) -//int MQTTStartTask(MQTTClient* client) -//{ -// return ThreadStart(&client->thread, &MQTTRun, client); -//} -//#endif - - -int waitfor(MQTTClient* c, int packet_type, Timer* timer) -{ - int rc = FAILURE; - - do - { - if (TimerIsExpired(timer)) - break; // we timed out - rc = cycle(c, timer); - } - while (rc != packet_type && rc >= 0); - - return rc; -} - - -int MQTTConnectWithResults(MQTTClient* c, MQTTPacket_connectData* options, MQTTConnackData* data) -{ - Timer connect_timer; - int rc = FAILURE; - MQTTPacket_connectData default_options = MQTTPacket_connectData_initializer; - int len = 0; - -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - if (c->isconnected) /* don't send connect packet again if we are already connected */ - goto exit; - - TimerInit(&connect_timer); - TimerCountdownMS(&connect_timer, c->command_timeout_ms); - - if (options == 0) - options = &default_options; /* set default options if none were supplied */ - - c->keepAliveInterval = options->keepAliveInterval; - c->cleansession = options->cleansession; - TimerCountdown(&c->last_received, c->keepAliveInterval); - if ((len = MQTTSerialize_connect(c->buf, c->buf_size, options)) <= 0) - goto exit; - if ((rc = sendPacket(c, len, &connect_timer)) != MQTT_SUCCESS) // send the connect packet - goto exit; // there was a problem - - // this will be a blocking call, wait for the connack - if (waitfor(c, CONNACK, &connect_timer) == CONNACK) - { - data->rc = 0; - data->sessionPresent = 0; - if (MQTTDeserialize_connack(&data->sessionPresent, &data->rc, c->readbuf, c->readbuf_size) == 1) - rc = data->rc; - else - rc = FAILURE; - } - else - rc = FAILURE; - -exit: - if (rc == MQTT_SUCCESS) - { - c->isconnected = 1; - c->ping_outstanding = 0; - } - -#if defined(MQTT_TASK) - - MutexUnlock(&c->mutex); -#endif - - return rc; -} - - -int MQTTConnect(MQTTClient* c, MQTTPacket_connectData* options) -{ - MQTTConnackData data; - return MQTTConnectWithResults(c, options, &data); -} - - -int MQTTSetMessageHandler(MQTTClient* c, const char* topicFilter, messageHandler messageHandler) -{ - int rc = FAILURE; - int i = -1; - - /* first check for an existing matching slot */ - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (c->messageHandlers[i].topicFilter != NULL && strcmp(c->messageHandlers[i].topicFilter, topicFilter) == 0) - { - if (messageHandler == NULL) /* remove existing */ - { - c->messageHandlers[i].topicFilter = NULL; - c->messageHandlers[i].fp = NULL; - } - rc = MQTT_SUCCESS; /* return i when adding new subscription */ - break; - } - } - /* if no existing, look for empty slot (unless we are removing) */ - if (messageHandler != NULL) - { - if (rc == FAILURE) - { - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (c->messageHandlers[i].topicFilter == NULL) - { - rc = MQTT_SUCCESS; - break; - } - } - } - if (i < MAX_MESSAGE_HANDLERS) - { - c->messageHandlers[i].topicFilter = topicFilter; - c->messageHandlers[i].fp = messageHandler; - } - } - return rc; -} - - -int MQTTSubscribeWithResults(MQTTClient *c, const char *topicFilter, enum QoS qos, - messageHandler messageHandler, MQTTSubackData *data) -{ - int rc = FAILURE; - Timer timer; - int len = 0; - MQTTString topic = MQTTString_initializer; - topic.cstring = (char *)topicFilter; - -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - if (!c->isconnected) - goto exit; - - TimerInit(&timer); - TimerCountdownMS(&timer, c->command_timeout_ms); - - len = MQTTSerialize_subscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic, (int *)&qos); - if (len <= 0) - goto exit; - if ((rc = sendPacket(c, len, &timer)) != MQTT_SUCCESS) // send the subscribe packet - goto exit; // there was a problem - - if (waitfor(c, SUBACK, &timer) == SUBACK) // wait for suback - { - int count = 0; - unsigned short mypacketid; - data->grantedQoS = QOS0; - if (MQTTDeserialize_suback(&mypacketid, 1, &count, (int *)&data->grantedQoS, c->readbuf, c->readbuf_size) == 1) - { - if (data->grantedQoS != 0x80) - rc = MQTTSetMessageHandler(c, topicFilter, messageHandler); - } - } - else - rc = FAILURE; - -exit: - if (rc == FAILURE) - MQTTCloseSession(c); -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - return rc; -} - -static int MQTTSetMessageHandlerArgs(MQTTClient* c, const char* topicFilter, messageHandler messageHandler,void *arg) -{ - int rc = FAILURE; - int i = -1; - - /* first check for an existing matching slot */ - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (c->messageHandlers[i].topicFilter != NULL && strcmp(c->messageHandlers[i].topicFilter, topicFilter) == 0) - { - if (messageHandler == NULL) /* remove existing */ - { - c->messageHandlers[i].topicFilter = NULL; - c->messageHandlers[i].fp = NULL; - c->messageHandlers[i].arg = NULL; - } - rc = MQTT_SUCCESS; /* return i when adding new subscription */ - break; - } - } - /* if no existing, look for empty slot (unless we are removing) */ - if (messageHandler != NULL) - { - if (rc == FAILURE) - { - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (c->messageHandlers[i].topicFilter == NULL) - { - rc = MQTT_SUCCESS; - break; - } - } - } - if (i < MAX_MESSAGE_HANDLERS) - { - c->messageHandlers[i].topicFilter = topicFilter; - c->messageHandlers[i].fp = messageHandler; - c->messageHandlers[i].arg = arg; - - } - } - return rc; -} - - -int MQTTSubscribeWithResultsArgs(MQTTClient *c, const char *topicFilter, enum QoS qos, - messageHandler messageHandler, MQTTSubackData *data,void *arg) -{ - int rc = FAILURE; - Timer timer; - int len = 0; - MQTTString topic = MQTTString_initializer; - topic.cstring = (char *)topicFilter; -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - if (!c->isconnected) - { - goto exit; - } - - TimerInit(&timer); - TimerCountdownMS(&timer, c->command_timeout_ms); - - len = MQTTSerialize_subscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic, (int *)&qos); - if (len <= 0) - { - goto exit; - } - - if ((rc = sendPacket(c, len, &timer)) != MQTT_SUCCESS) // send the subscribe packet - { - goto exit; - } - - if (waitfor(c, SUBACK, &timer) == SUBACK) // wait for suback - { - int count = 0; - unsigned short mypacketid; - data->grantedQoS = QOS0; - if (MQTTDeserialize_suback(&mypacketid, 1, &count, (int *)&data->grantedQoS, c->readbuf, c->readbuf_size) == 1) - { - if (data->grantedQoS != 0x80) - rc = MQTTSetMessageHandlerArgs(c, topicFilter, messageHandler,arg); - } - } - else - rc = FAILURE; - -exit: - if (rc == FAILURE) - { - MQTTCloseSession(c); - } - // MQTTCloseSession(c); -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - return rc; -} - -int MQTTSubscribe(MQTTClient* c, const char* topicFilter, enum QoS qos, - messageHandler messageHandler) -{ - MQTTSubackData data; - return MQTTSubscribeWithResults(c, topicFilter, qos, messageHandler, &data); -} - - -int MQTTUnsubscribe(MQTTClient* c, const char* topicFilter) -{ - int rc = FAILURE; - Timer timer; - MQTTString topic = MQTTString_initializer; - topic.cstring = (char *)topicFilter; - int len = 0; - -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - if (!c->isconnected) - goto exit; - - TimerInit(&timer); - TimerCountdownMS(&timer, c->command_timeout_ms); - - if ((len = MQTTSerialize_unsubscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic)) <= 0) - goto exit; - if ((rc = sendPacket(c, len, &timer)) != MQTT_SUCCESS) // send the subscribe packet - goto exit; // there was a problem - - if (waitfor(c, UNSUBACK, &timer) == UNSUBACK) - { - unsigned short mypacketid; // should be the same as the packetid above - if (MQTTDeserialize_unsuback(&mypacketid, c->readbuf, c->readbuf_size) == 1) - { - /* remove the subscription message handler associated with this topic, if there is one */ - MQTTSetMessageHandler(c, topicFilter, NULL); - } - } - else - rc = FAILURE; - -exit: - if (rc == FAILURE) - MQTTCloseSession(c); -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - return rc; -} - - -int MQTTPublish(MQTTClient* c, const char* topicName, MQTTMessage* message) -{ - int rc = FAILURE; - Timer timer; - MQTTString topic = MQTTString_initializer; - topic.cstring = (char *)topicName; - int len = 0; - -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - if (!c->isconnected) - goto exit; - - TimerInit(&timer); - if(message->qos == QOS2) - TimerCountdownMS(&timer, c->command_timeout_ms * 2); - else - TimerCountdownMS(&timer, c->command_timeout_ms); - - if (message->qos == QOS1 || message->qos == QOS2) - message->id = getNextPacketId(c); - - len = MQTTSerialize_publish(c->buf, c->buf_size, 0, message->qos, message->retained, message->id, - topic, (unsigned char*)message->payload, message->payloadlen); - if (len <= 0) - goto exit; - if ((rc = sendPacket(c, len, &timer)) != MQTT_SUCCESS) // send the subscribe packet - goto exit; // there was a problem - - if (message->qos == QOS1) - { - if (waitfor(c, PUBACK, &timer) == PUBACK) - { - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) - rc = FAILURE; - } - else - rc = FAILURE; - } - else if (message->qos == QOS2) - { - if (waitfor(c, PUBCOMP, &timer) == PUBCOMP) - { - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1) - rc = FAILURE; - } - else - rc = FAILURE; - } - -exit: - if (rc == FAILURE) - MQTTCloseSession(c); -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - return rc; -} - - -int MQTTDisconnect(MQTTClient* c) -{ - int rc = FAILURE; - Timer timer; // we might wait for incomplete incoming publishes to complete - int len = 0; - -#if defined(MQTT_TASK) - MutexLock(&c->mutex); -#endif - TimerInit(&timer); - TimerCountdownMS(&timer, c->command_timeout_ms); - - len = MQTTSerialize_disconnect(c->buf, c->buf_size); - if (len > 0) - rc = sendPacket(c, len, &timer); // send the disconnect packet - MQTTCloseSession(c); - -#if defined(MQTT_TASK) - MutexUnlock(&c->mutex); -#endif - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.h deleted file mode 100644 index 508b8248ab3b087714862b5a52145864a369fe00..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/MQTTClient.h +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander/Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - documentation and platform specific header - * Ian Craggs - add setMessageHandler function - *******************************************************************************/ - -#if !defined(__MQTT_CLIENT_C_) -#define __MQTT_CLIENT_C_ - -#if defined(__cplusplus) - extern "C" { -#endif - -#if defined(WIN32_DLL) || defined(WIN64_DLL) - #define DLLImport __declspec(dllimport) - #define DLLExport __declspec(dllexport) -#elif defined(LINUX_SO) - #define DLLImport extern - #define DLLExport __attribute__ ((visibility ("default"))) -#else - #define DLLImport - #define DLLExport -#endif - -#include "MQTTPacket.h" -#include "stdio.h" - -#if defined(MQTTCLIENT_PLATFORM_HEADER) -/* The following sequence of macros converts the MQTTCLIENT_PLATFORM_HEADER value - * into a string constant suitable for use with include. - */ -#define xstr(s) str(s) -#define str(s) #s -#include xstr(MQTTCLIENT_PLATFORM_HEADER) -#endif - -#define MAX_PACKET_ID 65535 /* according to the MQTT specification - do not change! */ - -#if !defined(MAX_MESSAGE_HANDLERS) -#define MAX_MESSAGE_HANDLERS 10/* redefinable - how many subscriptions do you want? */ -#endif - -enum QoS { QOS0, QOS1, QOS2, SUBFAIL=0x80 }; - -/* all failure return codes must be negative */ -enum returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, MQTT_SUCCESS = 0 }; - -/* The Platform specific header must define the Network and Timer structures and functions - * which operate on them. - * -typedef struct Network -{ - int (*mqttread)(Network*, unsigned char* read_buffer, int, int); - int (*mqttwrite)(Network*, unsigned char* send_buffer, int, int); -} Network;*/ - -/* The Timer structure must be defined in the platform specific header, - * and have the following functions to operate on it. */ -extern void TimerInit(Timer*); -extern char TimerIsExpired(Timer*); -extern void TimerCountdownMS(Timer*, unsigned int); -extern void TimerCountdown(Timer*, unsigned int); -extern int TimerLeftMS(Timer*); - -typedef struct MQTTMessage -{ - enum QoS qos; - unsigned char retained; - unsigned char dup; - unsigned short id; - void *payload; - size_t payloadlen; -} MQTTMessage; - -typedef struct MessageData -{ - MQTTMessage* message; - MQTTString* topicName; - void *arg; -} MessageData; - -typedef struct MQTTConnackData -{ - unsigned char rc; - unsigned char sessionPresent; -} MQTTConnackData; - -typedef struct MQTTSubackData -{ - enum QoS grantedQoS; -} MQTTSubackData; - -typedef void (*messageHandler)(MessageData*); - -typedef struct MQTTClient -{ - unsigned int next_packetid, - command_timeout_ms; - size_t buf_size, - readbuf_size; - unsigned char *buf, - *readbuf; - unsigned int keepAliveInterval; - char ping_outstanding; - int isconnected; - int cleansession; - - struct MessageHandlers - { - const char* topicFilter; - void (*fp) (MessageData*); - void *arg; - } messageHandlers[MAX_MESSAGE_HANDLERS]; /* Message handlers are indexed by subscription topic */ - - void (*defaultMessageHandler) (MessageData*); - - Network* ipstack; - Timer last_sent, last_received; -#if defined(MQTT_TASK) - Mutex mutex; - Thread thread; -#endif -} MQTTClient; - -#define DefaultClient {0, 0, 0, 0, NULL, NULL, 0, 0, 0} - - -/** - * Create an MQTT client object - * @param client - * @param network - * @param command_timeout_ms - * @param - */ -DLLExport int MQTTClientInit(MQTTClient* client, Network* network, unsigned int command_timeout_ms, - unsigned char* sendbuf, size_t sendbuf_size, unsigned char* readbuf, size_t readbuf_size); -DLLExport void MQTTClientDeInit(MQTTClient* c); - -/** MQTT Connect - send an MQTT connect packet down the network and wait for a Connack - * The nework object must be connected to the network endpoint before calling this - * @param options - connect options - * @return success code - */ -DLLExport int MQTTConnectWithResults(MQTTClient* client, MQTTPacket_connectData* options, - MQTTConnackData* data); - -/** MQTT Connect - send an MQTT connect packet down the network and wait for a Connack - * The nework object must be connected to the network endpoint before calling this - * @param options - connect options - * @return success code - */ -DLLExport int MQTTConnect(MQTTClient* client, MQTTPacket_connectData* options); - -/** MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs - * @param client - the client object to use - * @param topic - the topic to publish to - * @param message - the message to send - * @return success code - */ -DLLExport int MQTTPublish(MQTTClient* client, const char*, MQTTMessage*); - -/** MQTT SetMessageHandler - set or remove a per topic message handler - * @param client - the client object to use - * @param topicFilter - the topic filter set the message handler for - * @param messageHandler - pointer to the message handler function or NULL to remove - * @return success code - */ -DLLExport int MQTTSetMessageHandler(MQTTClient* c, const char* topicFilter, messageHandler messageHandler); - -/** MQTT Subscribe - send an MQTT subscribe packet and wait for suback before returning. - * @param client - the client object to use - * @param topicFilter - the topic filter to subscribe to - * @param message - the message to send - * @return success code - */ -DLLExport int MQTTSubscribe(MQTTClient* client, const char* topicFilter, enum QoS, messageHandler); - -/** MQTT Subscribe - send an MQTT subscribe packet and wait for suback before returning. - * @param client - the client object to use - * @param topicFilter - the topic filter to subscribe to - * @param message - the message to send - * @param data - suback granted QoS returned - * @return success code - */ -DLLExport int MQTTSubscribeWithResults(MQTTClient* client, const char* topicFilter, enum QoS, messageHandler, MQTTSubackData* data); - -/** MQTT Subscribe - send an MQTT subscribe packet and wait for suback before returning. - * @param client - the client object to use - * @param topicFilter - the topic filter to subscribe to - * @param message - the message to send - * @param data - suback granted QoS returned - * @param arg - which used for the messageHandler - * @return success code - */ -DLLExport int MQTTSubscribeWithResultsArgs(MQTTClient* client, const char* topicFilter, enum QoS, messageHandler, MQTTSubackData* data,void *args); - - -/** MQTT Subscribe - send an MQTT unsubscribe packet and wait for unsuback before returning. - * @param client - the client object to use - * @param topicFilter - the topic filter to unsubscribe from - * @return success code - */ -DLLExport int MQTTUnsubscribe(MQTTClient* client, const char* topicFilter); - -/** MQTT Disconnect - send an MQTT disconnect packet and close the connection - * @param client - the client object to use - * @return success code - */ -DLLExport int MQTTDisconnect(MQTTClient* client); - -/** MQTT Yield - MQTT background - * @param client - the client object to use - * @param time - the time, in milliseconds, to yield for - * @return success code - */ -DLLExport int MQTTYield(MQTTClient* client, int time); - -/** MQTT isConnected - * @param client - the client object to use - * @return truth value indicating whether the client is connected to the server - */ -static inline DLLExport int MQTTIsConnected(MQTTClient* client) -{ - return client->isconnected; -} -/** MQTT isConnected - * @param client - the client object to use - */ -DLLExport void MQTTClientDeInit(MQTTClient *c); - - -#if defined(MQTT_TASK) -/** MQTT start background thread for a client. After this, MQTTYield should not be called. -* @param client - the client object to use -* @return success code -*/ -DLLExport int MQTTStartTask(MQTTClient* client); -#endif - -#if defined(__cplusplus) - } -#endif - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.c deleted file mode 100644 index ef798cc52a1741aec878b77727f346b2db20a3c1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.c +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTCC3200.h" - -unsigned long MilliTimer; - -void SysTickIntHandler(void) { - MilliTimer++; -} - -char expired(Timer* timer) { - long left = timer->end_time - MilliTimer; - return (left < 0); -} - - -void countdown_ms(Timer* timer, unsigned int timeout) { - timer->end_time = MilliTimer + timeout; -} - - -void countdown(Timer* timer, unsigned int timeout) { - timer->end_time = MilliTimer + (timeout * 1000); -} - - -int left_ms(Timer* timer) { - long left = timer->end_time - MilliTimer; - return (left < 0) ? 0 : left; -} - - -void InitTimer(Timer* timer) { - timer->end_time = 0; -} - - -int cc3200_read(Network* n, unsigned char* buffer, int len, int timeout_ms) { - SlTimeval_t timeVal; - SlFdSet_t fdset; - int rc = 0; - int recvLen = 0; - - SL_FD_ZERO(&fdset); - SL_FD_SET(n->my_socket, &fdset); - - timeVal.tv_sec = 0; - timeVal.tv_usec = timeout_ms * 1000; - if (sl_Select(n->my_socket + 1, &fdset, NULL, NULL, &timeVal) == 1) { - do { - rc = sl_Recv(n->my_socket, buffer + recvLen, len - recvLen, 0); - recvLen += rc; - } while(recvLen < len); - } - return recvLen; -} - - -int cc3200_write(Network* n, unsigned char* buffer, int len, int timeout_ms) { - SlTimeval_t timeVal; - SlFdSet_t fdset; - int rc = 0; - int readySock; - - SL_FD_ZERO(&fdset); - SL_FD_SET(n->my_socket, &fdset); - - timeVal.tv_sec = 0; - timeVal.tv_usec = timeout_ms * 1000; - do { - readySock = sl_Select(n->my_socket + 1, NULL, &fdset, NULL, &timeVal); - } while(readySock != 1); - rc = sl_Send(n->my_socket, buffer, len, 0); - return rc; -} - - -void cc3200_disconnect(Network* n) { - sl_Close(n->my_socket); -} - - -void NewNetwork(Network* n) { - n->my_socket = 0; - n->mqttread = cc3200_read; - n->mqttwrite = cc3200_write; - n->disconnect = cc3200_disconnect; -} - -int TLSConnectNetwork(Network *n, char* addr, int port, SlSockSecureFiles_t* certificates, unsigned char sec_method, unsigned int cipher, char server_verify) { - SlSockAddrIn_t sAddr; - int addrSize; - int retVal; - unsigned long ipAddress; - - retVal = sl_NetAppDnsGetHostByName(addr, strlen(addr), &ipAddress, AF_INET); - if (retVal < 0) { - return -1; - } - - sAddr.sin_family = AF_INET; - sAddr.sin_port = sl_Htons((unsigned short)port); - sAddr.sin_addr.s_addr = sl_Htonl(ipAddress); - - addrSize = sizeof(SlSockAddrIn_t); - - n->my_socket = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET); - if (n->my_socket < 0) { - return -1; - } - - SlSockSecureMethod method; - method.secureMethod = sec_method; - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECMETHOD, &method, sizeof(method)); - if (retVal < 0) { - return retVal; - } - - SlSockSecureMask mask; - mask.secureMask = cipher; - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_MASK, &mask, sizeof(mask)); - if (retVal < 0) { - return retVal; - } - - if (certificates != NULL) { - retVal = sl_SetSockOpt(n->my_socket, SL_SOL_SOCKET, SL_SO_SECURE_FILES, certificates->secureFiles, sizeof(SlSockSecureFiles_t)); - if(retVal < 0) - { - return retVal; - } - } - - retVal = sl_Connect(n->my_socket, ( SlSockAddr_t *)&sAddr, addrSize); - if( retVal < 0 ) { - if (server_verify || retVal != -453) { - sl_Close(n->my_socket); - return retVal; - } - } - - SysTickIntRegister(SysTickIntHandler); - SysTickPeriodSet(80000); - SysTickEnable(); - - return retVal; -} - -int ConnectNetwork(Network* n, char* addr, int port) -{ - SlSockAddrIn_t sAddr; - int addrSize; - int retVal; - unsigned long ipAddress; - - sl_NetAppDnsGetHostByName(addr, strlen(addr), &ipAddress, AF_INET); - - sAddr.sin_family = AF_INET; - sAddr.sin_port = sl_Htons((unsigned short)port); - sAddr.sin_addr.s_addr = sl_Htonl(ipAddress); - - addrSize = sizeof(SlSockAddrIn_t); - - n->my_socket = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0); - if( n->my_socket < 0 ) { - // error - return -1; - } - - retVal = sl_Connect(n->my_socket, ( SlSockAddr_t *)&sAddr, addrSize); - if( retVal < 0 ) { - // error - sl_Close(n->my_socket); - return retVal; - } - - SysTickIntRegister(SysTickIntHandler); - SysTickPeriodSet(80000); - SysTickEnable(); - - return retVal; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.h deleted file mode 100644 index b23eff86d1d0dd3ba21536a93ac2040c9c4bf4f8..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/cc3200/MQTTCC3200.h +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#ifndef __MQTT_CC3200_ -#define __MQTT_CC3200_ - -#include "simplelink.h" -#include "netapp.h" -#include "socket.h" -#include "hw_types.h" -#include "systick.h" - -typedef struct Timer Timer; - -struct Timer { - unsigned long systick_period; - unsigned long end_time; -}; - -typedef struct Network Network; - -struct Network -{ - int my_socket; - int (*mqttread) (Network*, unsigned char*, int, int); - int (*mqttwrite) (Network*, unsigned char*, int, int); - void (*disconnect) (Network*); -}; - -char expired(Timer*); -void countdown_ms(Timer*, unsigned int); -void countdown(Timer*, unsigned int); -int left_ms(Timer*); - -void InitTimer(Timer*); - -int cc3200_read(Network*, unsigned char*, int, int); -int cc3200_write(Network*, unsigned char*, int, int); -void cc3200_disconnect(Network*); -void NewNetwork(Network*); - -int ConnectNetwork(Network*, char*, int); -int TLSConnectNetwork(Network*, char*, int, SlSockSecureFiles_t*, unsigned char, unsigned int, char); - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.c deleted file mode 100644 index 41994c6033d9b747d650d1a9037c72184c03cd2d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.c +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - * Ian Craggs - return codes from linux_read - *******************************************************************************/ - -#include "MQTTLinux.h" - -void TimerInit(Timer* timer) -{ - timer->end_time = (struct timeval){0, 0}; -} - -char TimerIsExpired(Timer* timer) -{ - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&timer->end_time, &now, &res); - return res.tv_sec < 0 || (res.tv_sec == 0 && res.tv_usec <= 0); -} - - -void TimerCountdownMS(Timer* timer, unsigned int timeout) -{ - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {timeout / 1000, (timeout % 1000) * 1000}; - timeradd(&now, &interval, &timer->end_time); -} - - -void TimerCountdown(Timer* timer, unsigned int timeout) -{ - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {timeout, 0}; - timeradd(&now, &interval, &timer->end_time); -} - - -int TimerLeftMS(Timer* timer) -{ - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&timer->end_time, &now, &res); - //printf("left %d ms\n", (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000); - return (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000; -} - - -int linux_read(Network* n, unsigned char* buffer, int len, int timeout_ms) -{ - struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; - if (interval.tv_sec < 0 || (interval.tv_sec == 0 && interval.tv_usec <= 0)) - { - interval.tv_sec = 0; - interval.tv_usec = 100; - } - - setsockopt(n->my_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&interval, sizeof(struct timeval)); - - int bytes = 0; - while (bytes < len) - { - int rc = recv(n->my_socket, &buffer[bytes], (size_t)(len - bytes), 0); - if (rc == -1) - { - if (errno != EAGAIN && errno != EWOULDBLOCK) - bytes = -1; - break; - } - else if (rc == 0) - { - bytes = 0; - break; - } - else - bytes += rc; - } - return bytes; -} - - -int linux_write(Network* n, unsigned char* buffer, int len, int timeout_ms) -{ - struct timeval tv; - - tv.tv_sec = 0; /* 30 Secs Timeout */ - tv.tv_usec = timeout_ms * 1000; // Not init'ing this can cause strange errors - - setsockopt(n->my_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval)); - int rc = write(n->my_socket, buffer, len); - return rc; -} - - -void NetworkInit(Network* n) -{ - n->my_socket = 0; - n->mqttread = linux_read; - n->mqttwrite = linux_write; -} - - -int NetworkConnect(Network* n, char* addr, int port) -{ - int type = SOCK_STREAM; - struct sockaddr_in address; - int rc = -1; - sa_family_t family = AF_INET; - struct addrinfo *result = NULL; - struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL}; - - if ((rc = getaddrinfo(addr, NULL, &hints, &result)) == 0) - { - struct addrinfo* res = result; - - /* prefer ip4 addresses */ - while (res) - { - if (res->ai_family == AF_INET) - { - result = res; - break; - } - res = res->ai_next; - } - - if (result->ai_family == AF_INET) - { - address.sin_port = htons(port); - address.sin_family = family = AF_INET; - address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr; - } - else - rc = -1; - - freeaddrinfo(result); - } - - if (rc == 0) - { - n->my_socket = socket(family, type, 0); - if (n->my_socket != -1) - rc = connect(n->my_socket, (struct sockaddr*)&address, sizeof(address)); - } - - return rc; -} - - -void NetworkDisconnect(Network* n) -{ - close(n->my_socket); -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.h deleted file mode 100644 index fb170a2ecad9e4ba417f1719136b093260b62f08..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/src/linux/MQTTLinux.h +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Allan Stockdill-Mander - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(__MQTT_LINUX_) -#define __MQTT_LINUX_ - -#if defined(WIN32_DLL) || defined(WIN64_DLL) - #define DLLImport __declspec(dllimport) - #define DLLExport __declspec(dllexport) -#elif defined(LINUX_SO) - #define DLLImport extern - #define DLLExport __attribute__ ((visibility ("default"))) -#else - #define DLLImport - #define DLLExport -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -typedef struct Timer -{ - struct timeval end_time; -} Timer; - -void TimerInit(Timer*); -char TimerIsExpired(Timer*); -void TimerCountdownMS(Timer*, unsigned int); -void TimerCountdown(Timer*, unsigned int); -int TimerLeftMS(Timer*); - -typedef struct Network -{ - int my_socket; - int (*mqttread) (struct Network*, unsigned char*, int, int); - int (*mqttwrite) (struct Network*, unsigned char*, int, int); -} Network; - -int linux_read(Network*, unsigned char*, int, int); -int linux_write(Network*, unsigned char*, int, int); - -DLLExport void NetworkInit(Network*); -DLLExport int NetworkConnect(Network*, char*, int); -DLLExport void NetworkDisconnect(Network*); - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/CMakeLists.txt deleted file mode 100644 index 9df121af55f2d87518b057983f4430b452b7a895..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -PROJECT(mqtt-tests) - -SET(MQTT_TEST_BROKER_HOST "localhost" CACHE STRING "Hostname of a test MQTT broker to use") -SET(MQTT_TEST_PROXY_PORT "1884" CACHE STRING "Port of the test proxy to use") -SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use") -SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl) - -ADD_EXECUTABLE( - testc1 - test1.c -) - -target_link_libraries(testc1 paho-embed-mqtt3cc paho-embed-mqtt3c) -target_include_directories(testc1 PRIVATE "../src" "../src/linux") -target_compile_definitions(testc1 PRIVATE MQTTCLIENT_PLATFORM_HEADER=MQTTLinux.h) - -ADD_TEST( - NAME testc1 - COMMAND "testc1" "--host" ${MQTT_TEST_BROKER_HOST} -) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/test1.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/test1.c deleted file mode 100644 index 5a99899298fed8accd025b82eb5dfde93367f28b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient-C/test/test1.c +++ /dev/null @@ -1,1050 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial implementation for embedded C client - *******************************************************************************/ - - -/** - * @file - * Tests for the Paho embedded C "high" level client - */ - - -#include "MQTTClient.h" -#include -#include - -#if !defined(_WINDOWS) - #include - #include - #include - #include -#else - #include - #define setenv(a, b, c) _putenv_s(a, b) -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -void usage(void) -{ - printf("help!!\n"); - exit(EXIT_FAILURE); -} - -struct Options -{ - char* host; /**< connection to system under test. */ - int port; - char* proxy_host; - int proxy_port; - int verbose; - int test_no; - int MQTTVersion; - int iterations; -} options = -{ - "localhost", - 1883, - "localhost", - 1885, - 0, //verbose - 0, //test_no - 4, - 1, -}; - -void getopts(int argc, char** argv) -{ - int count = 1; - - while (count < argc) - { - if (strcmp(argv[count], "--test_no") == 0) - { - if (++count < argc) - options.test_no = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--host") == 0) - { - if (++count < argc) - { - options.host = argv[count]; - printf("\nSetting host to %s\n", options.host); - } - else - usage(); - } - else if (strcmp(argv[count], "--port") == 0) - { - if (++count < argc) - { - options.port = atoi(argv[count]); - printf("\nSetting port to %d\n", options.port); - } - else - usage(); - } - else if (strcmp(argv[count], "--proxy_host") == 0) - { - if (++count < argc) - { - options.proxy_host = argv[count]; - printf("\nSetting proxy_host to %s\n", options.proxy_host); - } - else - usage(); - } - else if (strcmp(argv[count], "--proxy_port") == 0) - { - if (++count < argc) - { - options.proxy_port = atoi(argv[count]); - printf("\nSetting proxy_port to %d\n", options.proxy_port); - } - else - usage(); - } - else if (strcmp(argv[count], "--MQTTversion") == 0) - { - if (++count < argc) - { - options.MQTTVersion = atoi(argv[count]); - printf("setting MQTT version to %d\n", options.MQTTVersion); - } - else - usage(); - } - else if (strcmp(argv[count], "--iterations") == 0) - { - if (++count < argc) - options.iterations = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--verbose") == 0) - { - options.verbose = 1; - printf("\nSetting verbose on\n"); - } - count++; - } -} - - -#define LOGA_DEBUG 0 -#define LOGA_INFO 1 -#include -#include -#include -void MyLog(int LOGA_level, char* format, ...) -{ - static char msg_buf[256]; - va_list args; - struct timeb ts; - - struct tm *timeinfo; - - if (LOGA_level == LOGA_DEBUG && options.verbose == 0) - return; - - ftime(&ts); - timeinfo = localtime(&ts.time); - strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo); - - sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm); - - va_start(args, format); - vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args); - va_end(args); - - printf("%s\n", msg_buf); - fflush(stdout); -} - - -#if defined(WIN32) || defined(_WINDOWS) -#define mqsleep(A) Sleep(1000*A) -#define START_TIME_TYPE DWORD -static DWORD start_time = 0; -START_TIME_TYPE start_clock(void) -{ - return GetTickCount(); -} -#elif defined(AIX) -#define mqsleep sleep -#define START_TIME_TYPE struct timespec -START_TIME_TYPE start_clock(void) -{ - static struct timespec start; - clock_gettime(CLOCK_REALTIME, &start); - return start; -} -#else -#define mqsleep sleep -#define START_TIME_TYPE struct timeval -/* TODO - unused - remove? static struct timeval start_time; */ -START_TIME_TYPE start_clock(void) -{ - struct timeval start_time; - gettimeofday(&start_time, NULL); - return start_time; -} -#endif - - -#if defined(WIN32) -long elapsed(START_TIME_TYPE start_time) -{ - return GetTickCount() - start_time; -} -#elif defined(AIX) -#define assert(a) -long elapsed(struct timespec start) -{ - struct timespec now, res; - - clock_gettime(CLOCK_REALTIME, &now); - ntimersub(now, start, res); - return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L; -} -#else -long elapsed(START_TIME_TYPE start_time) -{ - struct timeval now, res; - - gettimeofday(&now, NULL); - timersub(&now, &start_time, &res); - return (res.tv_sec)*1000 + (res.tv_usec)/1000; -} -#endif - - -#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d) -#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e) - -int tests = 0; -int failures = 0; -FILE* xml; -START_TIME_TYPE global_start_time; -char output[3000]; -char* cur_output = output; - - -void write_test_result(void) -{ - long duration = elapsed(global_start_time); - - fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000); - if (cur_output != output) - { - fprintf(xml, "%s", output); - cur_output = output; - } - fprintf(xml, "\n"); -} - - -void myassert(char* filename, int lineno, char* description, int value, char* format, ...) -{ - ++tests; - if (!value) - { - va_list args; - - ++failures; - MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description); - - va_start(args, format); - vprintf(format, args); - va_end(args); - - cur_output += sprintf(cur_output, "file %s, line %d \n", - description, filename, lineno); - } - else - MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description); -} - - -static volatile MessageData* test1_message_data = NULL; -static MQTTMessage pubmsg; - -void messageArrived(MessageData* md) -{ - test1_message_data = md; - MQTTMessage* m = md->message; - - assert("Good message lengths", pubmsg.payloadlen == m->payloadlen, - "payloadlen was %d", m->payloadlen); - - if (pubmsg.payloadlen == m->payloadlen) - assert("Good message contents", memcmp(m->payload, pubmsg.payload, m->payloadlen) == 0, - "payload was %s", m->payload); -} - - -/********************************************************************* - -Test1: single-threaded client - -*********************************************************************/ -void test1_sendAndReceive(MQTTClient* c, int qos, char* test_topic) -{ - char* topicName = NULL; - int topicLen; - int i = 0; - int iterations = 50; - int rc; - int wait_seconds; - - MyLog(LOGA_DEBUG, "%d messages at QoS %d", iterations, qos); - memset(&pubmsg, '\0', sizeof(pubmsg)); - pubmsg.payload = "a much longer message that we can shorten to the extent that we need to payload up to 11"; - pubmsg.payloadlen = 11; - pubmsg.qos = qos; - pubmsg.retained = 0; - pubmsg.dup = 0; - - for (i = 0; i < iterations; ++i) - { - test1_message_data = NULL; - rc = MQTTPublish(c, test_topic, &pubmsg); - assert("Good rc from publish", rc == SUCCESS, "rc was %d", rc); - - /* wait for the message to be received */ - wait_seconds = 10; - while ((test1_message_data == NULL) && (wait_seconds-- > 0)) - { - MQTTYield(c, 100); - } - assert("Message Arrived", wait_seconds > 0, "Time out waiting for message %d\n", i); - - if (!test1_message_data) - printf("No message received within timeout period\n"); - } - - /* wait to receive any outstanding messages */ - wait_seconds = 2; - while (wait_seconds-- > 0) - { - MQTTYield(c, 1000); - } -} - - -int test1(struct Options options) -{ - int subsqos = 2; - Network n; - MQTTClient c; - int rc = 0; - char* test_topic = "C client test1"; - MQTTPacket_willOptions wopts; - unsigned char buf[100]; - unsigned char readbuf[100]; - - printf("test1\n"); - fprintf(xml, "message; - - assert("Good message lengths", pubmsg.payloadlen == m->payloadlen, - "payloadlen was %d", m->payloadlen); - - if (pubmsg.payloadlen == m->payloadlen) - assert("Good message contents", memcmp(m->payload, pubmsg.payload, m->payloadlen) == 0, - "payload was %s", m->payload); -} - - -int check_subs_exist(MQTTClient* c, const char* test_topic, int which) -{ - int rc = FAILURE; - int wait_seconds = 0; - - memset(&pubmsg, '\0', sizeof(pubmsg)); - pubmsg.payload = (void*)"a much longer message that we can shorten to the extent that we need to payload up to 11"; - pubmsg.payloadlen = 11; - pubmsg.qos = QOS2; - pubmsg.retained = 0; - pubmsg.dup = 0; - - test1_message_data = test2_message_data = NULL; - rc = MQTTPublish(c, test_topic, &pubmsg); - assert("Good rc from publish", rc == SUCCESS, "rc was %d", rc); - - /* wait for the message to be received */ - wait_seconds = 10; - while (wait_seconds-- > 0) - { - MQTTYield(c, 100); - } - - rc = (((which == 1 || which == 3) && test1_message_data) || - (which == 2 && test1_message_data == NULL)) ? SUCCESS : FAILURE; - assert("test1 subscription", rc == SUCCESS, "test1_message_data %p\n", - test1_message_data); - rc = (((which == 2 || which == 3) && test2_message_data) || - (which == 1 && test2_message_data == NULL)) ? SUCCESS : FAILURE; - assert("test2 subscription", rc == SUCCESS, "test2_message_data %p\n", - test2_message_data); - return rc; -} - - -int test3(struct Options options) -{ - enum QoS subsqos = QOS2; - Network n; - MQTTClient c; - int rc; - const char* test_topic = "C client test3"; - int wait_seconds = 0; - unsigned char buf[100]; - unsigned char readbuf[100]; - MQTTConnackData connack; - MQTTSubackData suback; - - fprintf(xml, " 0)) - { - MQTTYield(&c, 1000); - } - assert("Disconnected", !MQTTIsConnected(&c), "isConnected was %d", - MQTTIsConnected(&c)); - NetworkDisconnect(&n); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = NetworkConnect(&n, options.host, options.port); - assert("TCP connect successful", rc == SUCCESS, "rc was %d", rc); - rc = MQTTConnectWithResults(&c, &data, &connack); - assert("Connect successful", rc == SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 1", connack.sessionPresent == 1, - "sessionPresent was %d", connack.sessionPresent); - - check_subs_exist(&c, test_topic, 1); - - rc = MQTTSubscribeWithResults(&c, test_topic, subsqos, messageArrived2, &suback); - assert("Good rc from subscribe", rc == SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(&c, test_topic, 2); - - rc = MQTTDisconnect(&c); - assert("Disconnect successful", rc == SUCCESS, "rc was %d", rc); - NetworkDisconnect(&n); - - /* reconnect with cleansession true to clean up both server and client state */ - data.cleansession = 1; - rc = NetworkConnect(&n, options.host, options.port); - assert("TCP connect successful", rc == SUCCESS, "rc was %d", rc); - rc = MQTTConnectWithResults(&c, &data, &connack); - assert("Connect successful", rc == SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - rc = MQTTSubscribeWithResults(&c, test_topic, subsqos, messageArrived2, &suback); - assert("Good rc from subscribe", rc == SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(&c, test_topic, 2); - - rc = MQTTDisconnect(&c); - assert("Disconnect successful", rc == SUCCESS, "rc was %d", rc); - NetworkDisconnect(&n); - -exit: - MyLog(LOGA_INFO, "TEST2: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - -#if 0 -/********************************************************************* - -Test 4: connectionLost and will message - -*********************************************************************/ -MQTTClient test6_c1, test6_c2; -volatile int test6_will_message_arrived = 0; -volatile int test6_connection_lost_called = 0; - -void test6_connectionLost(void* context, char* cause) -{ - MQTTClient c = (MQTTClient)context; - printf("%s -> Callback: connection lost\n", (c == test6_c1) ? "Client-1" : "Client-2"); - test6_connection_lost_called = 1; -} - -void test6_deliveryComplete(void* context, MQTTClient_deliveryToken token) -{ - printf("Client-2 -> Callback: publish complete for token %d\n", token); -} - -char* test6_will_topic = "C Test 2: will topic"; -char* test6_will_message = "will message from Client-1"; - -int test6_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m) -{ - MQTTClient c = (MQTTClient)context; - printf("%s -> Callback: message received on topic '%s' is '%.*s'.\n", - (c == test6_c1) ? "Client-1" : "Client-2", topicName, m->payloadlen, (char*)(m->payload)); - if (c == test6_c2 && strcmp(topicName, test6_will_topic) == 0 && memcmp(m->payload, test6_will_message, m->payloadlen) == 0) - test6_will_message_arrived = 1; - MQTTClient_free(topicName); - MQTTClient_freeMessage(&m); - return 1; -} - - -int test6(struct Options options) -{ - char* testname = "test6"; - MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer; - MQTTClient_willOptions wopts = MQTTClient_willOptions_initializer; - MQTTClient_connectOptions opts2 = MQTTClient_connectOptions_initializer; - int rc, count; - char* mqttsas_topic = "MQTTSAS topic"; - - failures = 0; - MyLog(LOGA_INFO, "Starting test 6 - connectionLost and will messages"); - fprintf(xml, "message = test6_will_message; - opts.will->qos = 1; - opts.will->retained = 0; - opts.will->topicName = test6_will_topic; - if (options.haconnections != NULL) - { - opts.serverURIs = options.haconnections; - opts.serverURIcount = options.hacount; - } - - /* Client-1 with Will options */ - rc = MQTTClient_create(&test6_c1, options.proxy_connection, "Client_1", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - rc = MQTTClient_setCallbacks(test6_c1, (void*)test6_c1, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Connect to the broker */ - rc = MQTTClient_connect(test6_c1, &opts); - assert("good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Client - 2 (multi-threaded) */ - rc = MQTTClient_create(&test6_c2, options.connection, "Client_2", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Set the callback functions for the client */ - rc = MQTTClient_setCallbacks(test6_c2, (void*)test6_c2, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Connect to the broker */ - opts2.keepAliveInterval = 20; - opts2.cleansession = 1; - MyLog(LOGA_INFO, "Connecting Client_2 ..."); - rc = MQTTClient_connect(test6_c2, &opts2); - assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - rc = MQTTClient_subscribe(test6_c2, test6_will_topic, 2); - assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* now send the command which will break the connection and cause the will message to be sent */ - rc = MQTTClient_publish(test6_c1, mqttsas_topic, (int)strlen("TERMINATE"), "TERMINATE", 0, 0, NULL); - assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - MyLog(LOGA_INFO, "Waiting to receive the will message"); - count = 0; - while (++count < 40) - { - #if defined(WIN32) - Sleep(1000L); - #else - sleep(1); - #endif - if (test6_will_message_arrived == 1 && test6_connection_lost_called == 1) - break; - } - assert("will message arrived", test6_will_message_arrived == 1, - "will_message_arrived was %d\n", test6_will_message_arrived); - assert("connection lost called", test6_connection_lost_called == 1, - "connection_lost_called %d\n", test6_connection_lost_called); - - rc = MQTTClient_unsubscribe(test6_c2, test6_will_topic); - assert("Good rc from unsubscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - rc = MQTTClient_isConnected(test6_c2); - assert("Client-2 still connected", rc == 1, "isconnected is %d", rc); - - rc = MQTTClient_isConnected(test6_c1); - assert("Client-1 not connected", rc == 0, "isconnected is %d", rc); - - rc = MQTTClient_disconnect(test6_c2, 100L); - assert("Good rc from disconnect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - MQTTClient_destroy(&test6_c1); - MQTTClient_destroy(&test6_c2); - -exit: - MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.\n", - (failures == 0) ? "passed" : "failed", testname, tests, failures); - write_test_result(); - return failures; -} - - -int test6a(struct Options options) -{ - char* testname = "test6a"; - MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer; - MQTTClient_willOptions wopts = MQTTClient_willOptions_initializer; - MQTTClient_connectOptions opts2 = MQTTClient_connectOptions_initializer; - int rc, count; - char* mqttsas_topic = "MQTTSAS topic"; - - failures = 0; - MyLog(LOGA_INFO, "Starting test 6 - connectionLost and binary will messages"); - fprintf(xml, "payload.data = test6_will_message; - opts.will->payload.len = strlen(test6_will_message) + 1; - opts.will->qos = 1; - opts.will->retained = 0; - opts.will->topicName = test6_will_topic; - if (options.haconnections != NULL) - { - opts.serverURIs = options.haconnections; - opts.serverURIcount = options.hacount; - } - - /* Client-1 with Will options */ - rc = MQTTClient_create(&test6_c1, options.proxy_connection, "Client_1", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - rc = MQTTClient_setCallbacks(test6_c1, (void*)test6_c1, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Connect to the broker */ - rc = MQTTClient_connect(test6_c1, &opts); - assert("good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Client - 2 (multi-threaded) */ - rc = MQTTClient_create(&test6_c2, options.connection, "Client_2", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Set the callback functions for the client */ - rc = MQTTClient_setCallbacks(test6_c2, (void*)test6_c2, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Connect to the broker */ - opts2.keepAliveInterval = 20; - opts2.cleansession = 1; - MyLog(LOGA_INFO, "Connecting Client_2 ..."); - rc = MQTTClient_connect(test6_c2, &opts2); - assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - rc = MQTTClient_subscribe(test6_c2, test6_will_topic, 2); - assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* now send the command which will break the connection and cause the will message to be sent */ - rc = MQTTClient_publish(test6_c1, mqttsas_topic, (int)strlen("TERMINATE"), "TERMINATE", 0, 0, NULL); - assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - MyLog(LOGA_INFO, "Waiting to receive the will message"); - count = 0; - while (++count < 40) - { - #if defined(WIN32) - Sleep(1000L); - #else - sleep(1); - #endif - if (test6_will_message_arrived == 1 && test6_connection_lost_called == 1) - break; - } - assert("will message arrived", test6_will_message_arrived == 1, - "will_message_arrived was %d\n", test6_will_message_arrived); - assert("connection lost called", test6_connection_lost_called == 1, - "connection_lost_called %d\n", test6_connection_lost_called); - - rc = MQTTClient_unsubscribe(test6_c2, test6_will_topic); - assert("Good rc from unsubscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - rc = MQTTClient_isConnected(test6_c2); - assert("Client-2 still connected", rc == 1, "isconnected is %d", rc); - - rc = MQTTClient_isConnected(test6_c1); - assert("Client-1 not connected", rc == 0, "isconnected is %d", rc); - - rc = MQTTClient_disconnect(test6_c2, 100L); - assert("Good rc from disconnect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - MQTTClient_destroy(&test6_c1); - MQTTClient_destroy(&test6_c2); - -exit: - MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.\n", - (failures == 0) ? "passed" : "failed", testname, tests, failures); - write_test_result(); - return failures; -} -#endif - -int main(int argc, char** argv) -{ - int rc = 0; - int (*tests[])() = {NULL, test1, test2, test3}; - int i; - - xml = fopen("TEST-test1.xml", "w"); - fprintf(xml, "\n", (int)(ARRAY_SIZE(tests) - 1)); - - getopts(argc, argv); - - for (i = 0; i < options.iterations; ++i) - { - if (options.test_no == 0) - { /* run all the tests */ - for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no) - rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */ - } - else - rc = tests[options.test_no](options); /* run just the selected test */ - } - - if (rc == 0) - MyLog(LOGA_INFO, "verdict pass"); - else - MyLog(LOGA_INFO, "verdict fail"); - - fprintf(xml, "\n"); - fclose(xml); - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/CMakeLists.txt deleted file mode 100644 index 524c86f8f3087b765c3af4e7d69a5789a1fd29ff..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -project("paho-mqttclient" C) - -#ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(samples) -ADD_SUBDIRECTORY(test) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/CMakeLists.txt deleted file mode 100644 index 1cd6aac4b1bbafea1feee635e87143b28513e044..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -ADD_SUBDIRECTORY(linux) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/arduino/Hello/Hello.ino b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/arduino/Hello/Hello.ino deleted file mode 100644 index 60893e1dbe72d78b192d34e63c8dd3deb511b2f0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/arduino/Hello/Hello.ino +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. and others - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial contribution - * Benjamin Cabe - adapt to IPStack, and add Yun instructions - *******************************************************************************/ - -#define MQTTCLIENT_QOS2 1 - -#include -#include -#include -#include -#include - -char printbuf[100]; - -int arrivedcount = 0; - -void messageArrived(MQTT::MessageData& md) -{ - MQTT::Message &message = md.message; - - sprintf(printbuf, "Message %d arrived: qos %d, retained %d, dup %d, packetid %d\n", - ++arrivedcount, message.qos, message.retained, message.dup, message.id); - Serial.print(printbuf); - sprintf(printbuf, "Payload %s\n", (char*)message.payload); - Serial.print(printbuf); -} - -EthernetClient c; // replace by a YunClient if running on a Yun -IPStack ipstack(c); -MQTT::Client client = MQTT::Client(ipstack); - -byte mac[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; // replace with your device's MAC -const char* topic = "arduino-sample"; - -void connect() -{ - char hostname[] = "iot.eclipse.org"; - int port = 1883; - sprintf(printbuf, "Connecting to %s:%d\n", hostname, port); - Serial.print(printbuf); - int rc = ipstack.connect(hostname, port); - if (rc != 1) - { - sprintf(printbuf, "rc from TCP connect is %d\n", rc); - Serial.print(printbuf); - } - - Serial.println("MQTT connecting"); - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.MQTTVersion = 3; - data.clientID.cstring = (char*)"arduino-sample"; - rc = client.connect(data); - if (rc != 0) - { - sprintf(printbuf, "rc from MQTT connect is %d\n", rc); - Serial.print(printbuf); - } - Serial.println("MQTT connected"); - - rc = client.subscribe(topic, MQTT::QOS2, messageArrived); - if (rc != 0) - { - sprintf(printbuf, "rc from MQTT subscribe is %d\n", rc); - Serial.print(printbuf); - } - Serial.println("MQTT subscribed"); -} - -void setup() -{ - Serial.begin(9600); - Ethernet.begin(mac); // replace by Bridge.begin() if running on a Yun - Serial.println("MQTT Hello example"); - connect(); -} - -void loop() -{ - if (!client.isConnected()) - connect(); - - MQTT::Message message; - - arrivedcount = 0; - - // Send and receive QoS 0 message - char buf[100]; - sprintf(buf, "Hello World! QoS 0 message"); - Serial.println(buf); - message.qos = MQTT::QOS0; - message.retained = false; - message.dup = false; - message.payload = (void*)buf; - message.payloadlen = strlen(buf)+1; - int rc = client.publish(topic, message); - while (arrivedcount == 0) - client.yield(1000); - - // Send and receive QoS 1 message - sprintf(buf, "Hello World! QoS 1 message"); - Serial.println(buf); - message.qos = MQTT::QOS1; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, message); - while (arrivedcount == 1) - client.yield(1000); - - // Send and receive QoS 2 message - sprintf(buf, "Hello World! QoS 2 message"); - Serial.println(buf); - message.qos = MQTT::QOS2; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, message); - while (arrivedcount == 2) - client.yield(1000); - - delay(2000); -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/CMakeLists.txt deleted file mode 100644 index c037a92284360f94fc93ba862369f0a4e897a0f0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -# Samples - -add_executable( - hello - hello.cpp -) -target_include_directories(hello PRIVATE "../../src" "../../src/linux") -target_link_libraries(hello MQTTPacketClient) - -add_executable( - stdoutsub - stdoutsub.cpp -) -target_include_directories(stdoutsub PRIVATE "../../src" "../../src/linux") -target_link_libraries(stdoutsub paho-embed-mqtt3c) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/build.sh b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/build.sh deleted file mode 100644 index 08099ec4b7dade0b73c5fc2b4dde227320578b7b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -g++ hello.cpp -I ../../src/ -I ../../src/linux -I ../../../MQTTPacket/src ../../../MQTTPacket/src/MQTTPacket.c ../../../MQTTPacket/src/MQTTDeserializePublish.c ../../../MQTTPacket/src/MQTTConnectClient.c ../../../MQTTPacket/src/MQTTSubscribeClient.c ../../../MQTTPacket/src/MQTTSerializePublish.c ../../../MQTTPacket/src/MQTTUnsubscribeClient.c -o hello - -g++ -g stdoutsub.cpp -I ../../src -I ../../src/linux -I ../../../MQTTPacket/src ../../../MQTTPacket/src/MQTTFormat.c ../../../MQTTPacket/src/MQTTPacket.c ../../../MQTTPacket/src/MQTTDeserializePublish.c ../../../MQTTPacket/src/MQTTConnectClient.c ../../../MQTTPacket/src/MQTTSubscribeClient.c ../../../MQTTPacket/src/MQTTSerializePublish.c -o stdoutsub ../../../MQTTPacket/src/MQTTConnectServer.c ../../../MQTTPacket/src/MQTTSubscribeServer.c ../../../MQTTPacket/src/MQTTUnsubscribeServer.c ../../../MQTTPacket/src/MQTTUnsubscribeClient.c diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/hello.cpp b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/hello.cpp deleted file mode 100644 index 0c139ef06c4016c195dae8848b3f9c1e406225e4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/hello.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#define MQTTCLIENT_QOS2 1 - -#include - -#include "MQTTClient.h" - -#define DEFAULT_STACK_SIZE -1 - -#include "linux.cpp" - -int arrivedcount = 0; - -void messageArrived(MQTT::MessageData& md) -{ - MQTT::Message &message = md.message; - - printf("Message %d arrived: qos %d, retained %d, dup %d, packetid %d\n", - ++arrivedcount, message.qos, message.retained, message.dup, message.id); - printf("Payload %.*s\n", (int)message.payloadlen, (char*)message.payload); -} - - -int main(int argc, char* argv[]) -{ - IPStack ipstack = IPStack(); - float version = 0.3; - const char* topic = "mbed-sample"; - - printf("Version is %f\n", version); - - MQTT::Client client = MQTT::Client(ipstack); - - const char* hostname = "iot.eclipse.org"; - int port = 1883; - printf("Connecting to %s:%d\n", hostname, port); - int rc = ipstack.connect(hostname, port); - if (rc != 0) - printf("rc from TCP connect is %d\n", rc); - - printf("MQTT connecting\n"); - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.MQTTVersion = 3; - data.clientID.cstring = (char*)"mbed-icraggs"; - rc = client.connect(data); - if (rc != 0) - printf("rc from MQTT connect is %d\n", rc); - printf("MQTT connected\n"); - - rc = client.subscribe(topic, MQTT::QOS2, messageArrived); - if (rc != 0) - printf("rc from MQTT subscribe is %d\n", rc); - - MQTT::Message message; - - // QoS 0 - char buf[100]; - sprintf(buf, "Hello World! QoS 0 message from app version %f", version); - message.qos = MQTT::QOS0; - message.retained = false; - message.dup = false; - message.payload = (void*)buf; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, message); - if (rc != 0) - printf("Error %d from sending QoS 0 message\n", rc); - else while (arrivedcount == 0) - client.yield(100); - - // QoS 1 - printf("Now QoS 1\n"); - sprintf(buf, "Hello World! QoS 1 message from app version %f", version); - message.qos = MQTT::QOS1; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, message); - if (rc != 0) - printf("Error %d from sending QoS 1 message\n", rc); - else while (arrivedcount == 1) - client.yield(100); - - // QoS 2 - sprintf(buf, "Hello World! QoS 2 message from app version %f", version); - message.qos = MQTT::QOS2; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, message); - if (rc != 0) - printf("Error %d from sending QoS 2 message\n", rc); - while (arrivedcount == 2) - client.yield(100); - - rc = client.unsubscribe(topic); - if (rc != 0) - printf("rc from unsubscribe was %d\n", rc); - - rc = client.disconnect(); - if (rc != 0) - printf("rc from disconnect was %d\n", rc); - - ipstack.disconnect(); - - printf("Finishing with %d messages received\n", arrivedcount); - - return 0; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/main.cpp b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/main.cpp deleted file mode 100644 index b91d86db74b0ac4afa308a313c83a8bb50f95c03..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/main.cpp +++ /dev/null @@ -1,291 +0,0 @@ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "MQTTClient.h" -//#include "FP.cpp" - -#define DEFAULT_STACK_SIZE -1 - - -class IPStack -{ -public: - IPStack() - { - - } - - int Socket_error(const char* aString) - { - - if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK) - { - if (strcmp(aString, "shutdown") != 0 || (errno != ENOTCONN && errno != ECONNRESET)) - printf("Socket error %s in %s for socket %d\n", strerror(errno), aString, mysock); - } - return errno; - } - - int connect(const char* hostname, int port) - { - int type = SOCK_STREAM; - struct sockaddr_in address; - int rc = -1; - sa_family_t family = AF_INET; - struct addrinfo *result = NULL; - struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL}; - - if ((rc = getaddrinfo(hostname, NULL, &hints, &result)) == 0) - { - struct addrinfo* res = result; - - /* prefer ip4 addresses */ - while (res) - { - if (res->ai_family == AF_INET) - { - result = res; - break; - } - res = res->ai_next; - } - - if (result->ai_family == AF_INET) - { - address.sin_port = htons(port); - address.sin_family = family = AF_INET; - address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr; - } - else - rc = -1; - - freeaddrinfo(result); - } - - if (rc == 0) - { - mysock = socket(family, type, 0); - if (mysock != -1) - { - int opt = 1; - - //if (setsockopt(mysock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) - // printf("Could not set SO_NOSIGPIPE for socket %d", mysock); - - rc = ::connect(mysock, (struct sockaddr*)&address, sizeof(address)); - } - } - - return rc; - } - - int read(unsigned char* buffer, int len, int timeout_ms) - { - struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; - if (interval.tv_sec < 0 || (interval.tv_sec == 0 && interval.tv_usec <= 0)) - { - interval.tv_sec = 0; - interval.tv_usec = 100; - } - - setsockopt(mysock, SOL_SOCKET, SO_RCVTIMEO, (char *)&interval, sizeof(struct timeval)); - - //printf("reading %d bytes\n", len); - int rc = ::recv(mysock, buffer, (size_t)len, 0); - if (rc == -1) - Socket_error("read"); - //printf("read %d bytes\n", rc); - return rc; - } - - int write(unsigned char* buffer, int len, int timeout) - { - struct timeval tv; - - tv.tv_sec = 0; /* 30 Secs Timeout */ - tv.tv_usec = timeout * 1000; // Not init'ing this can cause strange errors - - setsockopt(mysock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); - int rc = ::write(mysock, buffer, len); - //printf("write rc %d\n", rc); - return rc; - } - - int disconnect() - { - return ::close(mysock); - } - -private: - - int mysock; - -}; - - -class Countdown -{ -public: - Countdown() - { - - } - - Countdown(int ms) - { - countdown_ms(ms); - } - - - bool expired() - { - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&end_time, &now, &res); - //printf("left %d ms\n", (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000); - //if (res.tv_sec > 0 || res.tv_usec > 0) - // printf("expired %d %d\n", res.tv_sec, res.tv_usec); - return res.tv_sec < 0 || (res.tv_sec == 0 && res.tv_usec <= 0); - } - - - void countdown_ms(int ms) - { - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {ms / 1000, (ms % 1000) * 1000}; - //printf("interval %d %d\n", interval.tv_sec, interval.tv_usec); - timeradd(&now, &interval, &end_time); - } - - - void countdown(int seconds) - { - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {seconds, 0}; - timeradd(&now, &interval, &end_time); - } - - - int left_ms() - { - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&end_time, &now, &res); - //printf("left %d ms\n", (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000); - return (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000; - } - -private: - - struct timeval end_time; -}; - - -int arrivedcount = 0; - -void messageArrived(MQTT::MessageData& md) -{ - MQTT::Message &message = md.message; - - printf("Message %d arrived: qos %d, retained %d, dup %d, packetid %d\n", - ++arrivedcount, message.qos, message.retained, message.dup, message.id); - printf("Payload %.*s\n", message.payloadlen, (char*)message.payload); -} - - -int main(int argc, char* argv[]) -{ - IPStack ipstack = IPStack(); - float version = 0.3; - const char* topic = "mbed-sample"; - - printf("Version is %f\n", version); - - MQTT::Client client = MQTT::Client(ipstack); - - const char* hostname = "localhost"; //"m2m.eclipse.org"; - int port = 1883; - printf("Connecting to %s:%d\n", hostname, port); - int rc = ipstack.connect(hostname, port); - if (rc != 0) - printf("rc from TCP connect is %d\n", rc); - - printf("MQTT connecting\n"); - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.MQTTVersion = 3; - data.clientID.cstring = (char*)"mbed-icraggs"; - rc = client.connect(&data); - if (rc != 0) - printf("rc from MQTT connect is %d\n", rc); - printf("MQTT connected\n"); - - rc = client.subscribe("+", MQTT::QOS2, messageArrived); - if (rc != 0) - printf("rc from MQTT subscribe is %d\n", rc); - - MQTT::Message message; - - // QoS 0 - char buf[100]; - sprintf(buf, "Hello World! QoS 0 message from app version %f", version); - message.qos = MQTT::QOS0; - message.retained = false; - message.dup = false; - message.payload = (void*)buf; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, &message); - while (arrivedcount == 0) - client.yield(100); - - // QoS 1 - printf("Now QoS 1\n"); - sprintf(buf, "Hello World! QoS 1 message from app version %f", version); - message.qos = MQTT::QOS1; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, &message); - while (arrivedcount == 1) - client.yield(100); - - // QoS 2 - sprintf(buf, "Hello World! QoS 2 message from app version %f", version); - message.qos = MQTT::QOS2; - message.payloadlen = strlen(buf)+1; - rc = client.publish(topic, &message); - while (arrivedcount == 2) - client.yield(100); - - rc = client.unsubscribe(topic); - if (rc != 0) - printf("rc from unsubscribe was %d\n", rc); - - rc = client.disconnect(); - if (rc != 0) - printf("rc from disconnect was %d\n", rc); - - ipstack.disconnect(); - - printf("Finishing with %d messages received\n", arrivedcount); - - return 0; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/stdoutsub.cpp b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/stdoutsub.cpp deleted file mode 100644 index 2e56cc298abf217aeab5640f5095c19ddf48e344..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/samples/linux/stdoutsub.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial contribution - * Ian Craggs - change delimiter option from char to string - *******************************************************************************/ - -/* - - stdout subscriber - - compulsory parameters: - - topic to subscribe to - - defaulted parameters: - - --host localhost - --port 1883 - --qos 2 - --delimiter \n - --clientid stdout_subscriber - - --userid none - --password none - -*/ -#include -#include -#define MQTT_DEBUG 1 -#include "MQTTClient.h" - -#define DEFAULT_STACK_SIZE -1 - -#include "linux.cpp" - -#include -#include -#include - - -volatile int toStop = 0; - - -void usage() -{ - printf("MQTT stdout subscriber\n"); - printf("Usage: stdoutsub topicname , where options are:\n"); - printf(" --host (default is localhost)\n"); - printf(" --port (default is 1883)\n"); - printf(" --qos (default is 2)\n"); - printf(" --delimiter (default is \\n)\n"); - printf(" --clientid (default is hostname+timestamp)\n"); - printf(" --username none\n"); - printf(" --password none\n"); - printf(" --showtopics (default is on if the topic has a wildcard, else off)\n"); - exit(-1); -} - - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - - -struct opts_struct -{ - char* clientid; - int nodelimiter; - char* delimiter; - MQTT::QoS qos; - char* username; - char* password; - char* host; - int port; - int showtopics; -} opts = -{ - (char*)"stdout-subscriber", 0, (char*)"\n", MQTT::QOS2, NULL, NULL, (char*)"localhost", 1883, 0 -}; - - -void getopts(int argc, char** argv) -{ - int count = 2; - - while (count < argc) - { - if (strcmp(argv[count], "--qos") == 0) - { - if (++count < argc) - { - if (strcmp(argv[count], "0") == 0) - opts.qos = MQTT::QOS0; - else if (strcmp(argv[count], "1") == 0) - opts.qos = MQTT::QOS1; - else if (strcmp(argv[count], "2") == 0) - opts.qos = MQTT::QOS2; - else - usage(); - } - else - usage(); - } - else if (strcmp(argv[count], "--host") == 0) - { - if (++count < argc) - opts.host = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--port") == 0) - { - if (++count < argc) - opts.port = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--clientid") == 0) - { - if (++count < argc) - opts.clientid = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--username") == 0) - { - if (++count < argc) - opts.username = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--password") == 0) - { - if (++count < argc) - opts.password = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--delimiter") == 0) - { - if (++count < argc) - opts.delimiter = argv[count]; - else - opts.nodelimiter = 1; - } - else if (strcmp(argv[count], "--showtopics") == 0) - { - if (++count < argc) - { - if (strcmp(argv[count], "on") == 0) - opts.showtopics = 1; - else if (strcmp(argv[count], "off") == 0) - opts.showtopics = 0; - else - usage(); - } - else - usage(); - } - count++; - } - -} - - -void myconnect(IPStack& ipstack, MQTT::Client& client, MQTTPacket_connectData& data) -{ - printf("Connecting to %s:%d\n", opts.host, opts.port); - int rc = ipstack.connect(opts.host, opts.port); - if (rc != 0) - printf("rc from TCP connect is %d\n", rc); - - rc = client.connect(data); - if (rc != 0) - { - printf("Failed to connect, return code %d\n", rc); - exit(-1); - } - printf("Connected\n"); -} - - -void messageArrived(MQTT::MessageData& md) -{ - MQTT::Message &message = md.message; - - if (opts.showtopics) - printf("%.*s\t", md.topicName.lenstring.len, md.topicName.lenstring.data); - if (opts.nodelimiter) - printf("%.*s", (int)message.payloadlen, (char*)message.payload); - else - printf("%.*s%s", (int)message.payloadlen, (char*)message.payload, opts.delimiter); - fflush(stdout); -} - - -int main(int argc, char** argv) -{ - int rc = 0; - - if (argc < 2) - usage(); - - char* topic = argv[1]; - - if (strchr(topic, '#') || strchr(topic, '+')) - opts.showtopics = 1; - if (opts.showtopics) - printf("topic is %s\n", topic); - - getopts(argc, argv); - - IPStack ipstack = IPStack(); - MQTT::Client client = MQTT::Client(ipstack); - - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); - - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.willFlag = 0; - data.MQTTVersion = 3; - data.clientID.cstring = opts.clientid; - data.username.cstring = opts.username; - data.password.cstring = opts.password; - - data.keepAliveInterval = 10; - data.cleansession = 1; - printf("will flag %d\n", data.willFlag); - - myconnect(ipstack, client, data); - - rc = client.subscribe(topic, opts.qos, messageArrived); - printf("Subscribed %d\n", rc); - - while (!toStop) - { - client.yield(1000); - - //if (!client.isconnected) - // myconnect(ipstack, client, data); - } - - printf("Stopping\n"); - - rc = client.disconnect(); - - ipstack.disconnect(); - - return 0; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/FP.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/FP.h deleted file mode 100644 index 84331826db0ec156e4ba8f867c3f24dd55231f61..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/FP.h +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Sam Grove - initial API and implementation and/or initial documentation - * Ian Craggs - added attached and detached member functions - * Sam Grove - removed need for FP.cpp - *******************************************************************************/ - -#ifndef FP_H -#define FP_H - -/** Example using the FP Class with global functions - * @code - * #include "mbed.h" - * #include "FP.h" - * - * FPfp; - * DigitalOut myled(LED1); - * - * void handler(bool value) - * { - * myled = value; - * return; - * } - * - * int main() - * { - * fp.attach(&handler); - * - * while(1) - * { - * fp(1); - * wait(0.2); - * fp(0); - * wait(0.2); - * } - * } - * @endcode - */ - -/** Example using the FP Class with different class member functions - * @code - * #include "mbed.h" - * #include "FP.h" - * - * FPfp; - * DigitalOut myled(LED4); - * - * class Wrapper - * { - * public: - * Wrapper(){} - * - * void handler(bool value) - * { - * myled = value; - * return; - * } - * }; - * - * int main() - * { - * Wrapper wrapped; - * fp.attach(&wrapped, &Wrapper::handler); - * - * while(1) - * { - * fp(1); - * wait(0.2); - * fp(0); - * wait(0.2); - * } - * } - * @endcode - */ - -/** Example using the FP Class with member FP and member function -* @code -* #include "mbed.h" -* #include "FP.h" -* -* DigitalOut myled(LED2); -* -* class Wrapper -* { -* public: -* Wrapper() -* { -* fp.attach(this, &Wrapper::handler); -* } -* -* void handler(bool value) -* { -* myled = value; -* return; -* } -* -* FPfp; -* }; -* -* int main() -* { -* Wrapper wrapped; -* -* while(1) -* { -* wrapped.fp(1); -* wait(0.2); -* wrapped.fp(0); -* wait(0.2); -* } -* } -* @endcode -*/ - -/** - * @class FP - * @brief API for managing Function Pointers - */ -template -class FP -{ -public: - /** Create the FP object - only one callback can be attached to the object, that is - * a member function or a global function, not both at the same time - */ - FP() - { - obj_callback = 0; - c_callback = 0; - } - - /** Add a callback function to the object - * @param item - Address of the initialized object - * @param member - Address of the member function (dont forget the scope that the function is defined in) - */ - template - void attach(T *item, retT (T::*method)(argT)) - { - obj_callback = (FPtrDummy *)(item); - method_callback = (retT (FPtrDummy::*)(argT))(method); - return; - } - - /** Add a callback function to the object - * @param function - The address of a globally defined function - */ - void attach(retT (*function)(argT)) - { - c_callback = function; - } - - /** Invoke the function attached to the class - * @param arg - An argument that is passed into the function handler that is called - * @return The return from the function hanlder called by this class - */ - retT operator()(argT arg) const - { - if( 0 != c_callback ) { - return obj_callback ? (obj_callback->*method_callback)(arg) : (*c_callback)(arg); - } - return (retT)0; - } - - /** Determine if an callback is currently hooked - * @return 1 if a method is hooked, 0 otherwise - */ - bool attached() - { - return obj_callback || c_callback; - } - - /** Release a function from the callback hook - */ - void detach() - { - obj_callback = 0; - c_callback = 0; - } - -private: - - // empty type used for casting - class FPtrDummy; - - FPtrDummy *obj_callback; - - /** - * @union Funciton - * @brief Member or global callback function - */ - union { - retT (*c_callback)(argT); /*!< Footprint for a global function */ - retT (FPtrDummy::*method_callback)(argT); /*!< Footprint for a member function */ - }; -}; - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTClient.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTClient.h deleted file mode 100644 index d76616939fb94eaa6778fb6e8a31ec19fca813f1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTClient.h +++ /dev/null @@ -1,1046 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - fix for bug 458512 - QoS 2 messages - * Ian Craggs - fix for bug 460389 - send loop uses wrong length - * Ian Craggs - fix for bug 464169 - clearing subscriptions - * Ian Craggs - fix for bug 464551 - enums and ints can be different size - * Mark Sonnentag - fix for bug 475204 - inefficient instantiation of Timer - * Ian Craggs - fix for bug 475749 - packetid modified twice - * Ian Craggs - add ability to set message handler separately #6 - *******************************************************************************/ - -#if !defined(MQTTCLIENT_H) -#define MQTTCLIENT_H - -#include "FP.h" -#include "MQTTPacket.h" -#include -#include "MQTTLogging.h" - -#if !defined(MQTTCLIENT_QOS1) - #define MQTTCLIENT_QOS1 1 -#endif -#if !defined(MQTTCLIENT_QOS2) - #define MQTTCLIENT_QOS2 0 -#endif - -namespace MQTT -{ - - -enum QoS { QOS0, QOS1, QOS2 }; - -// all failure return codes must be negative -enum returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESS = 0 }; - - -struct Message -{ - enum QoS qos; - bool retained; - bool dup; - unsigned short id; - void *payload; - size_t payloadlen; -}; - - -struct MessageData -{ - MessageData(MQTTString &aTopicName, struct Message &aMessage) : message(aMessage), topicName(aTopicName) - { } - - struct Message &message; - MQTTString &topicName; -}; - - -struct connackData -{ - int rc; - bool sessionPresent; -}; - - -struct subackData -{ - int grantedQoS; -}; - - -class PacketId -{ -public: - PacketId() - { - next = 0; - } - - int getNext() - { - return next = (next == MAX_PACKET_ID) ? 1 : next + 1; - } - -private: - static const int MAX_PACKET_ID = 65535; - int next; -}; - - -/** - * @class Client - * @brief blocking, non-threaded MQTT client API - * - * This version of the API blocks on all method calls, until they are complete. This means that only one - * MQTT request can be in process at any one time. - * @param Network a network class which supports send, receive - * @param Timer a timer class with the methods: - */ -template -class Client -{ - -public: - - typedef void (*messageHandler)(MessageData&); - - /** Construct the client - * @param network - pointer to an instance of the Network class - must be connected to the endpoint - * before calling MQTT connect - * @param limits an instance of the Limit class - to alter limits as required - */ - Client(Network& network, unsigned int command_timeout_ms = 30000); - - /** Set the default message handling callback - used for any message which does not match a subscription message handler - * @param mh - pointer to the callback function. Set to 0 to remove. - */ - void setDefaultMessageHandler(messageHandler mh) - { - if (mh != 0) - defaultMessageHandler.attach(mh); - else - defaultMessageHandler.detach(); - } - - /** Set a message handling callback. This can be used outside of the the subscribe method. - * @param topicFilter - a topic pattern which can include wildcards - * @param mh - pointer to the callback function. If 0, removes the callback if any - */ - int setMessageHandler(const char* topicFilter, messageHandler mh); - - /** MQTT Connect - send an MQTT connect packet down the network and wait for a Connack - * The nework object must be connected to the network endpoint before calling this - * Default connect options are used - * @return success code - - */ - int connect(); - - /** MQTT Connect - send an MQTT connect packet down the network and wait for a Connack - * The nework object must be connected to the network endpoint before calling this - * @param options - connect options - * @return success code - - */ - int connect(MQTTPacket_connectData& options); - - /** MQTT Connect - send an MQTT connect packet down the network and wait for a Connack - * The nework object must be connected to the network endpoint before calling this - * @param options - connect options - * @param connackData - connack data to be returned - * @return success code - - */ - int connect(MQTTPacket_connectData& options, connackData& data); - - /** MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs - * @param topic - the topic to publish to - * @param message - the message to send - * @return success code - - */ - int publish(const char* topicName, Message& message); - - /** MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs - * @param topic - the topic to publish to - * @param payload - the data to send - * @param payloadlen - the length of the data - * @param qos - the QoS to send the publish at - * @param retained - whether the message should be retained - * @return success code - - */ - int publish(const char* topicName, void* payload, size_t payloadlen, enum QoS qos = QOS0, bool retained = false); - - /** MQTT Publish - send an MQTT publish packet and wait for all acks to complete for all QoSs - * @param topic - the topic to publish to - * @param payload - the data to send - * @param payloadlen - the length of the data - * @param id - the packet id used - returned - * @param qos - the QoS to send the publish at - * @param retained - whether the message should be retained - * @return success code - - */ - int publish(const char* topicName, void* payload, size_t payloadlen, unsigned short& id, enum QoS qos = QOS1, bool retained = false); - - /** MQTT Subscribe - send an MQTT subscribe packet and wait for the suback - * @param topicFilter - a topic pattern which can include wildcards - * @param qos - the MQTT QoS to subscribe at - * @param mh - the callback function to be invoked when a message is received for this subscription - * @return success code - - */ - int subscribe(const char* topicFilter, enum QoS qos, messageHandler mh); - - /** MQTT Subscribe - send an MQTT subscribe packet and wait for the suback - * @param topicFilter - a topic pattern which can include wildcards - * @param qos - the MQTT QoS to subscribe at© - * @param mh - the callback function to be invoked when a message is received for this subscription - * @param - * @return success code - - */ - int subscribe(const char* topicFilter, enum QoS qos, messageHandler mh, subackData &data); - - /** MQTT Unsubscribe - send an MQTT unsubscribe packet and wait for the unsuback - * @param topicFilter - a topic pattern which can include wildcards - * @return success code - - */ - int unsubscribe(const char* topicFilter); - - /** MQTT Disconnect - send an MQTT disconnect packet, and clean up any state - * @return success code - - */ - int disconnect(); - - /** A call to this API must be made within the keepAlive interval to keep the MQTT connection alive - * yield can be called if no other MQTT operation is needed. This will also allow messages to be - * received. - * @param timeout_ms the time to wait, in milliseconds - * @return success code - on failure, this means the client has disconnected - */ - int yield(unsigned long timeout_ms = 1000L); - - /** Is the client connected? - * @return flag - is the client connected or not? - */ - bool isConnected() - { - return isconnected; - } - -private: - - void closeSession(); - void cleanSession(); - int cycle(Timer& timer); - int waitfor(int packet_type, Timer& timer); - int keepalive(); - int publish(int len, Timer& timer, enum QoS qos); - - int decodePacket(int* value, int timeout); - int readPacket(Timer& timer); - int sendPacket(int length, Timer& timer); - int deliverMessage(MQTTString& topicName, Message& message); - bool isTopicMatched(char* topicFilter, MQTTString& topicName); - - Network& ipstack; - unsigned long command_timeout_ms; - - unsigned char sendbuf[MAX_MQTT_PACKET_SIZE]; - unsigned char readbuf[MAX_MQTT_PACKET_SIZE]; - - Timer last_sent, last_received; - unsigned int keepAliveInterval; - bool ping_outstanding; - bool cleansession; - - PacketId packetid; - - struct MessageHandlers - { - const char* topicFilter; - FP fp; - } messageHandlers[MAX_MESSAGE_HANDLERS]; // Message handlers are indexed by subscription topic - - FP defaultMessageHandler; - - bool isconnected; - -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - unsigned char pubbuf[MAX_MQTT_PACKET_SIZE]; // store the last publish for sending on reconnect - int inflightLen; - unsigned short inflightMsgid; - enum QoS inflightQoS; -#endif - -#if MQTTCLIENT_QOS2 - bool pubrel; - #if !defined(MAX_INCOMING_QOS2_MESSAGES) - #define MAX_INCOMING_QOS2_MESSAGES 10 - #endif - unsigned short incomingQoS2messages[MAX_INCOMING_QOS2_MESSAGES]; - bool isQoS2msgidFree(unsigned short id); - bool useQoS2msgid(unsigned short id); - void freeQoS2msgid(unsigned short id); -#endif - -}; - -} - - -template -void MQTT::Client::cleanSession() -{ - for (int i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - messageHandlers[i].topicFilter = 0; - -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - inflightMsgid = 0; - inflightQoS = QOS0; -#endif - -#if MQTTCLIENT_QOS2 - pubrel = false; - for (int i = 0; i < MAX_INCOMING_QOS2_MESSAGES; ++i) - incomingQoS2messages[i] = 0; -#endif -} - - -template -void MQTT::Client::closeSession() -{ - ping_outstanding = false; - isconnected = false; - if (cleansession) - cleanSession(); -} - - -template -MQTT::Client::Client(Network& network, unsigned int command_timeout_ms) : ipstack(network), packetid() -{ - this->command_timeout_ms = command_timeout_ms; - cleansession = true; - closeSession(); -} - - -#if MQTTCLIENT_QOS2 -template -bool MQTT::Client::isQoS2msgidFree(unsigned short id) -{ - for (int i = 0; i < MAX_INCOMING_QOS2_MESSAGES; ++i) - { - if (incomingQoS2messages[i] == id) - return false; - } - return true; -} - - -template -bool MQTT::Client::useQoS2msgid(unsigned short id) -{ - for (int i = 0; i < MAX_INCOMING_QOS2_MESSAGES; ++i) - { - if (incomingQoS2messages[i] == 0) - { - incomingQoS2messages[i] = id; - return true; - } - } - return false; -} - - -template -void MQTT::Client::freeQoS2msgid(unsigned short id) -{ - for (int i = 0; i < MAX_INCOMING_QOS2_MESSAGES; ++i) - { - if (incomingQoS2messages[i] == id) - { - incomingQoS2messages[i] = 0; - return; - } - } -} -#endif - - -template -int MQTT::Client::sendPacket(int length, Timer& timer) -{ - int rc = FAILURE, - sent = 0; - - while (sent < length && !timer.expired()) - { - rc = ipstack.write(&sendbuf[sent], length - sent, timer.left_ms()); - if (rc < 0) // there was an error writing the data - break; - sent += rc; - } - if (sent == length) - { - if (this->keepAliveInterval > 0) - last_sent.countdown(this->keepAliveInterval); // record the fact that we have successfully sent the packet - rc = SUCCESS; - } - else - rc = FAILURE; - -#if defined(MQTT_DEBUG) - char printbuf[150]; - DEBUG("Rc %d from sending packet %s\n", rc, MQTTFormat_toServerString(printbuf, sizeof(printbuf), sendbuf, length)); -#endif - return rc; -} - - -template -int MQTT::Client::decodePacket(int* value, int timeout) -{ - unsigned char c; - int multiplier = 1; - int len = 0; - const int MAX_NO_OF_REMAINING_LENGTH_BYTES = 4; - - *value = 0; - do - { - int rc = MQTTPACKET_READ_ERROR; - - if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES) - { - rc = MQTTPACKET_READ_ERROR; /* bad data */ - goto exit; - } - rc = ipstack.read(&c, 1, timeout); - if (rc != 1) - goto exit; - *value += (c & 127) * multiplier; - multiplier *= 128; - } while ((c & 128) != 0); -exit: - return len; -} - - -/** - * If any read fails in this method, then we should disconnect from the network, as on reconnect - * the packets can be retried. - * @param timeout the max time to wait for the packet read to complete, in milliseconds - * @return the MQTT packet type, 0 if none, -1 if error - */ -template -int MQTT::Client::readPacket(Timer& timer) -{ - int rc = FAILURE; - MQTTHeader header = {0}; - int len = 0; - int rem_len = 0; - - /* 1. read the header byte. This has the packet type in it */ - rc = ipstack.read(readbuf, 1, timer.left_ms()); - if (rc != 1) - goto exit; - - len = 1; - /* 2. read the remaining length. This is variable in itself */ - decodePacket(&rem_len, timer.left_ms()); - len += MQTTPacket_encode(readbuf + 1, rem_len); /* put the original remaining length into the buffer */ - - if (rem_len > (MAX_MQTT_PACKET_SIZE - len)) - { - rc = BUFFER_OVERFLOW; - goto exit; - } - - /* 3. read the rest of the buffer using a callback to supply the rest of the data */ - if (rem_len > 0 && (ipstack.read(readbuf + len, rem_len, timer.left_ms()) != rem_len)) - goto exit; - - header.byte = readbuf[0]; - rc = header.bits.type; - if (this->keepAliveInterval > 0) - last_received.countdown(this->keepAliveInterval); // record the fact that we have successfully received a packet -exit: - -#if defined(MQTT_DEBUG) - if (rc >= 0) - { - char printbuf[50]; - DEBUG("Rc %d from receiving packet %s\n", rc, - MQTTFormat_toClientString(printbuf, sizeof(printbuf), readbuf, len)); - } -#endif - return rc; -} - - -// assume topic filter and name is in correct format -// # can only be at end -// + and # can only be next to separator -template -bool MQTT::Client::isTopicMatched(char* topicFilter, MQTTString& topicName) -{ - char* curf = topicFilter; - char* curn = topicName.lenstring.data; - char* curn_end = curn + topicName.lenstring.len; - - while (*curf && curn < curn_end) - { - if (*curn == '/' && *curf != '/') - break; - if (*curf != '+' && *curf != '#' && *curf != *curn) - break; - if (*curf == '+') - { // skip until we meet the next separator, or end of string - char* nextpos = curn + 1; - while (nextpos < curn_end && *nextpos != '/') - nextpos = ++curn + 1; - } - else if (*curf == '#') - curn = curn_end - 1; // skip until end of string - curf++; - curn++; - }; - - return (curn == curn_end) && (*curf == '\0'); -} - - - -template -int MQTT::Client::deliverMessage(MQTTString& topicName, Message& message) -{ - int rc = FAILURE; - - // we have to find the right message handler - indexed by topic - for (int i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (messageHandlers[i].topicFilter != 0 && (MQTTPacket_equals(&topicName, (char*)messageHandlers[i].topicFilter) || - isTopicMatched((char*)messageHandlers[i].topicFilter, topicName))) - { - if (messageHandlers[i].fp.attached()) - { - MessageData md(topicName, message); - messageHandlers[i].fp(md); - rc = SUCCESS; - } - } - } - - if (rc == FAILURE && defaultMessageHandler.attached()) - { - MessageData md(topicName, message); - defaultMessageHandler(md); - rc = SUCCESS; - } - - return rc; -} - - - -template -int MQTT::Client::yield(unsigned long timeout_ms) -{ - int rc = SUCCESS; - Timer timer; - - timer.countdown_ms(timeout_ms); - while (!timer.expired()) - { - if (cycle(timer) < 0) - { - rc = FAILURE; - break; - } - } - - return rc; -} - - -template -int MQTT::Client::cycle(Timer& timer) -{ - // get one piece of work off the wire and one pass through - int len = 0, - rc = SUCCESS; - - int packet_type = readPacket(timer); // read the socket, see what work is due - - switch (packet_type) - { - default: - // no more data to read, unrecoverable. Or read packet fails due to unexpected network error - rc = packet_type; - goto exit; - case 0: // timed out reading packet - break; - case CONNACK: - case PUBACK: - case SUBACK: - break; - case PUBLISH: - { - MQTTString topicName = MQTTString_initializer; - Message msg; - int intQoS; - msg.payloadlen = 0; /* this is a size_t, but deserialize publish sets this as int */ - if (MQTTDeserialize_publish((unsigned char*)&msg.dup, &intQoS, (unsigned char*)&msg.retained, (unsigned short*)&msg.id, &topicName, - (unsigned char**)&msg.payload, (int*)&msg.payloadlen, readbuf, MAX_MQTT_PACKET_SIZE) != 1) - goto exit; - msg.qos = (enum QoS)intQoS; -#if MQTTCLIENT_QOS2 - if (msg.qos != QOS2) -#endif - deliverMessage(topicName, msg); -#if MQTTCLIENT_QOS2 - else if (isQoS2msgidFree(msg.id)) - { - if (useQoS2msgid(msg.id)) - deliverMessage(topicName, msg); - else - WARN("Maximum number of incoming QoS2 messages exceeded"); - } -#endif -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - if (msg.qos != QOS0) - { - if (msg.qos == QOS1) - len = MQTTSerialize_ack(sendbuf, MAX_MQTT_PACKET_SIZE, PUBACK, 0, msg.id); - else if (msg.qos == QOS2) - len = MQTTSerialize_ack(sendbuf, MAX_MQTT_PACKET_SIZE, PUBREC, 0, msg.id); - if (len <= 0) - rc = FAILURE; - else - rc = sendPacket(len, timer); - if (rc == FAILURE) - goto exit; // there was a problem - } - break; -#endif - } -#if MQTTCLIENT_QOS2 - case PUBREC: - case PUBREL: - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1) - rc = FAILURE; - else if ((len = MQTTSerialize_ack(sendbuf, MAX_MQTT_PACKET_SIZE, - (packet_type == PUBREC) ? PUBREL : PUBCOMP, 0, mypacketid)) <= 0) - rc = FAILURE; - else if ((rc = sendPacket(len, timer)) != SUCCESS) // send the PUBREL packet - rc = FAILURE; // there was a problem - if (rc == FAILURE) - goto exit; // there was a problem - if (packet_type == PUBREL) - freeQoS2msgid(mypacketid); - break; - - case PUBCOMP: - break; -#endif - case PINGRESP: - ping_outstanding = false; - break; - } - - if (keepalive() != SUCCESS) - //check only keepalive FAILURE status so that previous FAILURE status can be considered as FAULT - rc = FAILURE; - -exit: - if (rc == SUCCESS) - rc = packet_type; - else if (isconnected) - closeSession(); - return rc; -} - - -template -int MQTT::Client::keepalive() -{ - int rc = SUCCESS; - - if (keepAliveInterval == 0) - goto exit; - - if (last_sent.expired() || last_received.expired()) - { - if (ping_outstanding) - { - rc = FAILURE; // session failure - #if defined(MQTT_DEBUG) - char printbuf[150]; - DEBUG("PINGRESP not received in keepalive interval\n"); - #endif - } - else - { - Timer timer(1000); - int len = MQTTSerialize_pingreq(sendbuf, MAX_MQTT_PACKET_SIZE); - if (len > 0 && (rc = sendPacket(len, timer)) == SUCCESS) // send the ping packet - ping_outstanding = true; - } - } - -exit: - return rc; -} - - -// only used in single-threaded mode where one command at a time is in process -template -int MQTT::Client::waitfor(int packet_type, Timer& timer) -{ - int rc = FAILURE; - - do - { - if (timer.expired()) - break; // we timed out - rc = cycle(timer); - } - while (rc != packet_type && rc >= 0); - - return rc; -} - - -template -int MQTT::Client::connect(MQTTPacket_connectData& options, connackData& data) -{ - Timer connect_timer(command_timeout_ms); - int rc = FAILURE; - int len = 0; - - if (isconnected) // don't send connect packet again if we are already connected - goto exit; - - this->keepAliveInterval = options.keepAliveInterval; - this->cleansession = options.cleansession; - if ((len = MQTTSerialize_connect(sendbuf, MAX_MQTT_PACKET_SIZE, &options)) <= 0) - goto exit; - if ((rc = sendPacket(len, connect_timer)) != SUCCESS) // send the connect packet - goto exit; // there was a problem - - if (this->keepAliveInterval > 0) - last_received.countdown(this->keepAliveInterval); - // this will be a blocking call, wait for the connack - if (waitfor(CONNACK, connect_timer) == CONNACK) - { - data.rc = 0; - data.sessionPresent = false; - if (MQTTDeserialize_connack((unsigned char*)&data.sessionPresent, - (unsigned char*)&data.rc, readbuf, MAX_MQTT_PACKET_SIZE) == 1) - rc = data.rc; - else - rc = FAILURE; - } - else - rc = FAILURE; - -#if MQTTCLIENT_QOS2 - // resend any inflight publish - if (inflightMsgid > 0 && inflightQoS == QOS2 && pubrel) - { - if ((len = MQTTSerialize_ack(sendbuf, MAX_MQTT_PACKET_SIZE, PUBREL, 0, inflightMsgid)) <= 0) - rc = FAILURE; - else - rc = publish(len, connect_timer, inflightQoS); - } - else -#endif -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - if (inflightMsgid > 0) - { - memcpy(sendbuf, pubbuf, MAX_MQTT_PACKET_SIZE); - rc = publish(inflightLen, connect_timer, inflightQoS); - } -#endif - -exit: - if (rc == SUCCESS) - { - isconnected = true; - ping_outstanding = false; - } - return rc; -} - - -template -int MQTT::Client::connect(MQTTPacket_connectData& options) -{ - connackData data; - return connect(options, data); -} - - -template -int MQTT::Client::connect() -{ - MQTTPacket_connectData default_options = MQTTPacket_connectData_initializer; - return connect(default_options); -} - - -template -int MQTT::Client::setMessageHandler(const char* topicFilter, messageHandler messageHandler) -{ - int rc = FAILURE; - int i = -1; - - // first check for an existing matching slot - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (messageHandlers[i].topicFilter != 0 && strcmp(messageHandlers[i].topicFilter, topicFilter) == 0) - { - if (messageHandler == 0) // remove existing - { - messageHandlers[i].topicFilter = 0; - messageHandlers[i].fp.detach(); - } - rc = SUCCESS; // return i when adding new subscription - break; - } - } - // if no existing, look for empty slot (unless we are removing) - if (messageHandler != 0) { - if (rc == FAILURE) - { - for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i) - { - if (messageHandlers[i].topicFilter == 0) - { - rc = SUCCESS; - break; - } - } - } - if (i < MAX_MESSAGE_HANDLERS) - { - messageHandlers[i].topicFilter = topicFilter; - messageHandlers[i].fp.attach(messageHandler); - } - } - return rc; -} - - -template -int MQTT::Client::subscribe(const char* topicFilter, - enum QoS qos, messageHandler messageHandler, subackData& data) -{ - int rc = FAILURE; - Timer timer(command_timeout_ms); - int len = 0; - MQTTString topic = {(char*)topicFilter, {0, 0}}; - - if (!isconnected) - goto exit; - - len = MQTTSerialize_subscribe(sendbuf, MAX_MQTT_PACKET_SIZE, 0, packetid.getNext(), 1, &topic, (int*)&qos); - if (len <= 0) - goto exit; - if ((rc = sendPacket(len, timer)) != SUCCESS) // send the subscribe packet - goto exit; // there was a problem - - if (waitfor(SUBACK, timer) == SUBACK) // wait for suback - { - int count = 0; - unsigned short mypacketid; - data.grantedQoS = 0; - if (MQTTDeserialize_suback(&mypacketid, 1, &count, &data.grantedQoS, readbuf, MAX_MQTT_PACKET_SIZE) == 1) - { - if (data.grantedQoS != 0x80) - rc = setMessageHandler(topicFilter, messageHandler); - } - } - else - rc = FAILURE; - -exit: - if (rc == FAILURE) - closeSession(); - return rc; -} - - -template -int MQTT::Client::subscribe(const char* topicFilter, enum QoS qos, messageHandler messageHandler) -{ - subackData data; - return subscribe(topicFilter, qos, messageHandler, data); -} - - -template -int MQTT::Client::unsubscribe(const char* topicFilter) -{ - int rc = FAILURE; - Timer timer(command_timeout_ms); - MQTTString topic = {(char*)topicFilter, {0, 0}}; - int len = 0; - - if (!isconnected) - goto exit; - - if ((len = MQTTSerialize_unsubscribe(sendbuf, MAX_MQTT_PACKET_SIZE, 0, packetid.getNext(), 1, &topic)) <= 0) - goto exit; - if ((rc = sendPacket(len, timer)) != SUCCESS) // send the unsubscribe packet - goto exit; // there was a problem - - if (waitfor(UNSUBACK, timer) == UNSUBACK) - { - unsigned short mypacketid; // should be the same as the packetid above - if (MQTTDeserialize_unsuback(&mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) == 1) - { - // remove the subscription message handler associated with this topic, if there is one - setMessageHandler(topicFilter, 0); - } - } - else - rc = FAILURE; - -exit: - if (rc != SUCCESS) - closeSession(); - return rc; -} - - -template -int MQTT::Client::publish(int len, Timer& timer, enum QoS qos) -{ - int rc; - - if ((rc = sendPacket(len, timer)) != SUCCESS) // send the publish packet - goto exit; // there was a problem - -#if MQTTCLIENT_QOS1 - if (qos == QOS1) - { - if (waitfor(PUBACK, timer) == PUBACK) - { - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1) - rc = FAILURE; - else if (inflightMsgid == mypacketid) - inflightMsgid = 0; - } - else - rc = FAILURE; - } -#endif -#if MQTTCLIENT_QOS2 - else if (qos == QOS2) - { - if (waitfor(PUBCOMP, timer) == PUBCOMP) - { - unsigned short mypacketid; - unsigned char dup, type; - if (MQTTDeserialize_ack(&type, &dup, &mypacketid, readbuf, MAX_MQTT_PACKET_SIZE) != 1) - rc = FAILURE; - else if (inflightMsgid == mypacketid) - inflightMsgid = 0; - } - else - rc = FAILURE; - } -#endif - -exit: - if (rc != SUCCESS) - closeSession(); - return rc; -} - - - -template -int MQTT::Client::publish(const char* topicName, void* payload, size_t payloadlen, unsigned short& id, enum QoS qos, bool retained) -{ - int rc = FAILURE; - Timer timer(command_timeout_ms); - MQTTString topicString = MQTTString_initializer; - int len = 0; - - if (!isconnected) - goto exit; - - topicString.cstring = (char*)topicName; - -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - if (qos == QOS1 || qos == QOS2) - id = packetid.getNext(); -#endif - - len = MQTTSerialize_publish(sendbuf, MAX_MQTT_PACKET_SIZE, 0, qos, retained, id, - topicString, (unsigned char*)payload, payloadlen); - if (len <= 0) - goto exit; - -#if MQTTCLIENT_QOS1 || MQTTCLIENT_QOS2 - if (!cleansession) - { - memcpy(pubbuf, sendbuf, len); - inflightMsgid = id; - inflightLen = len; - inflightQoS = qos; -#if MQTTCLIENT_QOS2 - pubrel = false; -#endif - } -#endif - - rc = publish(len, timer, qos); -exit: - return rc; -} - - -template -int MQTT::Client::publish(const char* topicName, void* payload, size_t payloadlen, enum QoS qos, bool retained) -{ - unsigned short id = 0; // dummy - not used for anything - return publish(topicName, payload, payloadlen, id, qos, retained); -} - - -template -int MQTT::Client::publish(const char* topicName, Message& message) -{ - return publish(topicName, message.payload, message.payloadlen, message.qos, message.retained); -} - - -template -int MQTT::Client::disconnect() -{ - int rc = FAILURE; - Timer timer(command_timeout_ms); // we might wait for incomplete incoming publishes to complete - int len = MQTTSerialize_disconnect(sendbuf, MAX_MQTT_PACKET_SIZE); - if (len > 0) - rc = sendPacket(len, timer); // send the disconnect packet - closeSession(); - return rc; -} - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTLogging.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTLogging.h deleted file mode 100644 index fd83e6169efb304e274a9045bf46b5efa0861b31..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/MQTTLogging.h +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(MQTT_LOGGING_H) -#define MQTT_LOGGING_H - -#define STREAM stdout -#if !defined(DEBUG) -#define DEBUG(...) \ - {\ - fprintf(STREAM, "DEBUG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ - fprintf(STREAM, ##__VA_ARGS__); \ - fflush(STREAM); \ - } -#endif -#if !defined(LOG) -#define LOG(...) \ - {\ - fprintf(STREAM, "LOG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ - fprintf(STREAM, ##__VA_ARGS__); \ - fflush(STREAM); \ - } -#endif -#if !defined(WARN) -#define WARN(...) \ - { \ - fprintf(STREAM, "WARN: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ - fprintf(STREAM, ##__VA_ARGS__); \ - fflush(STREAM); \ - } -#endif -#if !defined(ERROR) -#define ERROR(...) \ - { \ - fprintf(STREAM, "ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \ - fprintf(STREAM, ##__VA_ARGS__); \ - fflush(STREAM); \ - exit(1); \ - } -#endif - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/Countdown.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/Countdown.h deleted file mode 100644 index c9cb9607fa5b9f7d3d68661f67553ba8e85072de..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/Countdown.h +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(COUNTDOWN_H) -#define COUNTDOWN_H - -class Countdown -{ -public: - Countdown() - { - interval_end_ms = 0L; - } - - Countdown(int ms) - { - countdown_ms(ms); - } - - bool expired() - { - return (interval_end_ms > 0L) && (millis() >= interval_end_ms); - } - - void countdown_ms(unsigned long ms) - { - interval_end_ms = millis() + ms; - } - - void countdown(int seconds) - { - countdown_ms((unsigned long)seconds * 1000L); - } - - int left_ms() - { - return interval_end_ms - millis(); - } - -private: - unsigned long interval_end_ms; -}; - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/IPStack.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/IPStack.h deleted file mode 100644 index e0cea6679c4fdabc049cd87b0ad7c43accbe9399..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/IPStack.h +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Benjamin Cabe - generic IPStack - *******************************************************************************/ - -#if !defined(IPSTACK_H) -#define IPSTACK_H - -#ifndef WiFi_h - #include -#endif - -#include - -class IPStack -{ -public: - IPStack(Client& client) : client(&client) - { - - } - - int connect(char* hostname, int port) - { - return client->connect(hostname, port); - } - - int connect(uint32_t hostname, int port) - { - return client->connect(hostname, port); - } - - int read(unsigned char* buffer, int len, int timeout) - { - int interval = 10; // all times are in milliseconds - int total = 0, rc = -1; - - if (timeout < 30) - interval = 2; - while (client->available() < len && total < timeout) - { - delay(interval); - total += interval; - } - if (client->available() >= len) - rc = client->readBytes((char*)buffer, len); - return rc; - } - - int write(unsigned char* buffer, int len, int timeout) - { - client->setTimeout(timeout); - return client->write((uint8_t*)buffer, len); - } - - int disconnect() - { - client->stop(); - return 0; - } - -private: - - Client* client; -}; - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/WifiIPStack.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/WifiIPStack.h deleted file mode 100644 index 676103741b63b1a41d545eeb47ed70b06664f6ef..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/arduino/WifiIPStack.h +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#ifndef ARDUINOWIFIIPSTACK_H -#define ARDUINOWIFIIPSTACK_H - -#include - -class WifiIPStack -{ -public: - WifiIPStack() - { - //WiFi.begin(); // Use DHCP - iface.setTimeout(1000); // 1 second Timeout - } - - int connect(char* hostname, int port) - { - return iface.connect(hostname, port); - } - - int connect(uint32_t hostname, int port) - { - return iface.connect(hostname, port); - } - - int read(char* buffer, int len, int timeout) - { - iface.setTimeout(timeout); - while(!iface.available()); - return iface.readBytes(buffer, len); - } - - int write(char* buffer, int len, int timeout) - { - iface.setTimeout(timeout); - return iface.write((uint8_t*)buffer, len); - } - - int disconnect() - { - iface.stop(); - return 0; - } - -private: - - WiFiClient iface; - -}; - -#endif - - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/linux/linux.cpp b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/linux/linux.cpp deleted file mode 100644 index 13231144a9baf80e272dadebb83c84ed275febb2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/linux/linux.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - ensure read returns if no bytes read - *******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -class IPStack -{ -public: - IPStack() - { - - } - - int connect(const char* hostname, int port) - { - int type = SOCK_STREAM; - struct sockaddr_in address; - int rc = -1; - sa_family_t family = AF_INET; - struct addrinfo *result = NULL; - struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL}; - - if ((rc = getaddrinfo(hostname, NULL, &hints, &result)) == 0) - { - struct addrinfo* res = result; - - /* prefer ip4 addresses */ - while (res) - { - if (res->ai_family == AF_INET) - { - result = res; - break; - } - res = res->ai_next; - } - - if (result->ai_family == AF_INET) - { - address.sin_port = htons(port); - address.sin_family = family = AF_INET; - address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr; - } - else - rc = -1; - - freeaddrinfo(result); - } - - if (rc == 0) - { - mysock = socket(family, type, 0); - if (mysock != -1) - { - int opt = 1; - - //if (setsockopt(mysock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) - // printf("Could not set SO_NOSIGPIPE for socket %d", mysock); - - rc = ::connect(mysock, (struct sockaddr*)&address, sizeof(address)); - } - } - - return rc; - } - - // return -1 on error, or the number of bytes read - // which could be 0 on a read timeout - int read(unsigned char* buffer, int len, int timeout_ms) - { - struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; - if (interval.tv_sec < 0 || (interval.tv_sec == 0 && interval.tv_usec <= 0)) - { - interval.tv_sec = 0; - interval.tv_usec = 100; - } - - setsockopt(mysock, SOL_SOCKET, SO_RCVTIMEO, (char *)&interval, sizeof(struct timeval)); - - int bytes = 0; - int i = 0; const int max_tries = 10; - while (bytes < len) - { - int rc = ::recv(mysock, &buffer[bytes], (size_t)(len - bytes), 0); - if (rc == -1) - { - if (errno != EAGAIN && errno != EWOULDBLOCK) - bytes = -1; - break; - } - else - bytes += rc; - if (++i >= max_tries) - break; - if (rc == 0) - break; - } - return bytes; - } - - int write(unsigned char* buffer, int len, int timeout) - { - struct timeval tv; - - tv.tv_sec = 0; /* 30 Secs Timeout */ - tv.tv_usec = timeout * 1000; // Not init'ing this can cause strange errors - - setsockopt(mysock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval)); - int rc = ::write(mysock, buffer, len); - //printf("write rc %d\n", rc); - return rc; - } - - int disconnect() - { - return ::close(mysock); - } - -private: - - int mysock; -}; - - -class Countdown -{ -public: - Countdown() - { - - } - - Countdown(int ms) - { - countdown_ms(ms); - } - - - bool expired() - { - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&end_time, &now, &res); - //printf("left %d ms\n", (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000); - //if (res.tv_sec > 0 || res.tv_usec > 0) - // printf("expired %d %d\n", res.tv_sec, res.tv_usec); - return res.tv_sec < 0 || (res.tv_sec == 0 && res.tv_usec <= 0); - } - - - void countdown_ms(int ms) - { - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {ms / 1000, (ms % 1000) * 1000}; - //printf("interval %d %d\n", interval.tv_sec, interval.tv_usec); - timeradd(&now, &interval, &end_time); - } - - - void countdown(int seconds) - { - struct timeval now; - gettimeofday(&now, NULL); - struct timeval interval = {seconds, 0}; - timeradd(&now, &interval, &end_time); - } - - - int left_ms() - { - struct timeval now, res; - gettimeofday(&now, NULL); - timersub(&end_time, &now, &res); - //printf("left %d ms\n", (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000); - return (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000; - } - -private: - - struct timeval end_time; -}; diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTEthernet.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTEthernet.h deleted file mode 100644 index 728fd89bebf2e15b9901f597e6211fe30c44b30b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTEthernet.h +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(MQTTETHERNET_H) -#define MQTTETHERNET_H - -#include "MQTT_mbed.h" -#include "EthernetInterface.h" -#include "MQTTSocket.h" - -class MQTTEthernet : public MQTTSocket -{ -public: - MQTTEthernet() - { - eth.init(); // Use DHCP - eth.connect(); - } - -private: - - EthernetInterface eth; - -}; - - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTSocket.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTSocket.h deleted file mode 100644 index c38da8fe00c468ce2925465687452c49648ad155..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/src/mbed/MQTTSocket.h +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(MQTTSOCKET_H) -#define MQTTSOCKET_H - -#include "MQTT_mbed.h" -#include "TCPSocketConnection.h" - -class MQTTSocket -{ -public: - int connect(char* hostname, int port, int timeout=1000) - { - mysock.set_blocking(false, timeout); // 1 second Timeout - return mysock.connect(hostname, port); - } - - int read(unsigned char* buffer, int len, int timeout) - { - mysock.set_blocking(false, timeout); - return mysock.receive((char*)buffer, len); - } - - int write(unsigned char* buffer, int len, int timeout) - { - mysock.set_blocking(false, timeout); - return mysock.send((char*)buffer, len); - } - - int disconnect() - { - return mysock.close(); - } - -private: - - TCPSocketConnection mysock; - -}; - - - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/CMakeLists.txt deleted file mode 100644 index 6a485d81e4f7a96f61090aa243719ada8537abe8..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -PROJECT(mqttcpp-tests) - -SET(MQTT_TEST_BROKER_HOST "localhost" CACHE STRING "Hostname of a test MQTT broker to use") -SET(MQTT_TEST_PROXY_PORT "1884" CACHE STRING "Port of the test proxy to use") -SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use") -SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl) - -ADD_EXECUTABLE( - testcpp1 - test1.cpp -) - -target_compile_definitions(testcpp1 PRIVATE MQTTCLIENT_QOS1=1 MQTTCLIENT_QOS2=1) -target_include_directories(testcpp1 PRIVATE "../src" "../src/linux") -target_link_libraries(testcpp1 MQTTPacketClient MQTTPacketServer) - -ADD_TEST( - NAME testcpp1 - COMMAND "testcpp1" "--host" ${MQTT_TEST_BROKER_HOST} -) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/test1.cpp b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/test1.cpp deleted file mode 100644 index e52ca096e8b953892a611c405aa23619ad397130..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTClient/test/test1.cpp +++ /dev/null @@ -1,943 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial implementation for embedded C client - *******************************************************************************/ - - -/** - * @file - * Tests for the Paho embedded C "high" level client - */ - - #include - #include - #include - //#define MQTT_DEBUG - #include "MQTTClient.h" - - #define DEFAULT_STACK_SIZE -1 - - #include "linux.cpp" - - #include - #include - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -void usage(void) -{ - printf("help!!\n"); - exit(EXIT_FAILURE); -} - -struct Options -{ - char* host; /**< connection to system under test. */ - int port; - char* proxy_host; - int proxy_port; - int verbose; - int test_no; - int MQTTVersion; - int iterations; -} options = -{ - (char*)"localhost", - 1883, - (char*)"localhost", - 1885, - 0, - 0, - 4, - 1, -}; - -void getopts(int argc, char** argv) -{ - int count = 1; - - while (count < argc) - { - if (strcmp(argv[count], "--test_no") == 0) - { - if (++count < argc) - options.test_no = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--host") == 0) - { - if (++count < argc) - { - options.host = argv[count]; - printf("\nSetting host to %s\n", options.host); - } - else - usage(); - } - else if (strcmp(argv[count], "--port") == 0) - { - if (++count < argc) - { - options.port = atoi(argv[count]); - printf("\nSetting port to %d\n", options.port); - } - else - usage(); - } - else if (strcmp(argv[count], "--proxy_host") == 0) - { - if (++count < argc) - options.proxy_host = argv[count]; - else - usage(); - } - else if (strcmp(argv[count], "--proxy_port") == 0) - { - if (++count < argc) - { - options.proxy_port = atoi(argv[count]); - printf("\nSetting proxy port to %d\n", options.proxy_port); - } - else - usage(); - } - else if (strcmp(argv[count], "--MQTTversion") == 0) - { - if (++count < argc) - { - options.MQTTVersion = atoi(argv[count]); - printf("setting MQTT version to %d\n", options.MQTTVersion); - } - else - usage(); - } - else if (strcmp(argv[count], "--iterations") == 0) - { - if (++count < argc) - options.iterations = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--verbose") == 0) - { - options.verbose = 1; - printf("\nSetting verbose on\n"); - } - count++; - } -} - - -#define LOGA_DEBUG 0 -#define LOGA_INFO 1 -#include -#include -#include -void MyLog(int LOGA_level, const char* format, ...) -{ - static char msg_buf[256]; - va_list args; - struct timeb ts; - - struct tm *timeinfo; - - if (LOGA_level == LOGA_DEBUG && options.verbose == 0) - return; - - ftime(&ts); - timeinfo = localtime(&ts.time); - strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo); - - sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm); - - va_start(args, format); - vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args); - va_end(args); - - printf("%s\n", msg_buf); - fflush(stdout); -} - - -#if defined(WIN32) || defined(_WINDOWS) -#define mqsleep(A) Sleep(1000*A) -#define START_TIME_TYPE DWORD -static DWORD start_time = 0; -START_TIME_TYPE start_clock(void) -{ - return GetTickCount(); -} -#elif defined(AIX) -#define mqsleep sleep -#define START_TIME_TYPE struct timespec -START_TIME_TYPE start_clock(void) -{ - static struct timespec start; - clock_gettime(CLOCK_REALTIME, &start); - return start; -} -#else -#define mqsleep sleep -#define START_TIME_TYPE struct timeval -/* TODO - unused - remove? static struct timeval start_time; */ -START_TIME_TYPE start_clock(void) -{ - struct timeval start_time; - gettimeofday(&start_time, NULL); - return start_time; -} -#endif - - -#if defined(WIN32) -long elapsed(START_TIME_TYPE start_time) -{ - return GetTickCount() - start_time; -} -#elif defined(AIX) -#define assert(a) -long elapsed(struct timespec start) -{ - struct timespec now, res; - - clock_gettime(CLOCK_REALTIME, &now); - ntimersub(now, start, res); - return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L; -} -#else -long elapsed(START_TIME_TYPE start_time) -{ - struct timeval now, res; - - gettimeofday(&now, NULL); - timersub(&now, &start_time, &res); - return (res.tv_sec)*1000 + (res.tv_usec)/1000; -} -#endif - - -#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d) -#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e) - -int tests = 0; -int failures = 0; -FILE* xml; -START_TIME_TYPE global_start_time; -char output[3000]; -char* cur_output = output; - - -void write_test_result(void) -{ - long duration = elapsed(global_start_time); - - fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000); - if (cur_output != output) - { - fprintf(xml, "%s", output); - cur_output = output; - } - fprintf(xml, "\n"); -} - - -void myassert(const char* filename, int lineno, const char* description, int value, const char* format, ...) -{ - ++tests; - if (!value) - { - va_list args; - - ++failures; - MyLog(LOGA_INFO, (char*)"Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description); - - va_start(args, format); - vprintf(format, args); - va_end(args); - - cur_output += sprintf(cur_output, "file %s, line %d \n", - description, filename, lineno); - } - else - MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description); -} - - -static volatile MQTT::MessageData* test1_message_data = NULL; -static MQTT::Message pubmsg; - -void messageArrived(MQTT::MessageData& md) -{ - test1_message_data = &md; - MQTT::Message &m = md.message; - - assert("Good message lengths", pubmsg.payloadlen == m.payloadlen, - "payloadlen was %d", m.payloadlen); - - if (pubmsg.payloadlen == m.payloadlen) - assert("Good message contents", memcmp(m.payload, pubmsg.payload, m.payloadlen) == 0, - "payload was %s", m.payload); -} - - -/********************************************************************* - -Test1: single-threaded client - -*********************************************************************/ -void test1_sendAndReceive(MQTT::Client& client, int qos, const char* test_topic) -{ - char* topicName = NULL; - int topicLen; - int i = 0; - int iterations = 50; - int rc; - int wait_seconds; - - MyLog(LOGA_DEBUG, "%d messages at QoS %d", iterations, qos); - memset(&pubmsg, '\0', sizeof(pubmsg)); - pubmsg.payload = (void*)"a much longer message that we can shorten to the extent that we need to payload up to 11"; - pubmsg.payloadlen = 11; - pubmsg.qos = (MQTT::QoS)qos; - pubmsg.retained = false; - pubmsg.dup = false; - - for (i = 0; i < iterations; ++i) - { - test1_message_data = NULL; - rc = client.publish(test_topic, pubmsg); - assert("Good rc from publish", rc == MQTT::SUCCESS, "rc was %d", rc); - - /* wait for the message to be received */ - wait_seconds = 10; - while ((test1_message_data == NULL) && (wait_seconds-- > 0)) - { - client.yield(100); - } - assert("Message Arrived", wait_seconds > 0, "Time out waiting for message %d\n", i); - - if (!test1_message_data) - printf("No message received within timeout period\n"); - } - - /* wait to receive any outstanding messages */ - wait_seconds = 2; - while (wait_seconds-- > 0) - { - client.yield(1000); - } -} - - -int test1(struct Options options) -{ - MQTT::QoS subsqos = MQTT::QOS2; - int rc = 0; - const char* test_topic = "C client test1"; - - fprintf(xml, " client = MQTT::Client(ipstack); - - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.willFlag = 1; - data.MQTTVersion = options.MQTTVersion; - data.clientID.cstring = (char*)"single-threaded-test"; - data.username.cstring = (char*)"testuser"; - data.password.cstring = (char*)"testpassword"; - - data.keepAliveInterval = 20; - data.cleansession = 1; - - data.will.message.cstring = (char*)"will message"; - data.will.qos = 1; - data.will.retained = 0; - data.will.topicName.cstring = (char*)"will topic"; - - MyLog(LOGA_DEBUG, "Connecting"); - rc = ipstack.connect(options.host, options.port); - assert("Good rc from TCP connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - rc = client.connect(data); - assert("Good rc from connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - rc = client.subscribe(test_topic, subsqos, messageArrived); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - - test1_sendAndReceive(client, 0, test_topic); - test1_sendAndReceive(client, 1, test_topic); - test1_sendAndReceive(client, 2, test_topic); - - MyLog(LOGA_DEBUG, "Stopping\n"); - - rc = client.unsubscribe(test_topic); - assert("Unsubscribe successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* Just to make sure we can connect again */ - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - -exit: - MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -/********************************************************************* - -Test 2: connack return data - -*********************************************************************/ -int test2(struct Options options) -{ - MQTT::QoS subsqos = MQTT::QOS2; - int rc; - const char* test_topic = "C client test2"; - - fprintf(xml, " client = MQTT::Client(ipstack); - - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.willFlag = 1; - data.MQTTVersion = options.MQTTVersion; - data.clientID.cstring = (char*)"connack-return-data"; - data.username.cstring = (char*)"testuser"; - data.password.cstring = (char*)"testpassword"; - - data.keepAliveInterval = 20; - data.cleansession = 1; - - data.will.message.cstring = (char*)"will message"; - data.will.qos = 1; - data.will.retained = 0; - data.will.topicName.cstring = (char*)"will topic"; - - MyLog(LOGA_DEBUG, "Connecting"); - rc = ipstack.connect(options.host, options.port); - assert("Good rc from TCP connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - MQTT::connackData connack; - rc = client.connect(data, connack); - assert("Good rc from connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - MQTT::subackData suback; - rc = client.subscribe(test_topic, subsqos, messageArrived, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 1", connack.sessionPresent == 1, - "sessionPresent was %d", connack.sessionPresent); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession true */ - data.cleansession = 1; - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - -exit: - MyLog(LOGA_INFO, "TEST2: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -/********************************************************************* - -Test 3: client session state - -*********************************************************************/ -static volatile MQTT::MessageData* test2_message_data = NULL; - -void messageArrived2(MQTT::MessageData& md) -{ - test2_message_data = &md; - MQTT::Message &m = md.message; - - assert("Good message lengths", pubmsg.payloadlen == m.payloadlen, - "payloadlen was %d", m.payloadlen); - - if (pubmsg.payloadlen == m.payloadlen) - assert("Good message contents", memcmp(m.payload, pubmsg.payload, m.payloadlen) == 0, - "payload was %s", m.payload); -} - - -int check_subs_exist(MQTT::Client& client, const char* test_topic, int which) -{ - int rc = MQTT::FAILURE; - int wait_seconds = 0; - - memset(&pubmsg, '\0', sizeof(pubmsg)); - pubmsg.payload = (void*)"a much longer message that we can shorten to the extent that we need to payload up to 11"; - pubmsg.payloadlen = 11; - pubmsg.qos = MQTT::QOS2; - pubmsg.retained = false; - pubmsg.dup = false; - - test1_message_data = test2_message_data = NULL; - rc = client.publish(test_topic, pubmsg); - assert("Good rc from publish", rc == MQTT::SUCCESS, "rc was %d", rc); - - /* wait for the message to be received */ - wait_seconds = 10; - while (wait_seconds-- > 0) - { - client.yield(100); - } - - rc = (((which == 1 || which == 3) && test1_message_data) || - (which == 2 && test1_message_data == NULL)) ? MQTT::SUCCESS : MQTT::FAILURE; - assert("test1 subscription", rc == MQTT::SUCCESS, "test1_message_data %p\n", - test1_message_data); - rc = (((which == 2 || which == 3) && test2_message_data) || - (which == 1 && test2_message_data == NULL)) ? MQTT::SUCCESS : MQTT::FAILURE; - assert("test2 subscription", rc == MQTT::SUCCESS, "test2_message_data %p\n", - test2_message_data); - return rc; -} - - -int test3(struct Options options) -{ - MQTT::QoS subsqos = MQTT::QOS2; - int rc; - const char* test_topic = "C client test3"; - int wait_seconds = 0; - - fprintf(xml, " client = MQTT::Client(ipstack); - - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.willFlag = 1; - data.MQTTVersion = options.MQTTVersion; - data.clientID.cstring = (char*)"connack-return-data"; - data.username.cstring = (char*)"testuser"; - data.password.cstring = (char*)"testpassword"; - - data.keepAliveInterval = 10; - data.cleansession = 1; - - data.will.message.cstring = (char*)"will message"; - data.will.qos = 1; - data.will.retained = 0; - data.will.topicName.cstring = (char*)"will topic"; - - assert("Good rc in connack", client.isConnected() == false, - "isconnected was %d", client.isConnected()); - - MyLog(LOGA_DEBUG, "Connecting"); - rc = ipstack.connect(options.host, options.port); - assert("Good rc from TCP connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - MQTT::connackData connack; - rc = client.connect(data, connack); - assert("Good rc from connect", rc == MQTT::SUCCESS, "rc was %d", rc); - if (rc != MQTT::SUCCESS) - goto exit; - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - assert("Good rc in connack", client.isConnected() == true, - "isconnected was %d", client.isConnected()); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = ipstack.connect(options.proxy_host, options.proxy_port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - MQTT::subackData suback; - rc = client.subscribe(test_topic, subsqos, messageArrived, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(client, test_topic, 1); - - rc = client.subscribe(test_topic, subsqos, messageArrived2, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(client, test_topic, 2); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = ipstack.connect(options.proxy_host, options.proxy_port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 1", connack.sessionPresent == 1, - "sessionPresent was %d", connack.sessionPresent); - - check_subs_exist(client, test_topic, 2); - - rc = client.subscribe(test_topic, subsqos, messageArrived, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(client, test_topic, 1); - - // cause a connection FAILURE - memset(&pubmsg, '\0', sizeof(pubmsg)); - pubmsg.payload = (void*)"TERMINATE"; - pubmsg.payloadlen = strlen((char*)pubmsg.payload); - pubmsg.qos = MQTT::QOS0; - pubmsg.retained = false; - pubmsg.dup = false; - rc = client.publish("MQTTSAS topic", pubmsg); - assert("Good rc from publish", rc == MQTT::SUCCESS, "rc was %d", rc); - - // wait for failure to be noticed by keepalive - wait_seconds = 20; - while (client.isConnected() && (wait_seconds-- > 0)) - { - client.yield(1000); - } - assert("Disconnected", !client.isConnected(), "isConnected was %d", - client.isConnected()); - ipstack.disconnect(); - - /* reconnect with cleansession false */ - data.cleansession = 0; - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 1", connack.sessionPresent == 1, - "sessionPresent was %d", connack.sessionPresent); - - check_subs_exist(client, test_topic, 1); - - rc = client.subscribe(test_topic, subsqos, messageArrived2, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(client, test_topic, 2); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - - /* reconnect with cleansession true to clean up both server and client state */ - data.cleansession = 1; - rc = ipstack.connect(options.host, options.port); - assert("TCP connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - rc = client.connect(data, connack); - assert("Connect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - - assert("Good rc in connack", connack.rc == 0, "rc was %d", connack.rc); - assert("Session present is 0", connack.sessionPresent == 0, - "sessionPresent was %d", connack.sessionPresent); - - rc = client.subscribe(test_topic, subsqos, messageArrived2, suback); - assert("Good rc from subscribe", rc == MQTT::SUCCESS, "rc was %d", rc); - assert("Granted QoS rc from subscribe", suback.grantedQoS == MQTT::QOS2, - "rc was %d", suback.grantedQoS); - - check_subs_exist(client, test_topic, 2); - - rc = client.disconnect(); - assert("Disconnect successful", rc == MQTT::SUCCESS, "rc was %d", rc); - ipstack.disconnect(); - -exit: - MyLog(LOGA_INFO, "TEST2: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -#if 0 -/********************************************************************* - -Test 4: connectionLost and will message - -*********************************************************************/ -MQTTClient test6_c1, test6_c2; -volatile int test6_will_message_arrived = 0; -volatile int test6_connection_lost_called = 0; - -void test6_connectionLost(void* context, char* cause) -{ - MQTTClient c = (MQTTClient)context; - printf("%s -> Callback: connection lost\n", (c == test6_c1) ? "Client-1" : "Client-2"); - test6_connection_lost_called = 1; -} - -void test6_deliveryComplete(void* context, MQTTClient_deliveryToken token) -{ - printf("Client-2 -> Callback: publish complete for token %d\n", token); -} - -char* test6_will_topic = "C Test 2: will topic"; -char* test6_will_message = "will message from Client-1"; - -int test6_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m) -{ - MQTTClient c = (MQTTClient)context; - printf("%s -> Callback: message received on topic '%s' is '%.*s'.\n", - (c == test6_c1) ? "Client-1" : "Client-2", topicName, m->payloadlen, (char*)(m->payload)); - if (c == test6_c2 && strcmp(topicName, test6_will_topic) == 0 && memcmp(m->payload, test6_will_message, m->payloadlen) == 0) - test6_will_message_arrived = 1; - MQTTClient_free(topicName); - MQTTClient_freeMessage(&m); - return 1; -} - - -int test6(struct Options options) -{ - char* testname = "test6"; - MQTTClient_connectOptions opts = MQTTClient_connectOptions_initializer; - MQTTClient_willOptions wopts = MQTTClient_willOptions_initializer; - MQTTClient_connectOptions opts2 = MQTTClient_connectOptions_initializer; - int rc, count; - char* mqttsas_topic = "MQTTSAS topic"; - - failures = 0; - MyLog(LOGA_INFO, "Starting test 6 - connectionLost and will messages"); - fprintf(xml, "message = test6_will_message; - opts.will->qos = 1; - opts.will->retained = 0; - opts.will->topicName = test6_will_topic; - if (options.haconnections != NULL) - { - opts.serverURIs = options.haconnections; - opts.serverURIcount = options.hacount; - } - - /* Client-1 with Will options */ - rc = MQTTClient_create(&test6_c1, options.proxy_connection, "Client_1", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - rc = MQTTClient_setCallbacks(test6_c1, (void*)test6_c1, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Connect to the broker */ - rc = MQTTClient_connect(test6_c1, &opts); - assert("good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - if (rc != MQTTCLIENT_SUCCESS) - goto exit; - - /* Client - 2 (multi-threaded) */ - rc = MQTTClient_create(&test6_c2, options.connection, "Client_2", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL); - assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Set the callback functions for the client */ - rc = MQTTClient_setCallbacks(test6_c2, (void*)test6_c2, test6_connectionLost, test6_messageArrived, test6_deliveryComplete); - assert("good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* Connect to the broker */ - opts2.keepAliveInterval = 20; - opts2.cleansession = 1; - MyLog(LOGA_INFO, "Connecting Client_2 ..."); - rc = MQTTClient_connect(test6_c2, &opts2); - assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - rc = MQTTClient_subscribe(test6_c2, test6_will_topic, 2); - assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - /* now send the command which will break the connection and cause the will message to be sent */ - rc = MQTTClient_publish(test6_c1, mqttsas_topic, (int)strlen("TERMINATE"), "TERMINATE", 0, 0, NULL); - assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc); - - MyLog(LOGA_INFO, "Waiting to receive the will message"); - count = 0; - while (++count < 40) - { - #if defined(WIN32) - Sleep(1000L); - #else - sleep(1); - #endif - if (test6_will_message_arrived == 1 && test6_connection_lost_called == 1) - break; - } - assert("will message arrived", test6_will_message_arrived == 1, - "will_message_arrived was %d\n", test6_will_message_arrived); - assert("connection lost called", test6_connection_lost_called == 1, - "connection_lost_called %d\n", test6_connection_lost_called); - - rc = MQTTClient_unsubscribe(test6_c2, test6_will_topic); - assert("Good rc from unsubscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - rc = MQTTClient_isConnected(test6_c2); - assert("Client-2 still connected", rc == 1, "isconnected is %d", rc); - - rc = MQTTClient_isConnected(test6_c1); - assert("Client-1 not connected", rc == 0, "isconnected is %d", rc); - - rc = MQTTClient_disconnect(test6_c2, 100L); - assert("Good rc from disconnect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc); - - MQTTClient_destroy(&test6_c1); - MQTTClient_destroy(&test6_c2); - -exit: - MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.\n", - (failures == 0) ? "passed" : "failed", testname, tests, failures); - write_test_result(); - return failures; -} -#endif - -int main(int argc, char** argv) -{ - int rc = 0; - int (*tests[])(Options) = {NULL, test1, test2, test3, /*test4, test5, test6, test6a*/}; - int i; - - xml = fopen("TEST-test1.xml", "w"); - fprintf(xml, "\n", (int)(ARRAY_SIZE(tests) - 1)); - - //setenv("MQTT_C_CLIENT_TRACE", "ON", 1); - //setenv("MQTT_C_CLIENT_TRACE_LEVEL", "ERROR", 0); - - getopts(argc, argv); - - for (i = 0; i < options.iterations; ++i) - { - if (options.test_no == 0) - { /* run all the tests */ - for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no) - rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */ - } - else - rc = tests[options.test_no](options); /* run just the selected test */ - } - - if (rc == 0) - MyLog(LOGA_INFO, "verdict pass"); - else - MyLog(LOGA_INFO, "verdict fail"); - - fprintf(xml, "\n"); - fclose(xml); - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/CMakeLists.txt deleted file mode 100644 index 3c9f0f870371df7c450d2394cc3b8ae45514adc5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -project("paho-mqttpacket" C) - -ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(samples) -ADD_SUBDIRECTORY(test) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/CMakeLists.txt deleted file mode 100644 index a445535ffb2f6bb94d82e4f11e74ea6ca3526ee5..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -# Samples - -include_directories(../src) - -add_executable( - pub0sub1 - pub0sub1.c transport.c -) -target_link_libraries(pub0sub1 paho-embed-mqtt3c) - -add_executable( - pub0sub1_nb - pub0sub1_nb.c transport.c -) -target_link_libraries(pub0sub1_nb paho-embed-mqtt3c) - -add_executable( - qos0pub - qos0pub.c transport.c -) -target_link_libraries(qos0pub paho-embed-mqtt3c) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/build b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/build deleted file mode 100644 index aaf2e361928e51a8257d9791013e506893f4a0b3..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/build +++ /dev/null @@ -1,3 +0,0 @@ -gcc -g -Wall pub0sub1_nb.c transport.c -I ../../src ../../src/MQTTConnectClient.c ../../src/MQTTSerializePublish.c ../../src/MQTTPacket.c ../../src/MQTTSubscribeClient.c -o pub0sub1_nb ../../src/MQTTDeserializePublish.c ../../src/MQTTConnectServer.c ../../src/MQTTSubscribeServer.c ../../src/MQTTUnsubscribeServer.c ../../src/MQTTUnsubscribeClient.c -gcc -g -Wall ping_nb.c transport.c -I ../../src ../../src/MQTTConnectClient.c ../../src/MQTTPacket.c -o ping_nb - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/ping_nb.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/ping_nb.c deleted file mode 100644 index 6cfe0f0a25b70786070d5b18090a3758dab4431f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/ping_nb.c +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Sergio R. Caprile - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -#define KEEPALIVE_INTERVAL 20 - -/* This is to get a timebase in seconds to test the sample */ -#include -time_t old_t; -void start_ping_timer(void) -{ - time(&old_t); - old_t += KEEPALIVE_INTERVAL/2 + 1; -} - -int time_to_ping(void) -{ -time_t t; - - time(&t); - if(t >= old_t) - return 1; - return 0; -} - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach, but this sample can be -run on Linux so debugging of the non-hardware specific bare metal code is easier. -See at bottom of file for details */ -#include - -int toStop = 0; - -void stop_init(void); -/* */ - -/* Same as above, we provide a set of functions to test/debug on a friendlier system; -the init() and close() actions on the serial are just for this, you will probably -handle this on whatever handles your media in your application */ -void sampleserial_init(void); -void sampleserial_close(void); -int samplesend(unsigned char *address, unsigned int bytes); -int samplerecv(unsigned char *address, unsigned int maxbytes); -/* */ - -/* You will use your hardware specifics here, see transport.h. */ -static transport_iofunctions_t iof = {samplesend, samplerecv}; - -enum states { IDLE, SENDPING, GETPONG }; - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int len = 0; - MQTTTransport mytransport; - int state; - - stop_init(); - sampleserial_init(); - - mysock = transport_open(&iof); - if(mysock < 0) - return mysock; - /* You will (or already are) 'somehow' connect(ed) to host:port via your hardware specifics. E.g.: - you have a serial (RS-232/UART) link - you have a cell modem and you issue your AT+ magic - you have some TCP/IP which is not lwIP (nor a full-fledged socket compliant one) - and you TCP connect - */ - - mytransport.sck = &mysock; - mytransport.getfn = transport_getdatanb; - mytransport.state = 0; - data.clientID.cstring = "me"; - data.keepAliveInterval = KEEPALIVE_INTERVAL; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - /* This one blocks until it finishes sending, you will probably not want this in real life, - in such a case replace this call by a scheme similar to the one you'll see in the main loop */ - rc = transport_sendPacketBuffer(mysock, buf, len); - - printf("Sent MQTT connect\n"); - /* wait for connack */ - do { - int frc; - if ((frc=MQTTPacket_readnb(buf, buflen, &mytransport)) == CONNACK){ - unsigned char sessionPresent, connack_rc; - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0){ - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - break; - } - else if (frc == -1) - goto exit; - } while (1); /* handle timeouts here */ - - printf("MQTT connected\n"); - start_ping_timer(); - state = IDLE; - while (!toStop) { - switch(state){ - case IDLE: - if(time_to_ping()){ - len = MQTTSerialize_pingreq(buf, buflen); - transport_sendPacketBuffernb_start(mysock, buf, len); - state = SENDPING; - } - break; - case SENDPING: - switch(transport_sendPacketBuffernb(mysock)){ - case TRANSPORT_DONE: - printf("Ping..."); - start_ping_timer(); - state = GETPONG; - break; - case TRANSPORT_ERROR: - /* handle any I/O errors here */ - goto exit; - break; - case TRANSPORT_AGAIN: - default: - /* handle timeouts here, not probable unless there is a hardware problem */ - break; - } - break; - case GETPONG: - if((rc=MQTTPacket_readnb(buf, buflen, &mytransport)) == PINGRESP){ - printf("Pong\n"); - start_ping_timer(); - state = IDLE; - } else if(rc == -1){ - /* handle I/O errors here */ - printf("OOPS\n"); - goto exit; - } /* handle timeouts here */ - break; - } - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - /* Same blocking related stuff here */ - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - sampleserial_close(); - return 0; -} - - -/* To stop the sample */ -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} - -/* Serial hack: -Simulate serial transfers on an established TCP connection - */ -#include -#include -#include -#include -#include -#include -#include - -static int sockfd; - -void sampleserial_init(void) -{ -struct sockaddr_in serv_addr; - - - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror(NULL); - exit(2); - } - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = inet_addr("198.41.30.241"); - serv_addr.sin_port = htons(1883); - if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { - printf("ERROR connecting\n"); - exit(-1); - } - printf("- TCP Connected to Eclipse\n"); - /* set to non-blocking */ - fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK); -} - -void sampleserial_close(void) -{ - close(sockfd); -} - -int samplesend(unsigned char *address, unsigned int bytes) -{ -int len; - - if(rand() > (RAND_MAX/2)) // 50% probability of being busy - return 0; - if(rand() > (RAND_MAX/2)){ // 50% probability of sending half the requested data (no room in buffer) - if(bytes > 1) - bytes /= 2; - } - if((len = write(sockfd, address, bytes)) >= 0) - return len; - if(errno == EAGAIN) - return 0; - return -1; -} - -int samplerecv(unsigned char *address, unsigned int maxbytes) -{ -int len; - - if(rand() > (RAND_MAX/2)) // 50% probability of no data - return 0; - if(rand() > (RAND_MAX/2)){ // 50% probability of getting half the requested data (not arrived yet) - if(maxbytes > 1){ - maxbytes /= 2; - } - } - if((len = read(sockfd, address, maxbytes)) >= 0) - return len; - if(errno == EAGAIN) - return 0; - return -1; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/pub0sub1_nb.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/pub0sub1_nb.c deleted file mode 100644 index 9c5995d2dea1010a929bc1081af21363ac058bb6..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/pub0sub1_nb.c +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - port to the bare metal environment - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach, but this sample can be -run on Linux so debugging of the non-hardware specific bare metal code is easier. -See at bottom of file for details */ -#include - -int toStop = 0; - -void stop_init(void); -/* */ - -/* Same as above, we provide a set of functions to test/debug on a friendlier system; -the init() and close() actions on the serial are just for this, you will probably -handle this on whatever handles your media in your application */ -void sampleserial_init(void); -void sampleserial_close(void); -int samplesend(unsigned char *address, unsigned int bytes); -int samplerecv(unsigned char *address, unsigned int maxbytes); -/* */ - -/* You will use your hardware specifics here, see transport.h. */ -static transport_iofunctions_t iof = {samplesend, samplerecv}; - -enum states { READING, PUBLISHING }; - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int msgid = 1; - MQTTString topicString = MQTTString_initializer; - int req_qos = 0; - char* payload = "mypayload"; - int payloadlen = strlen(payload); - int len = 0; - MQTTTransport mytransport; - int state = READING; - - stop_init(); - sampleserial_init(); - - mysock = transport_open(&iof); - if(mysock < 0) - return mysock; - /* You will (or already are) 'somehow' connect(ed) to host:port via your hardware specifics. E.g.: - you have a serial (RS-232/UART) link - you have a cell modem and you issue your AT+ magic - you have some TCP/IP which is not lwIP (nor a full-fledged socket compliant one) - and you TCP connect - */ - - mytransport.sck = &mysock; - mytransport.getfn = transport_getdatanb; - mytransport.state = 0; - data.clientID.cstring = "me"; - data.keepAliveInterval = 20; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - /* This one blocks until it finishes sending, you will probably not want this in real life, - in such a case replace this call by a scheme similar to the one you'll see in the main loop */ - rc = transport_sendPacketBuffer(mysock, buf, len); - - printf("Sent MQTT connect\n"); - /* wait for connack */ - do { - int frc; - if ((frc=MQTTPacket_readnb(buf, buflen, &mytransport)) == CONNACK){ - unsigned char sessionPresent, connack_rc; - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0){ - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - break; - } - else if (frc == -1) - goto exit; - } while (1); /* handle timeouts here */ - - printf("MQTT connected\n"); - /* subscribe */ - topicString.cstring = "substopic"; - len = MQTTSerialize_subscribe(buf, buflen, 0, msgid, 1, &topicString, &req_qos); - - /* This is equivalent to the one above, but using the non-blocking functions. You will probably not want this in real life, - in such a case replace this call by a scheme similar to the one you'll see in the main loop */ - transport_sendPacketBuffernb_start(mysock, buf, len); - while((rc=transport_sendPacketBuffernb(mysock)) != TRANSPORT_DONE); - do { - int frc; - if ((frc=MQTTPacket_readnb(buf, buflen, &mytransport)) == SUBACK){ /* wait for suback */ - unsigned short submsgid; - int subcount; - int granted_qos; - - rc = MQTTDeserialize_suback(&submsgid, 1, &subcount, &granted_qos, buf, buflen); - if (granted_qos != 0){ - printf("granted qos != 0, %d\n", granted_qos); - goto exit; - } - break; - } - else if (frc == -1) - goto exit; - } while (1); /* handle timeouts here */ - printf("Subscribed\n"); - - /* loop getting msgs on subscribed topic */ - topicString.cstring = "pubtopic"; - state = READING; - while (!toStop) { - /* do other stuff here */ - switch(state){ - case READING: - if((rc=MQTTPacket_readnb(buf, buflen, &mytransport)) == PUBLISH){ - unsigned char dup; - int qos; - unsigned char retained; - unsigned short msgid; - int payloadlen_in; - unsigned char* payload_in; - int rc; - MQTTString receivedTopic; - - rc = MQTTDeserialize_publish(&dup, &qos, &retained, &msgid, &receivedTopic, - &payload_in, &payloadlen_in, buf, buflen); - printf("message arrived %.*s\n", payloadlen_in, payload_in); - printf("publishing reading\n"); - state = PUBLISHING; - len = MQTTSerialize_publish(buf, buflen, 0, 0, 0, 0, topicString, (unsigned char*)payload, payloadlen); - transport_sendPacketBuffernb_start(mysock, buf, len); - } else if(rc == -1){ - /* handle I/O errors here */ - goto exit; - } /* handle timeouts here */ - break; - case PUBLISHING: - switch(transport_sendPacketBuffernb(mysock)){ - case TRANSPORT_DONE: - printf("Published\n"); - state = READING; - break; - case TRANSPORT_ERROR: - /* handle any I/O errors here */ - goto exit; - break; - case TRANSPORT_AGAIN: - default: - /* handle timeouts here, not probable unless there is a hardware problem */ - break; - } - break; - } - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - /* Same blocking related stuff here */ - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - sampleserial_close(); - return 0; -} - - -/* To stop the sample */ -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} - -/* Serial hack: -Simulate serial transfers on an established TCP connection - */ -#include -#include -#include -#include -#include -#include -#include - -static int sockfd; - -void sampleserial_init(void) -{ -struct sockaddr_in serv_addr; - - - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror(NULL); - exit(2); - } - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = inet_addr("198.41.30.241"); - serv_addr.sin_port = htons(1883); - if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { - printf("ERROR connecting\n"); - exit(-1); - } - printf("- TCP Connected to Eclipse\n"); - /* set to non-blocking */ - fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK); -} - -void sampleserial_close(void) -{ - close(sockfd); -} - -int samplesend(unsigned char *address, unsigned int bytes) -{ -int len; - - if(rand() > (RAND_MAX/2)) // 50% probability of being busy - return 0; - if(rand() > (RAND_MAX/2)){ // 50% probability of sending half the requested data (no room in buffer) - if(bytes > 1) - bytes /= 2; - } - if((len = write(sockfd, address, bytes)) >= 0) - return len; - if(errno == EAGAIN) - return 0; - return -1; -} - -int samplerecv(unsigned char *address, unsigned int maxbytes) -{ -int len; - - if(rand() > (RAND_MAX/2)) // 50% probability of no data - return 0; - if(rand() > (RAND_MAX/2)){ // 50% probability of getting half the requested data (not arrived yet) - if(maxbytes > 1){ - maxbytes /= 2; - } - } - if((len = read(sockfd, address, maxbytes)) >= 0) - return len; - if(errno == EAGAIN) - return 0; - return -1; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.c deleted file mode 100644 index c9d6c9500818221bc442ebfbb689fe943ae27870..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.c +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - port to the bare metal environment and serial media specifics - *******************************************************************************/ - -/** By the way, this is a nice bare bones example, easier to expand to whatever non-OS -media you might have */ - -#include -#include -#include -#include -#include -#include "transport.h" - -/** -This simple low-level implementation assumes a single connection for a single thread. Thus, single static -variables are used for that connection. -On other scenarios, you might want to put all these variables into a structure and index via the 'sock' -parameter, as some functions show in the comments -The blocking rx function is not supported. -If you plan on writing one, take into account that the current implementation of -MQTTPacket_read() has a function pointer for a function call to get the data to a buffer, but no provisions -to know the caller or other indicator (the socket id): int (*getfn)(unsigned char*, int) -*/ -static transport_iofunctions_t *io = NULL; -static unsigned char *from = NULL; // to keep track of data sending -static int howmany; // ditto - - -void transport_sendPacketBuffernb_start(int sock, unsigned char* buf, int buflen) -{ - from = buf; // from[sock] or mystruct[sock].from - howmany = buflen; // myhowmany[sock] or mystruct[sock].howmany -} - -int transport_sendPacketBuffernb(int sock) -{ -transport_iofunctions_t *myio = io; // io[sock] or mystruct[sock].io -int len; - - /* you should have called open() with a valid pointer to a valid struct and - called sendPacketBuffernb_start with a valid buffer, before calling this */ - assert((myio != NULL) && (myio->send != NULL) && (from != NULL)); - if((len = myio->send(from, howmany)) > 0){ - from += len; - if((howmany -= len) <= 0){ - return TRANSPORT_DONE; - } - } else if(len < 0){ - return TRANSPORT_ERROR; - } - return TRANSPORT_AGAIN; -} - -int transport_sendPacketBuffer(int sock, unsigned char* buf, int buflen) -{ -int rc; - - transport_sendPacketBuffernb_start(sock, buf, buflen); - while((rc=transport_sendPacketBuffernb(sock)) == TRANSPORT_AGAIN){ - /* this is unlikely to loop forever unless there is a hardware problem */ - } - if(rc == TRANSPORT_DONE){ - return buflen; - } - return TRANSPORT_ERROR; -} - - -int transport_getdata(unsigned char* buf, int count) -{ - assert(0); /* This function is NOT supported, it is just here to tease you */ - return TRANSPORT_ERROR; /* nah, it is here for similarity with other transport examples */ -} - -int transport_getdatanb(void *sck, unsigned char* buf, int count) -{ -//int sock = *((int *)sck); /* sck: pointer to whatever the system may use to identify the transport */ -transport_iofunctions_t *myio = io; // io[sock] or mystruct[sock].io -int len; - - /* you should have called open() with a valid pointer to a valid struct before calling this */ - assert((myio != NULL) && (myio->recv != NULL)); - /* this call will return immediately if no bytes, or return whatever outstanding bytes we have, - upto count */ - if((len = myio->recv(buf, count)) >= 0) - return len; - return TRANSPORT_ERROR; -} - -/** -return >=0 for a connection descriptor, <0 for an error code -*/ -int transport_open(transport_iofunctions_t *thisio) -{ -int idx=0; // for multiple connections, you might, basically turn myio into myio[MAX_CONNECTIONS], - - //if((idx=assignidx()) >= MAX_CONNECTIONS) // somehow assign an index, - // return TRANSPORT_ERROR; - io = thisio; // store myio[idx] = thisio, or mystruct[idx].io = thisio, - return idx; // and return the index used -} - -int transport_close(int sock) -{ -int rc=TRANSPORT_DONE; - - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.h deleted file mode 100644 index becb8d70bf8642ea4f26eab81102f79907c5d406..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/baremetalserial/transport.h +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - media specifics, nice api doc :^) - *******************************************************************************/ - -typedef struct { - int (*send)(unsigned char *address, unsigned int bytes); ///< pointer to function to send 'bytes' bytes, returns the actual number of bytes sent - int (*recv)(unsigned char *address, unsigned int maxbytes); ///< pointer to function to receive upto 'maxbytes' bytes, returns the actual number of bytes copied -} transport_iofunctions_t; - -#define TRANSPORT_DONE 1 -#define TRANSPORT_AGAIN 0 -#define TRANSPORT_ERROR -1 -/** -@note Blocks until requested buflen is sent -*/ -int transport_sendPacketBuffer(int sock, unsigned char* buf, int buflen); -/** -@note Blocks until requested count is received, as MQTTPacket_read() expects -@warning This function is not supported (not implemented) -@warning unless you provide a timeout, this function can block forever. Socket based systems do have -a built in timeout, if your system can provide this, do modify this function, otherwise use getdatanb() instead -@returns number of bytes read -*/ -int transport_getdata(unsigned char* buf, int count); - -/** -This is a bare metal implementation, so we must have non-blocking functions, -the process of pumping to serial lines can result a bit slow and we don't want to busy wait. -This function starts the process, you will call sendPacketBuffernb() until it reports success (or error) -*/ -void transport_sendPacketBuffernb_start(int sock, unsigned char* buf, int buflen); -/** -This is a bare metal implementation, so we must have non-blocking functions, -the process of pumping to serial lines can result a bit slow and we don't want to busy wait -@returns TRANSPORT_DONE if finished, TRANSPORT_AGAIN for call again, or TRANSPORT_ERROR on error -@note you will call again until it finishes (this is stream) -*/ -int transport_sendPacketBuffernb(int sock); - -/** -This is a bare metal implementation, so we must have non-blocking functions, -the process of sucking from serial lines can result a bit slow and we don't want to busy wait -@return the actual number of bytes read, 0 for none, or TRANSPORT_ERROR on error -@note you will call again until total number of expected bytes is read (this is stream) -*/ -int transport_getdatanb(void *sck, unsigned char* buf, int count); - -/** -We assume whatever connection needs to be done, it is externally established by the specifics of the hardware -E.g.: -A cell modem: you will call AT+whatever and put the modem in transparent mode, OR, you will embed -the AT+xSENDx / AT+xRECVx commands into the former sendPacketBuffer() and getdatanb() functions -@param thisio pointer to a structure containing all necessary stuff to handle direct serial I/O -@returns whatever indicator the system assigns to this link, if any. (a.k.a. : 'sock'), or TRANSPORT_ERROR for error -*/ -int transport_open(transport_iofunctions_t *thisio); -int transport_close(int sock); diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/build b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/build deleted file mode 100644 index 6b452ee485687786c06a8afe748f07c59831dd8d..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/build +++ /dev/null @@ -1,6 +0,0 @@ -gcc -Wall -c transport.c -Os -s -gcc qos0pub.c transport.o -I ../src ../src/MQTTConnectClient.c ../src/MQTTSerializePublish.c ../src/MQTTPacket.c -o qos0pub -Os -s - -gcc pub0sub1.c transport.o -I ../src ../src/MQTTConnectClient.c ../src/MQTTSerializePublish.c ../src/MQTTPacket.c ../src/MQTTSubscribeClient.c -o pub0sub1 ../src/MQTTDeserializePublish.c -Os -s ../src/MQTTConnectServer.c ../src/MQTTSubscribeServer.c ../src/MQTTUnsubscribeServer.c ../src/MQTTUnsubscribeClient.c -ggdb -gcc pub0sub1_nb.c transport.o -I ../src ../src/MQTTConnectClient.c ../src/MQTTSerializePublish.c ../src/MQTTPacket.c ../src/MQTTSubscribeClient.c -o pub0sub1_nb ../src/MQTTDeserializePublish.c -Os -s ../src/MQTTConnectServer.c ../src/MQTTSubscribeServer.c ../src/MQTTUnsubscribeServer.c ../src/MQTTUnsubscribeClient.c -ggdb - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/null.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/null.c deleted file mode 100644 index c05c0c4bdf591a68fe5b426769f73581d0836909..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/null.c +++ /dev/null @@ -1,4 +0,0 @@ -int main(int argc, char **argv) -{ - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping.c deleted file mode 100644 index c0bc27caee3e4497a5165ee6fe7d7870abf81b80..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping.c +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - port - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -#define KEEPALIVE_INTERVAL 20 - -/* This is to get a timebase in seconds to test the sample */ -#include -time_t old_t; -void start_ping_timer(void) -{ - time(&old_t); - old_t += KEEPALIVE_INTERVAL/2 + 1; -} - -int time_to_ping(void) -{ -time_t t; - - time(&t); - if(t >= old_t) - return 1; - return 0; -} - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach*/ -#include - -int toStop = 0; - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} -/* */ - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int len = 0; - char *host = "m2m.eclipse.org"; - int port = 1883; - - stop_init(); - if (argc > 1) - host = argv[1]; - - if (argc > 2) - port = atoi(argv[2]); - - mysock = transport_open(host, port); - if(mysock < 0) - return mysock; - - printf("Sending to hostname %s port %d\n", host, port); - - data.clientID.cstring = "me"; - data.keepAliveInterval = KEEPALIVE_INTERVAL; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - rc = transport_sendPacketBuffer(mysock, buf, len); - - printf("Sent MQTT connect\n"); - /* wait for connack */ - if (MQTTPacket_read(buf, buflen, transport_getdata) == CONNACK) - { - unsigned char sessionPresent, connack_rc; - - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0) - { - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - } - else - goto exit; - - printf("MQTT connected\n"); - start_ping_timer(); - - while (!toStop) - { - while(!time_to_ping()); - len = MQTTSerialize_pingreq(buf, buflen); - transport_sendPacketBuffer(mysock, buf, len); - printf("Ping..."); - if (MQTTPacket_read(buf, buflen, transport_getdata) == PINGRESP){ - printf("Pong\n"); - start_ping_timer(); - } - else { - printf("OOPS\n"); - goto exit; - } - - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping_nb.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping_nb.c deleted file mode 100644 index aa51e2c6d5cc3dbf9a1d05afc7373f17ca6af299..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/ping_nb.c +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - port and nonblocking - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -#define KEEPALIVE_INTERVAL 20 - -/* This is to get a timebase in seconds to test the sample */ -#include -time_t old_t; -void start_ping_timer(void) -{ - time(&old_t); - old_t += KEEPALIVE_INTERVAL/2 + 1; -} - -int time_to_ping(void) -{ -time_t t; - - time(&t); - if(t >= old_t) - return 1; - return 0; -} - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach*/ -#include - -int toStop = 0; - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} -/* */ - -enum states { IDLE, GETPONG }; - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int len = 0; - char *host = "m2m.eclipse.org"; - int port = 1883; - MQTTTransport mytransport; - int state; - - stop_init(); - if (argc > 1) - host = argv[1]; - - if (argc > 2) - port = atoi(argv[2]); - - mysock = transport_open(host, port); - if(mysock < 0) - return mysock; - - printf("Sending to hostname %s port %d\n", host, port); - - mytransport.sck = &mysock; - mytransport.getfn = transport_getdatanb; - mytransport.state = 0; - data.clientID.cstring = "me"; - data.keepAliveInterval = KEEPALIVE_INTERVAL; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - rc = transport_sendPacketBuffer(mysock, buf, len); - - printf("Sent MQTT connect\n"); - /* wait for connack */ - do { - int frc; - if ((frc=MQTTPacket_readnb(buf, buflen, &mytransport)) == CONNACK){ - unsigned char sessionPresent, connack_rc; - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0){ - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - break; - } - else if (frc == -1) - goto exit; - } while (1); /* handle timeouts here */ - - printf("MQTT connected\n"); - start_ping_timer(); - - state = IDLE; - while (!toStop) { - switch(state){ - case IDLE: - if(time_to_ping()){ - len = MQTTSerialize_pingreq(buf, buflen); - transport_sendPacketBuffer(mysock, buf, len); - printf("Ping..."); - state = GETPONG; - } - break; - case GETPONG: - if((rc=MQTTPacket_readnb(buf, buflen, &mytransport)) == PINGRESP){ - printf("Pong\n"); - start_ping_timer(); - state = IDLE; - } else if(rc == -1){ - printf("OOPS\n"); - goto exit; - } - break; - } - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1.c deleted file mode 100644 index 37bc2d4924a14db9002eb8b39759e3c3de27a7f7..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1.c +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - clarifications and/or documentation extension - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach*/ -#include - -int toStop = 0; - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} -/* */ - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int msgid = 1; - MQTTString topicString = MQTTString_initializer; - int req_qos = 0; - char* payload = "mypayload"; - int payloadlen = strlen(payload); - int len = 0; - char *host = "m2m.eclipse.org"; - int port = 1883; - - stop_init(); - if (argc > 1) - host = argv[1]; - - if (argc > 2) - port = atoi(argv[2]); - - mysock = transport_open(host, port); - if(mysock < 0) - return mysock; - - printf("Sending to hostname %s port %d\n", host, port); - - data.clientID.cstring = "me"; - data.keepAliveInterval = 20; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - rc = transport_sendPacketBuffer(mysock, buf, len); - - /* wait for connack */ - if (MQTTPacket_read(buf, buflen, transport_getdata) == CONNACK) - { - unsigned char sessionPresent, connack_rc; - - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0) - { - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - } - else - goto exit; - - /* subscribe */ - topicString.cstring = "substopic"; - len = MQTTSerialize_subscribe(buf, buflen, 0, msgid, 1, &topicString, &req_qos); - - rc = transport_sendPacketBuffer(mysock, buf, len); - if (MQTTPacket_read(buf, buflen, transport_getdata) == SUBACK) /* wait for suback */ - { - unsigned short submsgid; - int subcount; - int granted_qos; - - rc = MQTTDeserialize_suback(&submsgid, 1, &subcount, &granted_qos, buf, buflen); - if (granted_qos != 0) - { - printf("granted qos != 0, %d\n", granted_qos); - goto exit; - } - } - else - goto exit; - - /* loop getting msgs on subscribed topic */ - topicString.cstring = "pubtopic"; - while (!toStop) - { - /* transport_getdata() has a built-in 1 second timeout, - your mileage will vary */ - if (MQTTPacket_read(buf, buflen, transport_getdata) == PUBLISH) - { - unsigned char dup; - int qos; - unsigned char retained; - unsigned short msgid; - int payloadlen_in; - unsigned char* payload_in; - int rc; - MQTTString receivedTopic; - - rc = MQTTDeserialize_publish(&dup, &qos, &retained, &msgid, &receivedTopic, - &payload_in, &payloadlen_in, buf, buflen); - printf("message arrived %.*s\n", payloadlen_in, payload_in); - } - - printf("publishing reading\n"); - len = MQTTSerialize_publish(buf, buflen, 0, 0, 0, 0, topicString, (unsigned char*)payload, payloadlen); - rc = transport_sendPacketBuffer(mysock, buf, len); - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1_nb.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1_nb.c deleted file mode 100644 index fdc79ba5335f7db74b38b02bf999c47a23d8a63b..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/pub0sub1_nb.c +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - clarifications and/or documentation extension - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - -/* This is in order to get an asynchronous signal to stop the sample, -as the code loops waiting for msgs on the subscribed topic. -Your actual code will depend on your hw and approach*/ -#include - -int toStop = 0; - -void cfinish(int sig) -{ - signal(SIGINT, NULL); - toStop = 1; -} - -void stop_init(void) -{ - signal(SIGINT, cfinish); - signal(SIGTERM, cfinish); -} -/* */ - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - int mysock = 0; - unsigned char buf[200]; - int buflen = sizeof(buf); - int msgid = 1; - MQTTString topicString = MQTTString_initializer; - int req_qos = 0; - char* payload = "mypayload"; - int payloadlen = strlen(payload); - int len = 0; - char *host = "m2m.eclipse.org"; - int port = 1883; - MQTTTransport mytransport; - - stop_init(); - if (argc > 1) - host = argv[1]; - - if (argc > 2) - port = atoi(argv[2]); - - mysock = transport_open(host, port); - if(mysock < 0) - return mysock; - - printf("Sending to hostname %s port %d\n", host, port); - - mytransport.sck = &mysock; - mytransport.getfn = transport_getdatanb; - mytransport.state = 0; - data.clientID.cstring = "me"; - data.keepAliveInterval = 20; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - - len = MQTTSerialize_connect(buf, buflen, &data); - rc = transport_sendPacketBuffer(mysock, buf, len); - - /* wait for connack */ - if (MQTTPacket_read(buf, buflen, transport_getdata) == CONNACK) - { - unsigned char sessionPresent, connack_rc; - - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) != 1 || connack_rc != 0) - { - printf("Unable to connect, return code %d\n", connack_rc); - goto exit; - } - } - else - goto exit; - - /* subscribe */ - topicString.cstring = "substopic"; - len = MQTTSerialize_subscribe(buf, buflen, 0, msgid, 1, &topicString, &req_qos); - - rc = transport_sendPacketBuffer(mysock, buf, len); - do { - int frc; - if ((frc=MQTTPacket_readnb(buf, buflen, &mytransport)) == SUBACK) /* wait for suback */ - { - unsigned short submsgid; - int subcount; - int granted_qos; - - rc = MQTTDeserialize_suback(&submsgid, 1, &subcount, &granted_qos, buf, buflen); - if (granted_qos != 0) - { - printf("granted qos != 0, %d\n", granted_qos); - goto exit; - } - break; - } - else if (frc == -1) - goto exit; - } while (1); /* handle timeouts here */ - /* loop getting msgs on subscribed topic */ - topicString.cstring = "pubtopic"; - while (!toStop) - { - /* handle timeouts */ - if (MQTTPacket_readnb(buf, buflen, &mytransport) == PUBLISH) - { - unsigned char dup; - int qos; - unsigned char retained; - unsigned short msgid; - int payloadlen_in; - unsigned char* payload_in; - int rc; - MQTTString receivedTopic; - - rc = MQTTDeserialize_publish(&dup, &qos, &retained, &msgid, &receivedTopic, - &payload_in, &payloadlen_in, buf, buflen); - printf("message arrived %.*s\n", payloadlen_in, payload_in); - printf("publishing reading\n"); - len = MQTTSerialize_publish(buf, buflen, 0, 0, 0, 0, topicString, (unsigned char*)payload, payloadlen); - rc = transport_sendPacketBuffer(mysock, buf, len); - } - } - - printf("disconnecting\n"); - len = MQTTSerialize_disconnect(buf, buflen); - rc = transport_sendPacketBuffer(mysock, buf, len); - -exit: - transport_close(mysock); - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/qos0pub.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/qos0pub.c deleted file mode 100644 index 8b0af7759f2f4de974bba030e689d22bbb34c4c0..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/qos0pub.c +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - clarifications and/or documentation extension - *******************************************************************************/ - -#include -#include -#include - -#include "MQTTPacket.h" -#include "transport.h" - - -int main(int argc, char *argv[]) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - int rc = 0; - char buf[200]; - int buflen = sizeof(buf); - int mysock = 0; - MQTTString topicString = MQTTString_initializer; - char* payload = "mypayload"; - int payloadlen = strlen(payload); - int len = 0; - char *host = "m2m.eclipse.org"; - int port = 1883; - - if (argc > 1) - host = argv[1]; - - if (argc > 2) - port = atoi(argv[2]); - - mysock = transport_open(host,port); - if(mysock < 0) - return mysock; - - printf("Sending to hostname %s port %d\n", host, port); - - data.clientID.cstring = "me"; - data.keepAliveInterval = 20; - data.cleansession = 1; - data.username.cstring = "testuser"; - data.password.cstring = "testpassword"; - data.MQTTVersion = 4; - - len = MQTTSerialize_connect((unsigned char *)buf, buflen, &data); - - topicString.cstring = "mytopic"; - len += MQTTSerialize_publish((unsigned char *)(buf + len), buflen - len, 0, 0, 0, 0, topicString, (unsigned char *)payload, payloadlen); - - len += MQTTSerialize_disconnect((unsigned char *)(buf + len), buflen - len); - - rc = transport_sendPacketBuffer(mysock, (unsigned char*)buf, len); - if (rc == len) - printf("Successfully published\n"); - else - printf("Publish failed\n"); - -exit: - transport_close(mysock); - - return 0; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.c deleted file mode 100644 index 98ded0eb75bcb84c9aae96562fe6880f69fe1550..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.c +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - "commonalization" from prior samples and/or documentation extension - *******************************************************************************/ - -#include - -#if !defined(SOCKET_ERROR) - /** error in socket operation */ - #define SOCKET_ERROR -1 -#endif - -#if defined(WIN32) -/* default on Windows is 64 - increase to make Linux and Windows the same */ -#define FD_SETSIZE 1024 -#include -#include -#define MAXHOSTNAMELEN 256 -#define EAGAIN WSAEWOULDBLOCK -#define EINTR WSAEINTR -#define EINVAL WSAEINVAL -#define EINPROGRESS WSAEINPROGRESS -#define EWOULDBLOCK WSAEWOULDBLOCK -#define ENOTCONN WSAENOTCONN -#define ECONNRESET WSAECONNRESET -#define ioctl ioctlsocket -#define socklen_t int -#else -#define INVALID_SOCKET SOCKET_ERROR -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#if defined(WIN32) -#include -#else -#include -#include -#endif - -/** -This simple low-level implementation assumes a single connection for a single thread. Thus, a static -variable is used for that connection. -On other scenarios, the user must solve this by taking into account that the current implementation of -MQTTPacket_read() has a function pointer for a function call to get the data to a buffer, but no provisions -to know the caller or other indicator (the socket id): int (*getfn)(unsigned char*, int) -*/ -static int mysock = INVALID_SOCKET; - - -int transport_sendPacketBuffer(int sock, unsigned char* buf, int buflen) -{ - int rc = 0; - rc = write(sock, buf, buflen); - return rc; -} - - -int transport_getdata(unsigned char* buf, int count) -{ - int rc = recv(mysock, buf, count, 0); - //printf("received %d bytes count %d\n", rc, (int)count); - return rc; -} - -int transport_getdatanb(void *sck, unsigned char* buf, int count) -{ - int sock = *((int *)sck); /* sck: pointer to whatever the system may use to identify the transport */ - /* this call will return after the timeout set on initialization if no bytes; - in your system you will use whatever you use to get whichever outstanding - bytes your socket equivalent has ready to be extracted right now, if any, - or return immediately */ - int rc = recv(sock, buf, count, 0); - if (rc == -1) { - /* check error conditions from your system here, and return -1 */ - return 0; - } - return rc; -} - -/** -return >=0 for a socket descriptor, <0 for an error code -@todo Basically moved from the sample without changes, should accomodate same usage for 'sock' for clarity, -removing indirections -*/ -int transport_open(char* addr, int port) -{ -int* sock = &mysock; - int type = SOCK_STREAM; - struct sockaddr_in address; -#if defined(AF_INET6) - struct sockaddr_in6 address6; -#endif - int rc = -1; -#if defined(WIN32) - short family; -#else - sa_family_t family = AF_INET; -#endif - struct addrinfo *result = NULL; - struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL}; - static struct timeval tv; - - *sock = -1; - if (addr[0] == '[') - ++addr; - - if ((rc = getaddrinfo(addr, NULL, &hints, &result)) == 0) - { - struct addrinfo* res = result; - - /* prefer ip4 addresses */ - while (res) - { - if (res->ai_family == AF_INET) - { - result = res; - break; - } - res = res->ai_next; - } - -#if defined(AF_INET6) - if (result->ai_family == AF_INET6) - { - address6.sin6_port = htons(port); - address6.sin6_family = family = AF_INET6; - address6.sin6_addr = ((struct sockaddr_in6*)(result->ai_addr))->sin6_addr; - } - else -#endif - if (result->ai_family == AF_INET) - { - address.sin_port = htons(port); - address.sin_family = family = AF_INET; - address.sin_addr = ((struct sockaddr_in*)(result->ai_addr))->sin_addr; - } - else - rc = -1; - - freeaddrinfo(result); - } - - if (rc == 0) - { - *sock = socket(family, type, 0); - if (*sock != -1) - { -#if defined(NOSIGPIPE) - int opt = 1; - - if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) - Log(TRACE_MIN, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock); -#endif - - if (family == AF_INET) - rc = connect(*sock, (struct sockaddr*)&address, sizeof(address)); - #if defined(AF_INET6) - else - rc = connect(*sock, (struct sockaddr*)&address6, sizeof(address6)); - #endif - } - } - if (mysock == INVALID_SOCKET) - return rc; - - tv.tv_sec = 1; /* 1 second Timeout */ - tv.tv_usec = 0; - setsockopt(mysock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval)); - return mysock; -} - -int transport_close(int sock) -{ -int rc; - - rc = shutdown(sock, SHUT_WR); - rc = recv(sock, NULL, (size_t)0, 0); - rc = close(sock); - - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.h deleted file mode 100644 index c3e7b6c312da14513e27ca84fecbcd32b850a631..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/samples/transport.h +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - "commonalization" from prior samples and/or documentation extension - *******************************************************************************/ - -int transport_sendPacketBuffer(int sock, unsigned char* buf, int buflen); -int transport_getdata(unsigned char* buf, int count); -int transport_getdatanb(void *sck, unsigned char* buf, int count); -int transport_open(char* host, int port); -int transport_close(int sock); diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/CMakeLists.txt deleted file mode 100644 index 5a6bd76060618d122e4b9be644a3e0d0e7f2b877..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2017 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Ian Craggs - initial version -#*******************************************************************************/ - -# MQTTPacket Library -file(GLOB SOURCES "*.c") -add_library(paho-embed-mqtt3c SHARED ${SOURCES}) -install(TARGETS paho-embed-mqtt3c DESTINATION /usr/lib) -target_compile_definitions(paho-embed-mqtt3c PRIVATE MQTT_SERVER MQTT_CLIENT) - -add_library(MQTTPacketClient SHARED MQTTFormat MQTTPacket - MQTTSerializePublish MQTTDeserializePublish - MQTTConnectClient MQTTSubscribeClient MQTTUnsubscribeClient) -target_compile_definitions(MQTTPacketClient PRIVATE MQTT_CLIENT) - -add_library(MQTTPacketServer SHARED MQTTFormat MQTTPacket - MQTTSerializePublish MQTTDeserializePublish - MQTTConnectServer MQTTSubscribeServer MQTTUnsubscribeServer) -target_compile_definitions(MQTTPacketServer PRIVATE MQTT_SERVER) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnect.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnect.h deleted file mode 100644 index 4d247a3c28c04e0793d5474967bc9a1558594a91..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnect.h +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014, 2017 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Xiang Rong - 442039 Add makefile to Embedded C client - * Ian Craggs - fix for issue #64, bit order in connack response - *******************************************************************************/ - -#ifndef MQTTCONNECT_H_ -#define MQTTCONNECT_H_ - -#if !defined(DLLImport) - #define DLLImport -#endif -#if !defined(DLLExport) - #define DLLExport -#endif - - -typedef union -{ - unsigned char all; /**< all connect flags */ -#if defined(REVERSED) - struct - { - unsigned int username : 1; /**< 3.1 user name */ - unsigned int password : 1; /**< 3.1 password */ - unsigned int willRetain : 1; /**< will retain setting */ - unsigned int willQoS : 2; /**< will QoS value */ - unsigned int will : 1; /**< will flag */ - unsigned int cleansession : 1; /**< clean session flag */ - unsigned int : 1; /**< unused */ - } bits; -#else - struct - { - unsigned int : 1; /**< unused */ - unsigned int cleansession : 1; /**< cleansession flag */ - unsigned int will : 1; /**< will flag */ - unsigned int willQoS : 2; /**< will QoS value */ - unsigned int willRetain : 1; /**< will retain setting */ - unsigned int password : 1; /**< 3.1 password */ - unsigned int username : 1; /**< 3.1 user name */ - } bits; -#endif -} MQTTConnectFlags; /**< connect flags byte */ - - - -/** - * Defines the MQTT "Last Will and Testament" (LWT) settings for - * the connect packet. - */ -typedef struct -{ - /** The eyecatcher for this structure. must be MQTW. */ - char struct_id[4]; - /** The version number of this structure. Must be 0 */ - int struct_version; - /** The LWT topic to which the LWT message will be published. */ - MQTTString topicName; - /** The LWT payload. */ - MQTTString message; - /** - * The retained flag for the LWT message (see MQTTAsync_message.retained). - */ - unsigned char retained; - /** - * The quality of service setting for the LWT message (see - * MQTTAsync_message.qos and @ref qos). - */ - char qos; -} MQTTPacket_willOptions; - - -#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 } - - -typedef struct -{ - /** The eyecatcher for this structure. must be MQTC. */ - char struct_id[4]; - /** The version number of this structure. Must be 0 */ - int struct_version; - /** Version of MQTT to be used. 3 = 3.1 4 = 3.1.1 - */ - unsigned char MQTTVersion; - MQTTString clientID; - unsigned short keepAliveInterval; - unsigned char cleansession; - unsigned char willFlag; - MQTTPacket_willOptions will; - MQTTString username; - MQTTString password; -} MQTTPacket_connectData; - -typedef union -{ - unsigned char all; /**< all connack flags */ -#if defined(REVERSED) - struct - { - unsigned int reserved : 7; /**< unused */ - unsigned int sessionpresent : 1; /**< session present flag */ - } bits; -#else - struct - { - unsigned int sessionpresent : 1; /**< session present flag */ - unsigned int reserved: 7; /**< unused */ - } bits; -#endif -} MQTTConnackFlags; /**< connack flags byte */ - -#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \ - MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} } - -DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options); -DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len); - -DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent); -DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen); - -DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen); -DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen); - -#endif /* MQTTCONNECT_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectClient.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectClient.c deleted file mode 100644 index 5f3cc2963c8995556476946a1f9580063573cd85..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectClient.c +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - -/** - * Determines the length of the MQTT connect packet that would be produced using the supplied connect options. - * @param options the options to be used to build the connect packet - * @return the length of buffer needed to contain the serialized version of the packet - */ -int MQTTSerialize_connectLength(MQTTPacket_connectData* options) -{ - int len = 0; - - FUNC_ENTRY; - - if (options->MQTTVersion == 3) - len = 12; /* variable depending on MQTT or MQIsdp */ - else if (options->MQTTVersion == 4) - len = 10; - - len += MQTTstrlen(options->clientID)+2; - if (options->willFlag) - len += MQTTstrlen(options->will.topicName)+2 + MQTTstrlen(options->will.message)+2; - if (options->username.cstring || options->username.lenstring.data) - len += MQTTstrlen(options->username)+2; - if (options->password.cstring || options->password.lenstring.data) - len += MQTTstrlen(options->password)+2; - - FUNC_EXIT_RC(len); - return len; -} - - -/** - * Serializes the connect options into the buffer. - * @param buf the buffer into which the packet will be serialized - * @param len the length in bytes of the supplied buffer - * @param options the options to be used to build the connect packet - * @return serialized length, or error if 0 - */ -int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options) -{ - unsigned char *ptr = buf; - MQTTHeader header = {0}; - MQTTConnectFlags flags = {0}; - int len = 0; - int rc = -1; - - FUNC_ENTRY; - if (MQTTPacket_len(len = MQTTSerialize_connectLength(options)) > buflen) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - - header.byte = 0; - header.bits.type = CONNECT; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, len); /* write remaining length */ - - if (options->MQTTVersion == 4) - { - writeCString(&ptr, "MQTT"); - writeChar(&ptr, (char) 4); - } - else - { - writeCString(&ptr, "MQIsdp"); - writeChar(&ptr, (char) 3); - } - - flags.all = 0; - flags.bits.cleansession = options->cleansession; - flags.bits.will = (options->willFlag) ? 1 : 0; - if (flags.bits.will) - { - flags.bits.willQoS = options->will.qos; - flags.bits.willRetain = options->will.retained; - } - - if (options->username.cstring || options->username.lenstring.data) - flags.bits.username = 1; - if (options->password.cstring || options->password.lenstring.data) - flags.bits.password = 1; - - writeChar(&ptr, flags.all); - writeInt(&ptr, options->keepAliveInterval); - writeMQTTString(&ptr, options->clientID); - if (options->willFlag) - { - writeMQTTString(&ptr, options->will.topicName); - writeMQTTString(&ptr, options->will.message); - } - if (flags.bits.username) - writeMQTTString(&ptr, options->username); - if (flags.bits.password) - writeMQTTString(&ptr, options->password); - - rc = ptr - buf; - - exit: FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Deserializes the supplied (wire) buffer into connack data - return code - * @param sessionPresent the session present flag returned (only for MQTT 3.1.1) - * @param connack_rc returned integer value of the connack return code - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param len the length in bytes of the data in the supplied buffer - * @return error code. 1 is success, 0 is failure - */ -int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = 0; - int mylen; - MQTTConnackFlags flags = {0}; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != CONNACK) - goto exit; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - if (enddata - curdata < 2) - goto exit; - - flags.all = readChar(&curdata); - *sessionPresent = flags.bits.sessionpresent; - *connack_rc = readChar(&curdata); - - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes a 0-length packet into the supplied buffer, ready for writing to a socket - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer, to avoid overruns - * @param packettype the message type - * @return serialized length, or error if 0 - */ -int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype) -{ - MQTTHeader header = {0}; - int rc = -1; - unsigned char *ptr = buf; - - FUNC_ENTRY; - if (buflen < 2) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - header.byte = 0; - header.bits.type = packettype; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */ - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes a disconnect packet into the supplied buffer, ready for writing to a socket - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer, to avoid overruns - * @return serialized length, or error if 0 - */ -int MQTTSerialize_disconnect(unsigned char* buf, int buflen) -{ - return MQTTSerialize_zero(buf, buflen, DISCONNECT); -} - - -/** - * Serializes a disconnect packet into the supplied buffer, ready for writing to a socket - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer, to avoid overruns - * @return serialized length, or error if 0 - */ -int MQTTSerialize_pingreq(unsigned char* buf, int buflen) -{ - return MQTTSerialize_zero(buf, buflen, PINGREQ); -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectServer.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectServer.c deleted file mode 100644 index 07c7cb53743d1e12ede274cb9d5ea7d0fe3ad51a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTConnectServer.c +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "StackTrace.h" -#include "MQTTPacket.h" -#include - -#define min(a, b) ((a < b) ? a : b) - - -/** - * Validates MQTT protocol name and version combinations - * @param protocol the MQTT protocol name as an MQTTString - * @param version the MQTT protocol version number, as in the connect packet - * @return correct MQTT combination? 1 is true, 0 is false - */ -int MQTTPacket_checkVersion(MQTTString* protocol, int version) -{ - int rc = 0; - - if (version == 3 && memcmp(protocol->lenstring.data, "MQIsdp", - min(6, protocol->lenstring.len)) == 0) - rc = 1; - else if (version == 4 && memcmp(protocol->lenstring.data, "MQTT", - min(4, protocol->lenstring.len)) == 0) - rc = 1; - return rc; -} - - -/** - * Deserializes the supplied (wire) buffer into connect data structure - * @param data the connect data structure to be filled out - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param len the length in bytes of the data in the supplied buffer - * @return error code. 1 is success, 0 is failure - */ -int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len) -{ - MQTTHeader header = {0}; - MQTTConnectFlags flags = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = &buf[len]; - int rc = 0; - MQTTString Protocol; - int version; - int mylen = 0; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != CONNECT) - goto exit; - - curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */ - - if (!readMQTTLenString(&Protocol, &curdata, enddata) || - enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */ - goto exit; - - version = (int)readChar(&curdata); /* Protocol version */ - /* If we don't recognize the protocol version, we don't parse the connect packet on the - * basis that we don't know what the format will be. - */ - if (MQTTPacket_checkVersion(&Protocol, version)) - { - flags.all = readChar(&curdata); - data->cleansession = flags.bits.cleansession; - data->keepAliveInterval = readInt(&curdata); - if (!readMQTTLenString(&data->clientID, &curdata, enddata)) - goto exit; - data->willFlag = flags.bits.will; - if (flags.bits.will) - { - data->will.qos = flags.bits.willQoS; - data->will.retained = flags.bits.willRetain; - if (!readMQTTLenString(&data->will.topicName, &curdata, enddata) || - !readMQTTLenString(&data->will.message, &curdata, enddata)) - goto exit; - } - if (flags.bits.username) - { - if (enddata - curdata < 3 || !readMQTTLenString(&data->username, &curdata, enddata)) - goto exit; /* username flag set, but no username supplied - invalid */ - if (flags.bits.password && - (enddata - curdata < 3 || !readMQTTLenString(&data->password, &curdata, enddata))) - goto exit; /* password flag set, but no password supplied - invalid */ - } - else if (flags.bits.password) - goto exit; /* password flag set without username - invalid */ - rc = 1; - } -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes the connack packet into the supplied buffer. - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param connack_rc the integer connack return code to be used - * @param sessionPresent the MQTT 3.1.1 sessionPresent flag - * @return serialized length, or error if 0 - */ -int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent) -{ - MQTTHeader header = {0}; - int rc = 0; - unsigned char *ptr = buf; - MQTTConnackFlags flags = {0}; - - FUNC_ENTRY; - if (buflen < 2) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - header.byte = 0; - header.bits.type = CONNACK; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */ - - flags.all = 0; - flags.bits.sessionpresent = sessionPresent; - writeChar(&ptr, flags.all); - writeChar(&ptr, connack_rc); - - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTDeserializePublish.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTDeserializePublish.c deleted file mode 100644 index dafb6a32a1d5ff70fc6410fb21451d1e0a5e0b10..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTDeserializePublish.c +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "StackTrace.h" -#include "MQTTPacket.h" -#include - -#define min(a, b) ((a < b) ? 1 : 0) - -/** - * Deserializes the supplied (wire) buffer into publish data - * @param dup returned integer - the MQTT dup flag - * @param qos returned integer - the MQTT QoS value - * @param retained returned integer - the MQTT retained flag - * @param packetid returned integer - the MQTT packet identifier - * @param topicName returned MQTTString - the MQTT topic in the publish - * @param payload returned byte buffer - the MQTT publish payload - * @param payloadlen returned integer - the length of the MQTT payload - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return error code. 1 is success - */ -int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName, - unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = 0; - int mylen = 0; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != PUBLISH) - goto exit; - *dup = header.bits.dup; - *qos = header.bits.qos; - *retained = header.bits.retain; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - - if (!readMQTTLenString(topicName, &curdata, enddata) || - enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */ - goto exit; - - if (*qos > 0) - *packetid = readInt(&curdata); - - *payloadlen = enddata - curdata; - *payload = curdata; - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - - -/** - * Deserializes the supplied (wire) buffer into an ack - * @param packettype returned integer - the MQTT packet type - * @param dup returned integer - the MQTT dup flag - * @param packetid returned integer - the MQTT packet identifier - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return error code. 1 is success, 0 is failure - */ -int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = 0; - int mylen; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - *dup = header.bits.dup; - *packettype = header.bits.type; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - - if (enddata - curdata < 2) - goto exit; - *packetid = readInt(&curdata); - - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.c deleted file mode 100644 index 2eff31f89d8ca51ef92617810574954f4283a673..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.c +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "StackTrace.h" -#include "MQTTPacket.h" - -#include - - -const char* MQTTPacket_names[] = -{ - "RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL", - "PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK", - "PINGREQ", "PINGRESP", "DISCONNECT" -}; - - -const char* MQTTPacket_getName(unsigned short packetid) -{ - return MQTTPacket_names[packetid]; -} - - -int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data) -{ - int strindex = 0; - - strindex = snprintf(strbuf, strbuflen, - "CONNECT MQTT version %d, client id %.*s, clean session %d, keep alive %d", - (int)data->MQTTVersion, data->clientID.lenstring.len, data->clientID.lenstring.data, - (int)data->cleansession, data->keepAliveInterval); - if (data->willFlag) - strindex += snprintf(&strbuf[strindex], strbuflen - strindex, - ", will QoS %d, will retain %d, will topic %.*s, will message %.*s", - data->will.qos, data->will.retained, - data->will.topicName.lenstring.len, data->will.topicName.lenstring.data, - data->will.message.lenstring.len, data->will.message.lenstring.data); - if (data->username.lenstring.data && data->username.lenstring.len > 0) - strindex += snprintf(&strbuf[strindex], strbuflen - strindex, - ", user name %.*s", data->username.lenstring.len, data->username.lenstring.data); - if (data->password.lenstring.data && data->password.lenstring.len > 0) - strindex += snprintf(&strbuf[strindex], strbuflen - strindex, - ", password %.*s", data->password.lenstring.len, data->password.lenstring.data); - return strindex; -} - - -int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent) -{ - int strindex = snprintf(strbuf, strbuflen, "CONNACK session present %d, rc %d", sessionPresent, connack_rc); - return strindex; -} - - -int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, - unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen) -{ - int strindex = snprintf(strbuf, strbuflen, - "PUBLISH dup %d, QoS %d, retained %d, packet id %d, topic %.*s, payload length %d, payload %.*s", - dup, qos, retained, packetid, - (topicName.lenstring.len < 20) ? topicName.lenstring.len : 20, topicName.lenstring.data, - payloadlen, (payloadlen < 20) ? payloadlen : 20, payload); - return strindex; -} - - -int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid) -{ - int strindex = snprintf(strbuf, strbuflen, "%s, packet id %d", MQTTPacket_names[packettype], packetid); - if (dup) - strindex += snprintf(strbuf + strindex, strbuflen - strindex, ", dup %d", dup); - return strindex; -} - - -int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, - MQTTString topicFilters[], int requestedQoSs[]) -{ - return snprintf(strbuf, strbuflen, - "SUBSCRIBE dup %d, packet id %d count %d topic %.*s qos %d", - dup, packetid, count, - topicFilters[0].lenstring.len, topicFilters[0].lenstring.data, - requestedQoSs[0]); -} - - -int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs) -{ - return snprintf(strbuf, strbuflen, - "SUBACK packet id %d count %d granted qos %d", packetid, count, grantedQoSs[0]); -} - - -int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, - int count, MQTTString topicFilters[]) -{ - return snprintf(strbuf, strbuflen, - "UNSUBSCRIBE dup %d, packet id %d count %d topic %.*s", - dup, packetid, count, - topicFilters[0].lenstring.len, topicFilters[0].lenstring.data); -} - - -#if defined(MQTT_CLIENT) -char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen) -{ - int index = 0; - int rem_length = 0; - MQTTHeader header = {0}; - int strindex = 0; - - header.byte = buf[index++]; - index += MQTTPacket_decodeBuf(&buf[index], &rem_length); - - switch (header.bits.type) - { - - case CONNACK: - { - unsigned char sessionPresent, connack_rc; - if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) == 1) - strindex = MQTTStringFormat_connack(strbuf, strbuflen, connack_rc, sessionPresent); - } - break; - case PUBLISH: - { - unsigned char dup, retained, *payload; - unsigned short packetid; - int qos, payloadlen; - MQTTString topicName = MQTTString_initializer; - if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName, - &payload, &payloadlen, buf, buflen) == 1) - strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid, - topicName, payload, payloadlen); - } - break; - case PUBACK: - case PUBREC: - case PUBREL: - case PUBCOMP: - { - unsigned char packettype, dup; - unsigned short packetid; - if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1) - strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid); - } - break; - case SUBACK: - { - unsigned short packetid; - int maxcount = 1, count = 0; - int grantedQoSs[1]; - if (MQTTDeserialize_suback(&packetid, maxcount, &count, grantedQoSs, buf, buflen) == 1) - strindex = MQTTStringFormat_suback(strbuf, strbuflen, packetid, count, grantedQoSs); - } - break; - case UNSUBACK: - { - unsigned short packetid; - if (MQTTDeserialize_unsuback(&packetid, buf, buflen) == 1) - strindex = MQTTStringFormat_ack(strbuf, strbuflen, UNSUBACK, 0, packetid); - } - break; - case PINGREQ: - case PINGRESP: - case DISCONNECT: - strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]); - break; - } - return strbuf; -} -#endif - -#if defined(MQTT_SERVER) -char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen) -{ - int index = 0; - int rem_length = 0; - MQTTHeader header = {0}; - int strindex = 0; - - header.byte = buf[index++]; - index += MQTTPacket_decodeBuf(&buf[index], &rem_length); - - switch (header.bits.type) - { - case CONNECT: - { - MQTTPacket_connectData data; - int rc; - if ((rc = MQTTDeserialize_connect(&data, buf, buflen)) == 1) - strindex = MQTTStringFormat_connect(strbuf, strbuflen, &data); - } - break; - case PUBLISH: - { - unsigned char dup, retained, *payload; - unsigned short packetid; - int qos, payloadlen; - MQTTString topicName = MQTTString_initializer; - if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName, - &payload, &payloadlen, buf, buflen) == 1) - strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid, - topicName, payload, payloadlen); - } - break; - case PUBACK: - case PUBREC: - case PUBREL: - case PUBCOMP: - { - unsigned char packettype, dup; - unsigned short packetid; - if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1) - strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid); - } - break; - case SUBSCRIBE: - { - unsigned char dup; - unsigned short packetid; - int maxcount = 1, count = 0; - MQTTString topicFilters[1]; - int requestedQoSs[1]; - if (MQTTDeserialize_subscribe(&dup, &packetid, maxcount, &count, - topicFilters, requestedQoSs, buf, buflen) == 1) - strindex = MQTTStringFormat_subscribe(strbuf, strbuflen, dup, packetid, count, topicFilters, requestedQoSs);; - } - break; - case UNSUBSCRIBE: - { - unsigned char dup; - unsigned short packetid; - int maxcount = 1, count = 0; - MQTTString topicFilters[1]; - if (MQTTDeserialize_unsubscribe(&dup, &packetid, maxcount, &count, topicFilters, buf, buflen) == 1) - strindex = MQTTStringFormat_unsubscribe(strbuf, strbuflen, dup, packetid, count, topicFilters); - } - break; - case PINGREQ: - case PINGRESP: - case DISCONNECT: - strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]); - break; - } - strbuf[strbuflen] = '\0'; - return strbuf; -} -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.h deleted file mode 100644 index 47b0c414341f193962785d0451aeab24da9154e4..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTFormat.h +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#if !defined(MQTTFORMAT_H) -#define MQTTFORMAT_H - -#include "StackTrace.h" -#include "MQTTPacket.h" - -const char* MQTTPacket_getName(unsigned short packetid); -int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data); -int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent); -int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, - unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen); -int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid); -int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, - MQTTString topicFilters[], int requestedQoSs[]); -int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs); -int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, - int count, MQTTString topicFilters[]); -char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen); -char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen); - -#endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.c deleted file mode 100644 index 4f1f95a780e288a231ef541ae9b2c34e2e7bdb49..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.c +++ /dev/null @@ -1,412 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Sergio R. Caprile - non-blocking packet read functions for stream transport - *******************************************************************************/ - -#include "StackTrace.h" -#include "MQTTPacket.h" - -#include - -/** - * Encodes the message length according to the MQTT algorithm - * @param buf the buffer into which the encoded data is written - * @param length the length to be encoded - * @return the number of bytes written to buffer - */ -int MQTTPacket_encode(unsigned char* buf, int length) -{ - int rc = 0; - - FUNC_ENTRY; - do - { - char d = length % 128; - length /= 128; - /* if there are more digits to encode, set the top bit of this digit */ - if (length > 0) - d |= 0x80; - buf[rc++] = d; - } while (length > 0); - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Decodes the message length according to the MQTT algorithm - * @param getcharfn pointer to function to read the next character from the data source - * @param value the decoded length returned - * @return the number of bytes read from the socket - */ -int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value) -{ - unsigned char c; - int multiplier = 1; - int len = 0; -#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4 - - FUNC_ENTRY; - *value = 0; - do - { - int rc = MQTTPACKET_READ_ERROR; - - if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES) - { - rc = MQTTPACKET_READ_ERROR; /* bad data */ - goto exit; - } - rc = (*getcharfn)(&c, 1); - if (rc != 1) - goto exit; - *value += (c & 127) * multiplier; - multiplier *= 128; - } while ((c & 128) != 0); -exit: - FUNC_EXIT_RC(len); - return len; -} - - -int MQTTPacket_len(int rem_len) -{ - rem_len += 1; /* header byte */ - - /* now remaining_length field */ - if (rem_len < 128) - rem_len += 1; - else if (rem_len < 16384) - rem_len += 2; - else if (rem_len < 2097151) - rem_len += 3; - else - rem_len += 4; - return rem_len; -} - - -static unsigned char* bufptr; - -int bufchar(unsigned char* c, int count) -{ - int i; - - for (i = 0; i < count; ++i) - *c = *bufptr++; - return count; -} - - -int MQTTPacket_decodeBuf(unsigned char* buf, int* value) -{ - bufptr = buf; - return MQTTPacket_decode(bufchar, value); -} - - -/** - * Calculates an integer from two bytes read from the input buffer - * @param pptr pointer to the input buffer - incremented by the number of bytes used & returned - * @return the integer value calculated - */ -int readInt(unsigned char** pptr) -{ - unsigned char* ptr = *pptr; - int len = 256*(*ptr) + (*(ptr+1)); - *pptr += 2; - return len; -} - - -/** - * Reads one character from the input buffer. - * @param pptr pointer to the input buffer - incremented by the number of bytes used & returned - * @return the character read - */ -char readChar(unsigned char** pptr) -{ - char c = **pptr; - (*pptr)++; - return c; -} - - -/** - * Writes one character to an output buffer. - * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned - * @param c the character to write - */ -void writeChar(unsigned char** pptr, char c) -{ - **pptr = c; - (*pptr)++; -} - - -/** - * Writes an integer as 2 bytes to an output buffer. - * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned - * @param anInt the integer to write - */ -void writeInt(unsigned char** pptr, int anInt) -{ - **pptr = (unsigned char)(anInt / 256); - (*pptr)++; - **pptr = (unsigned char)(anInt % 256); - (*pptr)++; -} - - -/** - * Writes a "UTF" string to an output buffer. Converts C string to length-delimited. - * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned - * @param string the C string to write - */ -void writeCString(unsigned char** pptr, const char* string) -{ - int len = strlen(string); - writeInt(pptr, len); - memcpy(*pptr, string, len); - *pptr += len; -} - - -int getLenStringLen(char* ptr) -{ - int len = 256*((unsigned char)(*ptr)) + (unsigned char)(*(ptr+1)); - return len; -} - - -void writeMQTTString(unsigned char** pptr, MQTTString mqttstring) -{ - if (mqttstring.lenstring.len > 0) - { - writeInt(pptr, mqttstring.lenstring.len); - memcpy(*pptr, mqttstring.lenstring.data, mqttstring.lenstring.len); - *pptr += mqttstring.lenstring.len; - } - else if (mqttstring.cstring) - writeCString(pptr, mqttstring.cstring); - else - writeInt(pptr, 0); -} - - -/** - * @param mqttstring the MQTTString structure into which the data is to be read - * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned - * @param enddata pointer to the end of the data: do not read beyond - * @return 1 if successful, 0 if not - */ -int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata) -{ - int rc = 0; - - FUNC_ENTRY; - /* the first two bytes are the length of the string */ - if (enddata - (*pptr) > 1) /* enough length to read the integer? */ - { - mqttstring->lenstring.len = readInt(pptr); /* increments pptr to point past length */ - if (&(*pptr)[mqttstring->lenstring.len] <= enddata) - { - mqttstring->lenstring.data = (char*)*pptr; - *pptr += mqttstring->lenstring.len; - rc = 1; - } - } - mqttstring->cstring = NULL; - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string - * @param mqttstring the string to return the length of - * @return the length of the string - */ -int MQTTstrlen(MQTTString mqttstring) -{ - int rc = 0; - - if (mqttstring.cstring) - rc = strlen(mqttstring.cstring); - else - rc = mqttstring.lenstring.len; - return rc; -} - - -/** - * Compares an MQTTString to a C string - * @param a the MQTTString to compare - * @param bptr the C string to compare - * @return boolean - equal or not - */ -int MQTTPacket_equals(MQTTString* a, char* bptr) -{ - int alen = 0, - blen = 0; - char *aptr; - - if (a->cstring) - { - aptr = a->cstring; - alen = strlen(a->cstring); - } - else - { - aptr = a->lenstring.data; - alen = a->lenstring.len; - } - blen = strlen(bptr); - - return (alen == blen) && (strncmp(aptr, bptr, alen) == 0); -} - - -/** - * Helper function to read packet data from some source into a buffer - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param getfn pointer to a function which will read any number of bytes from the needed source - * @return integer MQTT packet type, or -1 on error - * @note the whole message must fit into the caller's buffer - */ -int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int)) -{ - int rc = -1; - MQTTHeader header = {0}; - int len = 0; - int rem_len = 0; - - /* 1. read the header byte. This has the packet type in it */ - if ((*getfn)(buf, 1) != 1) - goto exit; - - len = 1; - /* 2. read the remaining length. This is variable in itself */ - MQTTPacket_decode(getfn, &rem_len); - len += MQTTPacket_encode(buf + 1, rem_len); /* put the original remaining length back into the buffer */ - - /* 3. read the rest of the buffer using a callback to supply the rest of the data */ - if((rem_len + len) > buflen) - goto exit; - if (rem_len && ((*getfn)(buf + len, rem_len) != rem_len)) - goto exit; - - header.byte = buf[0]; - rc = header.bits.type; -exit: - return rc; -} - -/** - * Decodes the message length according to the MQTT algorithm, non-blocking - * @param trp pointer to a transport structure holding what is needed to solve getting data from it - * @param value the decoded length returned - * @return integer the number of bytes read from the socket, 0 for call again, or -1 on error - */ -static int MQTTPacket_decodenb(MQTTTransport *trp) -{ - unsigned char c; - int rc = MQTTPACKET_READ_ERROR; - - FUNC_ENTRY; - if(trp->len == 0){ /* initialize on first call */ - trp->multiplier = 1; - trp->rem_len = 0; - } - do { - int frc; - if (trp->len >= MAX_NO_OF_REMAINING_LENGTH_BYTES) - goto exit; - if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1) - goto exit; - if (frc == 0){ - rc = 0; - goto exit; - } - ++(trp->len); - trp->rem_len += (c & 127) * trp->multiplier; - trp->multiplier *= 128; - } while ((c & 128) != 0); - rc = trp->len; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - -/** - * Helper function to read packet data from some source into a buffer, non-blocking - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param trp pointer to a transport structure holding what is needed to solve getting data from it - * @return integer MQTT packet type, 0 for call again, or -1 on error - * @note the whole message must fit into the caller's buffer - */ -int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp) -{ - int rc = -1, frc; - MQTTHeader header = {0}; - - switch(trp->state){ - default: - trp->state = 0; - /*FALLTHROUGH*/ - case 0: - /* read the header byte. This has the packet type in it */ - if ((frc=(*trp->getfn)(trp->sck, buf, 1)) == -1) - goto exit; - if (frc == 0) - return 0; - trp->len = 0; - ++trp->state; - /*FALLTHROUGH*/ - /* read the remaining length. This is variable in itself */ - case 1: - if((frc=MQTTPacket_decodenb(trp)) == MQTTPACKET_READ_ERROR) - goto exit; - if(frc == 0) - return 0; - trp->len = 1 + MQTTPacket_encode(buf + 1, trp->rem_len); /* put the original remaining length back into the buffer */ - if((trp->rem_len + trp->len) > buflen) - goto exit; - ++trp->state; - /*FALLTHROUGH*/ - case 2: - if(trp->rem_len){ - /* read the rest of the buffer using a callback to supply the rest of the data */ - if ((frc=(*trp->getfn)(trp->sck, buf + trp->len, trp->rem_len)) == -1) - goto exit; - if (frc == 0) - return 0; - trp->rem_len -= frc; - trp->len += frc; - if(trp->rem_len) - return 0; - } - header.byte = buf[0]; - rc = header.bits.type; - break; - } - -exit: - trp->state = 0; - return rc; -} - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.h deleted file mode 100644 index 0ee46231bcbd6dccbce7fe7950168a7f7e23c8a9..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPacket.h +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Xiang Rong - 442039 Add makefile to Embedded C client - *******************************************************************************/ - -#ifndef MQTTPACKET_H_ -#define MQTTPACKET_H_ - -#if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */ -extern "C" { -#endif - -#if defined(WIN32_DLL) || defined(WIN64_DLL) - #define DLLImport __declspec(dllimport) - #define DLLExport __declspec(dllexport) -#elif defined(LINUX_SO) - #define DLLImport extern - #define DLLExport __attribute__ ((visibility ("default"))) -#else - #define DLLImport - #define DLLExport -#endif - -enum errors -{ - MQTTPACKET_BUFFER_TOO_SHORT = -2, - MQTTPACKET_READ_ERROR = -1, - MQTTPACKET_READ_COMPLETE -}; - -enum msgTypes -{ - CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, - PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, - PINGREQ, PINGRESP, DISCONNECT -}; - -/** - * Bitfields for the MQTT header byte. - */ -typedef union -{ - unsigned char byte; /**< the whole byte */ -#if defined(REVERSED) - struct - { - unsigned int type : 4; /**< message type nibble */ - unsigned int dup : 1; /**< DUP flag bit */ - unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */ - unsigned int retain : 1; /**< retained flag bit */ - } bits; -#else - struct - { - unsigned int retain : 1; /**< retained flag bit */ - unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */ - unsigned int dup : 1; /**< DUP flag bit */ - unsigned int type : 4; /**< message type nibble */ - } bits; -#endif -} MQTTHeader; - -typedef struct -{ - int len; - char* data; -} MQTTLenString; - -typedef struct -{ - char* cstring; - MQTTLenString lenstring; -} MQTTString; - -#define MQTTString_initializer {NULL, {0, NULL}} - -int MQTTstrlen(MQTTString mqttstring); - -#include "MQTTConnect.h" -#include "MQTTPublish.h" -#include "MQTTSubscribe.h" -#include "MQTTUnsubscribe.h" -#include "MQTTFormat.h" - -DLLExport int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid); -DLLExport int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen); - -int MQTTPacket_len(int rem_len); -DLLExport int MQTTPacket_equals(MQTTString* a, char* b); - -DLLExport int MQTTPacket_encode(unsigned char* buf, int length); -int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value); -int MQTTPacket_decodeBuf(unsigned char* buf, int* value); - -int readInt(unsigned char** pptr); -char readChar(unsigned char** pptr); -void writeChar(unsigned char** pptr, char c); -void writeInt(unsigned char** pptr, int anInt); -int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata); -void writeCString(unsigned char** pptr, const char* string); -void writeMQTTString(unsigned char** pptr, MQTTString mqttstring); - -DLLExport int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int)); - -typedef struct { - int (*getfn)(void *, unsigned char*, int); /* must return -1 for error, 0 for call again, or the number of bytes read */ - void *sck; /* pointer to whatever the system may use to identify the transport */ - int multiplier; - int rem_len; - int len; - char state; -}MQTTTransport; - -int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp); - -#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */ -} -#endif - - -#endif /* MQTTPACKET_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPublish.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPublish.h deleted file mode 100644 index ebe479dd5bb9df6605fd285acf04e9f449a76db2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTPublish.h +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Xiang Rong - 442039 Add makefile to Embedded C client - *******************************************************************************/ - -#ifndef MQTTPUBLISH_H_ -#define MQTTPUBLISH_H_ - -#if !defined(DLLImport) - #define DLLImport -#endif -#if !defined(DLLExport) - #define DLLExport -#endif - -DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, - MQTTString topicName, unsigned char* payload, int payloadlen); - -DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName, - unsigned char** payload, int* payloadlen, unsigned char* buf, int len); - -DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid); -DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid); -DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid); - -#endif /* MQTTPUBLISH_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSerializePublish.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSerializePublish.c deleted file mode 100644 index 77a58b54ac1ffc0dec92988b83ad59cf5ecd2b90..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSerializePublish.c +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144 - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - - -/** - * Determines the length of the MQTT publish packet that would be produced using the supplied parameters - * @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0) - * @param topicName the topic name to be used in the publish - * @param payloadlen the length of the payload to be sent - * @return the length of buffer needed to contain the serialized version of the packet - */ -int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen) -{ - int len = 0; - - len += 2 + MQTTstrlen(topicName) + payloadlen; - if (qos > 0) - len += 2; /* packetid */ - return len; -} - - -/** - * Serializes the supplied publish data into the supplied buffer, ready for sending - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param dup integer - the MQTT dup flag - * @param qos integer - the MQTT QoS value - * @param retained integer - the MQTT retained flag - * @param packetid integer - the MQTT packet identifier - * @param topicName MQTTString - the MQTT topic in the publish - * @param payload byte buffer - the MQTT publish payload - * @param payloadlen integer - the length of the MQTT payload - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, - MQTTString topicName, unsigned char* payload, int payloadlen) -{ - unsigned char *ptr = buf; - MQTTHeader header = {0}; - int rem_len = 0; - int rc = 0; - - FUNC_ENTRY; - if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(qos, topicName, payloadlen)) > buflen) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - - header.bits.type = PUBLISH; - header.bits.dup = dup; - header.bits.qos = qos; - header.bits.retain = retained; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */; - - writeMQTTString(&ptr, topicName); - - if (qos > 0) - writeInt(&ptr, packetid); - - memcpy(ptr, payload, payloadlen); - ptr += payloadlen; - - rc = ptr - buf; - -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - - -/** - * Serializes the ack packet into the supplied buffer. - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param type the MQTT packet type - * @param dup the MQTT dup flag - * @param packetid the MQTT packet identifier - * @return serialized length, or error if 0 - */ -int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid) -{ - MQTTHeader header = {0}; - int rc = 0; - unsigned char *ptr = buf; - - FUNC_ENTRY; - if (buflen < 4) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - header.bits.type = packettype; - header.bits.dup = dup; - header.bits.qos = (packettype == PUBREL) ? 1 : 0; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */ - writeInt(&ptr, packetid); - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes a puback packet into the supplied buffer. - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param packetid integer - the MQTT packet identifier - * @return serialized length, or error if 0 - */ -int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid) -{ - return MQTTSerialize_ack(buf, buflen, PUBACK, 0, packetid); -} - - -/** - * Serializes a pubrel packet into the supplied buffer. - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param dup integer - the MQTT dup flag - * @param packetid integer - the MQTT packet identifier - * @return serialized length, or error if 0 - */ -int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid) -{ - return MQTTSerialize_ack(buf, buflen, PUBREL, dup, packetid); -} - - -/** - * Serializes a pubrel packet into the supplied buffer. - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param packetid integer - the MQTT packet identifier - * @return serialized length, or error if 0 - */ -int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid) -{ - return MQTTSerialize_ack(buf, buflen, PUBCOMP, 0, packetid); -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribe.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribe.h deleted file mode 100644 index aa918268063265df1ca43ce497c801c605d48c99..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribe.h +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Xiang Rong - 442039 Add makefile to Embedded C client - *******************************************************************************/ - -#ifndef MQTTSUBSCRIBE_H_ -#define MQTTSUBSCRIBE_H_ - -#if !defined(DLLImport) - #define DLLImport -#endif -#if !defined(DLLExport) - #define DLLExport -#endif - -DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, - int count, MQTTString topicFilters[], int requestedQoSs[]); - -DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, - int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len); - -DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs); - -DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len); - - -#endif /* MQTTSUBSCRIBE_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeClient.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeClient.c deleted file mode 100644 index 57a06138a72c25d1ca0d443a11d441fd97a1a276..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeClient.c +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - -/** - * Determines the length of the MQTT subscribe packet that would be produced using the supplied parameters - * @param count the number of topic filter strings in topicFilters - * @param topicFilters the array of topic filter strings to be used in the publish - * @return the length of buffer needed to contain the serialized version of the packet - */ -int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[]) -{ - int i; - int len = 2; /* packetid */ - - for (i = 0; i < count; ++i) - len += 2 + MQTTstrlen(topicFilters[i]) + 1; /* length + topic + req_qos */ - return len; -} - - -/** - * Serializes the supplied subscribe data into the supplied buffer, ready for sending - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied bufferr - * @param dup integer - the MQTT dup flag - * @param packetid integer - the MQTT packet identifier - * @param count - number of members in the topicFilters and reqQos arrays - * @param topicFilters - array of topic filter names - * @param requestedQoSs - array of requested QoS - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, int count, - MQTTString topicFilters[], int requestedQoSs[]) -{ - unsigned char *ptr = buf; - MQTTHeader header = {0}; - int rem_len = 0; - int rc = 0; - int i = 0; - - FUNC_ENTRY; - if (MQTTPacket_len(rem_len = MQTTSerialize_subscribeLength(count, topicFilters)) > buflen) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - - header.byte = 0; - header.bits.type = SUBSCRIBE; - header.bits.dup = dup; - header.bits.qos = 1; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */; - - writeInt(&ptr, packetid); - - for (i = 0; i < count; ++i) - { - writeMQTTString(&ptr, topicFilters[i]); - writeChar(&ptr, requestedQoSs[i]); - } - - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - - -/** - * Deserializes the supplied (wire) buffer into suback data - * @param packetid returned integer - the MQTT packet identifier - * @param maxcount - the maximum number of members allowed in the grantedQoSs array - * @param count returned integer - number of members in the grantedQoSs array - * @param grantedQoSs returned array of integers - the granted qualities of service - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return error code. 1 is success, 0 is failure - */ -int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = 0; - int mylen; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != SUBACK) - goto exit; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - if (enddata - curdata < 2) - goto exit; - - *packetid = readInt(&curdata); - - *count = 0; - while (curdata < enddata) - { - if (*count > maxcount) - { - rc = -1; - goto exit; - } - grantedQoSs[(*count)++] = readChar(&curdata); - } - - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeServer.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeServer.c deleted file mode 100644 index 5579645fec36ae4e30c5ae4fe175c922c9cc6255..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTSubscribeServer.c +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - - -/** - * Deserializes the supplied (wire) buffer into subscribe data - * @param dup integer returned - the MQTT dup flag - * @param packetid integer returned - the MQTT packet identifier - * @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays - * @param count - number of members in the topicFilters and requestedQoSs arrays - * @param topicFilters - array of topic filter names - * @param requestedQoSs - array of requested QoS - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[], - int requestedQoSs[], unsigned char* buf, int buflen) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = -1; - int mylen = 0; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != SUBSCRIBE) - goto exit; - *dup = header.bits.dup; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - - *packetid = readInt(&curdata); - - *count = 0; - while (curdata < enddata) - { - if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata)) - goto exit; - if (curdata >= enddata) /* do we have enough data to read the req_qos version byte? */ - goto exit; - requestedQoSs[*count] = readChar(&curdata); - (*count)++; - } - - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes the supplied suback data into the supplied buffer, ready for sending - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param packetid integer - the MQTT packet identifier - * @param count - number of members in the grantedQoSs array - * @param grantedQoSs - array of granted QoS - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs) -{ - MQTTHeader header = {0}; - int rc = -1; - unsigned char *ptr = buf; - int i; - - FUNC_ENTRY; - if (buflen < 2 + count) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - header.byte = 0; - header.bits.type = SUBACK; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, 2 + count); /* write remaining length */ - - writeInt(&ptr, packetid); - - for (i = 0; i < count; ++i) - writeChar(&ptr, grantedQoSs[i]); - - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribe.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribe.h deleted file mode 100644 index 355ca9a427fe7c2ed38efae6f91f0a61d831acca..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribe.h +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Xiang Rong - 442039 Add makefile to Embedded C client - *******************************************************************************/ - -#ifndef MQTTUNSUBSCRIBE_H_ -#define MQTTUNSUBSCRIBE_H_ - -#if !defined(DLLImport) - #define DLLImport -#endif -#if !defined(DLLExport) - #define DLLExport -#endif - -DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, - int count, MQTTString topicFilters[]); - -DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[], - unsigned char* buf, int len); - -DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid); - -DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len); - -#endif /* MQTTUNSUBSCRIBE_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeClient.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeClient.c deleted file mode 100644 index e7ec530215ab971b03ef98e378d40212e671dd23..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeClient.c +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - -/** - * Determines the length of the MQTT unsubscribe packet that would be produced using the supplied parameters - * @param count the number of topic filter strings in topicFilters - * @param topicFilters the array of topic filter strings to be used in the publish - * @return the length of buffer needed to contain the serialized version of the packet - */ -int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[]) -{ - int i; - int len = 2; /* packetid */ - - for (i = 0; i < count; ++i) - len += 2 + MQTTstrlen(topicFilters[i]); /* length + topic*/ - return len; -} - - -/** - * Serializes the supplied unsubscribe data into the supplied buffer, ready for sending - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @param dup integer - the MQTT dup flag - * @param packetid integer - the MQTT packet identifier - * @param count - number of members in the topicFilters array - * @param topicFilters - array of topic filter names - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, - int count, MQTTString topicFilters[]) -{ - unsigned char *ptr = buf; - MQTTHeader header = {0}; - int rem_len = 0; - int rc = -1; - int i = 0; - - FUNC_ENTRY; - if (MQTTPacket_len(rem_len = MQTTSerialize_unsubscribeLength(count, topicFilters)) > buflen) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - - header.byte = 0; - header.bits.type = UNSUBSCRIBE; - header.bits.dup = dup; - header.bits.qos = 1; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */; - - writeInt(&ptr, packetid); - - for (i = 0; i < count; ++i) - writeMQTTString(&ptr, topicFilters[i]); - - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Deserializes the supplied (wire) buffer into unsuback data - * @param packetid returned integer - the MQTT packet identifier - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return error code. 1 is success, 0 is failure - */ -int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int buflen) -{ - unsigned char type = 0; - unsigned char dup = 0; - int rc = 0; - - FUNC_ENTRY; - rc = MQTTDeserialize_ack(&type, &dup, packetid, buf, buflen); - if (type == UNSUBACK) - rc = 1; - FUNC_EXIT_RC(rc); - return rc; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeServer.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeServer.c deleted file mode 100644 index 42b6102a700edafd3b83eae769333d2979bc4aee..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/MQTTUnsubscribeServer.c +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - -#include "MQTTPacket.h" -#include "StackTrace.h" - -#include - - -/** - * Deserializes the supplied (wire) buffer into unsubscribe data - * @param dup integer returned - the MQTT dup flag - * @param packetid integer returned - the MQTT packet identifier - * @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays - * @param count - number of members in the topicFilters and requestedQoSs arrays - * @param topicFilters - array of topic filter names - * @param buf the raw buffer data, of the correct length determined by the remaining length field - * @param buflen the length in bytes of the data in the supplied buffer - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[], - unsigned char* buf, int len) -{ - MQTTHeader header = {0}; - unsigned char* curdata = buf; - unsigned char* enddata = NULL; - int rc = 0; - int mylen = 0; - - FUNC_ENTRY; - header.byte = readChar(&curdata); - if (header.bits.type != UNSUBSCRIBE) - goto exit; - *dup = header.bits.dup; - - curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */ - enddata = curdata + mylen; - - *packetid = readInt(&curdata); - - *count = 0; - while (curdata < enddata) - { - if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata)) - goto exit; - (*count)++; - } - - rc = 1; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - -/** - * Serializes the supplied unsuback data into the supplied buffer, ready for sending - * @param buf the buffer into which the packet will be serialized - * @param buflen the length in bytes of the supplied buffer - * @param packetid integer - the MQTT packet identifier - * @return the length of the serialized data. <= 0 indicates error - */ -int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid) -{ - MQTTHeader header = {0}; - int rc = 0; - unsigned char *ptr = buf; - - FUNC_ENTRY; - if (buflen < 2) - { - rc = MQTTPACKET_BUFFER_TOO_SHORT; - goto exit; - } - header.byte = 0; - header.bits.type = UNSUBACK; - writeChar(&ptr, header.byte); /* write header */ - - ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */ - - writeInt(&ptr, packetid); - - rc = ptr - buf; -exit: - FUNC_EXIT_RC(rc); - return rc; -} - - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/StackTrace.h b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/StackTrace.h deleted file mode 100644 index 2808a0d18aeb7700417fd62ca77959f4569db1b2..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/src/StackTrace.h +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - * Ian Craggs - fix for bug #434081 - *******************************************************************************/ - -#ifndef STACKTRACE_H_ -#define STACKTRACE_H_ - -#include -#define NOSTACKTRACE 1 - -#if defined(NOSTACKTRACE) -#define FUNC_ENTRY -#define FUNC_ENTRY_NOLOG -#define FUNC_ENTRY_MED -#define FUNC_ENTRY_MAX -#define FUNC_EXIT -#define FUNC_EXIT_NOLOG -#define FUNC_EXIT_MED -#define FUNC_EXIT_MAX -#define FUNC_EXIT_RC(x) -#define FUNC_EXIT_MED_RC(x) -#define FUNC_EXIT_MAX_RC(x) - -#else - -#if defined(WIN32) -#define inline __inline -#define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM) -#define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1) -#define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM) -#define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM) -#define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM) -#define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, -1) -#define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM) -#define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM) -#define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM) -#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM) -#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM) -#else -#define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM) -#define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1) -#define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM) -#define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM) -#define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM) -#define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1) -#define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM) -#define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM) -#define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM) -#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM) -#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM) - -void StackTrace_entry(const char* name, int line, int trace); -void StackTrace_exit(const char* name, int line, void* return_value, int trace); - -void StackTrace_printStack(FILE* dest); -char* StackTrace_get(unsigned long); - -#endif - -#endif - - - - -#endif /* STACKTRACE_H_ */ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/CMakeLists.txt b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/CMakeLists.txt deleted file mode 100644 index f3dc00ee777e6db5c781579d888b0db77e77a0a1..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -PROJECT(mqttpacket-tests) - -IF (WIN32) - SET(MQTT_TEST_BROKER "tcp://mqtt.iotree.co.uk:1883" CACHE STRING "Hostname of a test MQTT broker to use") - SET(MQTT_TEST_PROXY "tcp://localhost:1883" CACHE STRING "Hostname of the test proxy to use") - SET(MQTT_SSL_HOSTNAME "mqtt.iotree.co.uk" CACHE STRING "Hostname of a test SSL MQTT broker to use") - SET(CERTDIR $ENV{APPVEYOR_BUILD_FOLDER}/test/ssl) -ELSE () - SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use") - SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use") - SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use") - SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl) -ENDIF () - -include_directories(../src) - -ADD_EXECUTABLE( - test1 - test1.c -) - -TARGET_LINK_LIBRARIES( - test1 - paho-embed-mqtt3c -) - -ADD_TEST( - NAME test1 - COMMAND "test1" "--connection" ${MQTT_TEST_BROKER} -) - -SET_TESTS_PROPERTIES( - test1 - PROPERTIES TIMEOUT 540 -) diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/build_test b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/build_test deleted file mode 100644 index eedf3d1b93722e4dad70a940e0872f9a4fe18329..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/build_test +++ /dev/null @@ -1 +0,0 @@ -gcc -Wall test1.c -o test1 -I../src ../src/MQTTConnectClient.c ../src/MQTTConnectServer.c ../src/MQTTPacket.c ../src/MQTTSerializePublish.c ../src/MQTTDeserializePublish.c ../src/MQTTSubscribeServer.c ../src/MQTTSubscribeClient.c ../src/MQTTUnsubscribeServer.c ../src/MQTTUnsubscribeClient.c diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/test1.c b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/test1.c deleted file mode 100644 index 4614ff70080e8f50cb065fe42b4f59a5ade6848a..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/MQTTPacket/test/test1.c +++ /dev/null @@ -1,635 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 IBM Corp. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. - * - * The Eclipse Public License is available at - * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * Ian Craggs - initial API and implementation and/or initial documentation - *******************************************************************************/ - - -#include "MQTTPacket.h" -#include -#include -#include - -#if !defined(_WINDOWS) - #include - #include - #include - #include -#else -#include -#include -#define MAXHOSTNAMELEN 256 -#define EAGAIN WSAEWOULDBLOCK -#define EINTR WSAEINTR -#define EINPROGRESS WSAEINPROGRESS -#define EWOULDBLOCK WSAEWOULDBLOCK -#define ENOTCONN WSAENOTCONN -#define ECONNRESET WSAECONNRESET -#endif - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -struct Options -{ - char* connection; /**< connection to system under test. */ - char** haconnections; - int hacount; - int verbose; - int test_no; -} options = -{ - "tcp://m2m.eclipse.org:1883", - NULL, - 0, - 0, - 0, -}; - -void usage() -{ - -} - -void getopts(int argc, char** argv) -{ - int count = 1; - - while (count < argc) - { - if (strcmp(argv[count], "--test_no") == 0) - { - if (++count < argc) - options.test_no = atoi(argv[count]); - else - usage(); - } - else if (strcmp(argv[count], "--connection") == 0) - { - if (++count < argc) - { - options.connection = argv[count]; - printf("\nSetting connection to %s\n", options.connection); - } - else - usage(); - } - else if (strcmp(argv[count], "--haconnections") == 0) - { - if (++count < argc) - { - char* tok = strtok(argv[count], " "); - options.hacount = 0; - options.haconnections = malloc(sizeof(char*) * 5); - while (tok) - { - options.haconnections[options.hacount] = malloc(strlen(tok) + 1); - strcpy(options.haconnections[options.hacount], tok); - options.hacount++; - tok = strtok(NULL, " "); - } - } - else - usage(); - } - else if (strcmp(argv[count], "--verbose") == 0) - { - options.verbose = 1; - printf("\nSetting verbose on\n"); - } - count++; - } -} - - -#define LOGA_DEBUG 0 -#define LOGA_INFO 1 -#include -#include -#include -void MyLog(int LOGA_level, char* format, ...) -{ - static char msg_buf[256]; - va_list args; - struct timeb ts; - - struct tm *timeinfo; - - if (LOGA_level == LOGA_DEBUG && options.verbose == 0) - return; - - ftime(&ts); - timeinfo = localtime(&ts.time); - strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo); - - sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm); - - va_start(args, format); - vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args); - va_end(args); - - printf("%s\n", msg_buf); - fflush(stdout); -} - - -#if defined(WIN32) || defined(_WINDOWS) -#define mqsleep(A) Sleep(1000*A) -#define START_TIME_TYPE DWORD -static DWORD start_time = 0; -START_TIME_TYPE start_clock(void) -{ - return GetTickCount(); -} -#elif defined(AIX) -#define mqsleep sleep -#define START_TIME_TYPE struct timespec -START_TIME_TYPE start_clock(void) -{ - static struct timespec start; - clock_gettime(CLOCK_REALTIME, &start); - return start; -} -#else -#define mqsleep sleep -#define START_TIME_TYPE struct timeval -/* TODO - unused - remove? static struct timeval start_time; */ -START_TIME_TYPE start_clock(void) -{ - struct timeval start_time; - gettimeofday(&start_time, NULL); - return start_time; -} -#endif - - -#if defined(WIN32) -long elapsed(START_TIME_TYPE start_time) -{ - return GetTickCount() - start_time; -} -#elif defined(AIX) -#define assert(a) -long elapsed(struct timespec start) -{ - struct timespec now, res; - - clock_gettime(CLOCK_REALTIME, &now); - ntimersub(now, start, res); - return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L; -} -#else -long elapsed(START_TIME_TYPE start_time) -{ - struct timeval now, res; - - gettimeofday(&now, NULL); - timersub(&now, &start_time, &res); - return (res.tv_sec)*1000 + (res.tv_usec)/1000; -} -#endif - - -#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d) -#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e) - -int tests = 0; -int failures = 0; -FILE* xml; -START_TIME_TYPE global_start_time; -char output[3000]; -char* cur_output = output; - - -void write_test_result() -{ - long duration = elapsed(global_start_time); - - fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000); - if (cur_output != output) - { - fprintf(xml, "%s", output); - cur_output = output; - } - fprintf(xml, "\n"); -} - - -void myassert(char* filename, int lineno, char* description, int value, char* format, ...) -{ - ++tests; - if (!value) - { - va_list args; - - ++failures; - printf("Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description); - - va_start(args, format); - vprintf(format, args); - va_end(args); - - cur_output += sprintf(cur_output, "file %s, line %d \n", - description, filename, lineno); - } - else - MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description); -} - -#define min(a, b) ((a < b) ? a : b) - -int checkMQTTStrings(MQTTString a, MQTTString b) -{ - if (!a.lenstring.data) - { - a.lenstring.data = a.cstring; - if (a.cstring) - a.lenstring.len = strlen(a.cstring); - } - if (!b.lenstring.data) - { - b.lenstring.data = b.cstring; - if (b.cstring) - b.lenstring.len = strlen(b.cstring); - } - return memcmp(a.lenstring.data, b.lenstring.data, min(a.lenstring.len, b.lenstring.len)) == 0; -} - - -int checkConnectPackets(MQTTPacket_connectData* before, MQTTPacket_connectData* after) -{ - int rc = 0; - int start_failures = failures; - - assert("struct_ids should be the same", - memcmp(before->struct_id, after->struct_id, 4) == 0, "struct_ids were different %.4s\n", after->struct_id); - - assert("struct_versions should be the same", - before->struct_version == after->struct_version, "struct_versions were different\n", rc); - - assert("MQTT versions should be the same", - before->MQTTVersion == after->MQTTVersion, "MQTT versions were different\n", rc); - - assert("ClientIDs should be the same", - checkMQTTStrings(before->clientID, after->clientID), "ClientIDs were different\n", rc); - - assert("keepAliveIntervals should be the same", - before->keepAliveInterval == after->keepAliveInterval, "keepAliveIntervals were different %d\n", after->keepAliveInterval); - - assert("cleansessions should be the same", - before->cleansession == after->cleansession, "cleansessions were different\n", rc); - - assert("willFlags should be the same", - before->willFlag == after->willFlag, "willFlags were different\n", rc); - - if (before->willFlag) - { - assert("will struct_ids should be the same", - memcmp(before->will.struct_id, after->will.struct_id, 4) == 0, "will struct_ids were different %.4s\n", after->struct_id); - - assert("will struct_versions should be the same", - before->will.struct_version == after->will.struct_version, "will struct_versions were different\n", rc); - - assert("topic names should be the same", - checkMQTTStrings(before->will.topicName, after->will.topicName), "topic names were different\n", rc); - - assert("messages should be the same", - checkMQTTStrings(before->will.message, after->will.message), "messages were different\n", rc); - - assert("retained flags should be the same", - before->will.retained == after->will.retained, "retained flags were different\n", rc); - - assert("will qos should be the same", - before->will.qos == after->will.qos, "will qos were different\n", rc); - } - - assert("usernames should be the same", - checkMQTTStrings(before->clientID, after->clientID), "usernames were different\n", rc); - assert("passwords should be the same", - checkMQTTStrings(before->password, after->password), "passwords were different\n", rc); - return failures == start_failures; -} - -int test1(struct Options options) -{ - MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - MQTTPacket_connectData data_after = MQTTPacket_connectData_initializer; - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_connect(&data_after, buf, buflen); - assert("good rc from deserialize connect", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - rc = checkConnectPackets(&data, &data_after); - assert("packets should be the same", rc == 1, "packets were different\n", rc); - -/* exit: */ - MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -int test2(struct Options options) -{ - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); - - unsigned char dup = 0; - int qos = 2; - unsigned char retained = 0; - unsigned short msgid = 23; - MQTTString topicString = MQTTString_initializer; - unsigned char *payload = (unsigned char*)"kkhkhkjkj jkjjk jk jk "; - int payloadlen = strlen((char*)payload); - - unsigned char dup2 = 1; - int qos2 = 1; - unsigned char retained2 = 1; - unsigned short msgid2 = 3243; - MQTTString topicString2 = MQTTString_initializer; - unsigned char *payload2 = NULL; - int payloadlen2 = 0; - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_publish(&dup2, &qos2, &retained2, &msgid2, &topicString2, - &payload2, &payloadlen2, buf, buflen); - assert("good rc from deserialize publish", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2); - assert("qoss should be the same", qos == qos2, "qoss were different %d\n", qos2); - assert("retaineds should be the same", retained == retained2, "retaineds were different %d\n", retained2); - assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2); - - assert("topics should be the same", - checkMQTTStrings(topicString, topicString2), "topics were different %s\n", ""); //topicString2); - - assert("payload lengths should be the same", - payloadlen == payloadlen2, "payload lengths were different %d\n", payloadlen2); - - assert("payloads should be the same", - memcmp(payload, payload2, payloadlen) == 0, "payloads were different %s\n", ""); - -/*exit:*/ - MyLog(LOGA_INFO, "TEST2: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - - -int test3(struct Options options) -{ - int i = 0; - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); -#define TOPIC_COUNT 2 - - unsigned char dup = 0; - unsigned short msgid = 23; - int count = TOPIC_COUNT; - MQTTString topicStrings[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer }; - int req_qoss[TOPIC_COUNT] = {2, 1}; - - unsigned char dup2 = 1; - unsigned short msgid2 = 2223; - int count2 = 0; - MQTTString topicStrings2[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer }; - int req_qoss2[TOPIC_COUNT] = {0, 0}; - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_subscribe(&dup2, &msgid2, 2, &count2, topicStrings2, req_qoss2, buf, buflen); - assert("good rc from deserialize subscribe", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2); - assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2); - - assert("count should be the same", count == count2, "counts were different %d\n", count2); - - for (i = 0; i < count2; ++i) - { - assert("topics should be the same", - checkMQTTStrings(topicStrings[i], topicStrings2[i]), "topics were different %s\n", ""); - - assert("qoss should be the same", req_qoss[i] == req_qoss2[i], "qoss were different %d\n", req_qoss2[i]); - } - -/*exit:*/ - MyLog(LOGA_INFO, "TEST3: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -int test4(struct Options options) -{ - int i = 0; - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); -#define TOPIC_COUNT 2 - - int msgid = 23; - int count = TOPIC_COUNT; - int granted_qoss[TOPIC_COUNT] = {2, 1}; - - unsigned short msgid2 = 2223; - int count2 = 0; - int granted_qoss2[TOPIC_COUNT] = {0, 0}; - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_suback(&msgid2, 2, &count2, granted_qoss2, buf, buflen); - assert("good rc from deserialize suback", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2); - - assert("count should be the same", count == count2, "counts were different %d\n", count2); - - for (i = 0; i < count2; ++i) - assert("qoss should be the same", granted_qoss[i] == granted_qoss2[i], "qoss were different %d\n", granted_qoss2[i]); - -/* exit: */ - MyLog(LOGA_INFO, "TEST4: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -int test5(struct Options options) -{ - int i = 0; - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); -#define TOPIC_COUNT 2 - - unsigned char dup = 0; - unsigned short msgid = 23; - int count = TOPIC_COUNT; - MQTTString topicStrings[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer }; - - unsigned char dup2 = 1; - unsigned short msgid2 = 2223; - int count2 = 0; - MQTTString topicStrings2[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer }; - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_unsubscribe(&dup2, &msgid2, 2, &count2, topicStrings2, buf, buflen); - assert("good rc from deserialize unsubscribe", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2); - assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2); - - assert("count should be the same", count == count2, "counts were different %d\n", count2); - - for (i = 0; i < count2; ++i) - assert("topics should be the same", - checkMQTTStrings(topicStrings[i], topicStrings2[i]), "topics were different %s\n", ""); - -/* exit: */ - MyLog(LOGA_INFO, "TEST5: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -int test6(struct Options options) -{ - int rc = 0; - unsigned char buf[100]; - int buflen = sizeof(buf); - - unsigned char sessionPresent = 1; - unsigned char connack_rc = 77; - - unsigned char sessionPresent2 = 0; - unsigned char connack_rc2 = 0; - - fprintf(xml, " 0, "rc was %d\n", rc); - - rc = MQTTDeserialize_connack(&sessionPresent2, &connack_rc2, buf, buflen); - assert("good rc from deserialize connack", rc == 1, "rc was %d\n", rc); - - /* data after should be the same as data before */ - assert("connack rcs should be the same", connack_rc == connack_rc2, "connack rcs were different %d\n", connack_rc2); - assert("session present flags should be the same", sessionPresent == sessionPresent2, - "session present flags were different %d\n", sessionPresent2); - -/* exit: */ - MyLog(LOGA_INFO, "TEST6: test %s. %d tests run, %d failures.", - (failures == 0) ? "passed" : "failed", tests, failures); - write_test_result(); - return failures; -} - - -int main(int argc, char** argv) -{ - int rc = 0; - int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6}; - - xml = fopen("TEST-test1.xml", "w"); - fprintf(xml, "\n", (int)(ARRAY_SIZE(tests) - 1)); - - getopts(argc, argv); - - if (options.test_no == 0) - { /* run all the tests */ - for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no) - rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */ - } - else - rc = tests[options.test_no](options); /* run just the selected test */ - - if (rc == 0) - MyLog(LOGA_INFO, "verdict pass"); - else - MyLog(LOGA_INFO, "verdict fail"); - - fprintf(xml, "\n"); - fclose(xml); - return rc; -} diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Makefile b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Makefile deleted file mode 100644 index 49cbb134b8e8ea1e609fc2b7202e800247551afe..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/Makefile +++ /dev/null @@ -1,220 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2009, 2014 IBM Corp. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# and Eclipse Distribution License v1.0 which accompany this distribution. -# -# The Eclipse Public License is available at -# http://www.eclipse.org/legal/epl-v10.html -# and the Eclipse Distribution License is available at -# http://www.eclipse.org/org/documents/edl-v10.php. -# -# Contributors: -# Xiang Rong - 442039 Add makefile to Embedded C client -#*******************************************************************************/ - -# Note: on OS X you should install XCode and the associated command-line tools - -SHELL = /bin/sh -.PHONY: clean, mkdir, install, uninstall, html - -# assume this is normally run in the main Paho directory -ifndef srcdir - srcdir = MQTTPacket/src -endif - -ifndef blddir - blddir = build/output -endif - -ifndef prefix - prefix = /usr/local -endif - -ifndef exec_prefix - exec_prefix = ${prefix} -endif - -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -libdir = $(exec_prefix)/lib - -SOURCE_FILES_C = $(srcdir)/*.c - -HEADERS = $(srcdir)/*.h - - -SAMPLE_FILES_C = pub0sub1 qos0pub -SYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_C}} - - -TEST_FILES_C = test1 -SYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_C}} - - -# The names of libraries to be built -MQTT_EMBED_LIB_C = paho-embed-mqtt3c - - -# determine current platform -ifeq ($(OS),Windows_NT) - OSTYPE = $(OS) -else - OSTYPE = $(shell uname -s) - MACHINETYPE = $(shell uname -m) -endif - -ifeq ($(OSTYPE),Linux) - -CC ?= gcc - -ifndef INSTALL -INSTALL = install -endif -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -MAJOR_VERSION = 1 -MINOR_VERSION = 0 -VERSION = ${MAJOR_VERSION}.${MINOR_VERSION} - -EMBED_MQTTLIB_C_TARGET = ${blddir}/lib${MQTT_EMBED_LIB_C}.so.${VERSION} - - -CCFLAGS_SO = -g -fPIC -Os -Wall -fvisibility=hidden -DLINUX_SO -FLAGS_EXE = -I ${srcdir} -L ${blddir} - -LDFLAGS_C = -shared -Wl,-soname,lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} - -all: build - -build: | mkdir ${EMBED_MQTTLIB_C_TARGET} ${SYNC_SAMPLES} ${SYNC_TESTS} - -clean: - rm -rf ${blddir}/* - -mkdir: - -mkdir -p ${blddir}/samples - -mkdir -p ${blddir}/test - -${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c - ${CC} -g -o ${blddir}/test/${basename ${+F}} $< -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE} - - -${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/../samples/%.c ${srcdir}/../samples/transport.o - ${CC} -o $@ $^ -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE} - - - -${EMBED_MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C} - ${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C} - -ln -s lib$(MQTT_EMBED_LIB_C).so.${VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} - -ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so - - -strip_options: - $(eval INSTALL_OPTS := -s) - -install-strip: build strip_options install - -install: build - $(INSTALL_DATA) ${INSTALL_OPTS} ${EMBED_MQTTLIB_C_TARGET} $(DESTDIR)${libdir} - - - /sbin/ldconfig $(DESTDIR)${libdir} - ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so - - -uninstall: - rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so.${VERSION} - - /sbin/ldconfig $(DESTDIR)${libdir} - rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so - - -html: - -ARDUINO_LIB_FILES = MQTTClient/src/*.h MQTTClient/src/arduino/*.h $(srcdir)/* -ARDUINO_SAMPLES = MQTTClient/samples/arduino/* -LEGAL_FILES = edl-v10 epl-v10 notice.html about.html CONTRIBUTING.md README.md library.properties - -arduino: mkdir - -mkdir -p ${blddir}/arduino/MQTTClient/examples - -mkdir -p ${blddir}/arduino/MQTTClient/src - cp $(ARDUINO_LIB_FILES) ${blddir}/arduino/MQTTClient/src - cp $(LEGAL_FILES) ${blddir}/arduino/MQTTClient - cp -R $(ARDUINO_SAMPLES) ${blddir}/arduino/MQTTClient/examples - cd ${blddir}/arduino && zip -r arduino MQTTClient - -endif - - - -ifeq ($(OSTYPE),Darwin) - -CC ?= gcc - -ifndef INSTALL -INSTALL = install -endif -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -MAJOR_VERSION = 1 -MINOR_VERSION = 0 -VERSION = ${MAJOR_VERSION}.${MINOR_VERSION} - -EMBED_MQTTLIB_C_TARGET = ${blddir}/lib${MQTT_EMBED_LIB_C}.so.${VERSION} - - -CCFLAGS_SO = -g -fPIC -Os -Wall -fvisibility=hidden -Wno-deprecated-declarations -DUSE_NAMED_SEMAPHORES -FLAGS_EXE = -I ${srcdir} -L ${blddir} - -LDFLAGS_C = -shared -Wl,-install_name,lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} - -all: build - -build: | mkdir ${EMBED_MQTTLIB_C_TARGET} ${SYNC_SAMPLES} ${SYNC_TESTS} - -clean: - rm -rf ${blddir}/* - -mkdir: - -mkdir -p ${blddir}/samples - -mkdir -p ${blddir}/test - -${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c - ${CC} -g -o ${blddir}/test/${basename ${+F}} $< -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE} - -${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/../samples/%.c - ${CC} -o ${blddir}/samples/${basename ${+F}} $< ${FLAGS_EXE} -l${MQTT_EMBED_LIB_C} - -${EMBED_MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C} - ${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C} - -ln -s lib$(MQTT_EMBED_LIB_C).so.${VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} - -ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so - - -strip_options: - $(eval INSTALL_OPTS := -s) - -install-strip: build strip_options install - -install: build - $(INSTALL_DATA) ${INSTALL_OPTS} ${EMBED_MQTTLIB_C_TARGET} $(DESTDIR)${libdir} - - /sbin/ldconfig $(DESTDIR)${libdir} - ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so - - -uninstall: - rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so.${VERSION} - /sbin/ldconfig $(DESTDIR)${libdir} - rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so - - -html: - - -endif diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/README.md b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/README.md deleted file mode 100644 index c1f3a63dd28ada794102351ebe0a7849b20a0d8f..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Eclipse Paho MQTT C/C++ client for Embedded platforms - -This repository contains the source code for the [Eclipse Paho](http://eclipse.org/paho) MQTT C/C++ client library for Embedded platorms. - -It is dual licensed under the EPL and EDL (see about.html and notice.html for more details). You can choose which of these licenses you want to use the code under. The EDL allows you to embed the code into your application, and distribute your application in binary or source form without contributing any of your code, or any changes you make back to Paho. See the EDL for the exact conditions. - -There are three sub-projects: - -1. MQTTPacket - simple de/serialization of MQTT packets, plus helper functions -2. MQTTClient - high(er) level C++ client, plus -3. MQTTClient-C - high(er) level C client (pretty much a clone of the C++ client) - -The *MQTTPacket* directory contains the lowest level C library with the smallest requirements. This supplies simple serialization -and deserialization routines. They serve as a base for the higher level libraries, but can also be used on their own -It is mainly up to you to write and read to and from the network. - -The *MQTTClient* directory contains the next level C++ library. This networking code is contained in separate classes so that you can plugin the -network of your choice. Currently there are implementations for Linux, Arduino and mbed. ARM mbed was the first platform for which this was written, -where the conventional language choice is C++, which explains the language choice. I have written a starter [Porting Guide](http://modelbasedtesting.co.uk/2014/08/25/porting-a-paho-embedded-c-client/). - -The *MQTTClient-C* directory contains a C equivalent of MQTTClient, for those platforms where C++ is not supported or the convention. As far -as possible it is a direct translation from *MQTTClient*. - -## Build requirements / compilation - -CMake builds for the various packages have been introduced, along with Travis-CI configuration for automated build & testing. The basic -method of building on Linux is: - -``` -mkdir build.paho -cd build.paho -cmake .. -make -``` - -The travis-build.sh file has the full build and test sequence for Linux. - - -## Usage and API - -See the samples directories for examples of intended use. Doxygen config files for each package are available in the doc directory. - -## Runtime tracing - -The *MQTTClient* API has debug tracing for MQTT packets sent and received - turn this on by setting the MQTT_DEBUG preprocessor definition. - - -## Reporting bugs - -This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.embedded-c/issues](https://github.com/eclipse/paho.mqtt.embedded-c/issues) to track ongoing development and issues. - -## More information - -Discussion of the Paho clients takes place on the [Eclipse Mattermost Paho channel](https://mattermost.eclipse.org/eclipse/channels/paho) and the [Eclipse paho-dev mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev). - -General questions about the MQTT protocol are discussed in the [MQTT Google Group](https://groups.google.com/forum/?hl=en-US&fromgroups#!forum/mqtt). - -More information is available via the [MQTT community](http://mqtt.org). diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/THIRD PARTY OPEN SOURCE SOFTWARE NOTICE.docx b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/THIRD PARTY OPEN SOURCE SOFTWARE NOTICE.docx deleted file mode 100644 index 16f67baf02641a99f80130b1e80a70474f13c0ca..0000000000000000000000000000000000000000 Binary files a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/THIRD PARTY OPEN SOURCE SOFTWARE NOTICE.docx and /dev/null differ diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/about.html b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/about.html deleted file mode 100644 index 6555a44e5ba1e6f53d7fcba2e90b3d43053b33f9..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - -About - - -

About This Content

- -

December 9, 2013

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL") and Eclipse Distribution License Version 1.0 ("EDL"). -A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html -and a copy of the EDL is available at -http://www.eclipse.org/org/documents/edl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - diff --git a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/doc/DoxyfileMQTTClient-C.in b/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/doc/DoxyfileMQTTClient-C.in deleted file mode 100644 index b89d4338b1e8c3d0fc1225b6d67d34dceffcd3ac..0000000000000000000000000000000000000000 --- a/Device/RemoteLamp/device/third_party/iot_link/network/mqtt/paho_mqtt/paho/doc/DoxyfileMQTTClient-C.in +++ /dev/null @@ -1,2430 +0,0 @@ -# Doxyfile 1.8.13 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "Eclipse Paho Embedded MQTTClient-C Client Library" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -PROJECT_LOGO = "doc/pahologo.png" - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = "doc/MQTTClient-C/" - -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = NO - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = MQTTClient-C/src MQTTClient-C/src/linux - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new -# page for each member. If set to NO, the documentation of a member will be part -# of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note: For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up -# to that level are automatically included in the table of contents, even if -# they do not have an id attribute. -# Note: This feature currently applies only to Markdown headings. -# Minimum value: 0, maximum value: 99, default value: 0. -# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. - -TOC_INCLUDE_HEADINGS = 0 - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# If one adds a struct or class to a group and this option is enabled, then also -# any nested class or struct is added to the same group. By default this option -# is disabled and one has to add nested compounds explicitly via \ingroup. -# The default value is: NO. - -GROUP_NESTED_COMPOUNDS = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO, -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. If set to YES, local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO, only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO, these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES, the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = YES - -# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will -# append additional text to a page's title, such as Class Reference. If set to -# YES the compound reference will be hidden. -# The default value is: NO. - -HIDE_COMPOUND_REFERENCE= NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = NO - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo -# list. This list is created by putting \todo commands in the documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test -# list. This list is created by putting \test commands in the documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES, the -# list will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. -# The default value is: NO. - -WARN_AS_ERROR = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = MQTTClient-C/src MQTTClient-C/src/linux - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# read by doxygen. -# -# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, -# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = NO - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler (hhc.exe). If non-empty, -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated -# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NONE - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /