瀏覽代碼

add new app

zqy 2 年之前
父節點
當前提交
bf8194d643
共有 100 個文件被更改,包括 11478 次插入0 次删除
  1. 10 0
      vendor/bossay/CH2O_Monitoring/BUILD.gn
  2. 102 0
      vendor/bossay/CH2O_Monitoring/config.json
  3. 32 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/BUILD.gn
  4. 20 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/BUILD.gn
  5. 14 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/OLED_DisplayTask.c
  6. 44 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/OLED_I2C.h
  7. 281 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/codetab.h
  8. 228 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/iot_gpio.h
  9. 311 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/src/OLED_I2C.c
  10. 25 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/BUILD.gn
  11. 170 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/inc/cloud_communicate.h
  12. 78 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/inc/cloud_schedule.h
  13. 525 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/src/cloud_communicate.c
  14. 300 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/src/cloud_schedule.c
  15. 130 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/main_entry.c
  16. 23 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/BUILD.gn
  17. 33 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/inc/CH2O.h
  18. 169 0
      vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/src/CH2O.c
  19. 27 0
      vendor/bossay/CH2O_Monitoring/hals/utils/sys_param/BUILD.gn
  20. 128 0
      vendor/bossay/CH2O_Monitoring/hals/utils/sys_param/hal_sys_param.c
  21. 22 0
      vendor/bossay/CH2O_Monitoring/hals/utils/token/BUILD.gn
  22. 104 0
      vendor/bossay/CH2O_Monitoring/hals/utils/token/hal_token.c
  23. 10 0
      vendor/bossay/PM2_5_Monitoring/BUILD.gn
  24. 102 0
      vendor/bossay/PM2_5_Monitoring/config.json
  25. 32 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/BUILD.gn
  26. 20 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/BUILD.gn
  27. 14 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/OLED_DisplayTask.c
  28. 44 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/OLED_I2C.h
  29. 281 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/codetab.h
  30. 228 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/iot_gpio.h
  31. 311 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/src/OLED_I2C.c
  32. 25 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/BUILD.gn
  33. 170 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/inc/cloud_communicate.h
  34. 78 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/inc/cloud_schedule.h
  35. 525 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/src/cloud_communicate.c
  36. 300 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/src/cloud_schedule.c
  37. 133 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/main_entry.c
  38. 23 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/BUILD.gn
  39. 30 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/inc/PM2_5.h
  40. 120 0
      vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/src/PM2_5.c
  41. 27 0
      vendor/bossay/PM2_5_Monitoring/hals/utils/sys_param/BUILD.gn
  42. 128 0
      vendor/bossay/PM2_5_Monitoring/hals/utils/sys_param/hal_sys_param.c
  43. 22 0
      vendor/bossay/PM2_5_Monitoring/hals/utils/token/BUILD.gn
  44. 104 0
      vendor/bossay/PM2_5_Monitoring/hals/utils/token/hal_token.c
  45. 120 0
      vendor/bossay/common/communicationkit/js_api/@system.communicationkit.d.ts
  46. 25 0
      vendor/bossay/common/communicationkit/js_api/BUILD.gn
  47. 44 0
      vendor/bossay/common/communicationkit/native_utils/BUILD.gn
  48. 34 0
      vendor/bossay/common/communicationkit/native_utils/include/nativeapi_communication_kit.h
  49. 52 0
      vendor/bossay/common/communicationkit/native_utils/include/nativeapi_communication_kit_impl.h
  50. 159 0
      vendor/bossay/common/communicationkit/native_utils/src/nativeapi_communication_kit.cpp
  51. 105 0
      vendor/bossay/common/communicationkit/native_utils/src/nativeapi_communication_kit_impl.c
  52. 24 0
      vendor/bossay/common/hals/BUILD.gn
  53. 51 0
      vendor/bossay/common/hals/src/peripheral_hal.c
  54. 24 0
      vendor/bossay/common/hals/src/utils_hal.c
  55. 30 0
      vendor/bossay/common/inc/flower.h
  56. 94 0
      vendor/bossay/common/inc/iot_adc.h
  57. 31 0
      vendor/bossay/common/inc/iot_boardbutton.h
  58. 43 0
      vendor/bossay/common/inc/iot_boardbutton_xradio.h
  59. 61 0
      vendor/bossay/common/inc/iot_boardled.h
  60. 48 0
      vendor/bossay/common/inc/iot_boardled_xradio.h
  61. 123 0
      vendor/bossay/common/inc/iot_cloud.h
  62. 61 0
      vendor/bossay/common/inc/iot_demo_def.h
  63. 340 0
      vendor/bossay/common/inc/iot_gpio_ex.h
  64. 78 0
      vendor/bossay/common/inc/iot_i2c_ex.h
  65. 37 0
      vendor/bossay/common/inc/iot_list.h
  66. 35 0
      vendor/bossay/common/inc/iot_netcfg.h
  67. 81 0
      vendor/bossay/common/inc/iot_netcfg_nan.h
  68. 44 0
      vendor/bossay/common/inc/iot_nfc.h
  69. 39 0
      vendor/bossay/common/inc/iot_schedule.h
  70. 52 0
      vendor/bossay/common/inc/iot_sntp.h
  71. 40 0
      vendor/bossay/common/inc/iot_softap.h
  72. 40 0
      vendor/bossay/common/inc/iot_softap_xradio.h
  73. 368 0
      vendor/bossay/common/inc/iot_spi.h
  74. 38 0
      vendor/bossay/common/inc/iot_store_manager.h
  75. 41 0
      vendor/bossay/common/inc/iot_wifi.h
  76. 39 0
      vendor/bossay/common/inc/iot_wifi_xradio.h
  77. 375 0
      vendor/bossay/common/inc/network_config_service.h
  78. 175 0
      vendor/bossay/common/inc/peripheral_hal.h
  79. 46 0
      vendor/bossay/common/inc/schedule_list.h
  80. 49 0
      vendor/bossay/common/inc/schedule_store.h
  81. 21 0
      vendor/bossay/common/inc/utils_hal.h
  82. 30 0
      vendor/bossay/common/iot_boardbutton/BUILD.gn
  83. 122 0
      vendor/bossay/common/iot_boardbutton/iot_boardbutton.c
  84. 35 0
      vendor/bossay/common/iot_boardbutton_xradio/BUILD.gn
  85. 180 0
      vendor/bossay/common/iot_boardbutton_xradio/iot_boardbutton_xradio.c
  86. 30 0
      vendor/bossay/common/iot_boardled/BUILD.gn
  87. 168 0
      vendor/bossay/common/iot_boardled/iot_boardled.c
  88. 30 0
      vendor/bossay/common/iot_boardled_xradio/BUILD.gn
  89. 119 0
      vendor/bossay/common/iot_boardled_xradio/iot_boardled_xradio.c
  90. 37 0
      vendor/bossay/common/iot_cloud/BUILD.gn
  91. 350 0
      vendor/bossay/common/iot_cloud/iot_cloud.c
  92. 303 0
      vendor/bossay/common/iot_cloud/iot_profile_package.c
  93. 32 0
      vendor/bossay/common/iot_list/BUILD.gn
  94. 286 0
      vendor/bossay/common/iot_list/iot_list.c
  95. 530 0
      vendor/bossay/common/iot_list/iot_store_manager.c
  96. 41 0
      vendor/bossay/common/iot_nfc/BUILD.gn
  97. 217 0
      vendor/bossay/common/iot_nfc/NT3H.c
  98. 127 0
      vendor/bossay/common/iot_nfc/NT3H.h
  99. 248 0
      vendor/bossay/common/iot_nfc/ndef/ndef.c
  100. 23 0
      vendor/bossay/common/iot_nfc/ndef/ndef.h

+ 10 - 0
vendor/bossay/CH2O_Monitoring/BUILD.gn

@@ -0,0 +1,10 @@
+# Copyright (C) 2020 Hisilicon (Shanghai) Technologies Co., Ltd. All rights reserved.
+
+group("CH2O_Monitoring") {
+    deps = [
+        "//device/bossay/hi3861_l0/sdk_liteos:wifiiot_sdk",
+        "../common/iot_wifi:iot_wifi",
+        # "//applications/sample/app:app",
+        "demo_CH2O_Monitoring:bossay_hi3861_l0_CH2O_Monitoring",
+    ]
+}

+ 102 - 0
vendor/bossay/CH2O_Monitoring/config.json

@@ -0,0 +1,102 @@
+{
+    "product_name": "CH2O_Monitoring",
+    "ohos_version": "OpenHarmony 1.0",
+    "device_company": "bossay",
+    "board": "hi3861_l0",
+    "kernel_type": "liteos_m",
+    "kernel_version": "",
+    "subsystems": [
+      {
+        "subsystem": "applications",
+        "components": [
+          { "component": "wifi_iot_sample_app", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "iot_hardware",
+        "components": [
+          { "component": "iot_controller", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "hiviewdfx",
+        "components": [
+          { "component": "hilog_lite", "features":[] },
+          { "component": "hievent_lite", "features":[] },
+          { "component": "blackbox", "features":[] },
+          { "component": "hidumper_mini", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "distributed_schedule",
+        "components": [
+          { "component": "samgr_lite", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "security",
+        "components": [
+          { "component": "hichainsdk", "features":[] },
+          { "component": "deviceauth_lite", "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/bossay/hi3861_l0/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": "softbus_lite", "features":[] },
+          { "component": "wifi_aware", "features":[]}
+        ]
+      },
+      {
+        "subsystem": "update",
+        "components": [
+          { "component": "ota_lite", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "iot",
+        "components": [
+          { "component": "iot_link", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "utils",
+        "components": [
+          { "component": "file", "features":[] },
+          { "component": "kv_store", "features":[] },
+          { "component": "os_dump", "features":[] }
+        ]
+      },
+      {
+       "subsystem": "test",
+       "components": [
+         { "component": "xts_acts", "features":[] },
+         { "component": "xts_tools", "features":[] }
+        ]
+      }
+    ],
+    "third_party_dir": "//device/bossay/hi3861_l0/sdk_liteos/third_party",
+    "product_adapter_dir": "//vendor/bossay/hi3861_l0/hals"
+  }

+ 32 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/BUILD.gn

@@ -0,0 +1,32 @@
+static_library("bossay_hi3861_l0_CH2O_Monitoring") {
+    sources = [
+        "main_entry.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "./sensor/inc",
+        "../../common/inc",
+        "cloud_connect/inc",
+        "//third_party/cJSON",
+        "./OLED/include"
+        
+    ]
+
+    deps = [ 
+         "../../common/iot_sntp:iot_sntp",
+         "../../common/iot_wifi:iot_wifi",
+         "../../common/iot_schedule:iot_schedule",
+         #"../../common/iot_nfc:iot_nfc",
+         "../../common/iot_cloud:iot_cloud",
+         #"../../common/iot_boardled:iot_boardled",
+         #"../../common/iot_boardbutton:iot_boardbutton",
+         "cloud_connect:cloud_connect",
+         "sensor:bossay_hi3861_l0_sensor",
+         "OLED:bossay_hi3816l0_OLED",
+    ]
+
+}

+ 20 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/BUILD.gn

@@ -0,0 +1,20 @@
+static_library("bossay_hi3816l0_OLED"){
+
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//device/bossay/hi3861_l0/iot_hardware_hals/include",
+        "//device/bossay/hi3861_l0/sdk_liteos/include",
+        "include",
+    ]
+    sources = [
+        "src/OLED_I2C.c",
+        "OLED_DisplayTask.c",
+    ]
+}
+
+

+ 14 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/OLED_DisplayTask.c

@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2021 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.
+ */

+ 44 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/OLED_I2C.h

@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 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 __OLED_I2C_H
+#define	__OLED_I2C_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "iot_gpio.h"
+
+#define OLED_ADDRESS	0x3D //通过调整0R电阻,屏可以0x3C和0x3D两个地址 -- 默认0x3C
+#define KEY_GPIO 11
+
+void initKey(GpioIsrCallbackFunc func);
+bool isKeyON(void);
+
+
+
+void OLED_BoardInit(void);
+void I2C_WriteByte(uint8_t addr,uint8_t data);
+void WriteCmd(unsigned char I2C_Command);
+void WriteDat(unsigned char I2C_Data);
+void OLED_Init(void);
+void OLED_SetPos(unsigned char x, unsigned char y);
+void OLED_Fill(unsigned char fill_Data);
+void OLED_CLS(void);
+void OLED_ON(void);
+void OLED_OFF(void);
+void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize);
+void OLED_ShowCN(unsigned char x, unsigned char y, unsigned char N);
+void OLED_DrawBMP(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[]);
+
+#endif

+ 281 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/codetab.h

@@ -0,0 +1,281 @@
+#ifndef __CODETAB_H
+#define	__CODETAB_H
+
+
+/***************************16*16的点阵字体取模方式:共阴——列行式——逆向输出*********/
+unsigned char F16x16[] =
+
+{	0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
+	0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,/*"科",0*/
+
+	0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
+	0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00/*"技",1*/
+};
+
+
+/************************************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,// ,
+	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
+};
+
+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,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/
+};
+
+
+#endif

+ 228 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/include/iot_gpio.h

@@ -0,0 +1,228 @@
+/*
+ * 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_gpio.h
+ *
+ * @brief Declares functions for operating GPIO devices.
+ *
+ * These functions are used for GPIO initialization, input/output settings, and level settings. \n
+ *
+ * @since 2.2
+ * @version 2.2
+ */
+#ifndef IOT_GPIO_H
+#define IOT_GPIO_H
+
+/**
+ * @brief Enumerates GPIO level values.
+ */
+typedef enum {
+    /** Low GPIO level */
+    IOT_GPIO_VALUE0 = 0,
+    /** High GPIO level */
+    IOT_GPIO_VALUE1
+} IotGpioValue;
+
+/**
+ * @brief Enumerates GPIO directions.
+ */
+typedef enum {
+    /** Input */
+    IOT_GPIO_DIR_IN = 0,
+    /** Output */
+    IOT_GPIO_DIR_OUT
+} IotGpioDir;
+
+/**
+ * @brief Enumerates GPIO interrupt trigger modes.
+ */
+typedef enum {
+    /** Level-sensitive interrupt */
+    IOT_INT_TYPE_LEVEL = 0,
+    /** Edge-sensitive interrupt */
+    IOT_INT_TYPE_EDGE
+} IotGpioIntType;
+
+/**
+ * @brief Enumerates I/O interrupt polarities.
+ */
+typedef enum {
+    /** Interrupt at a low level or falling edge */
+    IOT_GPIO_EDGE_FALL_LEVEL_LOW = 0,
+    /** Interrupt at a high level or rising edge */
+    IOT_GPIO_EDGE_RISE_LEVEL_HIGH
+} IotGpioIntPolarity;
+
+/**
+ * @brief Indicates the GPIO interrupt callback.
+ *
+ */
+typedef void (*GpioIsrCallbackFunc) (char *arg);
+
+/**
+ * @brief Initializes a GPIO device.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the GPIO device is initialized;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioInit(unsigned int id);
+
+/**
+ * @brief Deinitializes a GPIO device.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the GPIO device is deinitialized;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioDeinit(unsigned int id);
+
+/**
+ * @brief Sets the direction for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param dir Indicates the GPIO input/output direction.
+ * @return Returns {@link IOT_SUCCESS} if the direction is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetDir(unsigned int id, IotGpioDir dir);
+
+/**
+ * @brief Obtains the direction for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param dir Indicates the pointer to the GPIO input/output direction.
+ * @return Returns {@link IOT_SUCCESS} if the direction is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetDir(unsigned int id, IotGpioDir *dir);
+
+/**
+ * @brief Sets the output level value for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the output level value.
+ * @return Returns {@link IOT_SUCCESS} if the output level value is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetOutputVal(unsigned int id, IotGpioValue val);
+
+/**
+ * @brief Obtains the output level value of a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the pointer to the output level value.
+ * @return Returns {@link IOT_SUCCESS} if the output level value is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetOutputVal(unsigned int id, IotGpioValue *val);
+
+/**
+ * @brief Obtains the input level value of a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the pointer to the input level value.
+ * @return Returns {@link IOT_SUCCESS} if the input level value is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetInputVal(unsigned int id, IotGpioValue *val);
+
+/**
+ * @brief Enables the interrupt feature for a GPIO pin.
+ *
+ * This function can be used to set the interrupt type, interrupt polarity, and interrupt callback for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param intType Indicates the interrupt type.
+ * @param intPolarity Indicates the interrupt polarity.
+ * @param func Indicates the interrupt callback function.
+ * @param arg Indicates the pointer to the argument used in the interrupt callback function.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is enabled;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioRegisterIsrFunc(unsigned int id, IotGpioIntType intType, IotGpioIntPolarity intPolarity,
+                                    GpioIsrCallbackFunc func, char *arg);
+
+/**
+ * @brief Disables the interrupt feature for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is disabled;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioUnregisterIsrFunc(unsigned int id);
+
+/**
+ * @brief Masks the interrupt feature for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param mask Indicates whether the interrupt function is masked.
+ * The value <b>1</b> means to mask the interrupt function, and <b>0</b> means not to mask the interrupt function.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is masked;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetIsrMask(unsigned int id, unsigned char mask);
+
+/**
+ * @brief Sets the interrupt trigger mode of a GPIO pin.
+ *
+ * This function configures a GPIO pin based on the interrupt type and interrupt polarity.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param intType Indicates the interrupt type.
+ * @param intPolarity Indicates the interrupt polarity.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt trigger mode is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetIsrMode(unsigned int id, IotGpioIntType intType, IotGpioIntPolarity intPolarity);
+
+#endif
+/** @} */

+ 311 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/OLED/src/OLED_I2C.c

@@ -0,0 +1,311 @@
+#include "OLED_I2C.h"
+#include "codetab.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "iot_i2c.h"
+#include "iot_i2c_ex.h"
+#include <cmsis_os2.h>
+
+#define I2C1_SDA_GPIO 10
+#define I2C1_SCL_GPIO 9
+#define IOT_GPIO_FUNC_GPIO_0_I2C1_SDA  6
+#define IOT_GPIO_FUNC_GPIO_1_I2C1_SCL 6
+#define WIFI_IOT_I2C_IDX_1 0
+
+#define BEEP_GPIO 12
+
+
+
+void initKey(GpioIsrCallbackFunc func)
+{    
+    IoTGpioInit(KEY_GPIO);
+    IoTGpioSetFunc(KEY_GPIO, IOT_GPIO_FUNC_GPIO_11_GPIO);
+    IoTGpioSetDir(KEY_GPIO, IOT_GPIO_DIR_IN);
+	IoTGpioSetPull(KEY_GPIO, IOT_GPIO_PULL_UP);
+    IoTGpioRegisterIsrFunc(KEY_GPIO, IOT_INT_TYPE_EDGE, IOT_GPIO_EDGE_FALL_LEVEL_LOW, func, NULL);
+}
+
+
+
+
+bool isKeyON(void)
+{
+    IotGpioValue temp;
+    IoTGpioGetInputVal(KEY_GPIO,&temp);
+    return !temp;
+}
+
+void OLED_BoardInit(void)
+{   
+    IoTGpioInit(BEEP_GPIO);
+    IoTGpioSetFunc(BEEP_GPIO, IOT_GPIO_FUNC_GPIO_12_GPIO);
+    IoTGpioSetDir(BEEP_GPIO, IOT_GPIO_DIR_OUT); // 设置GPIO_14为输出模式
+
+    IoTGpioSetOutputVal(BEEP_GPIO, 1); // 设置输出高电平打开蜂鸣器
+
+    //GPIO_0复用为I2C1_SDA
+    IoTGpioInit(I2C1_SDA_GPIO);
+    IoTGpioSetFunc(I2C1_SDA_GPIO, IOT_GPIO_FUNC_GPIO_10_I2C0_SDA);
+
+    //GPIO_1复用为I2C1_SCL
+    IoTGpioInit(I2C1_SCL_GPIO);
+    IoTGpioSetFunc(I2C1_SCL_GPIO, IOT_GPIO_FUNC_GPIO_9_I2C0_SCL);
+
+    //baudrate: 400kbps
+    IoTI2cInit(WIFI_IOT_I2C_IDX_1, 400000);
+
+}
+
+ /**
+  * @brief  I2C_WriteByte,向OLED寄存器地址写一个byte的数据
+  * @param  addr:寄存器地址
+	*					data:要写入的数据
+  * @retval 无
+  */
+void I2C_WriteByte(uint8_t addr,uint8_t data)
+{
+    uint32_t ret;
+    uint8_t send_data[2] = {addr, data};
+    ret = IoTI2cWrite(WIFI_IOT_I2C_IDX_1, (OLED_ADDRESS << 1) | 0x00, send_data, 2);
+    if (ret != 0) {
+        printf("===== Error: I2C write ret = 0x%x! =====\r\n", ret);
+        return -1;
+    }
+    return 0;
+}
+
+
+ /**
+  * @brief  WriteCmd,向OLED写入命令
+  * @param  I2C_Command:命令代码
+  * @retval 无
+  */
+void WriteCmd(unsigned char I2C_Command)//写命令
+{
+	I2C_WriteByte(0x00, I2C_Command);
+}
+
+
+ /**
+  * @brief  WriteDat,向OLED写入数据
+  * @param  I2C_Data:数据
+  * @retval 无
+  */
+void WriteDat(unsigned char I2C_Data)//写数据
+{
+	I2C_WriteByte(0x40, I2C_Data);
+}
+
+
+ /**
+  * @brief  OLED_Init,初始化OLED
+  * @param  无
+  * @retval 无
+  */
+void OLED_Init(void)
+{
+	osDelay(100); //这里的延时很重要
+	
+	WriteCmd(0xAE); //display off
+	WriteCmd(0x20);	//Set Memory Addressing Mode	
+	WriteCmd(0x10);	//00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
+	WriteCmd(0xb0);	//Set Page Start Address for Page Addressing Mode,0-7
+	WriteCmd(0xc8);	//Set COM Output Scan Direction
+	WriteCmd(0x00); //---set low column address
+	WriteCmd(0x10); //---set high column address
+	WriteCmd(0x40); //--set start line address
+	WriteCmd(0x81); //--set contrast control register
+	WriteCmd(0xff); //亮度调节 0x00~0xff
+	WriteCmd(0xa1); //--set segment re-map 0 to 127
+	WriteCmd(0xa6); //--set normal display
+	WriteCmd(0xa8); //--set multiplex ratio(1 to 64)
+	WriteCmd(0x3F); //
+	WriteCmd(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
+	WriteCmd(0xd3); //-set display offset
+	WriteCmd(0x00); //-not offset
+	WriteCmd(0xd5); //--set display clock divide ratio/oscillator frequency
+	WriteCmd(0xf0); //--set divide ratio
+	WriteCmd(0xd9); //--set pre-charge period
+	WriteCmd(0x22); //
+	WriteCmd(0xda); //--set com pins hardware configuration
+	WriteCmd(0x12);
+	WriteCmd(0xdb); //--set vcomh
+	WriteCmd(0x20); //0x20,0.77xVcc
+	WriteCmd(0x8d); //--set DC-DC enable
+	WriteCmd(0x14); //
+	WriteCmd(0xaf); //--turn on oled panel
+}
+
+
+ /**
+  * @brief  OLED_SetPos,设置光标
+  * @param  x,光标x位置
+	*					y,光标y位置
+  * @retval 无
+  */
+void OLED_SetPos(unsigned char x, unsigned char y) //设置起始点坐标
+{ 
+	WriteCmd(0xb0+y);
+	WriteCmd(((x&0xf0)>>4)|0x10);
+	WriteCmd((x&0x0f)|0x01);
+}
+
+ /**
+  * @brief  OLED_Fill,填充整个屏幕
+  * @param  fill_Data:要填充的数据
+	* @retval 无
+  */
+void OLED_Fill(unsigned char fill_Data)//全屏填充
+{
+	unsigned char m,n;
+	for(m=0;m<8;m++)
+	{
+		WriteCmd(0xb0+m);		//page0-page1
+		WriteCmd(0x00);		//low column start address
+		WriteCmd(0x10);		//high column start address
+		for(n=0;n<128;n++)
+			{
+				WriteDat(fill_Data);
+			}
+	}
+}
+
+ /**
+  * @brief  OLED_CLS,清屏
+  * @param  无
+	* @retval 无
+  */
+void OLED_CLS(void)//清屏
+{
+	OLED_Fill(0x00);
+}
+
+
+ /**
+  * @brief  OLED_ON,将OLED从休眠中唤醒
+  * @param  无
+	* @retval 无
+  */
+void OLED_ON(void)
+{
+	WriteCmd(0X8D);  //设置电荷泵
+	WriteCmd(0X14);  //开启电荷泵
+	WriteCmd(0XAF);  //OLED唤醒
+}
+
+
+ /**
+  * @brief  OLED_OFF,让OLED休眠 -- 休眠模式下,OLED功耗不到10uA
+  * @param  无
+	* @retval 无
+  */
+void OLED_OFF(void)
+{
+	WriteCmd(0X8D);  //设置电荷泵
+	WriteCmd(0X10);  //关闭电荷泵
+	WriteCmd(0XAE);  //OLED休眠
+}
+
+
+ /**
+  * @brief  OLED_ShowStr,显示codetab.h中的ASCII字符,有6*8和8*16可选择
+  * @param  x,y : 起始点坐标(x:0~127, y:0~7);
+	*					ch[] :- 要显示的字符串; 
+	*					TextSize : 字符大小(1:6*8 ; 2:8*16)
+	* @retval 无
+  */
+void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize)
+{
+	unsigned char c = 0,i = 0,j = 0;
+	switch(TextSize)
+	{
+		case 1:
+		{
+			while(ch[j] != '\0')
+			{
+				c = ch[j] - 32;
+				if(x > 126)
+				{
+					x = 0;
+					y++;
+				}
+				OLED_SetPos(x,y);
+				for(i=0;i<6;i++)
+					WriteDat(F6x8[c][i]);
+				x += 6;
+				j++;
+			}
+		}break;
+		case 2:
+		{
+			while(ch[j] != '\0')
+			{
+				c = ch[j] - 32;
+				if(x > 120)
+				{
+					x = 0;
+					y++;
+				}
+				OLED_SetPos(x,y);
+				for(i=0;i<8;i++)
+					WriteDat(F8X16[c*16+i]);
+				OLED_SetPos(x,y+1);
+				for(i=0;i<8;i++)
+					WriteDat(F8X16[c*16+i+8]);
+				x += 8;
+				j++;
+			}
+		}break;
+	}
+}
+
+ /**
+  * @brief  OLED_ShowCN,显示codetab.h中的汉字,16*16点阵
+  * @param  x,y: 起始点坐标(x:0~127, y:0~7); 
+	*					N:汉字在codetab.h中的索引
+	* @retval 无
+  */
+void OLED_ShowCN(unsigned char x, unsigned char y, unsigned char N)
+{
+	unsigned char wm=0;
+	unsigned int  adder=32*N;
+	OLED_SetPos(x , y);
+	for(wm = 0;wm < 16;wm++)
+	{
+		WriteDat(F16x16[adder]);
+		adder += 1;
+	}
+	OLED_SetPos(x,y + 1);
+	for(wm = 0;wm < 16;wm++)
+	{
+		WriteDat(F16x16[adder]);
+		adder += 1;
+	}
+}
+
+
+
+ /**
+  * @brief  OLED_DrawBMP,显示BMP位图
+  * @param  x0,y0 :起始点坐标(x0:0~127, y0:0~7);
+	*					x1,y1 : 起点对角线(结束点)的坐标(x1:1~128,y1:1~8)
+	* @retval 无
+  */
+void OLED_DrawBMP(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[])
+{
+	unsigned int j=0;
+	unsigned char x,y;
+
+  if(y1%8==0)
+		y = y1/8;
+  else
+		y = y1/8 + 1;
+	for(y=y0;y<y1;y++)
+	{
+		OLED_SetPos(x0,y);
+    for(x=x0;x<x1;x++)
+		{
+			WriteDat(BMP[j++]);
+		}
+	}
+}

+ 25 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/BUILD.gn

@@ -0,0 +1,25 @@
+static_library("cloud_connect") {
+    sources = [
+        "src/cloud_communicate.c",
+        "src/cloud_schedule.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "inc",
+        "../../../common/inc",
+        "//third_party/cJSON",
+        "//utils/native/lite/include/",
+    ]
+
+    deps = [ 
+        "../../../common/iot_schedule:iot_schedule",
+        "../../../common/iot_cloud:iot_cloud",
+        "../../../common/iot_wifi:iot_wifi",
+        "../../../common/iot_sntp:iot_sntp",
+    ]
+
+}

+ 170 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/inc/cloud_communicate.h

@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+
+/*
+    Standard information upload:
+    format:
+    serviceID
+        |-- proprety_01
+        |    |-- status
+        |-- proprety_02
+             |-- status
+
+        status:
+        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;
+
+    so we just construct a struct named InforUplod:
+    struct InforService
+    {
+        serviceIDName;
+        nextProtrety;
+    };
+    struct InforProprety
+    {
+        propretyType;
+        propretyName;
+        value;
+        nextProtrety;
+    };
+
+    IotProfileService service = createService("serviceID");
+    createProprety(&service,"propretyName",propretyType);
+    deleteProprety(&service,"propretyName",propretyType);
+    uploadService(&service);
+*/
+
+#ifndef __CLOUD_COMMUNICATE_H__
+#define __CLOUD_COMMUNICATE_H__
+
+#include "iot_cloud.h"
+#include <cmsis_os2.h>
+#include <stdbool.h>
+#include "cJSON.h"
+
+#define CLOUD_MALLOC_ENABEL true
+
+#define CLOUD_COMMAND_NAME "command_name"
+#define CLOUD_PARA_NAME "paras"
+#define WIFI_SSID_MAX_LEN_ 256
+#define WIFI_PWD_MAX_LEN_ 256
+#define KV_STORE_SSID_ID "ssid"
+#define KV_STORE_PWD_ID "pwd"
+#define NAN_WIFI_AP_SSID "bossay"
+
+#define MAX_STRING_VALUE_LEN 30
+#define MAX_CMD_NAME_LEN 30
+#define MAX_CMD_PARA_NAME_LEN 30
+
+
+typedef union 
+{
+    /* data */
+    int valueInt;
+    double valueDouble;
+    char valueString[MAX_STRING_VALUE_LEN];
+}CmdValue;
+
+typedef enum
+{
+    Cloud_Int,
+    Cloud_Double,
+    Cloud_String,
+}ValueType;
+
+typedef struct{
+    CmdValue value;
+    ValueType type;
+}FuncValue_t;
+
+typedef int (*cmdFuncCallback)(FuncValue_t value);
+
+typedef struct 
+{
+    /* data */
+    char name[MAX_CMD_PARA_NAME_LEN];
+    ValueType type;
+    cmdFuncCallback func;
+    struct CmdParam *nxt;
+}CmdParam;
+
+
+typedef struct {
+//    CmdValue value;
+    char name[MAX_CMD_NAME_LEN];
+    CmdParam* params;
+    struct cmdNode *nxt;
+}CmdNode;
+
+
+typedef struct{
+    char ssid[WIFI_SSID_MAX_LEN_];
+    char pwd[WIFI_PWD_MAX_LEN_];
+}WIFI_ssid_pwd;
+
+
+
+//int getStoredWifiInfo(WIFI_ssid_pwd* wifi);
+//int setStoredWifiInfo(WIFI_ssid_pwd* wifi);
+int NanWifiConnect(bool restartNan);
+int cloud_CloudInit(const char *deviceID, const char *devicePwd, \
+    const char *serverIP, const char *serverPort);
+
+// this .h file has the 'namespace' cloud, all the variables has the prefix cloud or CLOD
+/*---------------------- The lower is uploadind message to the cloud ------------------------*/
+typedef IotProfileService   Cloud_Servic;
+typedef IotProfileKV        Cloud_Proprety;
+typedef IotProfileDataType  Cloud_DataType;
+
+
+
+#if CLOUD_MALLOC_ENABEL == true
+
+Cloud_Servic* cloud_createService(const char* name,const char * event);
+int cloud_createAndAppendProprety(Cloud_Servic *service,const char *name,Cloud_DataType type,void* value);
+void cloud_deleteService(Cloud_Servic *service);
+
+CmdNode* cloud_createCmd(char* name);
+CmdParam* cloud_createAndAppendPara(CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func);
+void cloud_deleteCmd();
+#endif
+
+#if CLOUD_MALLOC_ENABEL == false
+
+void cloud_initService(Cloud_Servic *service,const char* name,const char * event);
+void cloud_initAndAppendProprety(Cloud_Servic *service,Cloud_Proprety *proprety,const char *name,Cloud_DataType type,void* value);
+
+void cloud_initCmd(CmdNode* nextNode,char* name);
+void cloud_initAndAppendPara(CmdNode* cmd,CmdParam* para,const char* name,ValueType type,cmdFuncCallback func);
+
+#endif
+
+int cloud_uploadService(Cloud_Servic *service);
+
+/*----------------------- The lower is download message from cloud -------------------------*/
+bool cloud_isCommandName(cJSON* root,char* name);
+
+
+
+#define cloud_Connect CLOUD_Connect
+
+#endif

+ 78 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/inc/cloud_schedule.h

@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2021 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 __CLOUD_SCHEDULE_H__
+#define __CLOUD_SCHEDULE_H__
+
+#include "iot_schedule.h"
+#include "cloud_communicate.h"
+
+#include <stdbool.h>
+#include <time.h>
+
+#define CN_MAX_WEEKDAY 7
+#define CN_MAX_SCHID 30
+
+
+// #define CLOUD_SCHEDULE_MALLOC_EN true
+// #if CLOUD_SCHEDULE_MALLOC_EN
+#define CLOUD_SCHEDULE_NAME_LEN 15
+// #else
+// #define CLOUD_SCHEDULE_NAME_LEN 30
+// #endif
+
+typedef struct tm TIME;
+
+typedef enum{
+    SCHE_UPDATE = 0,
+    SCHE_ADD,
+    SCHE_DELELTE,
+}SheduleUpdateOption;
+
+typedef struct{
+    CmdParam* param;
+    CmdValue value;
+}CmdControl;
+
+typedef struct {
+    uint8_t Days;         // the day which has 1001100 format
+    uint8_t startHour;   // less than 24
+    uint8_t startMinute; // less than 60
+    uint8_t startSeconds;
+    uint16_t duration;    // less than 1440
+    CmdControl ctrl;
+    char id[CLOUD_SCHEDULE_NAME_LEN];
+    struct ScheduleCtrl_t* nxt;
+}ScheduleCtrl_t;
+
+
+
+
+void bindingScheduleToCmd(ScheduleCtrl_t* schedule,CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func);
+
+void ScheduleInit();
+
+void updataSchedule(ScheduleCtrl_t* shedule,SheduleUpdateOption option);
+
+
+ScheduleCtrl_t* cloud_createSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur, CmdControl ctrl);
+int cloud_updateSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur);
+int cloud_deleteScheduleByID(const char* id);
+
+
+
+#endif

+ 525 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/src/cloud_communicate.c

@@ -0,0 +1,525 @@
+/*
+ * @Author: bearpi_gdtr
+ * @Date: 2022-03-18 17:32:25
+ * @LastEditTime: 2022-03-26 10:43:49
+ * @LastEditors: Please set LastEditors
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath: \v3_0_2\vendor\bossay\smart_door\demo_smartdoor\cloud_command\src\cloud_commuinate.c
+ */
+#include "cloud_communicate.h"
+#include "network_config_service.h"
+#include "iot_wifi.h"
+#include "kv_store.h"
+#include <stdio.h>
+#include <string.h>
+
+
+static CmdNode cmdNodeFirst = {
+    .nxt = NULL,
+    .params = NULL,
+    .name = NULL,
+    //.value.valueU64 = 0,
+};
+
+/**
+ * @description: get wifi inforamtion from kvstore
+ * @param {WIFI_ssid_pwd*} wifi
+ * @return {*}
+ */
+int getStoredWifiInfo(WIFI_ssid_pwd* wifi)
+{
+    int ret = -1;
+    ret = UtilsGetValue(KV_STORE_SSID_ID,wifi->ssid,WIFI_SSID_MAX_LEN_);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't get the wifi ssid from kV store");
+        return ret;
+    }
+    ret = UtilsGetValue(KV_STORE_PWD_ID,wifi->pwd,WIFI_PWD_MAX_LEN_);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't get the wifi pwd from kV store");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO, "get wifi success! \n");
+    RaiseLog(LOG_LEVEL_INFO,"Wifi ssid: %s",wifi->ssid);
+    RaiseLog(LOG_LEVEL_INFO,"Wifi pwd: %s",wifi->pwd);
+    return ret;
+}
+
+/**
+ * @description: store the wifi
+ * @param {WIFI_ssid_pwd*} wifi
+ * @return {*}
+ */
+int setStoredWifiInfo(WIFI_ssid_pwd* wifi)
+{
+    int ret = -1;
+    ret = UtilsSetValue(KV_STORE_SSID_ID,wifi->ssid);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't store the wifi ssid to the kV store");
+        return ret;
+    }
+    ret = UtilsSetValue(KV_STORE_PWD_ID,wifi->pwd);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't store the wifi pwd to the kV store");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO, "Store wifi success! \n");
+    return ret;
+}
+
+/**
+ * @description: initialize the cloud
+ * @param {*}
+ * @return {*}
+ */
+int cloud_CloudInit(const char *deviceID, const char *devicePwd, \
+    const char *serverIP, const char *serverPort)
+{
+    if (CLOUD_Init() != 0) {
+        RaiseLog(LOG_LEVEL_DEBUG,"Cloud init failed");
+        return -1;
+    }
+    if (CLOUD_Connect(deviceID, devicePwd,\
+            serverIP, serverPort) != 0) {
+        RaiseLog(LOG_LEVEL_DEBUG,"Cloud connect failed");
+        return -1;
+    }
+    return 0;
+}
+
+/**
+ * @description: NAN connect the wifi
+ * @param {WIFI_ssid_pwd} *wifi
+ * @return {*}
+ */
+int NanWifiConnect(bool restartNan)
+{
+    WIFI_ssid_pwd wifi;
+    printf("--------------- NAN --------------------%d\n",sizeof(wifi.ssid));
+    if(restartNan){
+        goto CLOUD_START_NAN;
+    }
+    if(getStoredWifiInfo(&wifi) == 0){
+        goto CLOUD_CONNECT_WIFI;
+    }
+    
+CLOUD_START_NAN:
+
+    RaiseLog(LOG_LEVEL_INFO,"Try to get the wifi info by NAN network....");
+    int ret;
+    ret = BOARD_NAN_NetCfgStartConfig(NAN_WIFI_AP_SSID,wifi.ssid,sizeof(wifi.ssid),\
+                                        wifi.pwd,sizeof(wifi.pwd));
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_INFO,"NAN network get wifi info failed");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO,"NAN network get wifi info success");
+    RaiseLog(LOG_LEVEL_INFO,"Wifi ssid: %s",wifi.ssid);
+    RaiseLog(LOG_LEVEL_INFO,"Wifi pwd: %s",wifi.pwd);
+
+CLOUD_CONNECT_WIFI:
+
+    BOARD_InitWifi();
+    ret = BOARD_ConnectWifi(wifi.ssid, wifi.pwd);
+    if (ret != 0) {
+        RaiseLog(LOG_LEVEL_ERR, "Connect to wifi failed! \n");
+        NotifyNetCfgResult(NETCFG_DEV_INFO_INVALID);
+        return ret;
+    }
+    NotifyNetCfgResult(NETCFG_OK);
+    StopNetCfg();
+    ret = setStoredWifiInfo(&wifi);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_ERR,"Wifi info store failed!");
+    }
+    return ret;
+}
+
+
+
+/**
+ * @description: cloud_createService: create one service
+ * @param {char*} name: serviceID's name.
+ * @param {char *} event: The event time of service,which cloud be the NULL
+ * @return {*}
+ */
+Cloud_Servic* cloud_createService(const char* name,const char * event)
+{
+    Cloud_Servic* service = malloc(sizeof(Cloud_Servic));
+    if(service == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"malloc Cloud_Proprety failed!");
+        return;
+    }
+    service->serviceID = name;
+    service->propertyLst = NULL;
+    service->nxt = NULL;
+    service->eventTime = NULL;
+    return service;
+}
+
+/**
+ * @description: cloud_appendProprety : append one proprety to service
+ * @param {Cloud_Servic} *service : .....
+ * @param {char} *name : proprety's name
+ * @param {Cloud_DataType} type: proprety's type.
+ * @param {void*} value: proprety's value
+ * @return {*}
+ */
+int cloud_createAndAppendProprety(Cloud_Servic *service,const char *name,Cloud_DataType type,void* value)
+{   
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+    Cloud_Proprety* prpty = malloc(sizeof(Cloud_Proprety));
+    if(prpty == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"malloc Cloud_Proprety failed!");
+        return -1;
+    }
+    prpty->nxt = NULL;
+    prpty->type = type;
+    prpty->value = value;
+    prpty->key = name;
+    tempPrp = service->propertyLst;
+    if(tempPrp == NULL){
+        service->propertyLst = prpty;
+    }else{
+        while(tempPrp->nxt != NULL){
+            tempPrp = tempPrp->nxt;
+        }
+        tempPrp->nxt = prpty;
+    }
+    return 0;
+}
+
+/**
+ * @description: cloud_appendPropretyAndUpload :
+ *               upload the service to the cloud,
+ * @param {Cloud_Servic} *service : .....
+ * @param {char} *name : proprety's name
+ * @param {Cloud_DataType} type: proprety's type.
+ * @param {void*} value: proprety's value
+ * @return {*}
+ */
+int cloud_uploadService(Cloud_Servic *service)
+{
+    cJSON* jsonString;
+    int ret;
+    jsonString = IoTProfilePackage(service);
+    if (NULL != jsonString) {
+        RaiseLog(LOG_LEVEL_INFO, "jsonString:%s", jsonString);
+        ret = CLOUD_ReportMsg(jsonString);
+        free(jsonString);
+        return ret;
+    }
+    return -1;
+}
+
+
+/**
+ * @description: delete the Service
+ * @param {Cloud_Servic} *service
+ * @return {*}
+ */
+void cloud_deleteService(Cloud_Servic *service)
+{
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+        // free the service and it's propreties.
+    tempService = service;
+    while(tempService != NULL){
+        tempPrp = tempService->propertyLst;
+        while(tempPrp != NULL){
+            Cloud_Proprety* prp = tempPrp;
+            tempPrp = tempPrp->nxt;
+            free(prp);
+        }
+        Cloud_Servic* svc;
+        tempService = tempService->nxt;
+        free(svc);
+    }
+}
+
+/**
+ * @description: 
+ * @param {Cloud_Servic} *service
+ * @param {char*} name
+ * @param {char *} event
+ * @return {*}
+ */
+void cloud_initService(Cloud_Servic *service,const char* name,const char * event)
+{
+    service->serviceID = name;
+    service->propertyLst = NULL;
+    service->nxt = NULL;
+    service->eventTime = NULL;
+    return service;
+}
+
+/**
+ * @description: 
+ * @param {Cloud_Servic} *service
+ * @param {Cloud_Proprety} *prpty
+ * @param {char} *name
+ * @param {Cloud_DataType} type
+ * @param {void*} value
+ * @return {*}
+ */
+void cloud_initAndAppendProprety(Cloud_Servic *service,Cloud_Proprety *prpty,const char *name,Cloud_DataType type,void* value)
+{
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+    prpty->nxt = NULL;
+    prpty->type = type;
+    prpty->value = value;
+    prpty->key = name;
+    tempPrp = service->propertyLst;
+    if(tempPrp == NULL){
+        service->propertyLst = prpty;
+    }else{
+        while(tempPrp->nxt != NULL){
+            tempPrp = tempPrp->nxt;
+        }
+        tempPrp->nxt = prpty;
+    }
+}
+
+/**
+ * @description: create Para for cmd
+ * @param {CmdNode*} cmd
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {CmdParam*}
+ */
+CmdParam* cloud_createAndAppendPara(CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func)
+{
+    CmdParam* para = malloc(sizeof(CmdParam));
+    if(para == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"Malloc CmdParam failed!");
+        return para;
+    }
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return para;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return para;
+}
+
+/**
+ * @description: create cmd add to the cmd list cmdNodeFirst which static defined in this file
+ * @param {char*} name
+ * @return {*}
+ */
+CmdNode* cloud_createCmd(char* name)
+{
+    CmdNode* cmd = malloc(sizeof(CmdNode));
+    if(cmd == NULL){
+        RaiseLog(LOG_LEVEL_ERR,"Malloc CmdBode failed!");
+        return -1;
+    }
+    strcpy(cmd->name,name);
+    cmd->nxt = NULL;
+    cmd->params = NULL;
+
+    CmdNode* pTemp = &cmdNodeFirst;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = cmd;
+    return cmd;
+}
+
+/**
+ * @description: free all the cmd and their paras except cmdNodeFirst
+ * @param {*}
+ * @return {*}
+ */
+void cloud_deleteCmd()
+{
+    CmdNode* pCmd = cmdNodeFirst.nxt;
+    CmdParam* pPara;
+    while (pCmd != NULL)
+    {
+        pPara = pCmd->params;
+        while (pPara != NULL){
+           CmdParam* tempP = pPara;
+           pPara = pPara->nxt;
+           free(tempP);
+        }
+        CmdNode* tempC = pCmd;
+        pCmd = pCmd->nxt;
+        free(tempC);
+    }
+}
+
+
+/**
+ * @description: init one cmd
+ * @param {CmdNode*} cmd
+ * @param {char*} name
+ * @return {*}
+ */
+void cloud_initCmd(CmdNode* cmd,char* name)
+{
+    strcpy(cmd->name,name);
+    cmd->nxt = NULL;
+    cmd->params = NULL;
+
+    CmdNode* pTemp = &cmdNodeFirst;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = cmd;
+}
+
+
+/**
+ * @description: init one cmdparam and append it to the end of cmd
+ * @param {CmdNode*} cmd
+ * @param {CmdParam*} para
+ * @param {char*} name
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {*}
+ */
+void cloud_initAndAppendPara(CmdNode* cmd,CmdParam* para,const char* name,ValueType type,cmdFuncCallback func)
+{
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return 0;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return 0;
+}
+
+/**
+ * @description: cloud_isCommandName: Determine if Parameters has the json object named objName
+ * @param {cJSON*} root
+ * @param {char*} objName
+ * @param {cJSON*} retObj
+ * @return {*}
+ */
+bool cloud_isCommandName(cJSON* root,char* name)
+{
+    cJSON* obj = cJSON_GetObjectItem(root,CLOUD_COMMAND_NAME);
+    if(obj==NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"root json don't has json object named 'command_name'.");
+        return false;
+    }
+    if(0 == strcmp(cJSON_GetStringValue(obj),name)){
+        return true;
+        
+    }
+    return false;
+}
+
+
+/**
+ * @description: check the cmd list and execute the callback functions of paras
+ * @param {*}
+ * @return {*}
+ */
+int cloud_checkCmdListAndExec(cJSON* root)
+{
+    CmdNode* cmd = cmdNodeFirst.nxt;
+    while (cmd != NULL)
+    {
+        CmdParam* para = cmd->params;
+        if(cloud_isCommandName(root,cmd->name))
+        {
+            while (para != NULL)
+            {
+                cJSON* paraObj = NULL;
+                CmdValue value;
+
+                cJSON* objParas = cJSON_GetObjectItem(root,CLOUD_PARA_NAME);
+                if(objParas==NULL){
+                    RaiseLog(LOG_LEVEL_DEBUG,"Root json don't has json object named 'paras'.");
+                    return -1;
+                }
+                paraObj = cJSON_GetObjectItem(objParas,para->name);
+                if(paraObj==NULL){
+                    RaiseLog(LOG_LEVEL_DEBUG,"paras don't has json object named %s",para->name);
+                    para = para->nxt;
+                    continue;
+                }
+                // if the paras object has parameter named para->name
+                FuncValue_t fValue;
+                switch(para->type)
+                {
+                    case Cloud_Int:
+                        value.valueInt = cJSON_GetNumberValue(paraObj);
+                        fValue.type = Cloud_Int;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    case Cloud_Double:
+                        value.valueDouble = cJSON_GetNumberValue(paraObj);
+                        fValue.type = Cloud_Double;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    case Cloud_String:
+                        strcpy(value.valueString,cJSON_GetStringValue(paraObj));
+                        fValue.type = Cloud_String;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    default: 
+                        break;
+                }
+                para = para->nxt;
+            }
+            return 0;
+        }
+        cmd = cmd->nxt;
+    }
+    return -1;
+}
+
+
+/**
+ * @description: The cloud call back function
+ * @param {char} *jsonString
+ * @return {*}
+ */
+int CLOUD_CommandCallBack(const char *jsonString)
+{
+    cJSON* root = NULL;
+    cJSON* obj = NULL;
+    int ret = -1;
+    if(jsonString == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"Received none data from cloud!");
+        return ret;
+    }
+    root = cJSON_Parse(jsonString);
+    if(root == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"No data parsed from json string!");
+        return ret;
+    }
+    ret = cloud_checkCmdListAndExec(root);
+    free(root);
+    return ret;
+}
+
+
+
+

+ 300 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/cloud_connect/src/cloud_schedule.c

@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#include "cloud_schedule.h"
+#include "iot_demo_def.h"
+#include "ohos_init.h"
+#include <time.h>
+#include <stdbool.h>
+#include "iot_sntp.h"
+
+
+#define TIMER_PERIOD 1      // [s]
+#define SCHEDULE_TASK_SIZE 1024*6
+#define SCHEDULE_TASK_PRIOR 25
+#define CONFIG_LOCAL_TIMEZONE  8
+#define ONE_MINUITE_SECONDS 60
+#define ONE_HOUR_SECONDS 3600
+#define ONE_DAY_SECOND_SECONDS 86400
+#define SNTP_TIME_YEAR_OFFSET 1900
+#define CONFIG_TASK_SCHEDULE_SIZE 0x1000
+#define CONFIG_TASK_SCHEDULE_PRIOR 31
+
+
+static time_t currentTime = 0;
+static osTimerId_t osTimer_ID;
+static ScheduleCtrl_t scheduleFirstNode = {
+    .nxt = NULL,
+};
+static int oneHourSeconds = TIMER_PERIOD * 3600;
+static int quarterMinuSeconds = TIMER_PERIOD * 15;
+
+/**
+ * @description: Bind the schedule to the command which is defined in cloud communicate
+ * @param {ScheduleCtrl_t*} schedule
+ * @param {CmdNode*} cmd
+ * @param {char*} name
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {*}
+ */
+void bindingScheduleToCmd(ScheduleCtrl_t* schedule,CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func)
+{
+    CmdParam* para = &schedule->ctrl;
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return para;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return para;
+}
+
+/**
+ * @description: Get current time by sntp and up sync the local time
+ * @param {*}
+ * @return {*}
+ */
+TIME getAndUpdateCurrentTm()
+{
+    TIME time;
+    if(SntpGetRtcTime(CONFIG_LOCAL_TIMEZONE, &time) != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Sync the time failed!");
+                return *localtime(&currentTime);
+    }
+    currentTime = mktime(&time);
+    return time;
+}
+/**
+ * @description: Get start seconds in one day  interval: (0,86400)
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+uint32_t getStartSecondsInDay(const ScheduleCtrl_t* schedule)
+{
+    return schedule->startHour * ONE_HOUR_SECONDS + schedule->startMinute * ONE_MINUITE_SECONDS + schedule->startSeconds;
+}
+
+/**
+ * @description: Get end seconds in one day  interval: (0,86400)
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+uint32_t getEndSecondsInDay(const ScheduleCtrl_t* schedule)
+{
+    return getStartSecondsInDay(schedule) + schedule->duration;
+}
+
+
+/**
+ * @description: determine whether current time is in the time period of schedule
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+bool isTimeToStartSchedule(const ScheduleCtrl_t* schedule)
+{
+    TIME ctime = getAndUpdateCurrentTm();
+    uint8_t days = schedule->Days;
+
+    uint8_t cday = ctime.tm_wday;
+    uint8_t chour = ctime.tm_hour;
+    uint8_t cmin = ctime.tm_min;
+    uint8_t csec = ctime.tm_sec;
+    RaiseLog(LOG_LEVEL_INFO,"%d%d%d%d",cday,chour,cmin,csec);
+    uint32_t currentSecondInday = chour*ONE_HOUR_SECONDS + cmin*ONE_MINUITE_SECONDS + csec;
+    //gdtr_TODO: check the format of tm_wday and change it
+    if((days >> (cday)) & 0x01){ // today is in schedule
+        if(currentSecondInday >= getStartSecondsInDay(schedule) &&\
+         currentSecondInday <= getEndSecondsInDay(schedule)){
+             RaiseLog(LOG_LEVEL_INFO,"is execute time of schedule");
+             return true;
+         }
+    }
+    RaiseLog(LOG_LEVEL_INFO," is not execute time of schedule");
+    return false;
+}
+
+/**
+ * @description: The local timer callback every a quarter minuite
+ * @param {void*} argument
+ * @return {*}
+ */
+void scheduleTimeCallback(void* argument)
+{
+    currentTime++;
+    quarterMinuSeconds -= TIMER_PERIOD;
+}
+
+void scheduleThreadCallback(void* arguement)
+{
+    for(;;)
+    {
+        if(quarterMinuSeconds <= 0){
+            ScheduleCtrl_t* ptr = scheduleFirstNode.nxt;
+            FuncValue_t value;
+            RaiseLog(LOG_LEVEL_INFO,"---------------------");
+            while (ptr != NULL)
+            {
+                if(isTimeToStartSchedule(ptr)){
+                    RaiseLog(LOG_LEVEL_INFO,"Start the schedule%s",ptr->id);
+                    value.type = ptr->ctrl.param->type;
+                    value.value = ptr->ctrl.value;
+                    ptr->ctrl.param->func(value);
+                }        
+                ptr = ptr->nxt;
+            }
+            quarterMinuSeconds = 15*TIMER_PERIOD;
+        }
+        osDelay(40);
+    }
+}
+
+/**
+ * @description: Schedule initilize function
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+void ScheduleInit()
+{
+    int ret;
+    TIME time;
+    SntpGetRtcTime(CONFIG_LOCAL_TIMEZONE, &time);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Get Simple Network Time Protocol failed!");
+        return;
+    }
+    currentTime = mktime(&time);
+    
+    RaiseLog(LOG_LEVEL_DEBUG,"Current time is:%d",currentTime);
+    RaiseLog(LOG_LEVEL_INFO,"%4d.%2d.%2d %2d:%2d:%2d",time.tm_yday + SNTP_TIME_YEAR_OFFSET,time.tm_mon,time.tm_mday,\
+                time.tm_hour,time.tm_min,time.tm_sec);
+    osTimerAttr_t attr_timer;
+    attr_timer.name = "scheduleTimer";
+    attr_timer.cb_mem = NULL;
+    attr_timer.cb_size = NULL;
+    osTimer_ID = osTimerNew(scheduleTimeCallback,osTimerPeriodic,NULL,&attr_timer);
+    osTimerStart(osTimer_ID,TIMER_PERIOD * 100);
+
+    osThreadAttr_t attr_thread;
+    attr_thread.attr_bits = 0U;
+    attr_thread.cb_mem = NULL;
+    attr_thread.cb_size = 0U;
+    attr_thread.stack_mem = NULL;
+    attr_thread.stack_size = CONFIG_TASK_SCHEDULE_SIZE;
+    attr_thread.priority = CONFIG_TASK_SCHEDULE_PRIOR;
+    attr_thread.name = "IoTMain";
+    (void) osThreadNew((osThreadFunc_t)scheduleThreadCallback, NULL, (const osThreadAttr_t *)&attr_thread);
+
+    return;
+}
+
+/**
+ * @description: Create one schedule and put it to the scheduleFirstNode static variable which defined in this file
+ * @param {*}
+ * @return {*}
+ */
+ScheduleCtrl_t* cloud_createSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur, CmdControl ctrl)
+{
+    if(start_hour > 24 || start_min > 60 || start_sec > 60 || dur > 1440){
+        RaiseLog(LOG_LEVEL_DEBUG,"Wrong format of schedule");
+        return NULL;
+    }
+
+    ScheduleCtrl_t* schedule = malloc(sizeof(ScheduleCtrl_t));
+    if(schedule == NULL){
+        RaiseLog(LOG_LEVEL_ERR,"Malloc Schedule failed!");
+        return schedule;
+    }
+    
+    strcpy(schedule->id,id);
+    schedule->ctrl = ctrl;
+    schedule->Days  = wdays;
+    schedule->startHour = start_hour;
+    schedule->startMinute = start_min;
+    schedule->startSeconds = start_sec;
+    schedule->duration = dur;
+    schedule->nxt = NULL;
+
+    ScheduleCtrl_t* ptr = &scheduleFirstNode;
+    while (ptr->nxt != NULL){
+        ptr = ptr->nxt;
+    }
+    ptr->nxt = schedule;
+    return schedule;
+}
+
+/**
+ * @description: Delete the schedule
+ * @param {char*} id
+ * @return {*}
+ */
+int cloud_deleteScheduleByID(const char* id)
+{
+    ScheduleCtrl_t* ptr = &scheduleFirstNode;
+    ScheduleCtrl_t* temp;
+    while (ptr->nxt != NULL)
+    { 
+        temp = ptr->nxt;
+        if(strcmp(temp->id,id) == 0){
+            ptr = temp->nxt;
+            free(temp);
+            return 0;
+        }
+        ptr = ptr->nxt;
+    }
+    RaiseLog(LOG_LEVEL_DEBUG,"No %s in the schedule list",id);
+    return -1;
+}
+
+/**
+ * @description: update the schedule
+ * @param {*}
+ * @return {*}
+ */
+int cloud_updateSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur)
+{
+    ScheduleCtrl_t* ptr = scheduleFirstNode.nxt;
+    while (ptr != NULL)
+    {
+        if(strcmp(ptr->id,id) == 0){
+            ptr->Days = wdays;
+            ptr->startHour = start_hour;
+            ptr->startMinute = start_min;
+            ptr->startSeconds = start_sec;
+            ptr->duration = dur;
+            return 0;
+        }
+        ptr = ptr->nxt;
+    }
+    RaiseLog(LOG_LEVEL_DEBUG,"No %s in the schedule list",id);
+    return -1;
+}
+
+
+
+
+
+

+ 130 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/main_entry.c

@@ -0,0 +1,130 @@
+
+/*
+ * Copyright (c) 2021 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.
+ */
+
+
+
+#include "iot_cloud.h"
+#include "iot_boardled.h"
+#include "iot_boardbutton.h"
+#include "iot_wifi.h"
+#include "iot_netcfg.h"
+#include "iot_sntp.h"
+#include "ohos_init.h"
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <cmsis_os2.h>
+#include <stdbool.h>
+#include "kv_store.h"
+#include "iot_schedule.h"
+#include "network_config_service.h"
+#include "iot_netcfg_nan.h"
+
+#include "hi_reset.h"
+#include "cloud_communicate.h"
+#include "cloud_schedule.h"
+#include "CH2O.h"
+#include "OLED_I2C.h"
+
+#define CONFIG_TASK_MAIN_STACKSIZE 0x2000
+#define CONFIG_TASK_MAIN_PRIOR 25
+
+#define CONFIG_CLOUD_DEFAULT_SERVERIP "121.36.42.100"   // Huawei cloud service ip
+#define CONFIG_CLOUD_DEFAULT_SERVERPORT "1883"          // // Huawei cloud service port
+#define CLOUD_DEVICE_ID "6221c7f2c4e6a958e354bb4b_BearPi_HM_Nano_ST1"   // user need to change it according to the device id in cloud
+#define CLOUD_DEVICE_PWD "bearpi12345"  // user need to change it according to the device pwd in cloud
+
+#define NFC_DEVICE_ID_LEN 50
+#define NFC_DEVICE_PWD_LEN 50
+
+typedef struct{
+    char* nfc_dev_id[NFC_DEVICE_ID_LEN];
+    char* nfc_dev_pwd[NFC_DEVICE_PWD_LEN];
+    ScheduleCtrl_t schedule;
+    osTimerId_t timeID;
+}AppCtrl_t;
+
+
+static bool keyStatus = false;
+void keycallback(char* arg){
+    keyStatus = true;
+    return;
+}
+
+void IotMainTaskEntry(void* argument)
+{
+    uint8_t ret;
+    float  ppm;
+    BoardInit();
+    usleep(1000000);   
+    MQ2PPMCalibration();  
+    LedSafeStatusSet(ON);
+    initKey(keycallback);
+    IOT_ScheduleInit();
+    BOARD_InitWifi();
+    osDelay(300);
+    NanWifiConnect(keyStatus);
+    cloud_CloudInit(CLOUD_DEVICE_ID,CLOUD_DEVICE_PWD,CONFIG_CLOUD_DEFAULT_SERVERIP,CONFIG_CLOUD_DEFAULT_SERVERPORT);
+
+    Cloud_Servic* service = cloud_createService("CH2O_Monitoring",NULL);
+    cloud_createAndAppendProprety(service,"CH2O_status",IOT_PROFILE_KEY_DATATYPE_INT,(void*)&ppm);
+    printf("=================================================\r\n");
+    printf("************* CH2O_Monitoring_example ***********\r\n");
+    printf("=================================================\r\n");
+    for(;;)
+    {
+        ret = GetMQ2PPM(&ppm);
+        if (ret != 0) {
+            printf("ADC Read Fail\n");
+            continue;
+        }
+        RaiseLog(LOG_LEVEL_INFO,"CH2O is  %d",ppm);
+        if (ppm > 20) {
+            BeepStatusSet(ON);
+            LedSafeStatusSet(OFF);
+            LedWarnStatusSet(ON);
+        } else {
+            BeepStatusSet(OFF);
+            LedSafeStatusSet(ON);
+            LedWarnStatusSet(OFF);
+        }
+        cloud_uploadService(service);
+        osDelay(100);
+    }
+}
+
+static void EntryMain(void)
+{
+    osThreadAttr_t attr;
+    RaiseLog(LOG_LEVEL_INFO, "DATA:%s Time:%s \r\n", __FUNCTION__, __DATE__, __TIME__);
+    // Create the IoT Main task
+    attr.attr_bits = 0U;
+    attr.cb_mem = NULL;
+    attr.cb_size = 0U;
+    attr.stack_mem = NULL;
+    attr.stack_size = CONFIG_TASK_MAIN_STACKSIZE;
+    attr.priority = CONFIG_TASK_MAIN_PRIOR;
+    attr.name = "IoTMain";
+    (void) osThreadNew((osThreadFunc_t)IotMainTaskEntry, NULL, (const osThreadAttr_t *)&attr);
+
+    return;
+}
+APP_FEATURE_INIT(EntryMain);
+
+
+

+ 23 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/BUILD.gn

@@ -0,0 +1,23 @@
+static_library("bossay_hi3861_l0_sensor") {
+    sources = [
+        "src/CH2O.c"
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "inc",
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//device/bossay/hi3861_l0/iot_hardware_hals/include",
+        "//device/bossay/hi3861_l0/sdk_liteos/include",
+    ]
+
+    deps = [ 
+
+    ]
+
+}
+
+

+ 33 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/inc/CH2O.h

@@ -0,0 +1,33 @@
+/*
+ * 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 __E53_SF1_H__
+#define __E53_SF1_H__
+
+typedef enum
+{
+	OFF = 0,
+	ON
+} SwitchStatus;
+
+void BoardInit(void);
+void MQ2PPMCalibration(void);
+int GetMQ2PPM(float *ppm);
+void BeepStatusSet(SwitchStatus status);
+void LedSafeStatusSet(SwitchStatus status);
+void LedWarnStatusSet(SwitchStatus status);	
+
+#endif /* __E53_SF1_H__ */
+

+ 169 - 0
vendor/bossay/CH2O_Monitoring/demo_CH2O_Monitoring/sensor/src/CH2O.c

@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+#include "CH2O.h"
+#include "iot_adc.h"
+#include "iot_errno.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "iot_pwm.h"
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#define CAL_PPM 20 //校准环境中PPM值
+#define RL 1       // RL阻值
+
+#define WIFI_IOT_IO_NAME_GPIO_8 8
+#define WIFI_IOT_PWM_PORT_PWM1 1
+#define WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT 5
+
+#define SAFE_LED_GPIO 14
+#define WARN_LED_GPIO 7
+
+static float R0; //元件在洁净空气中的阻值
+
+/***************************************************************
+ * 函数名称: MQ2Init
+ * 说    明: 初始化MQ2Init
+ * 参    数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+void BoardInit(void)
+{
+    IoTGpioInit(SAFE_LED_GPIO);
+    IoTGpioSetFunc(SAFE_LED_GPIO, IOT_GPIO_FUNC_GPIO_14_GPIO);
+    IoTGpioSetDir(SAFE_LED_GPIO, IOT_GPIO_DIR_OUT); //设置为输出模式
+
+    IoTGpioInit(WARN_LED_GPIO);
+    IoTGpioSetFunc(WARN_LED_GPIO, IOT_GPIO_FUNC_GPIO_7_GPIO);
+    IoTGpioSetDir(WARN_LED_GPIO, IOT_GPIO_DIR_OUT); //设置为输出模式
+
+    IoTGpioInit(WIFI_IOT_IO_NAME_GPIO_8);                                      //初始化GPIO_8
+    IoTGpioSetFunc(WIFI_IOT_IO_NAME_GPIO_8, WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT); //设置GPIO_8引脚复用功能为PWM
+    IoTGpioSetDir(WIFI_IOT_IO_NAME_GPIO_8, IOT_GPIO_DIR_OUT);                  //设置GPIO_8引脚为输出模式
+    IoTPwmInit(WIFI_IOT_PWM_PORT_PWM1);                                        //初始化PWM1端口
+}
+/***************************************************************
+* 函数名称: GetVoltage
+* 说    明: 获取电压值函数
+* 参    数: 无
+*								
+* 返 回 值: 无
+***************************************************************/
+static float GetVoltage(void)
+{
+    unsigned int ret;
+    unsigned short data;
+
+    ret = IoTAdcRead(5, &data, IOT_ADC_EQU_MODEL_8, IOT_ADC_CUR_BAIS_DEFAULT, 0xff);
+    if (ret != IOT_SUCCESS)
+    {
+        printf("ADC Read Fail\n");
+    }
+    return (float)data * 1.8 * 4 / 4096.0;
+}
+/***************************************************************
+ * 函数名称: GetMQ2PPM
+ * 说    明: 获取PPM函数
+ * 参    数: ppm 烟雾浓度
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+int GetMQ2PPM(float* ppm)
+{
+    unsigned int ret;
+    unsigned short data;
+    float voltage, RS;
+
+    ret = IoTAdcRead(6, &data, IOT_ADC_EQU_MODEL_8, IOT_ADC_CUR_BAIS_DEFAULT, 0xff);
+    if (ret != 0) {
+        printf("ADC Read Fail\n");
+        return -1;
+    }
+    voltage = (float)data * 1.8 * 4 / 4096.0;
+    RS = (5 - voltage) / voltage * RL;     //计算RS
+    if(R0 != 0){
+        *ppm = 613.9f * pow(RS / R0, -2.074f); //计算ppm
+    }
+    return 0;
+}
+
+/***************************************************************
+ * 函数名称: MQ2PPMCalibration
+ * 说    明: 传感器校准函数
+ * 参    数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+void MQ2PPMCalibration(void)
+{
+    float voltage = GetVoltage();
+    float RS = (5 - voltage) / voltage * RL;
+    R0 = RS / pow(CAL_PPM / 613.9f, 1 / -2.074f);
+}
+
+/***************************************************************
+ * 函数名称: BeepStatusSet
+ * 说    明: 蜂鸣器报警与否
+ * 参    数: status,ENUM枚举的数据
+ *									OFF,蜂鸣器
+ *									ON,开蜂鸣器
+ * 返 回 值: 无
+ ***************************************************************/
+void BeepStatusSet(SwitchStatus status)
+{
+    if (status == ON) {
+        IoTPwmStart(WIFI_IOT_PWM_PORT_PWM1, 50, 4000); //输出PWM波
+    }
+    if (status == OFF) {
+        IoTPwmStop(WIFI_IOT_PWM_PORT_PWM1);
+    }
+}
+/***************************************************************
+ * 函数名称: LedSafeStatusSet
+ * 说    明: LED_Safe状态设置
+ * 参    数: status,ENUM枚举的数据
+ *									OFF,关
+ *									ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void LedSafeStatusSet(SwitchStatus status)
+{
+    if (status == ON) {
+        IoTGpioSetOutputVal(SAFE_LED_GPIO, 1); // 设置GPIO_7输出高电平点亮灯
+    }
+    if (status == OFF) {
+        IoTGpioSetOutputVal(SAFE_LED_GPIO, 0); // 设置GPIO_7输出低电平关闭灯
+    }
+}
+
+/***************************************************************
+ * 函数名称: LedWarnStatusSet
+ * 说    明: LED_Warn状态设置
+ * 参    数: status,ENUM枚举的数据
+ *									OFF,关
+ *									ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void LedWarnStatusSet(SwitchStatus status)
+{
+    if (status == ON) {
+        IoTGpioSetOutputVal(WARN_LED_GPIO, 1); // 设置GPIO_14输出高电平点亮灯
+    }
+
+    if (status == OFF) {
+        IoTGpioSetOutputVal(WARN_LED_GPIO, 0); // 设置GPIO_14输出低电平关闭灯
+    }
+}

+ 27 - 0
vendor/bossay/CH2O_Monitoring/hals/utils/sys_param/BUILD.gn

@@ -0,0 +1,27 @@
+# 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}\"",
+    ]
+}

+ 128 - 0
vendor/bossay/CH2O_Monitoring/hals/utils/sys_param/hal_sys_param.c

@@ -0,0 +1,128 @@
+/*
+ * 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;
+}

+ 22 - 0
vendor/bossay/CH2O_Monitoring/hals/utils/token/BUILD.gn

@@ -0,0 +1,22 @@
+# Copyright (c) 2020 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+static_library("hal_token_static") {
+  sources = [ "hal_token.c" ]
+
+  include_dirs = [
+    "//base/startup/syspara_lite/hals",
+    "//utils/native/lite/include",
+  ]
+  deps = []
+}

+ 104 - 0
vendor/bossay/CH2O_Monitoring/hals/utils/token/hal_token.c

@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hal_token.h"
+#include "ohos_errno.h"
+#include "ohos_types.h"
+
+static int OEMReadToken(char *token, unsigned int len)
+{
+    // OEM need add here, read token from device
+    (void)(token);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMWriteToken(const char *token, unsigned int len)
+{
+    // OEM need add here, write token to device
+    (void)(token);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetAcKey(char *acKey, unsigned int len)
+{
+    // OEM need add here, get AcKey
+    (void)(acKey);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetProdId(char *productId, unsigned int len)
+{
+    // OEM need add here, get ProdId
+    (void)(productId);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetProdKey(char *productKey, unsigned int len)
+{
+    // OEM need add here, get ProdKey
+    (void)(productKey);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+
+int HalReadToken(char *token, unsigned int len)
+{
+    if (token == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMReadToken(token, len);
+}
+
+int HalWriteToken(const char *token, unsigned int len)
+{
+    if (token == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMWriteToken(token, len);
+}
+
+int HalGetAcKey(char *acKey, unsigned int len)
+{
+    if (acKey == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetAcKey(acKey, len);
+}
+
+int HalGetProdId(char *productId, unsigned int len)
+{
+    if (productId == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetProdId(productId, len);
+}
+
+int HalGetProdKey(char *productKey, unsigned int len)
+{
+    if (productKey == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetProdKey(productKey, len);
+}

+ 10 - 0
vendor/bossay/PM2_5_Monitoring/BUILD.gn

@@ -0,0 +1,10 @@
+# Copyright (C) 2020 Hisilicon (Shanghai) Technologies Co., Ltd. All rights reserved.
+
+group("PM2_5_Monitoring") {
+    deps = [
+        "//device/bossay/hi3861_l0/sdk_liteos:wifiiot_sdk",
+        "../common/iot_wifi:iot_wifi",
+        # "//applications/sample/app:app",
+        "demo_PM2_5_Monitoring:bossay_hi3861_l0_PM2_5_Monitoring",
+    ]
+}

+ 102 - 0
vendor/bossay/PM2_5_Monitoring/config.json

@@ -0,0 +1,102 @@
+{
+    "product_name": "PM2_5_Monitoring",
+    "ohos_version": "OpenHarmony 1.0",
+    "device_company": "bossay",
+    "board": "hi3861_l0",
+    "kernel_type": "liteos_m",
+    "kernel_version": "",
+    "subsystems": [
+      {
+        "subsystem": "applications",
+        "components": [
+          { "component": "wifi_iot_sample_app", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "iot_hardware",
+        "components": [
+          { "component": "iot_controller", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "hiviewdfx",
+        "components": [
+          { "component": "hilog_lite", "features":[] },
+          { "component": "hievent_lite", "features":[] },
+          { "component": "blackbox", "features":[] },
+          { "component": "hidumper_mini", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "distributed_schedule",
+        "components": [
+          { "component": "samgr_lite", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "security",
+        "components": [
+          { "component": "hichainsdk", "features":[] },
+          { "component": "deviceauth_lite", "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/bossay/hi3861_l0/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": "softbus_lite", "features":[] },
+          { "component": "wifi_aware", "features":[]}
+        ]
+      },
+      {
+        "subsystem": "update",
+        "components": [
+          { "component": "ota_lite", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "iot",
+        "components": [
+          { "component": "iot_link", "features":[] }
+        ]
+      },
+      {
+        "subsystem": "utils",
+        "components": [
+          { "component": "file", "features":[] },
+          { "component": "kv_store", "features":[] },
+          { "component": "os_dump", "features":[] }
+        ]
+      },
+      {
+       "subsystem": "test",
+       "components": [
+         { "component": "xts_acts", "features":[] },
+         { "component": "xts_tools", "features":[] }
+        ]
+      }
+    ],
+    "third_party_dir": "//device/bossay/hi3861_l0/sdk_liteos/third_party",
+    "product_adapter_dir": "//vendor/bossay/hi3861_l0/hals"
+  }

+ 32 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/BUILD.gn

@@ -0,0 +1,32 @@
+static_library("bossay_hi3861_l0_PM2_5_Monitoring") {
+    sources = [
+        "main_entry.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "./sensor/inc",
+        "../../common/inc",
+        "cloud_connect/inc",
+        "//third_party/cJSON",
+        "./OLED/include"
+        
+    ]
+
+    deps = [ 
+         "../../common/iot_sntp:iot_sntp",
+         "../../common/iot_wifi:iot_wifi",
+         "../../common/iot_schedule:iot_schedule",
+         #"../../common/iot_nfc:iot_nfc",
+         "../../common/iot_cloud:iot_cloud",
+         #"../../common/iot_boardled:iot_boardled",
+         #"../../common/iot_boardbutton:iot_boardbutton",
+         "cloud_connect:cloud_connect",
+         "sensor:bossay_hi3861_l0_sensor",
+         "OLED:bossay_hi3816l0_OLED",
+    ]
+
+}

+ 20 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/BUILD.gn

@@ -0,0 +1,20 @@
+static_library("bossay_hi3816l0_OLED"){
+
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//device/bossay/hi3861_l0/iot_hardware_hals/include",
+        "//device/bossay/hi3861_l0/sdk_liteos/include",
+        "include",
+    ]
+    sources = [
+        "src/OLED_I2C.c",
+        "OLED_DisplayTask.c",
+    ]
+}
+
+

+ 14 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/OLED_DisplayTask.c

@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2021 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.
+ */

+ 44 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/OLED_I2C.h

@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 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 __OLED_I2C_H
+#define	__OLED_I2C_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "iot_gpio.h"
+
+#define OLED_ADDRESS	0x3D //通过调整0R电阻,屏可以0x3C和0x3D两个地址 -- 默认0x3C
+#define KEY_GPIO 11
+
+void initKey(GpioIsrCallbackFunc func);
+bool isKeyON(void);
+
+
+
+void OLED_BoardInit(void);
+void I2C_WriteByte(uint8_t addr,uint8_t data);
+void WriteCmd(unsigned char I2C_Command);
+void WriteDat(unsigned char I2C_Data);
+void OLED_Init(void);
+void OLED_SetPos(unsigned char x, unsigned char y);
+void OLED_Fill(unsigned char fill_Data);
+void OLED_CLS(void);
+void OLED_ON(void);
+void OLED_OFF(void);
+void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize);
+void OLED_ShowCN(unsigned char x, unsigned char y, unsigned char N);
+void OLED_DrawBMP(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[]);
+
+#endif

+ 281 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/codetab.h

@@ -0,0 +1,281 @@
+#ifndef __CODETAB_H
+#define	__CODETAB_H
+
+
+/***************************16*16的点阵字体取模方式:共阴——列行式——逆向输出*********/
+unsigned char F16x16[] =
+
+{	0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
+	0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,/*"科",0*/
+
+	0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
+	0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00/*"技",1*/
+};
+
+
+/************************************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,// ,
+	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
+};
+
+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,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/
+};
+
+
+#endif

+ 228 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/include/iot_gpio.h

@@ -0,0 +1,228 @@
+/*
+ * 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_gpio.h
+ *
+ * @brief Declares functions for operating GPIO devices.
+ *
+ * These functions are used for GPIO initialization, input/output settings, and level settings. \n
+ *
+ * @since 2.2
+ * @version 2.2
+ */
+#ifndef IOT_GPIO_H
+#define IOT_GPIO_H
+
+/**
+ * @brief Enumerates GPIO level values.
+ */
+typedef enum {
+    /** Low GPIO level */
+    IOT_GPIO_VALUE0 = 0,
+    /** High GPIO level */
+    IOT_GPIO_VALUE1
+} IotGpioValue;
+
+/**
+ * @brief Enumerates GPIO directions.
+ */
+typedef enum {
+    /** Input */
+    IOT_GPIO_DIR_IN = 0,
+    /** Output */
+    IOT_GPIO_DIR_OUT
+} IotGpioDir;
+
+/**
+ * @brief Enumerates GPIO interrupt trigger modes.
+ */
+typedef enum {
+    /** Level-sensitive interrupt */
+    IOT_INT_TYPE_LEVEL = 0,
+    /** Edge-sensitive interrupt */
+    IOT_INT_TYPE_EDGE
+} IotGpioIntType;
+
+/**
+ * @brief Enumerates I/O interrupt polarities.
+ */
+typedef enum {
+    /** Interrupt at a low level or falling edge */
+    IOT_GPIO_EDGE_FALL_LEVEL_LOW = 0,
+    /** Interrupt at a high level or rising edge */
+    IOT_GPIO_EDGE_RISE_LEVEL_HIGH
+} IotGpioIntPolarity;
+
+/**
+ * @brief Indicates the GPIO interrupt callback.
+ *
+ */
+typedef void (*GpioIsrCallbackFunc) (char *arg);
+
+/**
+ * @brief Initializes a GPIO device.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the GPIO device is initialized;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioInit(unsigned int id);
+
+/**
+ * @brief Deinitializes a GPIO device.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the GPIO device is deinitialized;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioDeinit(unsigned int id);
+
+/**
+ * @brief Sets the direction for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param dir Indicates the GPIO input/output direction.
+ * @return Returns {@link IOT_SUCCESS} if the direction is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetDir(unsigned int id, IotGpioDir dir);
+
+/**
+ * @brief Obtains the direction for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param dir Indicates the pointer to the GPIO input/output direction.
+ * @return Returns {@link IOT_SUCCESS} if the direction is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetDir(unsigned int id, IotGpioDir *dir);
+
+/**
+ * @brief Sets the output level value for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the output level value.
+ * @return Returns {@link IOT_SUCCESS} if the output level value is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetOutputVal(unsigned int id, IotGpioValue val);
+
+/**
+ * @brief Obtains the output level value of a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the pointer to the output level value.
+ * @return Returns {@link IOT_SUCCESS} if the output level value is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetOutputVal(unsigned int id, IotGpioValue *val);
+
+/**
+ * @brief Obtains the input level value of a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param val Indicates the pointer to the input level value.
+ * @return Returns {@link IOT_SUCCESS} if the input level value is obtained;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioGetInputVal(unsigned int id, IotGpioValue *val);
+
+/**
+ * @brief Enables the interrupt feature for a GPIO pin.
+ *
+ * This function can be used to set the interrupt type, interrupt polarity, and interrupt callback for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param intType Indicates the interrupt type.
+ * @param intPolarity Indicates the interrupt polarity.
+ * @param func Indicates the interrupt callback function.
+ * @param arg Indicates the pointer to the argument used in the interrupt callback function.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is enabled;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioRegisterIsrFunc(unsigned int id, IotGpioIntType intType, IotGpioIntPolarity intPolarity,
+                                    GpioIsrCallbackFunc func, char *arg);
+
+/**
+ * @brief Disables the interrupt feature for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is disabled;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioUnregisterIsrFunc(unsigned int id);
+
+/**
+ * @brief Masks the interrupt feature for a GPIO pin.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param mask Indicates whether the interrupt function is masked.
+ * The value <b>1</b> means to mask the interrupt function, and <b>0</b> means not to mask the interrupt function.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt feature is masked;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetIsrMask(unsigned int id, unsigned char mask);
+
+/**
+ * @brief Sets the interrupt trigger mode of a GPIO pin.
+ *
+ * This function configures a GPIO pin based on the interrupt type and interrupt polarity.
+ *
+ * @param id Indicates the GPIO pin number.
+ * @param intType Indicates the interrupt type.
+ * @param intPolarity Indicates the interrupt polarity.
+ * @return Returns {@link IOT_SUCCESS} if the interrupt trigger mode is set;
+ * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
+ * @since 2.2
+ * @version 2.2
+ */
+unsigned int IoTGpioSetIsrMode(unsigned int id, IotGpioIntType intType, IotGpioIntPolarity intPolarity);
+
+#endif
+/** @} */

+ 311 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/OLED/src/OLED_I2C.c

@@ -0,0 +1,311 @@
+#include "OLED_I2C.h"
+#include "codetab.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "iot_i2c.h"
+#include "iot_i2c_ex.h"
+#include <cmsis_os2.h>
+
+#define I2C1_SDA_GPIO 10
+#define I2C1_SCL_GPIO 9
+#define IOT_GPIO_FUNC_GPIO_0_I2C1_SDA  6
+#define IOT_GPIO_FUNC_GPIO_1_I2C1_SCL 6
+#define WIFI_IOT_I2C_IDX_1 0
+
+#define BEEP_GPIO 12
+
+
+
+void initKey(GpioIsrCallbackFunc func)
+{    
+    IoTGpioInit(KEY_GPIO);
+    IoTGpioSetFunc(KEY_GPIO, IOT_GPIO_FUNC_GPIO_11_GPIO);
+    IoTGpioSetDir(KEY_GPIO, IOT_GPIO_DIR_IN);
+	IoTGpioSetPull(KEY_GPIO, IOT_GPIO_PULL_UP);
+    IoTGpioRegisterIsrFunc(KEY_GPIO, IOT_INT_TYPE_EDGE, IOT_GPIO_EDGE_FALL_LEVEL_LOW, func, NULL);
+}
+
+
+
+
+bool isKeyON(void)
+{
+    IotGpioValue temp;
+    IoTGpioGetInputVal(KEY_GPIO,&temp);
+    return !temp;
+}
+
+void OLED_BoardInit(void)
+{   
+    IoTGpioInit(BEEP_GPIO);
+    IoTGpioSetFunc(BEEP_GPIO, IOT_GPIO_FUNC_GPIO_12_GPIO);
+    IoTGpioSetDir(BEEP_GPIO, IOT_GPIO_DIR_OUT); // 设置GPIO_14为输出模式
+
+    IoTGpioSetOutputVal(BEEP_GPIO, 1); // 设置输出高电平打开蜂鸣器
+
+    //GPIO_0复用为I2C1_SDA
+    IoTGpioInit(I2C1_SDA_GPIO);
+    IoTGpioSetFunc(I2C1_SDA_GPIO, IOT_GPIO_FUNC_GPIO_10_I2C0_SDA);
+
+    //GPIO_1复用为I2C1_SCL
+    IoTGpioInit(I2C1_SCL_GPIO);
+    IoTGpioSetFunc(I2C1_SCL_GPIO, IOT_GPIO_FUNC_GPIO_9_I2C0_SCL);
+
+    //baudrate: 400kbps
+    IoTI2cInit(WIFI_IOT_I2C_IDX_1, 400000);
+
+}
+
+ /**
+  * @brief  I2C_WriteByte,向OLED寄存器地址写一个byte的数据
+  * @param  addr:寄存器地址
+	*					data:要写入的数据
+  * @retval 无
+  */
+void I2C_WriteByte(uint8_t addr,uint8_t data)
+{
+    uint32_t ret;
+    uint8_t send_data[2] = {addr, data};
+    ret = IoTI2cWrite(WIFI_IOT_I2C_IDX_1, (OLED_ADDRESS << 1) | 0x00, send_data, 2);
+    if (ret != 0) {
+        printf("===== Error: I2C write ret = 0x%x! =====\r\n", ret);
+        return -1;
+    }
+    return 0;
+}
+
+
+ /**
+  * @brief  WriteCmd,向OLED写入命令
+  * @param  I2C_Command:命令代码
+  * @retval 无
+  */
+void WriteCmd(unsigned char I2C_Command)//写命令
+{
+	I2C_WriteByte(0x00, I2C_Command);
+}
+
+
+ /**
+  * @brief  WriteDat,向OLED写入数据
+  * @param  I2C_Data:数据
+  * @retval 无
+  */
+void WriteDat(unsigned char I2C_Data)//写数据
+{
+	I2C_WriteByte(0x40, I2C_Data);
+}
+
+
+ /**
+  * @brief  OLED_Init,初始化OLED
+  * @param  无
+  * @retval 无
+  */
+void OLED_Init(void)
+{
+	osDelay(100); //这里的延时很重要
+	
+	WriteCmd(0xAE); //display off
+	WriteCmd(0x20);	//Set Memory Addressing Mode	
+	WriteCmd(0x10);	//00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
+	WriteCmd(0xb0);	//Set Page Start Address for Page Addressing Mode,0-7
+	WriteCmd(0xc8);	//Set COM Output Scan Direction
+	WriteCmd(0x00); //---set low column address
+	WriteCmd(0x10); //---set high column address
+	WriteCmd(0x40); //--set start line address
+	WriteCmd(0x81); //--set contrast control register
+	WriteCmd(0xff); //亮度调节 0x00~0xff
+	WriteCmd(0xa1); //--set segment re-map 0 to 127
+	WriteCmd(0xa6); //--set normal display
+	WriteCmd(0xa8); //--set multiplex ratio(1 to 64)
+	WriteCmd(0x3F); //
+	WriteCmd(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
+	WriteCmd(0xd3); //-set display offset
+	WriteCmd(0x00); //-not offset
+	WriteCmd(0xd5); //--set display clock divide ratio/oscillator frequency
+	WriteCmd(0xf0); //--set divide ratio
+	WriteCmd(0xd9); //--set pre-charge period
+	WriteCmd(0x22); //
+	WriteCmd(0xda); //--set com pins hardware configuration
+	WriteCmd(0x12);
+	WriteCmd(0xdb); //--set vcomh
+	WriteCmd(0x20); //0x20,0.77xVcc
+	WriteCmd(0x8d); //--set DC-DC enable
+	WriteCmd(0x14); //
+	WriteCmd(0xaf); //--turn on oled panel
+}
+
+
+ /**
+  * @brief  OLED_SetPos,设置光标
+  * @param  x,光标x位置
+	*					y,光标y位置
+  * @retval 无
+  */
+void OLED_SetPos(unsigned char x, unsigned char y) //设置起始点坐标
+{ 
+	WriteCmd(0xb0+y);
+	WriteCmd(((x&0xf0)>>4)|0x10);
+	WriteCmd((x&0x0f)|0x01);
+}
+
+ /**
+  * @brief  OLED_Fill,填充整个屏幕
+  * @param  fill_Data:要填充的数据
+	* @retval 无
+  */
+void OLED_Fill(unsigned char fill_Data)//全屏填充
+{
+	unsigned char m,n;
+	for(m=0;m<8;m++)
+	{
+		WriteCmd(0xb0+m);		//page0-page1
+		WriteCmd(0x00);		//low column start address
+		WriteCmd(0x10);		//high column start address
+		for(n=0;n<128;n++)
+			{
+				WriteDat(fill_Data);
+			}
+	}
+}
+
+ /**
+  * @brief  OLED_CLS,清屏
+  * @param  无
+	* @retval 无
+  */
+void OLED_CLS(void)//清屏
+{
+	OLED_Fill(0x00);
+}
+
+
+ /**
+  * @brief  OLED_ON,将OLED从休眠中唤醒
+  * @param  无
+	* @retval 无
+  */
+void OLED_ON(void)
+{
+	WriteCmd(0X8D);  //设置电荷泵
+	WriteCmd(0X14);  //开启电荷泵
+	WriteCmd(0XAF);  //OLED唤醒
+}
+
+
+ /**
+  * @brief  OLED_OFF,让OLED休眠 -- 休眠模式下,OLED功耗不到10uA
+  * @param  无
+	* @retval 无
+  */
+void OLED_OFF(void)
+{
+	WriteCmd(0X8D);  //设置电荷泵
+	WriteCmd(0X10);  //关闭电荷泵
+	WriteCmd(0XAE);  //OLED休眠
+}
+
+
+ /**
+  * @brief  OLED_ShowStr,显示codetab.h中的ASCII字符,有6*8和8*16可选择
+  * @param  x,y : 起始点坐标(x:0~127, y:0~7);
+	*					ch[] :- 要显示的字符串; 
+	*					TextSize : 字符大小(1:6*8 ; 2:8*16)
+	* @retval 无
+  */
+void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize)
+{
+	unsigned char c = 0,i = 0,j = 0;
+	switch(TextSize)
+	{
+		case 1:
+		{
+			while(ch[j] != '\0')
+			{
+				c = ch[j] - 32;
+				if(x > 126)
+				{
+					x = 0;
+					y++;
+				}
+				OLED_SetPos(x,y);
+				for(i=0;i<6;i++)
+					WriteDat(F6x8[c][i]);
+				x += 6;
+				j++;
+			}
+		}break;
+		case 2:
+		{
+			while(ch[j] != '\0')
+			{
+				c = ch[j] - 32;
+				if(x > 120)
+				{
+					x = 0;
+					y++;
+				}
+				OLED_SetPos(x,y);
+				for(i=0;i<8;i++)
+					WriteDat(F8X16[c*16+i]);
+				OLED_SetPos(x,y+1);
+				for(i=0;i<8;i++)
+					WriteDat(F8X16[c*16+i+8]);
+				x += 8;
+				j++;
+			}
+		}break;
+	}
+}
+
+ /**
+  * @brief  OLED_ShowCN,显示codetab.h中的汉字,16*16点阵
+  * @param  x,y: 起始点坐标(x:0~127, y:0~7); 
+	*					N:汉字在codetab.h中的索引
+	* @retval 无
+  */
+void OLED_ShowCN(unsigned char x, unsigned char y, unsigned char N)
+{
+	unsigned char wm=0;
+	unsigned int  adder=32*N;
+	OLED_SetPos(x , y);
+	for(wm = 0;wm < 16;wm++)
+	{
+		WriteDat(F16x16[adder]);
+		adder += 1;
+	}
+	OLED_SetPos(x,y + 1);
+	for(wm = 0;wm < 16;wm++)
+	{
+		WriteDat(F16x16[adder]);
+		adder += 1;
+	}
+}
+
+
+
+ /**
+  * @brief  OLED_DrawBMP,显示BMP位图
+  * @param  x0,y0 :起始点坐标(x0:0~127, y0:0~7);
+	*					x1,y1 : 起点对角线(结束点)的坐标(x1:1~128,y1:1~8)
+	* @retval 无
+  */
+void OLED_DrawBMP(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[])
+{
+	unsigned int j=0;
+	unsigned char x,y;
+
+  if(y1%8==0)
+		y = y1/8;
+  else
+		y = y1/8 + 1;
+	for(y=y0;y<y1;y++)
+	{
+		OLED_SetPos(x0,y);
+    for(x=x0;x<x1;x++)
+		{
+			WriteDat(BMP[j++]);
+		}
+	}
+}

+ 25 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/BUILD.gn

@@ -0,0 +1,25 @@
+static_library("cloud_connect") {
+    sources = [
+        "src/cloud_communicate.c",
+        "src/cloud_schedule.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "inc",
+        "../../../common/inc",
+        "//third_party/cJSON",
+        "//utils/native/lite/include/",
+    ]
+
+    deps = [ 
+        "../../../common/iot_schedule:iot_schedule",
+        "../../../common/iot_cloud:iot_cloud",
+        "../../../common/iot_wifi:iot_wifi",
+        "../../../common/iot_sntp:iot_sntp",
+    ]
+
+}

+ 170 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/inc/cloud_communicate.h

@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+
+/*
+    Standard information upload:
+    format:
+    serviceID
+        |-- proprety_01
+        |    |-- status
+        |-- proprety_02
+             |-- status
+
+        status:
+        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;
+
+    so we just construct a struct named InforUplod:
+    struct InforService
+    {
+        serviceIDName;
+        nextProtrety;
+    };
+    struct InforProprety
+    {
+        propretyType;
+        propretyName;
+        value;
+        nextProtrety;
+    };
+
+    IotProfileService service = createService("serviceID");
+    createProprety(&service,"propretyName",propretyType);
+    deleteProprety(&service,"propretyName",propretyType);
+    uploadService(&service);
+*/
+
+#ifndef __CLOUD_COMMUNICATE_H__
+#define __CLOUD_COMMUNICATE_H__
+
+#include "iot_cloud.h"
+#include <cmsis_os2.h>
+#include <stdbool.h>
+#include "cJSON.h"
+
+#define CLOUD_MALLOC_ENABEL true
+
+#define CLOUD_COMMAND_NAME "command_name"
+#define CLOUD_PARA_NAME "paras"
+#define WIFI_SSID_MAX_LEN_ 256
+#define WIFI_PWD_MAX_LEN_ 256
+#define KV_STORE_SSID_ID "ssid"
+#define KV_STORE_PWD_ID "pwd"
+#define NAN_WIFI_AP_SSID "bossay"
+
+#define MAX_STRING_VALUE_LEN 30
+#define MAX_CMD_NAME_LEN 30
+#define MAX_CMD_PARA_NAME_LEN 30
+
+
+typedef union 
+{
+    /* data */
+    int valueInt;
+    double valueDouble;
+    char valueString[MAX_STRING_VALUE_LEN];
+}CmdValue;
+
+typedef enum
+{
+    Cloud_Int,
+    Cloud_Double,
+    Cloud_String,
+}ValueType;
+
+typedef struct{
+    CmdValue value;
+    ValueType type;
+}FuncValue_t;
+
+typedef int (*cmdFuncCallback)(FuncValue_t value);
+
+typedef struct 
+{
+    /* data */
+    char name[MAX_CMD_PARA_NAME_LEN];
+    ValueType type;
+    cmdFuncCallback func;
+    struct CmdParam *nxt;
+}CmdParam;
+
+
+typedef struct {
+//    CmdValue value;
+    char name[MAX_CMD_NAME_LEN];
+    CmdParam* params;
+    struct cmdNode *nxt;
+}CmdNode;
+
+
+typedef struct{
+    char ssid[WIFI_SSID_MAX_LEN_];
+    char pwd[WIFI_PWD_MAX_LEN_];
+}WIFI_ssid_pwd;
+
+
+
+//int getStoredWifiInfo(WIFI_ssid_pwd* wifi);
+//int setStoredWifiInfo(WIFI_ssid_pwd* wifi);
+int NanWifiConnect(bool restartNan);
+int cloud_CloudInit(const char *deviceID, const char *devicePwd, \
+    const char *serverIP, const char *serverPort);
+
+// this .h file has the 'namespace' cloud, all the variables has the prefix cloud or CLOD
+/*---------------------- The lower is uploadind message to the cloud ------------------------*/
+typedef IotProfileService   Cloud_Servic;
+typedef IotProfileKV        Cloud_Proprety;
+typedef IotProfileDataType  Cloud_DataType;
+
+
+
+#if CLOUD_MALLOC_ENABEL == true
+
+Cloud_Servic* cloud_createService(const char* name,const char * event);
+int cloud_createAndAppendProprety(Cloud_Servic *service,const char *name,Cloud_DataType type,void* value);
+void cloud_deleteService(Cloud_Servic *service);
+
+CmdNode* cloud_createCmd(char* name);
+CmdParam* cloud_createAndAppendPara(CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func);
+void cloud_deleteCmd();
+#endif
+
+#if CLOUD_MALLOC_ENABEL == false
+
+void cloud_initService(Cloud_Servic *service,const char* name,const char * event);
+void cloud_initAndAppendProprety(Cloud_Servic *service,Cloud_Proprety *proprety,const char *name,Cloud_DataType type,void* value);
+
+void cloud_initCmd(CmdNode* nextNode,char* name);
+void cloud_initAndAppendPara(CmdNode* cmd,CmdParam* para,const char* name,ValueType type,cmdFuncCallback func);
+
+#endif
+
+int cloud_uploadService(Cloud_Servic *service);
+
+/*----------------------- The lower is download message from cloud -------------------------*/
+bool cloud_isCommandName(cJSON* root,char* name);
+
+
+
+#define cloud_Connect CLOUD_Connect
+
+#endif

+ 78 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/inc/cloud_schedule.h

@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2021 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 __CLOUD_SCHEDULE_H__
+#define __CLOUD_SCHEDULE_H__
+
+#include "iot_schedule.h"
+#include "cloud_communicate.h"
+
+#include <stdbool.h>
+#include <time.h>
+
+#define CN_MAX_WEEKDAY 7
+#define CN_MAX_SCHID 30
+
+
+// #define CLOUD_SCHEDULE_MALLOC_EN true
+// #if CLOUD_SCHEDULE_MALLOC_EN
+#define CLOUD_SCHEDULE_NAME_LEN 15
+// #else
+// #define CLOUD_SCHEDULE_NAME_LEN 30
+// #endif
+
+typedef struct tm TIME;
+
+typedef enum{
+    SCHE_UPDATE = 0,
+    SCHE_ADD,
+    SCHE_DELELTE,
+}SheduleUpdateOption;
+
+typedef struct{
+    CmdParam* param;
+    CmdValue value;
+}CmdControl;
+
+typedef struct {
+    uint8_t Days;         // the day which has 1001100 format
+    uint8_t startHour;   // less than 24
+    uint8_t startMinute; // less than 60
+    uint8_t startSeconds;
+    uint16_t duration;    // less than 1440
+    CmdControl ctrl;
+    char id[CLOUD_SCHEDULE_NAME_LEN];
+    struct ScheduleCtrl_t* nxt;
+}ScheduleCtrl_t;
+
+
+
+
+void bindingScheduleToCmd(ScheduleCtrl_t* schedule,CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func);
+
+void ScheduleInit();
+
+void updataSchedule(ScheduleCtrl_t* shedule,SheduleUpdateOption option);
+
+
+ScheduleCtrl_t* cloud_createSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur, CmdControl ctrl);
+int cloud_updateSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur);
+int cloud_deleteScheduleByID(const char* id);
+
+
+
+#endif

+ 525 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/src/cloud_communicate.c

@@ -0,0 +1,525 @@
+/*
+ * @Author: bearpi_gdtr
+ * @Date: 2022-03-18 17:32:25
+ * @LastEditTime: 2022-03-26 10:43:49
+ * @LastEditors: Please set LastEditors
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath: \v3_0_2\vendor\bossay\smart_door\demo_smartdoor\cloud_command\src\cloud_commuinate.c
+ */
+#include "cloud_communicate.h"
+#include "network_config_service.h"
+#include "iot_wifi.h"
+#include "kv_store.h"
+#include <stdio.h>
+#include <string.h>
+
+
+static CmdNode cmdNodeFirst = {
+    .nxt = NULL,
+    .params = NULL,
+    .name = NULL,
+    //.value.valueU64 = 0,
+};
+
+/**
+ * @description: get wifi inforamtion from kvstore
+ * @param {WIFI_ssid_pwd*} wifi
+ * @return {*}
+ */
+int getStoredWifiInfo(WIFI_ssid_pwd* wifi)
+{
+    int ret = -1;
+    ret = UtilsGetValue(KV_STORE_SSID_ID,wifi->ssid,WIFI_SSID_MAX_LEN_);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't get the wifi ssid from kV store");
+        return ret;
+    }
+    ret = UtilsGetValue(KV_STORE_PWD_ID,wifi->pwd,WIFI_PWD_MAX_LEN_);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't get the wifi pwd from kV store");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO, "get wifi success! \n");
+    RaiseLog(LOG_LEVEL_INFO,"Wifi ssid: %s",wifi->ssid);
+    RaiseLog(LOG_LEVEL_INFO,"Wifi pwd: %s",wifi->pwd);
+    return ret;
+}
+
+/**
+ * @description: store the wifi
+ * @param {WIFI_ssid_pwd*} wifi
+ * @return {*}
+ */
+int setStoredWifiInfo(WIFI_ssid_pwd* wifi)
+{
+    int ret = -1;
+    ret = UtilsSetValue(KV_STORE_SSID_ID,wifi->ssid);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't store the wifi ssid to the kV store");
+        return ret;
+    }
+    ret = UtilsSetValue(KV_STORE_PWD_ID,wifi->pwd);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Can't store the wifi pwd to the kV store");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO, "Store wifi success! \n");
+    return ret;
+}
+
+/**
+ * @description: initialize the cloud
+ * @param {*}
+ * @return {*}
+ */
+int cloud_CloudInit(const char *deviceID, const char *devicePwd, \
+    const char *serverIP, const char *serverPort)
+{
+    if (CLOUD_Init() != 0) {
+        RaiseLog(LOG_LEVEL_DEBUG,"Cloud init failed");
+        return -1;
+    }
+    if (CLOUD_Connect(deviceID, devicePwd,\
+            serverIP, serverPort) != 0) {
+        RaiseLog(LOG_LEVEL_DEBUG,"Cloud connect failed");
+        return -1;
+    }
+    return 0;
+}
+
+/**
+ * @description: NAN connect the wifi
+ * @param {WIFI_ssid_pwd} *wifi
+ * @return {*}
+ */
+int NanWifiConnect(bool restartNan)
+{
+    WIFI_ssid_pwd wifi;
+    printf("--------------- NAN --------------------%d\n",sizeof(wifi.ssid));
+    if(restartNan){
+        goto CLOUD_START_NAN;
+    }
+    if(getStoredWifiInfo(&wifi) == 0){
+        goto CLOUD_CONNECT_WIFI;
+    }
+    
+CLOUD_START_NAN:
+
+    RaiseLog(LOG_LEVEL_INFO,"Try to get the wifi info by NAN network....");
+    int ret;
+    ret = BOARD_NAN_NetCfgStartConfig(NAN_WIFI_AP_SSID,wifi.ssid,sizeof(wifi.ssid),\
+                                        wifi.pwd,sizeof(wifi.pwd));
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_INFO,"NAN network get wifi info failed");
+        return ret;
+    }
+    RaiseLog(LOG_LEVEL_INFO,"NAN network get wifi info success");
+    RaiseLog(LOG_LEVEL_INFO,"Wifi ssid: %s",wifi.ssid);
+    RaiseLog(LOG_LEVEL_INFO,"Wifi pwd: %s",wifi.pwd);
+
+CLOUD_CONNECT_WIFI:
+
+    BOARD_InitWifi();
+    ret = BOARD_ConnectWifi(wifi.ssid, wifi.pwd);
+    if (ret != 0) {
+        RaiseLog(LOG_LEVEL_ERR, "Connect to wifi failed! \n");
+        NotifyNetCfgResult(NETCFG_DEV_INFO_INVALID);
+        return ret;
+    }
+    NotifyNetCfgResult(NETCFG_OK);
+    StopNetCfg();
+    ret = setStoredWifiInfo(&wifi);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_ERR,"Wifi info store failed!");
+    }
+    return ret;
+}
+
+
+
+/**
+ * @description: cloud_createService: create one service
+ * @param {char*} name: serviceID's name.
+ * @param {char *} event: The event time of service,which cloud be the NULL
+ * @return {*}
+ */
+Cloud_Servic* cloud_createService(const char* name,const char * event)
+{
+    Cloud_Servic* service = malloc(sizeof(Cloud_Servic));
+    if(service == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"malloc Cloud_Proprety failed!");
+        return;
+    }
+    service->serviceID = name;
+    service->propertyLst = NULL;
+    service->nxt = NULL;
+    service->eventTime = NULL;
+    return service;
+}
+
+/**
+ * @description: cloud_appendProprety : append one proprety to service
+ * @param {Cloud_Servic} *service : .....
+ * @param {char} *name : proprety's name
+ * @param {Cloud_DataType} type: proprety's type.
+ * @param {void*} value: proprety's value
+ * @return {*}
+ */
+int cloud_createAndAppendProprety(Cloud_Servic *service,const char *name,Cloud_DataType type,void* value)
+{   
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+    Cloud_Proprety* prpty = malloc(sizeof(Cloud_Proprety));
+    if(prpty == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"malloc Cloud_Proprety failed!");
+        return -1;
+    }
+    prpty->nxt = NULL;
+    prpty->type = type;
+    prpty->value = value;
+    prpty->key = name;
+    tempPrp = service->propertyLst;
+    if(tempPrp == NULL){
+        service->propertyLst = prpty;
+    }else{
+        while(tempPrp->nxt != NULL){
+            tempPrp = tempPrp->nxt;
+        }
+        tempPrp->nxt = prpty;
+    }
+    return 0;
+}
+
+/**
+ * @description: cloud_appendPropretyAndUpload :
+ *               upload the service to the cloud,
+ * @param {Cloud_Servic} *service : .....
+ * @param {char} *name : proprety's name
+ * @param {Cloud_DataType} type: proprety's type.
+ * @param {void*} value: proprety's value
+ * @return {*}
+ */
+int cloud_uploadService(Cloud_Servic *service)
+{
+    cJSON* jsonString;
+    int ret;
+    jsonString = IoTProfilePackage(service);
+    if (NULL != jsonString) {
+        RaiseLog(LOG_LEVEL_INFO, "jsonString:%s", jsonString);
+        ret = CLOUD_ReportMsg(jsonString);
+        free(jsonString);
+        return ret;
+    }
+    return -1;
+}
+
+
+/**
+ * @description: delete the Service
+ * @param {Cloud_Servic} *service
+ * @return {*}
+ */
+void cloud_deleteService(Cloud_Servic *service)
+{
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+        // free the service and it's propreties.
+    tempService = service;
+    while(tempService != NULL){
+        tempPrp = tempService->propertyLst;
+        while(tempPrp != NULL){
+            Cloud_Proprety* prp = tempPrp;
+            tempPrp = tempPrp->nxt;
+            free(prp);
+        }
+        Cloud_Servic* svc;
+        tempService = tempService->nxt;
+        free(svc);
+    }
+}
+
+/**
+ * @description: 
+ * @param {Cloud_Servic} *service
+ * @param {char*} name
+ * @param {char *} event
+ * @return {*}
+ */
+void cloud_initService(Cloud_Servic *service,const char* name,const char * event)
+{
+    service->serviceID = name;
+    service->propertyLst = NULL;
+    service->nxt = NULL;
+    service->eventTime = NULL;
+    return service;
+}
+
+/**
+ * @description: 
+ * @param {Cloud_Servic} *service
+ * @param {Cloud_Proprety} *prpty
+ * @param {char} *name
+ * @param {Cloud_DataType} type
+ * @param {void*} value
+ * @return {*}
+ */
+void cloud_initAndAppendProprety(Cloud_Servic *service,Cloud_Proprety *prpty,const char *name,Cloud_DataType type,void* value)
+{
+    Cloud_Proprety* tempPrp;
+    Cloud_Servic* tempService;
+    prpty->nxt = NULL;
+    prpty->type = type;
+    prpty->value = value;
+    prpty->key = name;
+    tempPrp = service->propertyLst;
+    if(tempPrp == NULL){
+        service->propertyLst = prpty;
+    }else{
+        while(tempPrp->nxt != NULL){
+            tempPrp = tempPrp->nxt;
+        }
+        tempPrp->nxt = prpty;
+    }
+}
+
+/**
+ * @description: create Para for cmd
+ * @param {CmdNode*} cmd
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {CmdParam*}
+ */
+CmdParam* cloud_createAndAppendPara(CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func)
+{
+    CmdParam* para = malloc(sizeof(CmdParam));
+    if(para == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"Malloc CmdParam failed!");
+        return para;
+    }
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return para;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return para;
+}
+
+/**
+ * @description: create cmd add to the cmd list cmdNodeFirst which static defined in this file
+ * @param {char*} name
+ * @return {*}
+ */
+CmdNode* cloud_createCmd(char* name)
+{
+    CmdNode* cmd = malloc(sizeof(CmdNode));
+    if(cmd == NULL){
+        RaiseLog(LOG_LEVEL_ERR,"Malloc CmdBode failed!");
+        return -1;
+    }
+    strcpy(cmd->name,name);
+    cmd->nxt = NULL;
+    cmd->params = NULL;
+
+    CmdNode* pTemp = &cmdNodeFirst;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = cmd;
+    return cmd;
+}
+
+/**
+ * @description: free all the cmd and their paras except cmdNodeFirst
+ * @param {*}
+ * @return {*}
+ */
+void cloud_deleteCmd()
+{
+    CmdNode* pCmd = cmdNodeFirst.nxt;
+    CmdParam* pPara;
+    while (pCmd != NULL)
+    {
+        pPara = pCmd->params;
+        while (pPara != NULL){
+           CmdParam* tempP = pPara;
+           pPara = pPara->nxt;
+           free(tempP);
+        }
+        CmdNode* tempC = pCmd;
+        pCmd = pCmd->nxt;
+        free(tempC);
+    }
+}
+
+
+/**
+ * @description: init one cmd
+ * @param {CmdNode*} cmd
+ * @param {char*} name
+ * @return {*}
+ */
+void cloud_initCmd(CmdNode* cmd,char* name)
+{
+    strcpy(cmd->name,name);
+    cmd->nxt = NULL;
+    cmd->params = NULL;
+
+    CmdNode* pTemp = &cmdNodeFirst;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = cmd;
+}
+
+
+/**
+ * @description: init one cmdparam and append it to the end of cmd
+ * @param {CmdNode*} cmd
+ * @param {CmdParam*} para
+ * @param {char*} name
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {*}
+ */
+void cloud_initAndAppendPara(CmdNode* cmd,CmdParam* para,const char* name,ValueType type,cmdFuncCallback func)
+{
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return 0;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return 0;
+}
+
+/**
+ * @description: cloud_isCommandName: Determine if Parameters has the json object named objName
+ * @param {cJSON*} root
+ * @param {char*} objName
+ * @param {cJSON*} retObj
+ * @return {*}
+ */
+bool cloud_isCommandName(cJSON* root,char* name)
+{
+    cJSON* obj = cJSON_GetObjectItem(root,CLOUD_COMMAND_NAME);
+    if(obj==NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"root json don't has json object named 'command_name'.");
+        return false;
+    }
+    if(0 == strcmp(cJSON_GetStringValue(obj),name)){
+        return true;
+        
+    }
+    return false;
+}
+
+
+/**
+ * @description: check the cmd list and execute the callback functions of paras
+ * @param {*}
+ * @return {*}
+ */
+int cloud_checkCmdListAndExec(cJSON* root)
+{
+    CmdNode* cmd = cmdNodeFirst.nxt;
+    while (cmd != NULL)
+    {
+        CmdParam* para = cmd->params;
+        if(cloud_isCommandName(root,cmd->name))
+        {
+            while (para != NULL)
+            {
+                cJSON* paraObj = NULL;
+                CmdValue value;
+
+                cJSON* objParas = cJSON_GetObjectItem(root,CLOUD_PARA_NAME);
+                if(objParas==NULL){
+                    RaiseLog(LOG_LEVEL_DEBUG,"Root json don't has json object named 'paras'.");
+                    return -1;
+                }
+                paraObj = cJSON_GetObjectItem(objParas,para->name);
+                if(paraObj==NULL){
+                    RaiseLog(LOG_LEVEL_DEBUG,"paras don't has json object named %s",para->name);
+                    para = para->nxt;
+                    continue;
+                }
+                // if the paras object has parameter named para->name
+                FuncValue_t fValue;
+                switch(para->type)
+                {
+                    case Cloud_Int:
+                        value.valueInt = cJSON_GetNumberValue(paraObj);
+                        fValue.type = Cloud_Int;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    case Cloud_Double:
+                        value.valueDouble = cJSON_GetNumberValue(paraObj);
+                        fValue.type = Cloud_Double;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    case Cloud_String:
+                        strcpy(value.valueString,cJSON_GetStringValue(paraObj));
+                        fValue.type = Cloud_String;
+                        fValue.value = value;
+                        para->func(fValue);
+                        break;
+                    default: 
+                        break;
+                }
+                para = para->nxt;
+            }
+            return 0;
+        }
+        cmd = cmd->nxt;
+    }
+    return -1;
+}
+
+
+/**
+ * @description: The cloud call back function
+ * @param {char} *jsonString
+ * @return {*}
+ */
+int CLOUD_CommandCallBack(const char *jsonString)
+{
+    cJSON* root = NULL;
+    cJSON* obj = NULL;
+    int ret = -1;
+    if(jsonString == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"Received none data from cloud!");
+        return ret;
+    }
+    root = cJSON_Parse(jsonString);
+    if(root == NULL){
+        RaiseLog(LOG_LEVEL_DEBUG,"No data parsed from json string!");
+        return ret;
+    }
+    ret = cloud_checkCmdListAndExec(root);
+    free(root);
+    return ret;
+}
+
+
+
+

+ 300 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/cloud_connect/src/cloud_schedule.c

@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#include "cloud_schedule.h"
+#include "iot_demo_def.h"
+#include "ohos_init.h"
+#include <time.h>
+#include <stdbool.h>
+#include "iot_sntp.h"
+
+
+#define TIMER_PERIOD 1      // [s]
+#define SCHEDULE_TASK_SIZE 1024*6
+#define SCHEDULE_TASK_PRIOR 25
+#define CONFIG_LOCAL_TIMEZONE  8
+#define ONE_MINUITE_SECONDS 60
+#define ONE_HOUR_SECONDS 3600
+#define ONE_DAY_SECOND_SECONDS 86400
+#define SNTP_TIME_YEAR_OFFSET 1900
+#define CONFIG_TASK_SCHEDULE_SIZE 0x1000
+#define CONFIG_TASK_SCHEDULE_PRIOR 31
+
+
+static time_t currentTime = 0;
+static osTimerId_t osTimer_ID;
+static ScheduleCtrl_t scheduleFirstNode = {
+    .nxt = NULL,
+};
+static int oneHourSeconds = TIMER_PERIOD * 3600;
+static int quarterMinuSeconds = TIMER_PERIOD * 15;
+
+/**
+ * @description: Bind the schedule to the command which is defined in cloud communicate
+ * @param {ScheduleCtrl_t*} schedule
+ * @param {CmdNode*} cmd
+ * @param {char*} name
+ * @param {ValueType} type
+ * @param {cmdFuncCallback} func
+ * @return {*}
+ */
+void bindingScheduleToCmd(ScheduleCtrl_t* schedule,CmdNode* cmd,const char* name,ValueType type,cmdFuncCallback func)
+{
+    CmdParam* para = &schedule->ctrl;
+    strcpy(para->name,name);
+    para->nxt = NULL;
+    para->func = func;
+    para->type = type;
+
+    if(cmd->params == NULL){
+        cmd->params = para;
+        return para;
+    }
+
+    CmdParam* pTemp = cmd->params;
+    while (pTemp->nxt != NULL){
+        pTemp = pTemp->nxt;
+    }
+    pTemp->nxt = para;
+    return para;
+}
+
+/**
+ * @description: Get current time by sntp and up sync the local time
+ * @param {*}
+ * @return {*}
+ */
+TIME getAndUpdateCurrentTm()
+{
+    TIME time;
+    if(SntpGetRtcTime(CONFIG_LOCAL_TIMEZONE, &time) != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Sync the time failed!");
+                return *localtime(&currentTime);
+    }
+    currentTime = mktime(&time);
+    return time;
+}
+/**
+ * @description: Get start seconds in one day  interval: (0,86400)
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+uint32_t getStartSecondsInDay(const ScheduleCtrl_t* schedule)
+{
+    return schedule->startHour * ONE_HOUR_SECONDS + schedule->startMinute * ONE_MINUITE_SECONDS + schedule->startSeconds;
+}
+
+/**
+ * @description: Get end seconds in one day  interval: (0,86400)
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+uint32_t getEndSecondsInDay(const ScheduleCtrl_t* schedule)
+{
+    return getStartSecondsInDay(schedule) + schedule->duration;
+}
+
+
+/**
+ * @description: determine whether current time is in the time period of schedule
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+bool isTimeToStartSchedule(const ScheduleCtrl_t* schedule)
+{
+    TIME ctime = getAndUpdateCurrentTm();
+    uint8_t days = schedule->Days;
+
+    uint8_t cday = ctime.tm_wday;
+    uint8_t chour = ctime.tm_hour;
+    uint8_t cmin = ctime.tm_min;
+    uint8_t csec = ctime.tm_sec;
+    RaiseLog(LOG_LEVEL_INFO,"%d%d%d%d",cday,chour,cmin,csec);
+    uint32_t currentSecondInday = chour*ONE_HOUR_SECONDS + cmin*ONE_MINUITE_SECONDS + csec;
+    //gdtr_TODO: check the format of tm_wday and change it
+    if((days >> (cday)) & 0x01){ // today is in schedule
+        if(currentSecondInday >= getStartSecondsInDay(schedule) &&\
+         currentSecondInday <= getEndSecondsInDay(schedule)){
+             RaiseLog(LOG_LEVEL_INFO,"is execute time of schedule");
+             return true;
+         }
+    }
+    RaiseLog(LOG_LEVEL_INFO," is not execute time of schedule");
+    return false;
+}
+
+/**
+ * @description: The local timer callback every a quarter minuite
+ * @param {void*} argument
+ * @return {*}
+ */
+void scheduleTimeCallback(void* argument)
+{
+    currentTime++;
+    quarterMinuSeconds -= TIMER_PERIOD;
+}
+
+void scheduleThreadCallback(void* arguement)
+{
+    for(;;)
+    {
+        if(quarterMinuSeconds <= 0){
+            ScheduleCtrl_t* ptr = scheduleFirstNode.nxt;
+            FuncValue_t value;
+            RaiseLog(LOG_LEVEL_INFO,"---------------------");
+            while (ptr != NULL)
+            {
+                if(isTimeToStartSchedule(ptr)){
+                    RaiseLog(LOG_LEVEL_INFO,"Start the schedule%s",ptr->id);
+                    value.type = ptr->ctrl.param->type;
+                    value.value = ptr->ctrl.value;
+                    ptr->ctrl.param->func(value);
+                }        
+                ptr = ptr->nxt;
+            }
+            quarterMinuSeconds = 15*TIMER_PERIOD;
+        }
+        osDelay(40);
+    }
+}
+
+/**
+ * @description: Schedule initilize function
+ * @param {ScheduleCtrl_t*} schedule
+ * @return {*}
+ */
+void ScheduleInit()
+{
+    int ret;
+    TIME time;
+    SntpGetRtcTime(CONFIG_LOCAL_TIMEZONE, &time);
+    if(ret != 0){
+        RaiseLog(LOG_LEVEL_DEBUG,"Get Simple Network Time Protocol failed!");
+        return;
+    }
+    currentTime = mktime(&time);
+    
+    RaiseLog(LOG_LEVEL_DEBUG,"Current time is:%d",currentTime);
+    RaiseLog(LOG_LEVEL_INFO,"%4d.%2d.%2d %2d:%2d:%2d",time.tm_yday + SNTP_TIME_YEAR_OFFSET,time.tm_mon,time.tm_mday,\
+                time.tm_hour,time.tm_min,time.tm_sec);
+    osTimerAttr_t attr_timer;
+    attr_timer.name = "scheduleTimer";
+    attr_timer.cb_mem = NULL;
+    attr_timer.cb_size = NULL;
+    osTimer_ID = osTimerNew(scheduleTimeCallback,osTimerPeriodic,NULL,&attr_timer);
+    osTimerStart(osTimer_ID,TIMER_PERIOD * 100);
+
+    osThreadAttr_t attr_thread;
+    attr_thread.attr_bits = 0U;
+    attr_thread.cb_mem = NULL;
+    attr_thread.cb_size = 0U;
+    attr_thread.stack_mem = NULL;
+    attr_thread.stack_size = CONFIG_TASK_SCHEDULE_SIZE;
+    attr_thread.priority = CONFIG_TASK_SCHEDULE_PRIOR;
+    attr_thread.name = "IoTMain";
+    (void) osThreadNew((osThreadFunc_t)scheduleThreadCallback, NULL, (const osThreadAttr_t *)&attr_thread);
+
+    return;
+}
+
+/**
+ * @description: Create one schedule and put it to the scheduleFirstNode static variable which defined in this file
+ * @param {*}
+ * @return {*}
+ */
+ScheduleCtrl_t* cloud_createSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur, CmdControl ctrl)
+{
+    if(start_hour > 24 || start_min > 60 || start_sec > 60 || dur > 1440){
+        RaiseLog(LOG_LEVEL_DEBUG,"Wrong format of schedule");
+        return NULL;
+    }
+
+    ScheduleCtrl_t* schedule = malloc(sizeof(ScheduleCtrl_t));
+    if(schedule == NULL){
+        RaiseLog(LOG_LEVEL_ERR,"Malloc Schedule failed!");
+        return schedule;
+    }
+    
+    strcpy(schedule->id,id);
+    schedule->ctrl = ctrl;
+    schedule->Days  = wdays;
+    schedule->startHour = start_hour;
+    schedule->startMinute = start_min;
+    schedule->startSeconds = start_sec;
+    schedule->duration = dur;
+    schedule->nxt = NULL;
+
+    ScheduleCtrl_t* ptr = &scheduleFirstNode;
+    while (ptr->nxt != NULL){
+        ptr = ptr->nxt;
+    }
+    ptr->nxt = schedule;
+    return schedule;
+}
+
+/**
+ * @description: Delete the schedule
+ * @param {char*} id
+ * @return {*}
+ */
+int cloud_deleteScheduleByID(const char* id)
+{
+    ScheduleCtrl_t* ptr = &scheduleFirstNode;
+    ScheduleCtrl_t* temp;
+    while (ptr->nxt != NULL)
+    { 
+        temp = ptr->nxt;
+        if(strcmp(temp->id,id) == 0){
+            ptr = temp->nxt;
+            free(temp);
+            return 0;
+        }
+        ptr = ptr->nxt;
+    }
+    RaiseLog(LOG_LEVEL_DEBUG,"No %s in the schedule list",id);
+    return -1;
+}
+
+/**
+ * @description: update the schedule
+ * @param {*}
+ * @return {*}
+ */
+int cloud_updateSchedule(char* id,uint8_t wdays,uint8_t start_hour,uint8_t start_min,\
+                                    uint8_t start_sec,uint16_t dur)
+{
+    ScheduleCtrl_t* ptr = scheduleFirstNode.nxt;
+    while (ptr != NULL)
+    {
+        if(strcmp(ptr->id,id) == 0){
+            ptr->Days = wdays;
+            ptr->startHour = start_hour;
+            ptr->startMinute = start_min;
+            ptr->startSeconds = start_sec;
+            ptr->duration = dur;
+            return 0;
+        }
+        ptr = ptr->nxt;
+    }
+    RaiseLog(LOG_LEVEL_DEBUG,"No %s in the schedule list",id);
+    return -1;
+}
+
+
+
+
+
+

+ 133 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/main_entry.c

@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+
+
+#include "iot_cloud.h"
+#include "iot_boardled.h"
+#include "iot_boardbutton.h"
+#include "iot_wifi.h"
+#include "iot_netcfg.h"
+#include "iot_sntp.h"
+#include "ohos_init.h"
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <cmsis_os2.h>
+#include <stdbool.h>
+#include "kv_store.h"
+#include "iot_schedule.h"
+#include "network_config_service.h"
+#include "iot_netcfg_nan.h"
+
+#include "hi_reset.h"
+#include "cloud_communicate.h"
+#include "cloud_schedule.h"
+#include "PM2_5.h"
+#include "OLED_I2C.h"
+
+#define CONFIG_TASK_MAIN_STACKSIZE 0x2000
+#define CONFIG_TASK_MAIN_PRIOR 25
+
+#define CONFIG_CLOUD_DEFAULT_SERVERIP "121.36.42.100"   // Huawei cloud service ip
+#define CONFIG_CLOUD_DEFAULT_SERVERPORT "1883"          // // Huawei cloud service port
+#define CLOUD_DEVICE_ID "6221c7f2c4e6a958e354bb4b_BearPi_HM_Nano_ST1"   // user need to change it according to the device id in cloud
+#define CLOUD_DEVICE_PWD "bearpi12345"  // user need to change it according to the device pwd in cloud
+
+#define NFC_DEVICE_ID_LEN 50
+#define NFC_DEVICE_PWD_LEN 50
+
+typedef struct{
+    char* nfc_dev_id[NFC_DEVICE_ID_LEN];
+    char* nfc_dev_pwd[NFC_DEVICE_PWD_LEN];
+    ScheduleCtrl_t schedule;
+    osTimerId_t timeID;
+}AppCtrl_t;
+
+
+/* if user want to en able the schedule control could disable comment below  */
+
+// int scheduleCallback(FuncValue_t value)
+// {
+//     switch(value.type)
+//     {
+//     case Cloud_Int:
+//     break;
+//     case Cloud_Double:
+//     break;
+//     case Cloud_String:
+//     break;
+//     default:
+//     break;
+//     }
+//     return 0;
+// }
+
+static bool keyStatus = false;
+void keycallback(char* arg){
+    keyStatus = true;
+    return;
+}
+
+void IotMainTaskEntry(void* argument)
+{
+    PM2D5Data data;
+    BoardInit();
+    LedSafeStatusSet(ON);
+    initKey(keycallback);
+    IOT_ScheduleInit();
+    BOARD_InitWifi();
+    osDelay(300);
+    NanWifiConnect(keyStatus);
+    cloud_CloudInit(CLOUD_DEVICE_ID,CLOUD_DEVICE_PWD,CONFIG_CLOUD_DEFAULT_SERVERIP,CONFIG_CLOUD_DEFAULT_SERVERPORT);
+
+    Cloud_Servic* service = cloud_createService("PM2_5_Service",NULL);
+    cloud_createAndAppendProprety(service,"pm1_0_status",IOT_PROFILE_KEY_DATATYPE_INT,(void*)&data.pm1_0);
+    cloud_createAndAppendProprety(service,"pm2_5_status",IOT_PROFILE_KEY_DATATYPE_INT,(void*)&data.pm2_5);
+    cloud_createAndAppendProprety(service,"pm10_status",IOT_PROFILE_KEY_DATATYPE_INT,(void*)&data.pm10);
+
+    for(;;)
+    {
+        PM2DReadData(&data);
+        RaiseLog(LOG_LEVEL_INFO,"PM1.0 is  %d", data.pm1_0);
+        RaiseLog(LOG_LEVEL_INFO,"PM2.5 is  %d", data.pm2_5);
+        RaiseLog(LOG_LEVEL_INFO,"PM10 is  %d", data.pm10);
+        cloud_uploadService(service);
+        osDelay(100);
+    }
+}
+
+static void EntryMain(void)
+{
+    osThreadAttr_t attr;
+    RaiseLog(LOG_LEVEL_INFO, "DATA:%s Time:%s \r\n", __FUNCTION__, __DATE__, __TIME__);
+    // Create the IoT Main task
+    attr.attr_bits = 0U;
+    attr.cb_mem = NULL;
+    attr.cb_size = 0U;
+    attr.stack_mem = NULL;
+    attr.stack_size = CONFIG_TASK_MAIN_STACKSIZE;
+    attr.priority = CONFIG_TASK_MAIN_PRIOR;
+    attr.name = "IoTMain";
+    (void) osThreadNew((osThreadFunc_t)IotMainTaskEntry, NULL, (const osThreadAttr_t *)&attr);
+
+    return;
+}
+APP_FEATURE_INIT(EntryMain);
+
+
+

+ 23 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/BUILD.gn

@@ -0,0 +1,23 @@
+static_library("bossay_hi3861_l0_sensor") {
+    sources = [
+        "src/PM2_5.c"
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "inc",
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//device/bossay/hi3861_l0/iot_hardware_hals/include",
+        "//device/bossay/hi3861_l0/sdk_liteos/include",
+    ]
+
+    deps = [ 
+
+    ]
+
+}
+
+

+ 30 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/inc/PM2_5.h

@@ -0,0 +1,30 @@
+#ifndef __PM_2_5_H__
+#define __PM_2_5_H__
+
+
+#include <stdint.h>
+
+
+typedef enum
+{
+	OFF = 0,
+	ON
+} SwitchStatus;
+
+typedef struct
+{
+    uint32_t    pm1_0;	
+    uint32_t    pm2_5;
+    uint32_t    pm10;		
+} PM2D5Data;
+
+void BoardInit(void);
+
+uint8_t Button_Left_Read_Data(void);
+
+void PM2DReadData(PM2D5Data* ReadData);
+void LedWarnStatusSet(SwitchStatus status);	
+void LedSafeStatusSet(SwitchStatus status);
+#endif
+
+

+ 120 - 0
vendor/bossay/PM2_5_Monitoring/demo_PM2_5_Monitoring/sensor/src/PM2_5.c

@@ -0,0 +1,120 @@
+#include "PM2_5.h"
+#include "iot_errno.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "iot_uart.h"
+#include "stdio.h"
+
+#define RESET_GPIO 7
+#define LED_SAFE_GPIO 8
+#define LED_WARN_GPIO 14
+#define SET_GPIO 13
+#define WIFI_IOT_UART_IDX_1 1
+
+uint8_t     RxBuffer[3];
+
+
+void BoardInit(void)
+{   
+    IoTGpioInit(RESET_GPIO);
+    IoTGpioSetFunc(RESET_GPIO, IOT_GPIO_FUNC_GPIO_7_GPIO);
+    IoTGpioSetDir(RESET_GPIO, IOT_GPIO_DIR_OUT); // 设置为输出模式
+    IoTGpioSetOutputVal(RESET_GPIO, 1);
+
+    IoTGpioInit(LED_SAFE_GPIO);
+    IoTGpioSetFunc(LED_SAFE_GPIO, IOT_GPIO_FUNC_GPIO_8_GPIO);
+    IoTGpioSetDir(LED_SAFE_GPIO, IOT_GPIO_DIR_OUT); // 设置为输出模式
+
+    IoTGpioInit(LED_WARN_GPIO);
+    IoTGpioSetFunc(LED_WARN_GPIO, IOT_GPIO_FUNC_GPIO_14_GPIO);
+    IoTGpioSetDir(LED_WARN_GPIO, IOT_GPIO_DIR_OUT); // 设置为输出模式
+
+    IoTGpioInit(SET_GPIO);
+    IoTGpioSetFunc(SET_GPIO, IOT_GPIO_FUNC_GPIO_13_GPIO);
+    IoTGpioSetDir(SET_GPIO, IOT_GPIO_DIR_OUT); // 设置为输入模式
+    IoTGpioSetOutputVal(SET_GPIO, 1);
+
+    uint32_t ret;
+
+    IotUartAttribute uart_attr = {
+
+        // baud_rate: 9600
+        .baudRate = 9600,
+
+        // data_bits: 8bits
+        .dataBits = 8,
+        .stopBits = 1,
+        .parity = 0,
+    };
+
+    // Initialize uart driver
+    ret = IoTUartInit(WIFI_IOT_UART_IDX_1, &uart_attr);
+    if (ret != IOT_SUCCESS) {
+        printf("Failed to init uart! Err code = %d\n", ret);
+        return;
+    }
+}
+
+static unsigned char read_date[32];
+
+/***************************************************************
+ * 函数名称: PM2DReadData
+ * 说    明: 获取GPS经纬度信息
+ * 参    数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+void PM2DReadData(PM2D5Data* ReadData)
+{
+    //通过串口1接收数据
+    IoTUartRead(WIFI_IOT_UART_IDX_1, read_date, 32);
+
+    // for(int i = 0; i<32; i++)
+    // {
+    //     printf("%d------%x\r\n",i,read_date[i]);
+    // }
+    if(read_date[0]== 0x42 && read_date[1]== 0x4d)
+    {
+        ReadData->pm1_0=read_date[2]<<8|read_date[3];
+        ReadData->pm2_5=read_date[4]<<8|read_date[5];
+        ReadData->pm10=read_date[6]<<8|read_date[7];
+    }
+
+}
+
+
+/***************************************************************
+ * 函数名称: LedWarnStatusSet
+ * 说    明: LED_Warn状态设置
+ * 参    数: status,ENUM枚举的数据
+ *									OFF,关
+ *									ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void LedWarnStatusSet(SwitchStatus status)
+{
+    if (status == ON) {
+        IoTGpioSetOutputVal(LED_WARN_GPIO, 1); // 设置输出高电平点亮灯
+    }
+
+    if (status == OFF) {
+        IoTGpioSetOutputVal(LED_WARN_GPIO, 0); // 设置输出低电平关闭灯
+    }
+}
+/***************************************************************
+ * 函数名称: LedSafeStatusSet
+ * 说    明: LED_Safe状态设置
+ * 参    数: status,ENUM枚举的数据
+ *									OFF,关
+ *									ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void LedSafeStatusSet(SwitchStatus status)
+{
+    if (status == ON) {
+        IoTGpioSetOutputVal(LED_SAFE_GPIO, 1); // 设置输出高电平点亮灯
+    }
+
+    if (status == OFF) {
+        IoTGpioSetOutputVal(LED_SAFE_GPIO, 0); // 设置输出低电平关闭灯
+    }
+}

+ 27 - 0
vendor/bossay/PM2_5_Monitoring/hals/utils/sys_param/BUILD.gn

@@ -0,0 +1,27 @@
+# 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}\"",
+    ]
+}

+ 128 - 0
vendor/bossay/PM2_5_Monitoring/hals/utils/sys_param/hal_sys_param.c

@@ -0,0 +1,128 @@
+/*
+ * 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;
+}

+ 22 - 0
vendor/bossay/PM2_5_Monitoring/hals/utils/token/BUILD.gn

@@ -0,0 +1,22 @@
+# Copyright (c) 2020 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+static_library("hal_token_static") {
+  sources = [ "hal_token.c" ]
+
+  include_dirs = [
+    "//base/startup/syspara_lite/hals",
+    "//utils/native/lite/include",
+  ]
+  deps = []
+}

+ 104 - 0
vendor/bossay/PM2_5_Monitoring/hals/utils/token/hal_token.c

@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hal_token.h"
+#include "ohos_errno.h"
+#include "ohos_types.h"
+
+static int OEMReadToken(char *token, unsigned int len)
+{
+    // OEM need add here, read token from device
+    (void)(token);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMWriteToken(const char *token, unsigned int len)
+{
+    // OEM need add here, write token to device
+    (void)(token);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetAcKey(char *acKey, unsigned int len)
+{
+    // OEM need add here, get AcKey
+    (void)(acKey);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetProdId(char *productId, unsigned int len)
+{
+    // OEM need add here, get ProdId
+    (void)(productId);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+static int OEMGetProdKey(char *productKey, unsigned int len)
+{
+    // OEM need add here, get ProdKey
+    (void)(productKey);
+    (void)(len);
+    return EC_SUCCESS;
+}
+
+
+int HalReadToken(char *token, unsigned int len)
+{
+    if (token == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMReadToken(token, len);
+}
+
+int HalWriteToken(const char *token, unsigned int len)
+{
+    if (token == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMWriteToken(token, len);
+}
+
+int HalGetAcKey(char *acKey, unsigned int len)
+{
+    if (acKey == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetAcKey(acKey, len);
+}
+
+int HalGetProdId(char *productId, unsigned int len)
+{
+    if (productId == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetProdId(productId, len);
+}
+
+int HalGetProdKey(char *productKey, unsigned int len)
+{
+    if (productKey == NULL) {
+        return EC_FAILURE;
+    }
+
+    return OEMGetProdKey(productKey, len);
+}

+ 120 - 0
vendor/bossay/common/communicationkit/js_api/@system.communicationkit.d.ts

@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+/**
+ * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+ */
+export interface GetCommunicationKitOptions {
+  /**
+   * Content index.
+   * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  key: string;
+
+  /**
+   * Default value returned when the key does not exist.
+   * If this parameter is not specified, an empty string is returned.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  default?: string;
+
+  /**
+   * Called when the stored content is read successfully.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  success?: (data: any) => void;
+
+  /**
+   * Called when the stored content fails to be read.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  fail?: (data: string, code: number) => void;
+
+  /**
+   * Called when the execution is completed.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  complete?: () => void;
+}
+
+/**
+ * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+ */
+export interface SetCommunicationKitOptions {
+  /**
+   * Index of the stored content to be modified.
+   * For liteWearable and smartVision, the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  key: string;
+
+  /**
+   * Target storage content. If the content is an empty string, the data item with the key as the index will be deleted.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  value: string;
+
+  /**
+   * Called when the stored content is modified successfully.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  success?: () => void;
+
+  /**
+   * Called when the stored content fails to be modified.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  fail?: (data: string, code: number) => void;
+
+  /**
+   * Called when the execution is completed.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   * @since 3
+   */
+  complete?: () => void;
+}
+
+
+
+
+
+/**
+ * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+ */
+export default class CommunicationKit {
+  /**
+   * Reads the stored content.
+   * @param options Options.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   */
+  static get(options: GetCommunicationKitOptions): void;
+
+  /**
+   * Modifies the stored content.
+   * @param options Options.
+   * @devices tv, phone, tablet, wearable, liteWearable, smartVision
+   */
+  static set(options: SetCommunicationKitOptions): void;
+}

+ 25 - 0
vendor/bossay/common/communicationkit/js_api/BUILD.gn

@@ -0,0 +1,25 @@
+# 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.
+
+import("//build/ohos.gni")
+import("//build/ohos/notice/notice.gni")
+import("//build/templates/metadata/module_info.gni")
+
+ohos_copy("communicationkit_api") {
+  sources = [
+    "@system.communicationkit.d.ts",
+  ]
+  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
+  module_source_dir = target_out_dir + "/$target_name"
+  module_install_name = ""
+}

+ 44 - 0
vendor/bossay/common/communicationkit/native_utils/BUILD.gn

@@ -0,0 +1,44 @@
+#
+# 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.
+#
+
+import("//build/lite/config/component/lite_component.gni")
+import("//build/lite/config/subsystem/aafwk/path.gni")
+
+lite_library("native_communication_kit") {
+
+  target_type = "static_library"
+
+  sources = [
+    "src/nativeapi_communication_kit.cpp",
+    "src/nativeapi_communication_kit_impl.c",
+  ]
+  cflags = [ "-Wall" ]
+  cflags_cc = cflags
+
+  include_dirs = [
+    "include",
+    "//utils/native/lite/js/builtin/common/include",
+    "//third_party/bounds_checking_function/include",
+    "//foundation/ace/ace_engine_lite/interfaces/innerkits/builtin",
+    "//foundation/ace/ace_engine_lite/interfaces/innerkits/builtin/base",
+    "//foundation/ace/ace_engine_lite/interfaces/innerkits/builtin/async",
+    "${aafwk_lite_path}/interfaces/kits/ability_lite",
+    "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
+  ]
+  deps = [ 
+    "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
+    "//third_party/bounds_checking_function:libsec_shared",
+    ]
+}

+ 34 - 0
vendor/bossay/common/communicationkit/native_utils/include/nativeapi_communication_kit.h

@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#ifndef JS_NATIVE_API_COMMUNICATION_KIT_H
+#define JS_NATIVE_API_COMMUNICATION_KIT_H
+
+#include "jsi/jsi.h"
+
+namespace OHOS {
+namespace ACELite {
+class NativeapiCommunicationKit {
+public:
+    NativeapiCommunicationKit() = default;
+    ~NativeapiCommunicationKit() = default;
+
+    static JSIValue Get(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+    static JSIValue Set(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+
+};
+} // ACELite
+} // OHOS
+#endif // JS_NATIVE_API_COMMUNICATION_KIT_H

+ 52 - 0
vendor/bossay/common/communicationkit/native_utils/include/nativeapi_communication_kit_impl.h

@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#ifndef JS_FS_COMMUNICATION_KIT_IMPL_API_H
+#define JS_FS_COMMUNICATION_KIT_IMPL_API_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif /* __cplusplus */
+
+#define KEY_MAX_LEN 32
+#define VALUE_MAX_LEN 128
+
+
+#define LOG_TAG "COMMUNICATION_KIT"
+#include "hilog/hiview_log.h"
+
+#define LOG_E(fmt, ...) HILOG_ERROR(HILOG_MODULE_APP, fmt, ##__VA_ARGS__)
+#define LOG_I(fmt, ...) HILOG_INFO(HILOG_MODULE_APP, fmt, ##__VA_ARGS__)
+
+
+typedef int (*JsCallClangFunctionDef)(const char *key, char *value);
+
+void JsGetClangFuncationRegister(JsCallClangFunctionDef jsGetClang);
+void JsSetClangFuncationRegister(JsCallClangFunctionDef jsSetClang);
+void JsGetClangFuncationUnregister(void);
+void JsSetClangFuncationUnregister(void);
+
+int GetCommunicationKitValue(const char* key, char* value);
+int SetCommunicationKitValue(const char* key, const char* value);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif /* __cplusplus */
+
+#endif /* JS_FS_COMMUNICATION_KIT_IMPL_API_H */

+ 159 - 0
vendor/bossay/common/communicationkit/native_utils/src/nativeapi_communication_kit.cpp

@@ -0,0 +1,159 @@
+/*
+ * 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 "nativeapi_communication_kit.h"
+#include "nativeapi_communication_kit_impl.h"
+
+#include <securec.h>
+#include "ability_env.h"
+#include "js_async_work.h"
+#include "nativeapi_common.h"
+#include "nativeapi_config.h"
+
+
+namespace OHOS {
+namespace ACELite {
+namespace {
+char g_kvFullPath[FILE_NAME_MAX_LEN + 1] = {0};
+
+bool IsValidKey(const char* key)
+{
+    if (key == nullptr) {
+        return false;
+    }
+    size_t keyLen = strnlen(key, KEY_MAX_LEN + 1);
+    if ((keyLen == 0) || (keyLen > KEY_MAX_LEN)) {
+        return false;
+    }
+    if (strpbrk(key, "/\\\"*+,:;<=>\?[]|\x7F")) {
+        return false;
+    }
+    return true;
+}
+
+JSIValue ExecuteAsyncWork(const JSIValue thisVal, const JSIValue* args,
+    uint8_t argsNum, AsyncWorkHandler ExecuteFunc, bool flag)
+{
+    JSIValue undefValue = JSI::CreateUndefined();
+    if (!NativeapiCommon::IsValidJSIValue(args, argsNum)) {
+        return undefValue;
+    }
+    FuncParams* params = new FuncParams();
+    if (params == nullptr) {
+        return undefValue;
+    }
+    params->thisVal = JSI::AcquireValue(thisVal);
+    params->args = JSI::AcquireValue(args[0]);
+    params->flag = flag;
+    JsAsyncWork::DispatchAsyncWork(ExecuteFunc, reinterpret_cast<void *>(params));
+    return undefValue;
+}
+
+void ExecuteGet(void* data)
+{
+    FuncParams* params = reinterpret_cast<FuncParams *>(data);
+    if (params == nullptr) {
+        return;
+    }
+
+    JSIValue args = params->args;
+    JSIValue thisVal = params->thisVal;
+    char* key = JSI::GetStringProperty(args, KV_KEY);
+    const char* dataPath = GetDataPath();
+    JSIValue result = JSI::CreateUndefined();
+    int ret = ERROR_CODE_GENERAL;
+    char* value = reinterpret_cast<char *>(malloc(VALUE_MAX_LEN + 1));
+    if (value == nullptr) {
+        NativeapiCommon::FailCallBack(thisVal, args, ret);
+        goto EXIT;
+    }
+
+    ret = GetCommunicationKitValue(key, value);
+
+    if (ret == ERROR_FR_NO_FILE) {
+        // GetDefault(thisVal, args);
+        goto EXIT;
+    }
+    if (ret != NATIVE_SUCCESS) {
+        NativeapiCommon::FailCallBack(thisVal, args, ret);
+        goto EXIT;
+    }
+    result = JSI::CreateString(value);
+    NativeapiCommon::SuccessCallBack(thisVal, args, result);
+EXIT:
+    free(value);
+    JSI::ReleaseString(key);
+    JSI::ReleaseValueList(args, thisVal, result, ARGS_END);
+    delete params;
+}
+
+void ExecuteSet(void* data)
+{
+    FuncParams* params = reinterpret_cast<FuncParams *>(data);
+    if (params == nullptr) {
+        return;
+    }
+
+    JSIValue args = params->args;
+    JSIValue thisVal = params->thisVal;
+    int ret = ERROR_CODE_GENERAL;
+
+    char* key = JSI::GetStringProperty(args, KV_KEY);
+    char* value = JSI::GetStringProperty(args, KV_VALUE);
+
+    LOG_I("JsSet:ExecuteSet::key=%s,value=%s\r\n",key,value);
+
+    if ((key == nullptr) || !strlen(key)) {
+        NativeapiCommon::FailCallBack(thisVal, args, ERROR_CODE_PARAM);
+        goto EXIT;
+    }
+    if ((value == nullptr) || !strlen(value)) {
+        NativeapiCommon::SuccessCallBack(thisVal, args, JSI::CreateUndefined());
+        goto EXIT;
+    }
+    ret = SetCommunicationKitValue(key, value);
+    if (ret != NATIVE_SUCCESS) {
+        NativeapiCommon::FailCallBack(thisVal, args, ret);
+        goto EXIT;
+    }
+    NativeapiCommon::SuccessCallBack(thisVal, args, JSI::CreateUndefined());
+    
+EXIT:
+    JSI::ReleaseString(key);
+    JSI::ReleaseString(value);
+    JSI::ReleaseValueList(args, thisVal, ARGS_END);
+    delete params;
+}
+
+}
+
+void InitNativeApiCommunicationKit(JSIValue exports)
+{
+    JSI::SetModuleAPI(exports, "get", NativeapiCommunicationKit::Get);
+    JSI::SetModuleAPI(exports, "set", NativeapiCommunicationKit::Set);
+}
+
+JSIValue NativeapiCommunicationKit::Get(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum)
+{
+    return ExecuteAsyncWork(thisVal, args, argsNum, ExecuteGet, false);
+}
+
+JSIValue NativeapiCommunicationKit::Set(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum)
+{
+    return ExecuteAsyncWork(thisVal, args, argsNum, ExecuteSet, false);
+}
+
+} // ACELite
+} // OHOS

+ 105 - 0
vendor/bossay/common/communicationkit/native_utils/src/nativeapi_communication_kit_impl.c

@@ -0,0 +1,105 @@
+/*
+ * 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 "nativeapi_communication_kit_impl.h"
+#include <ctype.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <securec.h>
+#include <stdbool.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "nativeapi_config.h"
+#if (defined _WIN32 || defined _WIN64)
+#include "shlwapi.h"
+#endif
+
+static JsCallClangFunctionDef g_jsGetClang = NULL;
+static JsCallClangFunctionDef g_jsSetClang = NULL;
+
+static bool IsValidValue(const char *value)
+{
+    if (value == NULL)
+    {
+        return false;
+    }
+    size_t valueLen = strnlen(value, VALUE_MAX_LEN + 1);
+    if ((valueLen == 0) || (valueLen > VALUE_MAX_LEN))
+    {
+        return false;
+    }
+    return true;
+}
+
+int GetCommunicationKitValue(const char *key, char *value)
+{
+    if ((key == NULL) || (value == NULL))
+    {
+        return ERROR_CODE_PARAM;
+    }
+    if (NULL != g_jsGetClang)
+    {
+        if (0 != g_jsGetClang(key, value))
+        {
+            LOG_E("g_jsGetClang error!\r\n");
+        }
+    }
+    else
+    {
+        LOG_I("If you want use js get c interface, you should use JsGetClangFuncationRegister function.\r\n");
+    }
+    return NATIVE_SUCCESS;
+}
+
+int SetCommunicationKitValue(const char *key, const char *value)
+{
+    if ((key == NULL) || (!IsValidValue(value)))
+    {
+        return ERROR_CODE_PARAM;
+    }
+    if (NULL != g_jsSetClang)
+    {
+        if (0 != g_jsSetClang(key, value))
+        {
+            LOG_E("g_jsSetClang error!\r\n");
+        }
+        LOG_I("CommunicationKit:SetJsonValue::entry--key=%s;value=%s.\r\n", key, value);
+    }
+    else
+    {
+        LOG_I("If you want use js set c interface, you should use JsSetClangFuncationRegister function.\r\n");
+    }
+    return NATIVE_SUCCESS;
+}
+
+void JsGetClangFuncationRegister(JsCallClangFunctionDef jsGetClang)
+{
+    g_jsGetClang = jsGetClang;
+}
+void JsSetClangFuncationRegister(JsCallClangFunctionDef jsSetClang)
+{
+    g_jsSetClang = jsSetClang;
+}
+
+void JsGetClangFuncationUnregister(void)
+{
+    g_jsGetClang = NULL;
+}
+void JsSetClangFuncationUnregister(void)
+{
+    g_jsSetClang = NULL;
+}

+ 24 - 0
vendor/bossay/common/hals/BUILD.gn

@@ -0,0 +1,24 @@
+# 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",
+    ]
+}

+ 51 - 0
vendor/bossay/common/hals/src/peripheral_hal.c

@@ -0,0 +1,51 @@
+/*
+ * 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);
+}

+ 24 - 0
vendor/bossay/common/hals/src/utils_hal.c

@@ -0,0 +1,24 @@
+/*
+ * 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);
+}

+ 30 - 0
vendor/bossay/common/inc/flower.h

@@ -0,0 +1,30 @@
+/*
+ * 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__

+ 94 - 0
vendor/bossay/common/inc/iot_adc.h

@@ -0,0 +1,94 @@
+/*
+ * 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
+/** @} */

+ 31 - 0
vendor/bossay/common/inc/iot_boardbutton.h

@@ -0,0 +1,31 @@
+/*
+ * 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_ */

+ 43 - 0
vendor/bossay/common/inc/iot_boardbutton_xradio.h

@@ -0,0 +1,43 @@
+/*
+ * 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_ */

+ 61 - 0
vendor/bossay/common/inc/iot_boardled.h

@@ -0,0 +1,61 @@
+/*
+ * 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__ */

+ 48 - 0
vendor/bossay/common/inc/iot_boardled_xradio.h

@@ -0,0 +1,48 @@
+/*
+ * 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__ */

+ 123 - 0
vendor/bossay/common/inc/iot_cloud.h

@@ -0,0 +1,123 @@
+/*
+ * 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 <stdbool.h>
+#include <iot_demo_def.h>
+
+/**
+ * @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);
+
+
+
+int CLOUD_GetCloudConnectedStatus(void);
+
+#endif /* __IOT_CLOUD_H__ */
+

+ 61 - 0
vendor/bossay/common/inc/iot_demo_def.h

@@ -0,0 +1,61 @@
+/*
+ * 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
+
+#define DISABLE_LEVEL LOG_LEVEL_INFO
+
+#ifdef RAISE_LOG
+#define RaiseLog(level,fmt, ...) \
+    do \
+    { \
+       if(level < DISABLE_LEVEL) break;\
+        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__ */

+ 340 - 0
vendor/bossay/common/inc/iot_gpio_ex.h

@@ -0,0 +1,340 @@
+/*
+ * 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
+/** @} */

+ 78 - 0
vendor/bossay/common/inc/iot_i2c_ex.h

@@ -0,0 +1,78 @@
+/*
+ * 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
+/** @} */

+ 37 - 0
vendor/bossay/common/inc/iot_list.h

@@ -0,0 +1,37 @@
+/*
+ * 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__ */

+ 35 - 0
vendor/bossay/common/inc/iot_netcfg.h

@@ -0,0 +1,35 @@
+/*
+ * 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__ */

+ 81 - 0
vendor/bossay/common/inc/iot_netcfg_nan.h

@@ -0,0 +1,81 @@
+/*
+ * 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
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+void NetCfgRegister(void);
+
+/**
+ * @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__

+ 44 - 0
vendor/bossay/common/inc/iot_nfc.h

@@ -0,0 +1,44 @@
+/*
+ * 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__ */

+ 39 - 0
vendor/bossay/common/inc/iot_schedule.h

@@ -0,0 +1,39 @@
+/*
+ * 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__ */

+ 52 - 0
vendor/bossay/common/inc/iot_sntp.h

@@ -0,0 +1,52 @@
+/*
+ * 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 <time.h>
+
+/**
+ * @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 */

+ 40 - 0
vendor/bossay/common/inc/iot_softap.h

@@ -0,0 +1,40 @@
+/*
+ * 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__ */

+ 40 - 0
vendor/bossay/common/inc/iot_softap_xradio.h

@@ -0,0 +1,40 @@
+/*
+ * 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__ */

+ 368 - 0
vendor/bossay/common/inc/iot_spi.h

@@ -0,0 +1,368 @@
+/*
+ * 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 <b>byteLen</b> in <b>writeData</b> through
+ * the channel specified by <b>spiId</b> within the duration <b>timeOutMs</b>.
+ *
+ * @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 <b>byteLen</b> in <b>readData</b> through the channel
+ * specified by <b>spiId</b> within the duration <b>timeOutMs</b>.
+ *
+ * @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 <b>byteLen</b> in <b>writeData</b>
+ * through the channel specified by <b>spiId</b>.
+ *
+ * @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 <b>byteLen</b> in <b>readData</b>
+ * through the channel specified by <b>spiId</b>.
+ *
+ * @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 <b>writeData</b> and
+ * reads data of the length specified by <b>byteLen</b> in <b>readData</b>
+ * both through the channel specified by <b>spiId</b>.
+ *
+ * @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 <b>spiId</b>,
+ * device type <b>initParam</b>, and device parameter <b>param</b>.
+ *
+ * @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 <b>1</b> means to enable IRQ, and <b>0</b> 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 <b>1</b> means to enable DMA, and <b>0</b> 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 <b>prepareF</b> and <b>restoreF</b> for
+ * an SPI device with a channel specified by <b>spiId</b>.
+ *
+ * @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 <b>1</b>
+ * means to enable loopback test, and <b>0</b> 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
+/** @} */

+ 38 - 0
vendor/bossay/common/inc/iot_store_manager.h

@@ -0,0 +1,38 @@
+
+/*
+ * 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__ */

+ 41 - 0
vendor/bossay/common/inc/iot_wifi.h

@@ -0,0 +1,41 @@
+/*
+ * 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);
+
+int BOARD_GetWifiSignalLevel(void);
+
+#endif /* IOT_WIFI_H_ */

+ 39 - 0
vendor/bossay/common/inc/iot_wifi_xradio.h

@@ -0,0 +1,39 @@
+/*
+ * 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_ */

+ 375 - 0
vendor/bossay/common/inc/network_config_service.h

@@ -0,0 +1,375 @@
+/*
+ * 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 <b>NetcfgService</b> module.
+ *
+ * You can use the functions to: \n
+ * <ul>
+ *   <li>Start the network configuration service.</li>
+ *   <li>Stop the network configuration service.</li>
+ *   <li>Register callbacks for events of the network configuration service.</li>
+ *   <li>Notify the network configuration result.</li>
+ * </ul>
+ *
+ * @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 <b>NetcfgService</b> 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 <b>PWD_MAX_LEN</b>.
+     */
+    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 <b>WEP</b>, <b>WPA2-PSK</b>, or both.
+     */
+    int authType;
+    /** (Optional) Encryption type.
+     * Currently, <b>UNKNOWN</b>, <b>AES</b>, <b>TKIP</b>, and <b>TKIP and AES</b> encryption types are supported.
+     */
+    int pairwise;
+    /** (Optional) Whether to hide the SSID.
+     * <b>0</b> means not to hide the SSID, and <b>1</b> means to hide the SSID.
+     */
+    int isHidden;
+    /** (Optional) Working channel required in the SoftAP mode
+     * <b>0</b>: The channel is specified by the system. <b>1</b> to <b>14</b>: 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 <b>WEP</b>, <b>WPA2-PSK</b>, 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 <b>svcId</b> parameter is reserved for device compatibility. The default value is <b>NULL</b>.
+     * The <b>mode</b> parameter is reserved. The default value is <b>0</b>.
+     */
+    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
+     * <b>status</b> indicates the network configuration status. \n
+     * The value <b>0</b> means to stop buzzing or blinking. \n
+     * The value <b>1</b> means to start buzzing or blinking. \n
+     * The value <b>2</b> 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 <b>errCode</b> values are as follows: \n
+     * <b>0</b>: The application fails to receive the network configuration data. \n
+     *           The network configuration service automatically starts. \n
+     * <b>1</b>: 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 <b>-70</b>, <b>-67</b>, <b>-65</b>, <b>-63</b>, <b>-61</b>, <b>-58</b>, <b>-55</b>, \n
+ *        <b>-52</b>, <b>-48</b>, <b>-45</b>, or <b>-42</b>. 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 surface (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

+ 175 - 0
vendor/bossay/common/inc/peripheral_hal.h

@@ -0,0 +1,175 @@
+/*
+ * 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

+ 46 - 0
vendor/bossay/common/inc/schedule_list.h

@@ -0,0 +1,46 @@
+/*
+ * 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__ */

+ 49 - 0
vendor/bossay/common/inc/schedule_store.h

@@ -0,0 +1,49 @@
+/*
+ * 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__ */

+ 21 - 0
vendor/bossay/common/inc/utils_hal.h

@@ -0,0 +1,21 @@
+/*
+ * 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__

+ 30 - 0
vendor/bossay/common/iot_boardbutton/BUILD.gn

@@ -0,0 +1,30 @@
+# 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("iot_boardbutton") {
+    sources = [
+        "iot_boardbutton.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "../inc",
+    ]
+
+    deps = [ ]
+
+}

+ 122 - 0
vendor/bossay/common/iot_boardbutton/iot_boardbutton.c

@@ -0,0 +1,122 @@
+/*
+ * 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 "iot_boardbutton.h"
+#include "cmsis_os2.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "ohos_init.h"
+
+typedef enum {
+    BUTTON_ID_F1 = 0,
+    BUTTON_ID_F2,
+    BUTTON_ID_MAX,
+}ButtonID;
+
+typedef struct {
+    ButtonPressedCallback callback;
+    char *args;
+}ButtonCallBackController;
+
+typedef struct {
+    ButtonCallBackController controller[BUTTON_ID_MAX];
+}ButtonController;
+static ButtonController g_buttonController;
+
+
+
+#define BUTTON_F1_GPIO 11
+#define BUTTON_F2_GPIO 12
+
+/**
+ * @brief Callback for F1 key
+ *
+ */
+static void F1Pressed(char* arg)
+{
+    (void)arg;
+    printf("%s:pressed \r\n", __FUNCTION__);
+    if (g_buttonController.controller[BUTTON_ID_F1].callback != NULL) {
+        g_buttonController.controller[BUTTON_ID_F1].callback(arg);
+    }
+}
+
+/**
+ * @brief Callback for F2 key
+ *
+ */
+static void F2Pressed(char* arg)
+{
+    printf("%s:pressed \r\n", __FUNCTION__);
+    if (g_buttonController.controller[BUTTON_ID_F2].callback != NULL) {
+        g_buttonController.controller[BUTTON_ID_F2].callback(arg);
+    }
+}
+
+int Board_IsButtonPressedF2(void)
+{
+    int value = 1;
+    int tmcnt = 10;
+
+    IoTGpioInit(BUTTON_F2_GPIO);
+    IoTGpioSetFunc(BUTTON_F2_GPIO, IOT_GPIO_FUNC_GPIO_12_GPIO);
+    IoTGpioSetDir(BUTTON_F2_GPIO, IOT_GPIO_DIR_IN);
+
+    while (--tmcnt > 0) {
+        osDelay(20);
+        if (IoTGpioGetInputVal(BUTTON_F2_GPIO, &value) != 0) {
+            printf("[ERROR][%s|%d] IoTGpioGetInputVal failed! \n", __func__, __LINE__);
+            break;
+        }
+        if (value) {
+            break;
+        }
+    }
+
+    return value ? 0 : 1;
+}
+
+int Board_InitButtonF1(ButtonPressedCallback callback, char *arg)
+{
+    g_buttonController.controller[BUTTON_ID_F1].callback = callback;
+    g_buttonController.controller[BUTTON_ID_F1].args = arg;
+    // init gpio of F1 key and set it as the falling edge to trigger interrupt
+    IoTGpioInit(BUTTON_F1_GPIO);
+    IoTGpioSetFunc(BUTTON_F1_GPIO, IOT_GPIO_FUNC_GPIO_11_GPIO);
+    IoTGpioSetDir(BUTTON_F1_GPIO, IOT_GPIO_DIR_IN);
+    IoTGpioSetPull(BUTTON_F1_GPIO, IOT_GPIO_PULL_UP);
+    IoTGpioRegisterIsrFunc(BUTTON_F1_GPIO, IOT_INT_TYPE_EDGE, IOT_GPIO_EDGE_FALL_LEVEL_LOW, F1Pressed, NULL);
+
+    return 0;
+}
+
+int Board_InitButtonF2(ButtonPressedCallback callback, char *arg)
+{
+    g_buttonController.controller[BUTTON_ID_F2].callback = callback;
+    g_buttonController.controller[BUTTON_ID_F2].args = arg;
+    // init gpio of F2 key and set it as the falling edge to trigger interrupt
+    IoTGpioInit(BUTTON_F2_GPIO);
+    IoTGpioSetFunc(BUTTON_F2_GPIO, IOT_GPIO_FUNC_GPIO_12_GPIO);
+    IoTGpioSetDir(BUTTON_F2_GPIO, IOT_GPIO_DIR_IN);
+    IoTGpioSetPull(BUTTON_F2_GPIO, IOT_GPIO_PULL_UP);
+    IoTGpioRegisterIsrFunc(BUTTON_F2_GPIO, IOT_INT_TYPE_EDGE, IOT_GPIO_EDGE_FALL_LEVEL_LOW, F2Pressed, NULL);
+
+    return 0;
+}
+
+
+
+
+

+ 35 - 0
vendor/bossay/common/iot_boardbutton_xradio/BUILD.gn

@@ -0,0 +1,35 @@
+# 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.
+
+source_set("iot_boardbutton") {
+    sources = [
+        "iot_boardbutton_xradio.c"
+    ]
+
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//kernel/liteos_m/kal/cmsis",
+        "../inc",
+        "../hals/inc",
+        "//drivers/framework/include/platform",
+        "//drivers/framework/include/utils",
+        "//drivers/adapter/khdf/liteos_m/osal/include",
+        "//drivers/framework/include/core",
+        "//drivers/framework/include/osal"
+    ]
+
+}

+ 180 - 0
vendor/bossay/common/iot_boardbutton_xradio/iot_boardbutton_xradio.c

@@ -0,0 +1,180 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <os_thread.h>
+
+#include "iot_boardbutton_xradio.h"
+#include "gpio_if.h"
+#include "cmsis_os2.h"
+#include "ohos_init.h"
+
+#define KEY_OK      1
+#define TASK_SIZE   1024
+#define LONG_PRESS_TIME 2000
+
+#define USER_DEF    0
+#define USER_XR     1
+
+#define CS_SELECT   USER_XR
+
+#if (CS_SELECT == USER_XR)
+#define KEY_BUTTON_IO   11
+#else
+#define KEY_BUTTON_IO   0
+#endif
+
+#define SLEEP_10MS              10000
+#define SLEEP_100MS             100000
+#define MINISECONDS_IN_SECOND   1000
+
+#define BTTN_DBG(fmt, arg...)   printf("[%s|%d][BUTTON_DEBUG]" fmt, __func__, __LINE__, ##arg)
+#define BTTN_ERR(fmt, arg...)   printf("[%s|%d][BUTTON_ERROR]" fmt, __func__, __LINE__, ##arg)
+
+static ButtonPressedCallback g_ButtonPressedCallback = NULL;
+static unsigned char g_button_state = BUTTON_INVALID;
+static OS_Thread_t g_button_thread;
+
+static unsigned long GetMillionSecond(void)
+{
+    struct  timeval tv;
+
+    gettimeofday(&tv, NULL);
+
+    return tv.tv_sec * MINISECONDS_IN_SECOND + tv.tv_usec / MINISECONDS_IN_SECOND;        // 1000 is millionsecond
+}
+
+static int KeyIrqCallback(int gpio, void *arg)
+{
+    BTTN_DBG("KeyIrqCallback! gpio = %d \n", gpio);
+    return 0;
+}
+
+static int g_threadRunning = 0;
+
+static void ButtonEventThread(void *arg)
+{
+    ButtonEvent *event = (ButtonEvent *)arg;
+    if (g_ButtonPressedCallback != NULL) {
+        g_ButtonPressedCallback(event);
+    }
+    g_threadRunning = 0;
+    BTTN_DBG("g_threadRunning = %d \n", g_threadRunning);
+}
+
+static void ButtonEventHandle(ButtonEvent *event)
+{
+    BTTN_DBG("g_threadRunning = %d \n", g_threadRunning);
+    if (g_threadRunning == 0) {
+        const int priority = 25;
+        const int stack_size = (1024 * 2);
+        osThreadAttr_t attr;
+        attr.attr_bits = 0U;
+        attr.cb_mem = NULL;
+        attr.cb_size = 0U;
+        attr.stack_mem = NULL;
+        attr.stack_size = stack_size;
+        attr.priority = priority;
+        attr.name = "ButtonEventThread";
+        g_threadRunning = 1;
+        if (osThreadNew((osThreadFunc_t)ButtonEventThread, event, (const osThreadAttr_t *)&attr) == NULL) {
+            BTTN_ERR("create ButtonEventThread failed! \n");
+            g_threadRunning = 0;
+            return;
+        }
+    }
+}
+
+static void ButtonProcess(void *args)
+{
+    unsigned long pressTime = 0;
+    ButtonEvent event;
+
+    GpioSetIrq(KEY_BUTTON_IO, GPIO_IRQ_TRIGGER_FALLING, KeyIrqCallback, NULL);
+    GpioEnableIrq(KEY_BUTTON_IO);
+    while (1) {
+        int value = 0;
+        if (GpioRead(KEY_BUTTON_IO, &value) < 0) {
+            BTTN_ERR("read io(%d) failed! \n", KEY_BUTTON_IO);
+            sleep(1);
+            continue;
+        }
+
+        if (value == 0) {   // button pressed!
+            if (g_button_state == BUTTON_PRESS) {
+                if (pressTime == 0) {
+                    pressTime = GetMillionSecond();
+                }
+                if ((GetMillionSecond() - pressTime) >= LONG_PRESS_TIME) {
+                    event.button_id = KEY_BUTTON_IO;
+                    event.value = BUTTON_LONG_PRESS;
+                    g_button_state = BUTTON_LONG_PRESS;
+                    ButtonEventHandle(&event);
+                }
+            } else {
+                if (g_button_state != BUTTON_LONG_PRESS) {
+                    g_button_state = BUTTON_PRESS;
+                }
+            }
+        } else {    // button release or no button pressed!
+            if (g_button_state == BUTTON_PRESS) {
+                event.button_id = KEY_BUTTON_IO;
+                event.value = BUTTON_PRESS;
+                ButtonEventHandle(&event);
+            }
+            if (g_button_state != BUTTON_RELEASE) {
+                pressTime = 0;
+                g_button_state = BUTTON_RELEASE;
+            }
+        }
+        usleep(SLEEP_10MS);
+    }
+}
+
+int Board_ButtonInit(ButtonPressedCallback callback)
+{
+    g_ButtonPressedCallback = callback;
+    if (OS_ThreadCreate(&g_button_thread, "ButtonProcess", ButtonProcess,
+        NULL, OS_THREAD_PRIO_APP, TASK_SIZE) != OS_OK) {
+        BTTN_ERR("OS_ThreadCreate failed! \n");
+        return -1;
+    }
+    return 0;
+}
+
+int Board_IsButtonPressed(void)
+{
+    int tmCount = 20;
+    int result = 1;
+    while (tmCount-- > 0) {
+        int value = 0;
+        if (GpioRead(KEY_BUTTON_IO, &value) < 0) {
+            BTTN_ERR("read io(%d) failed! \n", KEY_BUTTON_IO);
+            result = 0;
+            break;
+        }
+        if (value == 1) {
+            BTTN_DBG("key have not pressed!\n");
+            result = 0;
+            break;
+        }
+        usleep(SLEEP_100MS);
+    }
+
+    return result;
+}

+ 30 - 0
vendor/bossay/common/iot_boardled/BUILD.gn

@@ -0,0 +1,30 @@
+# 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("iot_boardled") {
+    sources = [
+        "iot_boardled.c",
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "../inc",
+    ]
+
+    deps = [ ]
+
+}

+ 168 - 0
vendor/bossay/common/iot_boardled/iot_boardled.c

@@ -0,0 +1,168 @@
+/*
+ * 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 "iot_demo_def.h"
+#include "iot_boardled.h"
+#include "iot_gpio.h"
+#include "iot_gpio_ex.h"
+#include "iot_pwm.h"
+#include "ohos_init.h"
+#include <cmsis_os2.h>
+
+
+#define DEVICE_STATUS_LED_GPIO  2
+#define DEVICE_SATTUS_LED_PWD   2
+#define CONFIG_FLASHLED_FREDEFAULT 5
+  
+/**
+ * @brief Initialize the board pwd led
+ * @return Returns 0 success while others failed
+ */
+int BOARD_InitPwmLed(void)
+{
+    IoTGpioInit(DEVICE_STATUS_LED_GPIO);
+    IoTGpioSetFunc(DEVICE_STATUS_LED_GPIO, IOT_GPIO_FUNC_GPIO_2_PWM2_OUT);
+    IoTGpioSetDir(DEVICE_STATUS_LED_GPIO, IOT_GPIO_DIR_OUT);
+    IoTPwmInit(DEVICE_SATTUS_LED_PWD);
+
+    return 0;
+}
+
+/**
+ * @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_SetPwmLedDutyCycle(int dutyCycle)
+{
+    dutyCycle = dutyCycle < 0 ? 1 : dutyCycle;
+    dutyCycle = dutyCycle >= 100 ? 99 : dutyCycle;
+    IoTPwmStart(DEVICE_STATUS_LED_GPIO, dutyCycle, 40000);
+    return 0;
+}
+
+// the led part
+int BOARD_InitIoLed(void)
+{
+    //设置GPIO_2的复用功能为普通GPIO
+    IoTGpioSetFunc(DEVICE_STATUS_LED_GPIO, IOT_GPIO_FUNC_GPIO_2_GPIO);
+    //设置GPIO_2为输出模式
+    IoTGpioSetDir(DEVICE_STATUS_LED_GPIO, IOT_GPIO_DIR_OUT);
+    return 0;
+}
+
+int BOARD_SetIoLedStatus(int status)
+{
+    if (status) {
+        IoTGpioSetOutputVal(DEVICE_STATUS_LED_GPIO, 1);
+    } else {
+        IoTGpioSetOutputVal(DEVICE_STATUS_LED_GPIO, 0);
+    }
+    return 0;
+}
+
+
+#define CONFIG_TASK_MAIN_STACKSIZE 0x800                 // main task stacksize must be bigger
+#define CONFIG_TASK_MAIN_PRIOR 22                        // default task priority
+
+/**
+ * @brief Convert miniseconds to system ticks
+ * @param ms Indicates the mimiseconds to convert
+ * @return Returns the corresponding ticks of specified time
+ */
+static uint32_t Time2Tick(uint32_t ms)
+{
+    uint64_t ret;
+    ret = ((uint64_t)ms * osKernelGetTickFreq()) / CN_MINISECONDS_IN_SECOND;
+    return (uint32_t)ret;
+}
+
+
+/**
+ @ brief Set the main task flash frequency
+ */
+
+typedef struct
+{
+    int cycleTicks;
+    int cycleLightTicks;
+    osThreadId_t taskID;
+}LedFlashController;
+static LedFlashController g_ledFlashController;
+
+#define CN_LED_FLASH_HIGHBASE  200
+#define CN_LED_FLASH_CYCLEBASE 1000
+int LedFlashFrequencySet(float flashHz)
+{
+    int cycleHighMs = 0;
+    int cycleMs = 0;
+
+    cycleMs = (int)(CN_MINISECONDS_IN_SECOND / flashHz);
+    cycleHighMs = cycleMs *CN_LED_FLASH_HIGHBASE /CN_LED_FLASH_CYCLEBASE;
+
+    g_ledFlashController.cycleTicks = Time2Tick(cycleMs);
+    g_ledFlashController.cycleLightTicks = Time2Tick(cycleHighMs);
+    RaiseLog(LOG_LEVEL_INFO, "cycle:%d cycleon:%d ",g_ledFlashController.cycleTicks, g_ledFlashController.cycleLightTicks);
+    return 0;
+}
+
+
+int LedFlashTaskDeinit(void)
+{
+    osThreadTerminate(g_ledFlashController.taskID);
+    g_ledFlashController.taskID = NULL;
+    return 0;
+}
+
+/**
+ * @brief LED flashing task entry
+ */
+static void LedTaskEntry(const void *arg)
+{
+    (void)arg;
+    BOARD_InitIoLed();
+    LedFlashFrequencySet(CONFIG_FLASHLED_FREDEFAULT);
+    while (1) {
+        BOARD_SetIoLedStatus(CN_BOARD_SWITCH_ON);
+        osDelay((uint32_t)g_ledFlashController.cycleLightTicks);
+        BOARD_SetIoLedStatus(CN_BOARD_SWITCH_OFF);
+        osDelay((uint32_t)(g_ledFlashController.cycleTicks - g_ledFlashController.cycleLightTicks));
+    }
+    return;
+}
+
+static void LedFlashTaskInit(void)
+{
+    osThreadAttr_t attr;
+    RaiseLog(LOG_LEVEL_INFO, "DATA:%s Time:%s \r\n", __DATE__, __TIME__);
+    // Create the IoT Main task
+    attr.attr_bits = 0U;
+    attr.cb_mem = NULL;
+    attr.cb_size = 0U;
+    attr.stack_mem = NULL;
+    attr.stack_size = CONFIG_TASK_MAIN_STACKSIZE;
+    attr.priority = CONFIG_TASK_MAIN_PRIOR;
+    attr.name = "LedFlashTask";
+    g_ledFlashController.taskID =  osThreadNew((osThreadFunc_t)LedTaskEntry, NULL, (const osThreadAttr_t *)&attr);
+    if (g_ledFlashController.taskID == NULL) {
+        RaiseLog(LOG_LEVEL_ERR, "Create the LED FLASH TASK failed");
+    } else {
+        RaiseLog(LOG_LEVEL_INFO, "Create the LED FLASH TASK success");
+    }
+
+    return;
+}
+
+APP_FEATURE_INIT(LedFlashTaskInit);

+ 30 - 0
vendor/bossay/common/iot_boardled_xradio/BUILD.gn

@@ -0,0 +1,30 @@
+# 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("iot_boardled_xradio") {
+    sources = [
+        "iot_boardled_xradio.c"
+    ]
+
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "../inc",
+    ]
+
+    deps = [ ]
+
+}

+ 119 - 0
vendor/bossay/common/iot_boardled_xradio/iot_boardled_xradio.c

@@ -0,0 +1,119 @@
+/*
+ * 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 "iot_demo_def.h"
+#include "iot_boardled_xradio.h"
+#include "ohos_init.h"
+#include <cmsis_os2.h>
+
+#define DEVICE_STATUS_LED_GPIO  21      // PA21
+
+// the led part
+int BOARD_InitIoLed(void)
+{
+    printf("LED INIT! \n");
+    return 0;
+}
+
+int BOARD_SetIoLedStatus(int status)
+{
+    if (status) {
+        GpioWrite(DEVICE_STATUS_LED_GPIO, 1);
+    } else {
+        GpioWrite(DEVICE_STATUS_LED_GPIO, 0);
+    }
+    return 0;
+}
+
+#define CONFIG_TASK_MAIN_STACKSIZE 0x800                 // main task stacksize must be bigger
+#define CONFIG_TASK_MAIN_PRIOR 22                        // default task priority
+
+/**
+ @ brief Set the main task flash frequency
+ */
+
+typedef struct {
+    int mode;
+    osThreadId_t taskID;
+}LedFlashController;
+static LedFlashController g_ledFlashController;
+
+int LedFlashFrequencySet(LED_FLASH_MODE mode)
+{
+    g_ledFlashController.mode = mode;
+
+    return 0;
+}
+
+int LedFlashTaskDeinit(void)
+{
+    osThreadTerminate(g_ledFlashController.taskID);
+    g_ledFlashController.taskID = NULL;
+    return 0;
+}
+
+/**
+ * @brief LED flashing task entry
+ */
+static void LedTaskEntry(const void *arg)
+{
+    const int ledFlashTime[LED_FLASH_MAX] = {
+        100000, 300000, 500000, 1000000, 5000000
+    };
+    (void)arg;
+    BOARD_InitIoLed();
+    LedFlashFrequencySet(LED_FLASH_FAST_PLUGS);
+    while (1) {
+        if (g_ledFlashController.mode > LED_FLASH_SLOW_PLUGS) {
+            g_ledFlashController.mode = LED_FLASH_SLOW_PLUGS;
+        }
+        BOARD_SetIoLedStatus(CN_BOARD_SWITCH_ON);
+        if (g_ledFlashController.mode == LED_FLASH_SLOW_PLUGS) {
+            usleep(ledFlashTime[LED_FLASH_SLOW]);
+        } else {
+            usleep(ledFlashTime[g_ledFlashController.mode]);
+        }
+        BOARD_SetIoLedStatus(CN_BOARD_SWITCH_OFF);
+        usleep(ledFlashTime[g_ledFlashController.mode]);
+    }
+    return;
+}
+
+static void LedFlashTaskInit(void)
+{
+    osThreadAttr_t attr;
+    RaiseLog(LOG_LEVEL_INFO, "DATA:%s Time:%s \r\n", __DATE__, __TIME__);
+    // Create the IoT Main task
+    attr.attr_bits = 0U;
+    attr.cb_mem = NULL;
+    attr.cb_size = 0U;
+    attr.stack_mem = NULL;
+    attr.stack_size = CONFIG_TASK_MAIN_STACKSIZE;
+    attr.priority = CONFIG_TASK_MAIN_PRIOR;
+    attr.name = "LedFlashTask";
+    g_ledFlashController.taskID =  osThreadNew((osThreadFunc_t)LedTaskEntry, NULL, (const osThreadAttr_t *)&attr);
+    if (g_ledFlashController.taskID == NULL) {
+        RaiseLog(LOG_LEVEL_ERR, "Create the LED FLASH TASK failed");
+    } else {
+        RaiseLog(LOG_LEVEL_INFO, "Create the LED FLASH TASK success");
+    }
+
+    return;
+}
+
+void LedFlashTaskStart(void)
+{
+    LedFlashTaskInit();
+}

+ 37 - 0
vendor/bossay/common/iot_cloud/BUILD.gn

@@ -0,0 +1,37 @@
+# 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("iot_cloud") {
+    sources = [
+        "iot_cloud.c",
+        "iot_profile_package.c"
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//third_party/cJSON",
+        "//third_party/iot_link/inc",
+        "//third_party/iot_link/oc_mqtt/oc_mqtt_al",
+        "//third_party/iot_link/oc_mqtt/oc_mqtt_profile_v5",
+        "//third_party/iot_link/queue",
+        "../inc",
+    ]
+
+    deps = [ 
+             "//third_party/iot_link:iot_link",
+    ]
+
+}

+ 350 - 0
vendor/bossay/common/iot_cloud/iot_cloud.c

@@ -0,0 +1,350 @@
+/*
+ * 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 "iot_cloud.h"
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "ohos_init.h"
+#include "cmsis_os2.h"
+#include <cJSON.h>
+#include <dtls_al.h>
+#include <mqtt_al.h>
+#include <oc_mqtt_al.h>
+#include <oc_mqtt_profile.h>
+#include <queue.h>
+
+
+
+
+// we use this function to send the data here
+extern int OcMqttReportString(char *deviceID, const char *jsonString);
+extern int OcMqttMsgUpString(char *deviceID, const char *jsonString);
+typedef enum {
+    EN_MSG_TYPE_CMD = 0,
+    EN_MSG_TYPE_REPORT,
+    EN_MSG_TYPE_CONN,
+    EN_MSG_TYPE_DISCONN,
+    EN_MSG_TYPE_NOTIFY,
+}CloudMsgType;
+
+typedef struct
+{
+    char *requestID;
+    char *payload;
+}CloudCommandMsg;
+
+typedef struct {
+    char *jsonString;
+}CloudReportMsg;
+
+typedef struct {
+    CloudMsgType msgType;
+    union {
+        CloudCommandMsg cmd;
+        CloudReportMsg report;
+        CloudReportMsg notify;
+    }msg;
+}ApplicationMsg;
+
+typedef struct
+{
+    osMessageQueueId_t           applicationMsgQueue;
+    int                          connected;
+    osThreadId_t                 mainTaskID;
+}CloudController;
+
+
+#define CONFIG_APP_LIFETIME       60     ///< seconds
+#define CONFIG_QUEUE_GET_TIMEOUT      0xffffffff
+#define CONFIG_QUEUE_PUSH_TIMEOUT   5000
+#define CLOUD_TASK_DELAY        40
+#define MSGQUEUE_OBJECTS 10
+
+
+
+static CloudController  g_cloudController;
+
+static void HuaweiIoTSDKInit(void)
+{
+    dtls_al_init();
+    mqtt_al_init();
+    oc_mqtt_init();
+}
+
+/**
+ * @brief This function used to report the data to the cloud
+ *
+*/
+static void DealReportMsg(CloudReportMsg *reportMsg)
+{
+    OcMqttReportString(NULL, reportMsg->jsonString);
+    return;
+}
+
+static void DealNotificationMsg(CloudReportMsg *notifyMsg)
+{
+    OcMqttMsgUpString(NULL, notifyMsg->jsonString);
+}
+
+static void DealCommandMsg(CloudCommandMsg *cmd);
+
+
+/**
+ * @brief This function used to deal with message received from the cloud
+ *        we package the received data to the queue to do next step
+*/
+static int CloudMsgRcvCallBack(oc_mqtt_profile_msgrcv_t *msg)
+{
+    int    ret = 0;
+    char  *buf = NULL;
+    int    bufLen;
+    ApplicationMsg *applicationMsg = NULL;
+
+    if ((NULL == msg) || (msg->request_id == NULL) || (msg->type != EN_OC_MQTT_PROFILE_MSG_TYPE_DOWN_COMMANDS)) {
+        RaiseLog(LOG_LEVEL_WARN,"Parameter is wrong format\n");
+        return ret;
+    }
+
+    bufLen = sizeof(ApplicationMsg) + strlen(msg->request_id) + 1 + msg->msg_len + 1;
+    buf = malloc(bufLen);
+    if (NULL == buf) {
+        RaiseLog(LOG_LEVEL_ERR,"No memory for the command buffer\n");
+        return ret;
+    }
+    applicationMsg = (ApplicationMsg *)buf;
+    buf += sizeof(ApplicationMsg);
+
+    applicationMsg->msgType = EN_MSG_TYPE_CMD;
+    applicationMsg->msg.cmd.requestID = buf;
+    bufLen = strlen(msg->request_id);
+    buf += bufLen + 1;
+    memcpy(applicationMsg->msg.cmd.requestID, msg->request_id, bufLen);
+    applicationMsg->msg.cmd.requestID[bufLen] = '\0';
+    bufLen = msg->msg_len;
+    applicationMsg->msg.cmd.payload = buf;
+    memcpy(applicationMsg->msg.cmd.payload, msg->msg, bufLen);
+    applicationMsg->msg.cmd.payload[bufLen] = '\0';
+    RaiseLog(LOG_LEVEL_INFO,"GetCommand:reqID:%s payload:%s \n", \
+            applicationMsg->msg.cmd.requestID,  applicationMsg->msg.cmd.payload);
+
+    ret = osMessageQueuePut(g_cloudController.applicationMsgQueue,(void**)&applicationMsg,NULL,CONFIG_QUEUE_PUSH_TIMEOUT);
+    if (ret != 0){
+        free(applicationMsg);
+        RaiseLog(LOG_LEVEL_ERR,"Push the message to the queue failed");
+    }
+    return ret;
+}
+
+static void DealCommandMsg(CloudCommandMsg *cmd)
+{
+    oc_mqtt_profile_cmdresp_t cmdresp;
+
+    int ret = CLOUD_CommandCallBack((const char *)(cmd->payload));
+    ///< do the response
+    cmdresp.paras = NULL;
+    cmdresp.request_id = cmd->requestID;
+    cmdresp.ret_code = (ret == 0 ? 0 : 1);
+    cmdresp.ret_name = NULL;
+    (void)oc_mqtt_profile_cmdresp(NULL, &cmdresp);
+    return;
+}
+
+/**
+ * @brief this is the cloud main task entry
+ *        we deal all the message in the queue
+*/
+static int CloudMainTaskEntry(void *arg)
+{
+    ApplicationMsg* applicationMsg = NULL;
+    uint32_t ret ;
+    // receive the message from the queue ,maybe receive from the clould, or maybe from the local
+    while (1) {
+        applicationMsg = NULL;
+        (void)osMessageQueueGet(g_cloudController.applicationMsgQueue,(void **)&applicationMsg,NULL,CONFIG_QUEUE_GET_TIMEOUT);
+        if (applicationMsg != NULL) {
+            RaiseLog(LOG_LEVEL_INFO,"GetMsgType:%d",applicationMsg->msgType);
+            switch (applicationMsg->msgType){
+                case EN_MSG_TYPE_CMD:
+                    DealCommandMsg(&applicationMsg->msg.cmd);
+                    break;
+                case EN_MSG_TYPE_REPORT:
+                    DealReportMsg(&applicationMsg->msg.report);
+                    break;
+                case EN_MSG_TYPE_NOTIFY:
+                    DealNotificationMsg(&applicationMsg->msg.notify);
+                    break;
+                default:
+                    break;
+            }
+            free(applicationMsg);
+        }else {
+            RaiseLog(LOG_LEVEL_INFO,"osMessageQueueGet failed");
+        }
+        osDelay(CLOUD_TASK_DELAY);
+    }
+    return 0;
+}
+
+
+int CLOUD_Init(void)
+{
+    int ret = -1;
+    /* create a queue to buffer the data */
+    printf("Could init begin\n");
+    g_cloudController.applicationMsgQueue = osMessageQueueNew(MSGQUEUE_OBJECTS, sizeof(ApplicationMsg*), NULL);
+    if(NULL ==  g_cloudController.applicationMsgQueue){
+        printf("Create receive msg queue failed");
+        return ret;
+    }
+    /* initialize the iot sdk */
+    HuaweiIoTSDKInit();
+    /* create a task to deal the send message or received message */
+    osThreadAttr_t attr;
+    attr.attr_bits = 0U;
+    attr.cb_mem = NULL;
+    attr.cb_size = 0U;
+    attr.stack_mem = NULL;
+    attr.name = "IoTCloudMain";
+    attr.stack_size = 1024*8;
+    attr.priority = 30;
+    printf("Could Thread init begin\n");
+    if ((g_cloudController.mainTaskID = osThreadNew((osThreadFunc_t)CloudMainTaskEntry, NULL, &attr)) == NULL) {
+        printf("Could not create the iotcloud thread");
+        return ret;
+    }
+    ret = 0;
+    printf("Could init success\n");
+    return ret;
+}
+
+int CLOUD_Deinit(void)
+{
+    int ret = -1;
+    osThreadTerminate(g_cloudController.mainTaskID);
+    g_cloudController.mainTaskID = NULL;
+    osMessageQueueDelete( g_cloudController.applicationMsgQueue);
+    g_cloudController.applicationMsgQueue = NULL;
+    return ret;
+}
+
+int CLOUD_Connect(const char *deviceID, const char *devicePwd, \
+    const char *serverIP, const char *serverPort)
+{
+    int ret;
+    oc_mqtt_profile_connect_t  connect_para;
+    (void) memset( &connect_para, 0, sizeof(connect_para));
+
+    connect_para.boostrap = 0;
+    connect_para.device_id = (char *)deviceID;
+    connect_para.device_passwd = (char *)devicePwd;
+    connect_para.server_addr = (char *)serverIP;
+    connect_para.server_port = (char *)serverPort;
+    connect_para.life_time =  CONFIG_APP_LIFETIME;
+    connect_para.rcvfunc = CloudMsgRcvCallBack;
+    connect_para.security.type = EN_DTLS_AL_SECURITY_TYPE_NONE;
+    ret = oc_mqtt_profile_connect(&connect_para);
+    if ((ret == (int)en_oc_mqtt_err_ok)) {
+        g_cloudController.connected = 1;
+        ret = 0;
+    }
+    else {
+        RaiseLog(LOG_LEVEL_ERR,"Could not connect to the huaweiIotPlatform:deviceID:%s devicePwd:%s serverIP:%s serverPort:%s", \
+            deviceID, devicePwd, serverIP, serverPort);
+        ret = -1;
+    }
+    return ret;
+}
+
+int CLOUD_Disconnect(void)
+{
+    int ret;
+    ret = oc_mqtt_profile_disconnect();
+    if (ret == (int)en_oc_mqtt_err_ok) {
+        return 0;
+    } else {
+        return -1;
+    }
+}
+
+int CLOUD_ReportMsg(const char *jsonString)
+{
+    int ret = -1;
+    ApplicationMsg *applicationMsg = NULL;
+
+    if (jsonString == NULL) {
+        RaiseLog(LOG_LEVEL_WARN,"Parameter jsonString is NULL");
+        return ret;
+    }
+
+    applicationMsg = malloc(sizeof(ApplicationMsg) + strlen(jsonString) + 1);
+    if (NULL != applicationMsg) {
+        applicationMsg->msgType = EN_MSG_TYPE_REPORT;
+        applicationMsg->msg.report.jsonString = (char *)applicationMsg + sizeof(ApplicationMsg);
+        strcpy(applicationMsg->msg.report.jsonString, jsonString);
+        if (0 != osMessageQueuePut(g_cloudController.applicationMsgQueue, (void **)&applicationMsg, NULL,CONFIG_QUEUE_PUSH_TIMEOUT)) {
+            RaiseLog(LOG_LEVEL_ERR,"Could not push message to the message queue");
+        } else {
+            ret = 0;
+        }
+    } else {
+        RaiseLog(LOG_LEVEL_ERR,"Could not get the memory for the application message");
+    }
+    free(applicationMsg);
+    return ret;
+}
+
+int CLOUD_ReportNotification(int type, const char *enString, const char *chString)
+{
+    int ret = -1;
+    ApplicationMsg *applicationMsg = NULL;
+    char *jsonString = NULL;
+    if (type >= NOTIFY_TYPE_LAST || enString == NULL || chString == NULL) {
+        RaiseLog(LOG_LEVEL_WARN,"Parameter failed!\n");
+        return -1;
+    }
+
+    jsonString = IotNotificationPackage(type, enString, chString);
+    if (jsonString == NULL) {
+        RaiseLog(LOG_LEVEL_WARN,"IotNotificationPackage jsonString failed! \n");
+        return ret;
+    }
+
+    applicationMsg = malloc(sizeof(ApplicationMsg) + strlen(jsonString) + 1);
+    if (NULL != applicationMsg) {
+        applicationMsg->msgType = EN_MSG_TYPE_NOTIFY;
+        applicationMsg->msg.report.jsonString = (char *)applicationMsg + sizeof(ApplicationMsg);
+        strcpy(applicationMsg->msg.report.jsonString, jsonString);
+        if (0 != osMessageQueuePut(g_cloudController.applicationMsgQueue, (void**)&applicationMsg, NULL,CONFIG_QUEUE_PUSH_TIMEOUT)) {
+            free(applicationMsg);
+            RaiseLog(LOG_LEVEL_ERR,"Could not push message to the message queue");
+        } else {
+            ret = 0;
+        }
+    } else {
+        RaiseLog(LOG_LEVEL_ERR,"Could not get the memory for the application message");
+    }
+
+    free(jsonString);
+
+    return ret;
+}
+
+int CLOUD_GetCloudConnectedStatus(void)
+{
+    return g_cloudController.connected;
+}

+ 303 - 0
vendor/bossay/common/iot_cloud/iot_profile_package.c

@@ -0,0 +1,303 @@
+/*
+ * 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 "iot_cloud.h"
+#include "cJSON.h"
+
+#define IOT_PROFILE_KEY_SERVICES         "services"
+#define IOT_PROFILE_KEY_SERVICEID        "service_id"
+#define IOT_PROFILE_KEY_PROPERTIES       "properties"
+#define IOT_PROFILE_KEY_EVENTTIME        "event_time"
+#define IOT_PROFILE_KEY_SERVICES         "services"
+
+// format the report data to json string mode
+static cJSON  *FormatValue(IotProfileKV  *kv)
+{
+    cJSON  *ret = NULL;
+    switch (kv->type)
+    {
+        case IOT_PROFILE_KEY_DATATYPE_INT:
+            ret = cJSON_CreateNumber((double)(*(int *)kv->value));
+            break;
+        case IOT_PROFILE_KEY_DATATYPE_LONG:
+            ret = cJSON_CreateNumber((double)(*(long *)kv->value));
+            break;
+        case IOT_PROFILE_KEY_DATATYPE_FLOAT:
+            ret = cJSON_CreateNumber((double)(*(float *)kv->value));
+            break;
+        case IOT_PROFILE_KEY_DATATYPE_DOUBLE:
+            ret = cJSON_CreateNumber((*(double *)kv->value));
+            break;
+        case IOT_PROFILE_KEY_DATATYPE_STRING:
+            ret = cJSON_CreateString((const char *)kv->value);
+            break;
+        default:
+            break;
+    }
+
+    return ret;
+}
+
+
+static cJSON *FormatProperty(IotProfileKV *propertyLst)
+{
+    cJSON *rootObj = NULL;
+    cJSON *propertyObj = NULL;
+    IotProfileKV *property = NULL;
+    // build a root node
+    rootObj = cJSON_CreateObject();
+    if (rootObj == NULL) {
+        goto EXIT_MEM;
+    }
+    // add all the property to the properties
+    property = propertyLst;
+    while (NULL != property) {
+        propertyObj = FormatValue(property);
+        if (propertyObj == NULL) {
+            goto EXIT_MEM;
+        }
+
+        cJSON_AddItemToObject(rootObj, property->key, propertyObj);
+        property = property->nxt;
+    }
+
+    // OK, now we return it
+    return rootObj;
+
+EXIT_MEM:
+    if (NULL != rootObj) {
+        cJSON_Delete(rootObj);
+        rootObj = NULL;
+    }
+    return rootObj;
+
+}
+
+static cJSON *FormatService(IotProfileService *service)
+{
+    cJSON *rootObj;
+    cJSON *serviceID;
+    cJSON *propertyObj;
+    cJSON *eventTimeObj;
+
+    // build a rootObj node
+    rootObj = cJSON_CreateObject();
+    if (NULL == rootObj) {
+        goto EXIT_MEM;
+    }
+    // add the serviceID node to the rootObj node
+    serviceID = cJSON_CreateString(service->serviceID);
+    if (NULL == serviceID) {
+        goto EXIT_MEM;
+    }
+    cJSON_AddItemToObjectCS(rootObj, IOT_PROFILE_KEY_SERVICEID, serviceID);
+
+    // add the propertyObj node to the rootObj
+    propertyObj = FormatProperty(service->propertyLst);
+    if (NULL == propertyObj) {
+        goto EXIT_MEM;
+    }
+    cJSON_AddItemToObjectCS(rootObj, IOT_PROFILE_KEY_PROPERTIES, propertyObj);
+    // add the event time (optional) to the rootObj
+    if (NULL != service->eventTime) {
+        eventTimeObj = cJSON_CreateString(service->eventTime);
+        if (NULL == eventTimeObj) {
+            goto EXIT_MEM;
+        }
+        cJSON_AddItemToObjectCS(rootObj, IOT_PROFILE_KEY_EVENTTIME, eventTimeObj);
+    }
+    // OK, now we return it
+    return rootObj;
+
+EXIT_MEM:
+    if (NULL != rootObj) {
+        cJSON_Delete(rootObj);
+        rootObj = NULL;
+    }
+    return rootObj;
+}
+
+static cJSON *FormatServices(IotProfileService *serviceLst)
+{
+    cJSON *rootObj = NULL;
+    cJSON * serviceObj;
+    IotProfileService *service;
+
+    // create the rootObj array node
+    rootObj = cJSON_CreateArray();
+    if (NULL == rootObj) {
+        goto EXIT_MEM;
+    }
+    service = serviceLst;
+    while (NULL != service) {
+        serviceObj = FormatService(service);
+        if (NULL == serviceObj) {
+            goto EXIT_MEM;
+        }
+
+        cJSON_AddItemToArray(rootObj, serviceObj);
+        service = service->nxt;
+    }
+
+    // now we return the rootObj
+    return rootObj;
+
+EXIT_MEM:
+    if (NULL != rootObj) {
+        cJSON_Delete(rootObj);
+        rootObj = NULL;
+    }
+    return rootObj;
+}
+
+char *IoTProfilePackage(IotProfileService *serviceLst)
+{
+    char *ret = NULL;
+    cJSON *rootObj;
+    cJSON *servicesObj;
+
+    // create the rootObj node
+    rootObj = cJSON_CreateObject();
+    if (NULL == rootObj) {
+        goto EXIT_MEM;
+    }
+    // create the services array node to the rootObj
+    servicesObj = FormatServices(serviceLst);
+    if (NULL == servicesObj) {
+        goto EXIT_MEM;
+    }
+    cJSON_AddItemToObjectCS(rootObj, IOT_PROFILE_KEY_SERVICES, servicesObj);
+    // OK, now we make it to a buffer
+    ret = cJSON_PrintUnformatted(rootObj);
+    cJSON_Delete(rootObj);
+    return ret;
+
+EXIT_MEM:
+    if (NULL != rootObj) {
+        cJSON_Delete(rootObj);
+    }
+    return ret;
+}
+
+
+static cJSON *NotifyGetMsgObj(const char *enString, const char *chString)
+{
+    cJSON *objRoot;
+    cJSON *objEn, *objCh;
+    char *ret = NULL;
+
+    objRoot = cJSON_CreateObject();
+    if (objRoot == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateObject \n", __func__,__LINE__);
+        return NULL;
+    }
+
+    objEn = cJSON_CreateString(enString);
+    if (objEn == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateString %s\n", __func__,__LINE__,enString);
+        goto MSG_ERR;
+    }
+    cJSON_AddItemToObjectCS(objRoot, "msg_en", objEn);
+
+    objCh = cJSON_CreateString(chString);
+    if (objCh == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateString %s\n", __func__,__LINE__,chString);
+        goto MSG_ERR;
+    }
+    cJSON_AddItemToObjectCS(objRoot, "msg_zh", objCh);
+
+    return objRoot;
+MSG_ERR:
+    if (objRoot) {
+        cJSON_Delete(objRoot);
+    }
+    return NULL;
+}
+
+static cJSON *NotifyGetParamObj(int type, const char *enString, const char *chString)
+{
+    cJSON *objRoot;
+    cJSON *objtype;
+    cJSON *objmsg;
+
+    objRoot = cJSON_CreateObject();
+    if (objRoot == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateObject \n", __func__,__LINE__);
+        return NULL;
+    }
+
+    objtype = cJSON_CreateNumber(type);
+    if (objtype == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateNumber \n", __func__,__LINE__);
+        goto PARAM_ERR;
+    }
+    cJSON_AddItemToObjectCS(objRoot, "AlarmType", objtype);
+
+    objmsg = NotifyGetMsgObj(enString, chString);
+    if (objmsg == NULL) {
+        goto PARAM_ERR;
+        printf("[%s|%d][ERROR] NotifyGetMsgObj \n", __func__,__LINE__);
+    }
+    cJSON_AddItemToObjectCS(objRoot, "ALarmMsg", objmsg);
+
+    return objRoot;
+PARAM_ERR:
+    if (objRoot) {
+        cJSON_Delete(objRoot);
+    }
+    return NULL;
+}
+char *IotNotificationPackage(int type, const char *enString, const char *chString)
+{
+    char *ret = NULL;
+    cJSON *rootObj;
+    cJSON *serviceidObjs;
+    cJSON *propertiesObj;
+    cJSON *objtype;
+    cJSON *objmsg;
+    cJSON *objEn, *objCh;
+
+    // create the rootObj node
+    rootObj = cJSON_CreateObject();
+    if (NULL == rootObj) {
+        printf("[%s|%d][ERROR] cJSON_CreateObject \n", __func__,__LINE__);
+        goto EXIT_MEM;
+    }
+    // create the services array node to the rootObj
+    serviceidObjs = cJSON_CreateString("DeviceAlarm");
+    if (serviceidObjs == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateString DeviceAlarm \n", __func__,__LINE__);
+        goto EXIT_MEM;
+    }
+    cJSON_AddItemToObjectCS(rootObj, "serviceId", serviceidObjs);
+
+    propertiesObj = NotifyGetParamObj(type, enString, chString);
+    if (propertiesObj == NULL) {
+        printf("[%s|%d][ERROR] cJSON_CreateObject \n", __func__,__LINE__);
+        goto EXIT_MEM;
+    }
+    cJSON_AddItemToObjectCS(rootObj, "properties", propertiesObj);
+
+    // OK, now we make it to a buffer
+    ret = cJSON_PrintUnformatted(rootObj);
+    cJSON_Delete(rootObj);
+    printf("ret = %s \n", ret);
+    return ret;
+EXIT_MEM:
+    if (NULL != rootObj) {
+        cJSON_Delete(rootObj);
+    }
+    return NULL;
+}

+ 32 - 0
vendor/bossay/common/iot_list/BUILD.gn

@@ -0,0 +1,32 @@
+# 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.
+
+source_set("iot_list") {
+    sources = [
+        "iot_list.c",
+        "iot_store_manager.c"
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "../inc"
+    ]
+
+    deps = [ 
+
+    ]
+
+}

+ 286 - 0
vendor/bossay/common/iot_list/iot_list.c

@@ -0,0 +1,286 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+#include "iot_list.h"
+
+#define LIST_DEBUG
+#ifdef  LIST_DEBUG
+#define LST_DBG(fmt, args...)   printf("[LIST_DEBUG][%s|%d]" fmt, __func__, __LINE__, ##args)
+#define LST_ERR(fmt, args...)   printf("[LIST_ERROR][%s|%d]" fmt, __func__, __LINE__, ##args)
+#else
+#define LST_DBG(fmt, args...)   do {} while (0)
+#define LST_ERR(fmt, args...)   do {} while (0)
+#endif
+
+typedef struct __ListNode {
+    void *data;
+    int size;
+    struct __ListNode *prev;
+    struct __ListNode *next;
+} ListNode;
+
+typedef struct {
+    ListNode *head, *tail;
+    int total;
+} DLinkList;
+
+static ListNode *ListNodeCreate(void *data, int size)
+{
+    ListNode *pNode = NULL;
+    if (data == NULL || size <= 0) {
+        LST_ERR("NULL POINT!\n");
+        return pNode;
+    }
+
+    pNode = (ListNode *)malloc(sizeof(ListNode));
+    if (pNode == NULL) {
+        LST_ERR("OOM!\n");
+        return NULL;
+    }
+
+    pNode->data = malloc(size);
+    if (pNode->data == NULL) {
+        LST_ERR("OOM!\n");
+        free(pNode);
+        return NULL;
+    }
+
+    memcpy(pNode->data, data, size);
+    pNode->size = size;
+    pNode->prev = NULL;
+    pNode->next = NULL;
+
+    return pNode;
+}
+
+static void ListNodeDestroy(ListNode *pNode)
+{
+    if (pNode == NULL) {
+        return;
+    }
+    if (pNode->data) {
+        free(pNode->data);
+        pNode->data = NULL;
+    }
+    free(pNode);
+}
+
+static ListNode *ListNodeSearch(ListNode *head, int idx)
+{
+    ListNode *pNode = head;
+    for (int i = 0; i < idx; i++) {
+        if (pNode == NULL) {
+            break;
+        }
+        pNode = pNode->next;
+    }
+
+    return pNode;
+}
+
+static ListNode *ListNodeSearchData(ListNode *head, void *data)
+{
+    ListNode *pNode = head;
+
+    while (pNode != NULL) {
+        if (memcmp(pNode->data, data, pNode->size) == 0) {
+            break;
+        }
+        pNode = pNode->next;
+    }
+
+    return pNode;
+}
+
+IOT_LIST IoT_ListCreate(void *data, int size)
+{
+    ListNode *pNode = NULL;
+    DLinkList *list = (DLinkList *)malloc(sizeof(DLinkList));
+    if (list == NULL) {
+        LST_ERR("OOM!\n");
+        return NULL;
+    }
+
+    pNode = ListNodeCreate(data, size);
+    if (pNode != NULL) {
+        list->total = 1;
+    } else {
+        list->total = 0;
+    }
+    list->head = list->tail = pNode;
+
+    return (DLinkList *)list;
+}
+
+int IoT_ListAppend(IOT_LIST mHandle, void *data, int size)
+{
+    ListNode *pNode = NULL;
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL) {
+        LST_ERR("NULL POINT! \n");
+        return -1;
+    }
+
+    pNode = ListNodeCreate(data, size);
+    if (pNode == NULL) {
+        LST_ERR("ListNodeCreate failed! \n");
+        return -1;
+    }
+
+    if (list->head == NULL) {
+        list->head = list->tail = pNode;
+    } else {
+        list->tail->next = pNode;
+        pNode->prev = list->tail;
+        list->tail = pNode;
+    }
+
+    list->total++;
+
+    return 0;
+}
+
+int IoT_ListUpdate(IOT_LIST mHandle, int idx, void *data, int size)
+{
+    int retval = 0;
+    ListNode *pNode = NULL;
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL || data == NULL) {
+        LST_ERR("NULL POINT! \n");
+        return -1;
+    }
+
+    pNode = ListNodeSearch(list->head, idx);
+    if (pNode != NULL) {
+        if (size != pNode->size) {
+            pNode->data = realloc(pNode->data, size);
+            pNode->size = size;
+        }
+        memcpy(pNode->data, data, size);
+    } else {
+        retval = IoT_ListAppend(mHandle, data, size);
+    }
+
+    return retval;
+}
+
+int IoT_ListDelete(IOT_LIST mHandle, void *data)
+{
+    ListNode *pNode = NULL;
+    ListNode *prev = NULL;
+    ListNode *next = NULL;
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL || data == NULL) {
+        LST_ERR("NULL POINT! \n");
+        return -1;
+    }
+
+    pNode = ListNodeSearchData(list->head, data);
+    if (pNode == NULL) {
+        return -1;
+    }
+    prev = pNode->prev;
+    next = pNode->next;
+
+    if (prev != NULL && next != NULL){
+        prev->next = next;
+        next->prev = prev;
+    } else if (prev == NULL && next != NULL) {
+        next->prev = NULL;
+        list->head = next;
+    } else if (prev != NULL && next == NULL) {
+        prev->next = NULL;
+        list->tail = prev;
+    } else {
+        list->head = list->tail = NULL;
+    }
+    pNode->next = NULL;
+    pNode->prev = NULL;
+    list->total--;
+
+    ListNodeDestroy(pNode);
+    pNode = NULL;
+
+    return 0;
+}
+
+int IoT_ListGet(IOT_LIST mHandle, int idx, void *data, int size)
+{
+    ListNode *pNode;
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL) {
+        LST_ERR("NULL POINT! \n");
+        return -1;
+    }
+
+    pNode = ListNodeSearch(list->head, idx);
+    if (pNode == NULL || pNode->data == NULL || data == NULL || size < pNode->size) {
+        LST_ERR("no such node(%d) \n", idx);
+        return -1;
+    }
+
+    memcpy(data, pNode->data, pNode->size);
+
+    return 0;
+}
+
+int IoT_ListGetSize(IOT_LIST mHandle)
+{
+    if (mHandle == NULL) {
+        return -1;
+    }
+
+    return ((DLinkList *)mHandle)->total;
+}
+
+void IoT_ListClear(IOT_LIST mHandle)
+{
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL) {
+        return;
+    }
+    while (list->head) {
+        ListNode *pNode = list->head;
+        list->head = pNode->next;
+        pNode->next = NULL;
+        list->head->prev = NULL;
+
+        ListNodeDestroy(pNode);
+    }
+    list->total = 0;
+}
+
+void IoT_ListDestroy(IOT_LIST mHandle)
+{
+    DLinkList *list = (DLinkList *)mHandle;
+    if (list == NULL) {
+        return;
+    }
+    while (list->head) {
+        ListNode *pNode = list->head;
+        list->head = pNode->next;
+        pNode->next = NULL;
+        list->head->prev = NULL;
+
+        ListNodeDestroy(pNode);
+    }
+    list->total = 0;
+
+    free(list);
+    list = NULL;
+}

+ 530 - 0
vendor/bossay/common/iot_list/iot_store_manager.c

@@ -0,0 +1,530 @@
+/*
+ * 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 <ctype.h>
+#include <securec.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "ohos_errno.h"
+#include "ohos_types.h"
+#include "utils_config.h"
+#include "utils_file.h"
+
+#include "iot_store_manager.h"
+
+#if (USER_KV_STORE)
+#define INDX_KEY        "//offset.idx"
+#define INDX_TMP        "//offset.tmp"
+#define DATA_KEY        "//data.info"
+#define DATA_TMP        "//data.tmp"
+
+#define TEMP_KEY        "//tmp.idx"
+
+#define STORE_DEBUG
+#ifdef  STORE_DEBUG
+#define STORE_DBG(fmt, args...)     printf("[%s|%d][STORE_DEBUG]" fmt, __func__, __LINE__, ##args)
+#define STORE_ERR(fmt, args...)     printf("[%s|%d][STORE_ERROR]" fmt, __func__, __LINE__, ##args)
+#else
+#define STORE_DBG(fmt, args...)     do {} while (0)
+#define STORE_ERR(fmt, args...)     do {} while (0)
+#endif
+
+#define UTILS_CLOSE(fdx, idx)       ({                              \
+                                        if ((fdx) != -1) {          \
+                                            close((fdx));  \
+                                            (fdx) = -1;             \
+                                        }                           \
+                                        if ((idx) != -1) {          \
+                                            close((idx));  \
+                                            (idx) = -1;             \
+                                        }                           \
+                                    })
+
+static int GetFileSize(const char *filename)
+{
+    int offset = 0;
+    struct stat fileStat;
+    if (stat(filename, &fileStat) == 0) {
+        offset = fileStat.st_size;
+    }
+
+    return offset;
+}
+
+int StoreManagerAddData(const char *data, int length)
+{
+    int total = 0;
+    int offset = 0;
+    int ret = 0;
+    int fd = -1;
+    int fidx = -1;
+
+    offset = GetFileSize(DATA_KEY);
+
+    if (data == NULL || length <= 0) {
+        STORE_ERR("NULL POINT! \n");
+        return -1;
+    }
+
+    fidx = open(INDX_KEY, O_RDWR | O_CREAT | O_APPEND, 0);
+    if (fidx < 0) {
+        STORE_ERR("UtilsFileOpen %s failed! \n", INDX_KEY);
+        return -1;
+    }
+
+    fd = open(DATA_KEY, O_RDWR | O_CREAT | O_APPEND, 0);
+    if (fd < 0) {
+        ret = -1;
+        STORE_ERR("UtilsFileOpen %s failed! \n", DATA_KEY);
+        goto ADD_EXIT;
+    }
+
+    lseek(fidx, 0, SEEK_SET);
+
+    if (read(fidx, &total, sizeof(int)) < 0) {
+        ret = -1;
+        STORE_ERR("UtilsFileRead total failed! \n");
+        goto ADD_EXIT;
+    }
+    total += 1;
+    printf("save total = %d! \n", total);
+
+    lseek(fidx, 0, SEEK_SET);
+
+    if (write(fidx, &total, sizeof(int)) < 0) {
+        ret = -1;
+        STORE_ERR("UtilsFileWrite total failed! \n");
+        goto ADD_EXIT;
+    }
+    lseek(fidx, 0, SEEK_END);
+
+    if (write(fidx, &offset, sizeof(int)) < 0) {
+        ret = -1;
+        STORE_ERR("UtilsFileWrite offset failed! \n");
+        goto ADD_EXIT;
+    }
+    lseek(fd, 0, SEEK_END);
+    write(fd, &length, sizeof(int));
+
+    if (write(fd, data, length) < 0) {
+        ret = -1;
+        STORE_ERR("UtilsFileWrite data failed! \n");
+        goto ADD_EXIT;
+    }
+    STORE_DBG("save data[%d|%s]->%d success! \n", length, data, offset);
+ADD_EXIT:
+
+    UTILS_CLOSE(fd, fidx);
+
+    return ret;
+}
+
+int StoreManagerUpdateData(int idx, const char *data, int length)
+{
+    int fd = -1;
+    int fidx = -1;
+    int tmp = -1;
+    int tmpidx = -1;
+    int total = 0;
+
+    fidx = open(INDX_KEY, O_RDWR, 0);
+    if (fidx < 0) {
+        printf("UtilsFileOpen INDX_KEY failed! \n");
+        return -1;
+    }
+
+    lseek(fidx, 0, SEEK_SET);
+    if (read(fidx, (char *)&total, sizeof(int)) < 0) {
+        printf("UtilsFileRead failed! \n");
+        goto ERR_UPDATE;
+    }
+    if (total <= 0) {
+        printf("total is 0! \n");
+        goto ERR_UPDATE;
+    }
+
+    if (idx >= total) {
+        printf("idx(%d) > total(%d) \n", idx, total);
+        goto ERR_UPDATE;
+    }
+
+    fd = open(DATA_KEY, O_RDWR, 0);
+    if (fd < 0) {
+        printf("UtilsFileOpen DATA_KEY failed! \n");
+        goto ERR_UPDATE;
+    }
+
+    tmp = open(DATA_TMP, O_CREAT | O_RDWR, 0);
+    if (tmp < 0) {
+        printf("UtilsFileOpen DATA_TMP failed! \n");
+        goto ERR_UPDATE;
+    }
+    tmpidx = open(INDX_TMP, O_CREAT | O_RDWR, 0);
+    if (tmpidx < 0) {
+        printf("UtilsFileOpen INDX_TMP failed! \n");
+        goto ERR_UPDATE;
+    }
+
+    if (write(tmpidx, &total, sizeof(int)) < 0) {
+        printf("UtilsFileWrite tmpidx failed! \n");
+        goto ERR_UPDATE;
+    }
+
+    for (int i = 0; i <= total; i++) {
+        void *pdata = NULL;
+        int offset = 0;
+        int psize = 0;
+
+        if (read(fidx, (void *)&offset, sizeof(int)) < 0) {
+            printf("UtilsFileRead fidx  offset failed! \n");
+            goto ERR_UPDATE;
+        }
+        if (i == idx) {
+            offset = GetFileSize(DATA_TMP);
+            write(tmp, data, length);
+            write(tmpidx, (void *)&offset, sizeof(int));
+            continue;
+        }
+
+        lseek(fd, offset, SEEK_SET);
+        if (read(fd, &psize, sizeof(int)) < 0) {
+            printf("UtilsFileRead fd  psize failed! \n");
+            goto ERR_UPDATE;
+        }
+        if (psize <= 0) {
+            goto ERR_UPDATE; 
+        }
+        pdata = malloc(psize);
+        if (read(fd, pdata, psize) < 0) {
+            free(pdata);
+            goto ERR_UPDATE;
+        }
+        offset = GetFileSize(DATA_TMP);
+        write(tmp, psize, sizeof(int));
+        write(tmp, pdata, psize);
+        write(tmpidx, &offset, sizeof(int));
+
+        free(pdata);
+    }
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    unlink(INDX_KEY);
+    unlink(DATA_KEY);
+
+    rename(DATA_TMP, DATA_KEY);
+    rename(INDX_TMP, INDX_KEY);
+
+    return 0;
+ERR_UPDATE:
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    return -1;
+}
+
+int StoreManagerDeleteDataWithId(int idx)
+{
+    int fd = -1;
+    int fidx = -1;
+    int tmp = -1;
+    int tmpidx = -1;
+    int total = 0;
+
+    fidx = open(INDX_KEY, O_RDWR, 0);
+    if (fidx < 0) {
+        return -1;
+    }
+
+    lseek(fidx, 0, SEEK_SET);
+    if (read(fidx, &total, sizeof(int)) < 0) {
+        goto ERR_DELETE_ID;
+    }
+    if (total <= 0) {
+        goto ERR_DELETE_ID;
+    }
+
+    if (idx >= total) {
+        goto ERR_DELETE_ID;
+    }
+
+    if (total == 1) {
+        close(fidx);
+        unlink(INDX_KEY);
+        unlink(DATA_KEY);
+        return 0;
+    }
+
+    total -= 1;
+    fd = open(DATA_KEY, O_RDWR, 0);
+    if (fd < 0) {
+        goto ERR_DELETE_ID;
+    }
+
+    tmp = open(DATA_TMP, O_CREAT | O_RDWR, 0);
+    if (tmp < 0) {
+        goto ERR_DELETE_ID;
+    }
+    tmpidx = open(INDX_TMP, O_CREAT | O_RDWR, 0);
+    if (tmpidx < 0) {
+        goto ERR_DELETE_ID;
+    }
+
+    if (write(tmpidx, &total, sizeof(int)) < 0) {
+        goto ERR_DELETE_ID;
+    }
+
+    for (int i = 0; i <= total; i++) {
+        void *data = NULL;
+        int offset = 0;
+        int size = 0;
+
+        if (read(fidx, &offset, sizeof(int)) < 0) {
+            goto ERR_DELETE_ID;
+        }
+        if (i == idx) {
+            continue;
+        }
+
+        lseek(fd, offset, SEEK_SET);
+        if (read(fd, &size, sizeof(int)) < 0) {
+            goto ERR_DELETE_ID;
+        }
+        if (size <= 0) {
+            goto ERR_DELETE_ID;
+        }
+        data = malloc(size);
+        if (read(fd, data, size) < 0) {
+            free(data);
+            goto ERR_DELETE_ID;
+        }
+        offset = GetFileSize(DATA_TMP);
+        write(tmp, size, sizeof(int));
+        write(tmp, data, size);
+        write(tmpidx, &offset, sizeof(int));
+
+        free(data);
+    }
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    unlink(INDX_KEY);
+    unlink(DATA_KEY);
+
+    rename(DATA_TMP, DATA_KEY);
+    rename(INDX_TMP, INDX_KEY);
+
+    return 0;
+
+ERR_DELETE_ID:
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    return -1;
+}
+
+int StoreManagerDeleteData(const char *data)
+{
+    int fd = -1;
+    int fidx = -1;
+    int tmp = -1;
+    int tmpidx = -1;
+    int total = 0;
+
+    fidx = open(INDX_KEY, O_RDWR, 0);
+    if (fidx < 0) {
+        return -1;
+    }
+
+    lseek(fidx, 0, SEEK_SET);
+    if (read(fidx, &total, sizeof(int)) < 0) {
+        goto ERR_DELETE_DATA;
+    }
+    if (total <= 0) {
+        goto ERR_DELETE_DATA;
+    }
+
+    fd = open(DATA_KEY, O_RDWR, 0);
+    if (fd < 0) {
+        goto ERR_DELETE_DATA;
+    }
+
+    tmp = open(DATA_TMP, O_CREAT | O_RDWR, 0);
+    if (tmp < 0) {
+        goto ERR_DELETE_DATA;
+    }
+    tmpidx = open(INDX_TMP, O_CREAT | O_RDWR, 0);
+    if (tmpidx < 0) {
+        goto ERR_DELETE_DATA;
+    }
+
+    if (write(tmpidx, &total, sizeof(int)) < 0) {
+        goto ERR_DELETE_DATA;
+    }
+
+    for (int i = 0; i <= total; i++) {
+        void *pdata = NULL;
+        int offset = 0;
+        int psize = 0;
+
+        if (read(fidx, &offset, sizeof(int)) < 0) {
+            goto ERR_DELETE_DATA;
+        }
+
+        lseek(fd, offset, SEEK_SET);
+        if (read(fd, &psize, sizeof(int)) < 0) {
+            goto ERR_DELETE_DATA;
+        }
+        if (psize <= 0) {
+            goto ERR_DELETE_DATA;
+        }
+        pdata = malloc(psize);
+        if (read(fd, pdata, psize) < 0) {
+            free(pdata);
+            goto ERR_DELETE_DATA;
+        }
+
+        if (memcmp(pdata, data, psize) != 0) {
+            offset = GetFileSize(DATA_TMP);
+            write(tmp, psize, sizeof(int));
+            write(tmp, pdata, psize);
+            write(tmpidx, &offset, sizeof(int));
+        }
+
+        free(pdata);
+    }
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    unlink(INDX_KEY);
+    unlink(DATA_KEY);
+
+    rename(DATA_TMP, DATA_KEY);
+    rename(INDX_TMP, INDX_KEY);
+
+    return 0;
+ERR_DELETE_DATA:
+
+    UTILS_CLOSE(fd, fidx);
+    UTILS_CLOSE(tmp, tmpidx);
+
+    return -1;
+}
+
+int StoreManagerGetTotal(void)
+{
+    int total = 0;
+    int fd = open(INDX_KEY, O_RDWR, 0);
+
+    if (fd < 0) {
+        STORE_ERR("open INDX_KEY failed! \n");
+        return -1;
+    }
+
+    lseek(fd, 0, SEEK_SET);
+
+    if (read(fd, &total, sizeof(int)) < 0) {
+        STORE_ERR("read total failed! \n");
+        total = -1;
+    } else {
+        STORE_ERR("read total =%d \n", total);
+    }
+
+    close(fd);
+
+    return total;
+}
+
+int StoreManagerGetData(char *data, int size, int idx)
+{
+    int fd = -1;
+    int fidx = -1;
+    unsigned int total = 0;
+    unsigned int offset = 0;
+    unsigned int psize = 0;
+
+    fidx = open(INDX_KEY, O_RDWR, 0);
+    if (fidx < 0) {
+        return -1;
+    }
+
+    fd = open(DATA_KEY, O_RDWR, 0);
+    if (fd < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+    lseek(fidx, 0, SEEK_SET);
+
+    if (read(fidx, &total, sizeof(int)) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (idx >= total) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (lseek(fidx, (idx + 1) * sizeof(int), SEEK_SET) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (read(fidx, &offset, sizeof(int)) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (lseek(fd, offset, SEEK_SET) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (read(fd, &psize, sizeof(int)) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (size < psize) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    if (read(fd, data, psize) < 0) {
+        UTILS_CLOSE(fd, fidx);
+        return -1;
+    }
+
+    UTILS_CLOSE(fd, fidx);
+
+    return 0;
+}
+
+void StoreManagerDelete(void)
+{
+    unlink(DATA_KEY);
+    unlink(INDX_KEY);
+}
+
+#endif

+ 41 - 0
vendor/bossay/common/iot_nfc/BUILD.gn

@@ -0,0 +1,41 @@
+# 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("iot_nfc") {
+    sources = [
+        "NT3H.c",
+        "nfc.c",
+        "nfc_app.c",
+        "ndef/rtd/nfcForum.c",
+        "ndef/rtd/rtdText.c",
+        "ndef/rtd/rtdUri.c",
+        "ndef/ndef.c",  
+        
+    ]
+    
+    cflags = [ "-Wno-unused-variable" ]
+    cflags += [ "-Wno-unused-but-set-variable" ]
+    cflags += [ "-Wno-unused-parameter" ]
+    
+    include_dirs = [
+        "//base/iot_hardware/peripheral/interfaces/kits",
+        "//third_party/cJSON",
+        ".",
+        "ndef",
+        "ndef/rtd/",
+        "../inc",
+    ]
+
+    deps = [ ]
+
+}

+ 217 - 0
vendor/bossay/common/iot_nfc/NT3H.c

@@ -0,0 +1,217 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "iot_i2c.h"
+#include "iot_i2c_ex.h"
+#include "NT3H.h"
+#include "ndef.h"
+#include "nfc.h"
+#include "nfcForum.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;
+} WifiIotI2cData;
+
+uint8_t     nfcPageBuffer[NFC_PAGE_SIZE];
+NT3HerrNo   errNo;
+// due to the nature of the NT3H a timeout is required to
+// protectd 2 consecutive I2C access
+
+inline const uint8_t* get_last_ncf_page(void) {
+    return nfcPageBuffer;
+}
+
+static bool writeTimeout(  uint8_t *data, uint8_t dataSend) {
+    uint32_t status = 0;
+    status = IoTI2cWrite(1, (NT3H1X_SLAVE_ADDRESS<<1)|0x00, data,dataSend);
+    if (status != 0) {
+        printf("===== Error: I2C write status1 = 0x%x! =====\r\n", status);
+        return 0;
+    }
+    usleep(300000);
+    return 1;
+}
+
+static bool readTimeout(uint8_t address, uint8_t *block_data) {
+    uint32_t status = 0;
+    IotI2cData nt3h1101_i2c_data = {0};
+    uint8_t  buffer[1] = {address};
+    nt3h1101_i2c_data.sendBuf = buffer;
+    nt3h1101_i2c_data.sendLen = 1;
+    nt3h1101_i2c_data.receiveBuf = block_data;
+    nt3h1101_i2c_data.receiveLen = NFC_PAGE_SIZE;
+    status = IoTI2cWriteread(1, (NT3H1X_SLAVE_ADDRESS<<1)|0x00, &nt3h1101_i2c_data);
+    if (status != 0) {
+        printf("===== Error: I2C write status = 0x%x! =====\r\n", status);
+        return 0;
+    }
+    return 1;
+}
+
+bool NT3HReadHeaderNfc(uint8_t *endRecordsPtr, uint8_t *ndefHeader) {
+    *endRecordsPtr=0;
+    bool ret = NT3HReadUserData(0);
+
+    // read the first page to see where is the end of the Records.
+    if (ret == true) {
+        // if the first byte is equals to NDEF_START_BYTE there are some records
+        // store theend of that
+        if ((NDEF_START_BYTE == nfcPageBuffer[0]) && (NTAG_ERASED != nfcPageBuffer[2])) {
+            *endRecordsPtr = nfcPageBuffer[1];
+            *ndefHeader    = nfcPageBuffer[2];
+        }
+        return true;
+    } else {
+        errNo = NT3HERROR_READ_HEADER;
+    }
+
+    return ret;
+}
+
+
+bool NT3HWriteHeaderNfc(uint8_t endRecordsPtr, uint8_t ndefHeader) {
+
+    // read the first page to see where is the end of the Records.
+    bool ret = NT3HReadUserData(0);
+    if (ret == true) {
+
+        nfcPageBuffer[1] = endRecordsPtr;
+        nfcPageBuffer[2] = ndefHeader;
+        ret = NT3HWriteUserData(0, nfcPageBuffer);
+        if (ret == false) {
+            errNo = NT3HERROR_WRITE_HEADER;
+        }
+    } else {
+        errNo = NT3HERROR_READ_HEADER;
+    }
+
+    return ret;
+}
+
+
+
+bool NT3HEraseAllTag(void) {
+    bool ret = true;
+    uint8_t erase[NFC_PAGE_SIZE+1] = {USER_START_REG, 0x03, 0x03, 0xD0, 0x00, 0x00, 0xFE};
+    ret = writeTimeout(erase, sizeof(erase));
+
+    if (ret == false) {
+        errNo = NT3HERROR_ERASE_USER_MEMORY_PAGE;
+    }
+    return ret;
+}
+
+bool NT3HReaddManufactoringData(uint8_t *manuf) {
+    return readTimeout(MANUFACTORING_DATA_REG, manuf);
+}
+
+bool NT3HReadConfiguration(uint8_t *configuration){
+    return readTimeout(CONFIG_REG, configuration);
+}
+
+bool getSessionReg(void) {
+    return readTimeout(SESSION_REG, nfcPageBuffer);
+}
+
+
+bool NT3HReadUserData(uint8_t page) {
+    uint8_t reg = USER_START_REG+page;
+    // if the requested page is out of the register exit with error
+    if (reg > USER_END_REG) {
+        errNo = NT3HERROR_INVALID_USER_MEMORY_PAGE;
+        return false;
+    }
+
+    bool ret = readTimeout(reg, nfcPageBuffer);
+
+    if (ret == false) {
+        errNo = NT3HERROR_READ_USER_MEMORY_PAGE;
+    }
+
+    return ret;
+}
+
+void NT3H1101_Read_Userpages(uint8_t pagenumber,uint8_t *outbuf)
+{
+    for (int i = 0; i < pagenumber; i++)
+    {
+        NT3HReadUserData(i);
+        for (int j = 0; j < 16; j++)
+        {
+            outbuf[16 * i + j] = nfcPageBuffer[j];
+        }
+    }
+}
+
+bool NT3HWriteUserData(uint8_t page, const uint8_t* data) {
+    bool ret = true;
+    uint8_t dataSend[NFC_PAGE_SIZE +1]; // data plus register
+    uint8_t reg = USER_START_REG+page;
+
+    // if the requested page is out of the register exit with error
+    if (reg > USER_END_REG) {
+        errNo = NT3HERROR_INVALID_USER_MEMORY_PAGE;
+        ret = false;
+        goto end;
+    }
+
+    dataSend[0] = reg; // store the register
+    memcpy(&dataSend[1], data, NFC_PAGE_SIZE);
+    ret = writeTimeout(dataSend, sizeof(dataSend));
+    if (ret == false) {
+        errNo = NT3HERROR_WRITE_USER_MEMORY_PAGE;
+        goto end;
+    }
+
+    end:
+    return ret;
+}
+
+
+bool NT3HReadSram(void){
+    bool ret=false;
+    for (int i = SRAM_START_REG, j=0; i<=SRAM_END_REG; i++,j++) {
+        ret = readTimeout(i, nfcPageBuffer);
+        if (ret==false) {
+            return ret;
+        }
+        //memcpy(&userData[offset], pageBuffer, sizeof(pageBuffer));
+    }
+    return ret;
+}
+
+
+void NT3HGetNxpSerialNumber(uint8_t *buffer) {
+    uint8_t manuf[16];
+
+    if (NT3HReaddManufactoringData(manuf)) {
+        for(int i=0; i<16; i++) {
+            buffer[i] = manuf[i];
+        }
+    }
+}

+ 127 - 0
vendor/bossay/common/iot_nfc/NT3H.h

@@ -0,0 +1,127 @@
+/*
+ * 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 NT3H_H_
+#define NT3H_H_
+
+#include "stdbool.h"
+#include <stdint.h>
+
+#define NT3H1X_SLAVE_ADDRESS 0x55  
+#define MANUFACTORING_DATA_REG 0x0
+#define USER_START_REG 0x1
+#define USER_END_REG   0x77 
+#define CONFIG_REG       0x7A
+#define SRAM_START_REG 0xF8
+#define SRAM_END_REG   0xFB // just the first 8 bytes
+#define SESSION_REG       0xFE
+#define NFC_PAGE_SIZE 16
+
+typedef enum {
+    NT3HERROR_NO_ERROR,
+    NT3HERROR_READ_HEADER,
+    NT3HERROR_WRITE_HEADER,
+    NT3HERROR_INVALID_USER_MEMORY_PAGE,
+    NT3HERROR_READ_USER_MEMORY_PAGE,
+    NT3HERROR_WRITE_USER_MEMORY_PAGE,
+    NT3HERROR_ERASE_USER_MEMORY_PAGE,
+    NT3HERROR_READ_NDEF_TEXT,
+    NT3HERROR_WRITE_NDEF_TEXT,
+    NT3HERROR_TYPE_NOT_SUPPORTED
+}NT3HerrNo;
+
+extern uint8_t      nfcPageBuffer[NFC_PAGE_SIZE];
+extern NT3HerrNo    errNo;
+
+typedef enum {
+    NDEFFirstPos,
+    NDEFMiddlePos,
+    NDEFLastPos
+} RecordPosEnu;
+/*
+ * This strucure is used in the ADD record functionality
+ * to store the last nfc page information, in order to continue from that point.
+ */
+typedef struct {
+    uint8_t page;
+    uint16_t usedBytes;
+} UncompletePageStr;
+
+
+typedef struct {
+    RecordPosEnu ndefPosition;
+    uint8_t rtdType;
+    uint8_t *rtdPayload;
+    uint16_t rtdPayloadlength;
+    void    *specificRtdData;
+}NDEFDataStr;
+
+
+void NT3HGetNxpSerialNumber(uint8_t *buffer);
+
+/*
+ * read the user data from the requested page
+ * first page is 0
+ *
+ * the NT3H1201 has 119 PAges 
+ * the NT3H1101 has 56 PAges (but the 56th page has only 8 Bytes)
+*/
+bool NT3HReadUserData(uint8_t page);
+
+/*
+ * Write data information from the starting requested page.
+ * If the dataLen is bigger of NFC_PAGE_SIZE, the consecuiteve needed 
+ * pages will be automatically used.
+ * 
+ * The functions stops to the latest available page.
+ * 
+ first page is 0
+ * the NT3H1201 has 119 PAges 
+ * the NT3H1101 has 56 PAges (but the 56th page has only 8 Bytes)
+*/
+bool NT3HWriteUserData(uint8_t page, const uint8_t* data);
+
+/*
+ * The function read the first page of user data where is stored the NFC Header.
+ * It is important because it contains the total size of all the stored records.
+ *
+ * param endRecordsPtr return the value of the total size excluding the NDEF_END_BYTE
+ * param ndefHeader    Store the NDEF Header of the first record
+ */
+bool NT3HReadHeaderNfc(uint8_t *endRecordsPtr, uint8_t *ndefHeader);
+
+/*
+ * The function write the first page of user data where is stored the NFC Header.
+ * update the bytes that contains the payload Length and the first NDEF Header
+ *
+ * param endRecordsPtr The value of the total size excluding the NDEF_END_BYTE
+ * param ndefHeader    The NDEF Header of the first record
+ */
+bool NT3HWriteHeaderNfc(uint8_t endRecordsPtr, uint8_t ndefHeader);
+
+bool getSessionReg(void);
+bool getNxpUserData(char* buffer);
+bool NT3HReadSram(void);
+bool NT3HReadSession(void);
+bool NT3HReadConfiguration(uint8_t *configuration);
+
+bool NT3HEraseAllTag(void);
+
+bool NT3HReaddManufactoringData(uint8_t *manuf) ;
+
+bool NT3HResetUserData(void);
+void NT3H1101_Read_Userpages(uint8_t pagenumber,uint8_t *outbuf);
+
+#endif /* NFC_H_ */

+ 248 - 0
vendor/bossay/common/iot_nfc/ndef/ndef.c

@@ -0,0 +1,248 @@
+/*
+ * 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 "ndef.h"
+#include <string.h>
+#include "nfcForum.h"
+#include "rtdTypes.h"
+#include "NT3H.h"
+
+typedef uint8_t (*composeRtdPtr)(const NDEFDataStr *ndef, NDEFRecordStr *ndefRecord, uint8_t *I2CMsg);
+static composeRtdPtr composeRtd[] = {composeRtdText,composeRtdUri};
+
+int16_t firstRecord(UncompletePageStr *page, const NDEFDataStr *data, RecordPosEnu rtdPosition) {
+    
+    NDEFRecordStr record;
+    NDEFHeaderStr header;
+    uint8_t typeFunct=0;
+
+    switch (data->rtdType){
+    case RTD_TEXT:
+        typeFunct =0;
+        break;
+
+    case RTD_URI:
+        typeFunct = 1;
+        break;
+
+    default:
+        return -1;
+        break;
+    }
+
+    // clear all buffers
+    memset(&record,0,sizeof(NDEFRecordStr));
+    memset(nfcPageBuffer, 0, NFC_PAGE_SIZE);
+
+    // this is the first record
+    nfcPageBuffer[0] = NDEF_START_BYTE;
+    composeNDEFMBME(true, true, &record);
+    uint8_t recordLength;
+    // prepare the NDEF Header and payload
+    if(data->rtdPayloadlength>248){
+        recordLength = composeRtd[typeFunct](data, &record, &nfcPageBuffer[4]);        
+        header.payloadLength = data->rtdPayloadlength + recordLength;
+    }
+    else{
+        recordLength = composeRtd[typeFunct](data, &record, &nfcPageBuffer[2]);    
+        header.payloadLength = data->rtdPayloadlength + recordLength;    
+        
+    }
+    if(header.payloadLength>255){
+        nfcPageBuffer[1] = 0xff;
+        nfcPageBuffer[2] = header.payloadLength/256;
+        nfcPageBuffer[3] = header.payloadLength%256;
+         return 4+recordLength;
+    }
+    nfcPageBuffer[1] = header.payloadLength;
+    return 2+recordLength;
+
+}
+
+
+int16_t addRecord(UncompletePageStr *pageToUse, const NDEFDataStr *data, RecordPosEnu rtdPosition) {
+    NDEFRecordStr record;
+    NDEFHeaderStr header={0};
+    uint8_t       newRecordPtr, mbMe;
+    bool          ret = true;
+    uint8_t       tmpBuffer[NFC_PAGE_SIZE];
+
+    uint8_t typeFunct=0;
+
+    switch (data->rtdType){
+    case RTD_TEXT:
+        typeFunct =0;
+        break;
+
+    case RTD_URI:
+        typeFunct = 1;
+        break;
+
+    default:
+        return -1;
+        break;
+    }
+
+    // first Change the Header of the first Record
+    NT3HReadHeaderNfc(&newRecordPtr, &mbMe);
+    record.header = mbMe;
+    composeNDEFMBME(true, false, &record); // this is the first record
+    mbMe = record.header;
+
+    memset(&record,0,sizeof(NDEFRecordStr));
+    memset(tmpBuffer,0,NFC_PAGE_SIZE);
+
+    // prepare second record
+    uint8_t recordLength = composeRtd[typeFunct](data, &record, tmpBuffer);
+
+    if (rtdPosition == NDEFMiddlePos) {
+        // this is a record in the middle adjust it on the buffet
+        composeNDEFMBME(false, false, &record);
+    } else if (rtdPosition == NDEFLastPos){
+        // this is the last record adjust it on the buffet
+        composeNDEFMBME(false, true, &record);
+    }
+
+    tmpBuffer[0] = record.header;
+
+    header.payloadLength += data->rtdPayloadlength + recordLength;
+
+    // save the new value of length on the first page
+    NT3HWriteHeaderNfc((newRecordPtr+header.payloadLength), mbMe);
+
+
+    // use the last valid page and start to add the new record
+    NT3HReadUserData(pageToUse->page);
+    if (pageToUse->usedBytes+recordLength< NFC_PAGE_SIZE) {
+        memcpy(&nfcPageBuffer[pageToUse->usedBytes], tmpBuffer, recordLength);
+        return recordLength+pageToUse->usedBytes;
+    } else {
+        uint8_t byteToCopy = NFC_PAGE_SIZE-pageToUse->usedBytes;
+        memcpy(&nfcPageBuffer[pageToUse->usedBytes], tmpBuffer, byteToCopy);
+        NT3HWriteUserData(pageToUse->page, nfcPageBuffer);
+        // update the info with the new page
+        pageToUse->page++;
+        pageToUse->usedBytes=recordLength-byteToCopy;
+        //copy the remain part in the pageBuffer because this is what the caller expect
+        memcpy(nfcPageBuffer, &tmpBuffer[byteToCopy], pageToUse->usedBytes);
+        return pageToUse->usedBytes;
+    }
+
+}
+
+
+
+static bool writeUserPayload(int16_t payloadPtr, const NDEFDataStr *data, UncompletePageStr *addPage){
+    uint16_t addedPayload;
+    bool ret=false;
+
+    uint8_t finish=payloadPtr+data->rtdPayloadlength;
+    bool endRecord = false;
+    uint8_t copyByte=0;
+
+    // if the header is less then the NFC_PAGE_SIZE, fill it with the payload
+    if (NFC_PAGE_SIZE>payloadPtr) {
+        if (data->rtdPayloadlength > NFC_PAGE_SIZE-payloadPtr)
+            copyByte = NFC_PAGE_SIZE-payloadPtr;
+        else
+            copyByte = data->rtdPayloadlength;
+    }
+
+    // Copy the payload
+    memcpy(&nfcPageBuffer[payloadPtr], data->rtdPayload, copyByte);
+    addedPayload = copyByte;
+
+
+    //if it is sufficient one send add the NDEF_END_BYTE
+    if ((addedPayload >= data->rtdPayloadlength)&&((payloadPtr+copyByte) < NFC_PAGE_SIZE)) {
+        nfcPageBuffer[(payloadPtr+copyByte)] = NDEF_END_BYTE;
+        endRecord = true;
+    }
+
+    ret = NT3HWriteUserData(addPage->page, nfcPageBuffer);
+    while (!endRecord) {
+        addPage->page++; // move to a new register
+        memset(nfcPageBuffer,0,NFC_PAGE_SIZE);
+
+        //special case just the NDEF_END_BYTE remain out
+        if (addedPayload == data->rtdPayloadlength) {
+            nfcPageBuffer[0] = NDEF_END_BYTE;
+            ret = NT3HWriteUserData(addPage->page, nfcPageBuffer);
+
+            endRecord = true;
+            if (ret == false) {
+                errNo = NT3HERROR_WRITE_NDEF_TEXT;
+            }
+            goto end;
+        }
+
+        if (addedPayload < data->rtdPayloadlength) {
+
+            // add the NDEF_END_BYTE if there is enough space
+            if ((data->rtdPayloadlength-addedPayload) < NFC_PAGE_SIZE){
+                memcpy(nfcPageBuffer, &data->rtdPayload[addedPayload], (data->rtdPayloadlength-addedPayload));
+                nfcPageBuffer[(data->rtdPayloadlength-addedPayload)] = NDEF_END_BYTE;
+            } else {
+                memcpy(nfcPageBuffer, &data->rtdPayload[addedPayload], NFC_PAGE_SIZE);
+            }
+
+            addedPayload += NFC_PAGE_SIZE;
+            ret = NT3HWriteUserData(addPage->page, nfcPageBuffer);
+
+            if (ret == false) {
+                errNo = NT3HERROR_WRITE_NDEF_TEXT;
+                goto end;
+            }
+        } else {
+            endRecord = true;
+        }
+    }
+
+    end:
+    return ret;
+}
+
+
+typedef int16_t (*addFunct_T) (UncompletePageStr *page, const NDEFDataStr *data, RecordPosEnu rtdPosition);
+static addFunct_T addFunct[] = {firstRecord, addRecord, addRecord};
+
+bool NT3HwriteRecord(const NDEFDataStr *data) {
+
+
+    uint8_t recordLength=0, mbMe;
+    UncompletePageStr addPage;
+    addPage.page = 0;
+
+
+    // calculate the last used page
+    if (data->ndefPosition != NDEFFirstPos ) {
+        NT3HReadHeaderNfc(&recordLength, &mbMe);
+        addPage.page  = (recordLength+sizeof(NDEFHeaderStr)+1)/NFC_PAGE_SIZE;
+
+        //remove the NDEF_END_BYTE byte because it will overwrite by the new Record
+        addPage.usedBytes = (recordLength+sizeof(NDEFHeaderStr)+1)%NFC_PAGE_SIZE - 1;
+    }
+
+
+    // call the appropriate function and consider the pointer
+    // within the NFC_PAGE_SIZE that need to be used
+    int16_t payloadPtr = addFunct[data->ndefPosition](&addPage, data, data->ndefPosition);
+    if (payloadPtr == -1) {
+        errNo = NT3HERROR_TYPE_NOT_SUPPORTED;
+        return false;
+    }
+    return  writeUserPayload(payloadPtr, data, &addPage);
+}
+

+ 23 - 0
vendor/bossay/common/iot_nfc/ndef/ndef.h

@@ -0,0 +1,23 @@
+/*
+ * 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 NDEF_H_
+#define NDEF_H_
+
+#include "NT3H.h"
+
+bool NT3HwriteRecord(const NDEFDataStr *data);
+
+#endif /* NDEF_H_ */

部分文件因文件數量過多而無法顯示