<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>
0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

OpenHarmony鴻蒙南向開發案例:【智能加濕器】

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-04-19 15:50 ? 次閱讀

樣例簡介

智能加濕器具有實時監控其所處環境溫度、濕度,并通過數字管家設置日程,自動打開加濕器控制濕度功能。顯示界面使用DevEco Studio 編寫的js應用,具有很好的兼容和移植特性。硬件上采用了帶有HDF框架的驅動模型,通過GPIO和IIC分別來控制電機開關和采集濕度信息,還可以通過語音模塊識別語音命令,再通過串口跟主板通信來控制加濕器電機開關。

image-20211229111026037

運行效果

當設備應用啟動之后,操作效果如下

image-20211229161901515

樣例原理

產品示意圖——智能垃圾桶

如上圖所示,智能加濕器整體方案原理圖可以大致分成:智能加濕器設備、數字管家應用、云平臺三部分。智能加濕器通過MQTT協議連接華為IOT物聯網平臺,從而實現命令的接收和屬性上報。

工程版本

  • 系統版本/API版本:OpenHarmony 3.1 Beta
  • hb版本:0.4.4
  • 工具鏈版本:gcc-arm-none-eabi-10.3-2021.10

快速上手

鴻蒙開發指導文檔:[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

搜狗高速瀏覽器截圖20240326151450.png

準備硬件環境

  • V200Z-R藍牙WIFI語音AIoT模組恒玄BES2600WM開發板
  • BearPi-HM Nano套件中的E53_IA1拓展板
  • 機芯智能語音模塊
  • 預裝HarmonyOS手機一臺
    注:HarmonyOS是華為基于開源項目OpenHarmony開發的面向多種全場景智能設備的商用版本

準備開發環境

安裝必備軟件

開發基礎環境由 windows 工作臺和 Linux 編譯服務器組成。windows 工作臺可以通過 samba 服務或 ssh 方式訪問 Linux編譯服務器。其中 windows 工作臺用來燒錄和代碼編輯,Linux 編譯服務器用來編譯 OpenHarmony 代碼,為了簡化步驟,Linux 編譯服務器推薦安裝 Ubuntu20.04 64位。

安裝編譯依賴基礎軟件
sudo apt-get install -y build-essential gcc g++ make zlib* libffi-dev git git-lfs
安裝和配置Python
  • 打開Linux終端。
  • 輸入如下命令,查看python版本號,需要使用python3.7以上版本。
python3 --version
  • 安裝并升級Python包管理工具(pip3)。
sudo apt-get install python3-setuptools python3-pip -y
sudo pip3 install --upgrade pip
  • 設置pip的國內鏡像
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
安裝hb
  • 輸入如下命令確認hb是否為version 0.4.4
hb -v

a. 若提示如下內容,則表示未安裝可以從第2步開始操作。

bash: /home/***/.local/bin/hb: No such file or directory

b.若提示如下內容,需要先卸載該版本,然后再執行第2步操作步驟。

[OHOS INFO] hb version 0.4.3

卸載命令:

pip3 uninstall ohos-build
  • 運行如下命令安裝hb
pip3 install build/lite   // 該命令需在OpenHarmony源碼根目錄下執行
  • 設置環境變量
vim ~/.bashrc

將以下命令拷貝到.bashrc文件的最后一行,保存并退出。

export PATH=~/.local/bin:$PATH

執行如下命令更新環境變量。

source ~/.bashrc
  • 再次執行”hb -v“,有以下版本顯示則表示安裝的hb版本正確。
[OHOS INFO] hb version 0.4.4
安裝交叉編譯環境

在Linux編譯服務器上搭建好基礎開發環境后,需要安裝OpenHarmony 編譯V200Z-R平臺特有的開發環境。

安裝arm-none-eabi-gcc
  • 打開Linux終端。
  • 下載[arm-none-eabi-gcc]編譯工具。
  • 安裝[arm-none-eabi-gcc]

解壓 [gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2]安裝包至~/toolchain/路徑下。

mkdir -p ~/toolchain/
tar -jxvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C ~/toolchain/

設置環境變量。

vim ~/.bashrc

將以下命令拷貝到.bashrc文件的最后一行,保存并退出。

export PATH=~/toolchain/gcc-arm-none-eabi-10.3-2021.10/bin:$PATH

生效環境變量。

source ~/.bashrc
  • 在命令行中輸入如下命令,如果能正確顯示編譯器版本號,表明編譯器安裝成功。
arm-none-eabi-gcc -v

準備工程

本用例采用repo的方式從碼云官倉下載系統系統源碼以及開發板適配代碼,使用git從gitee的sig倉庫拉取設備應用代碼。

配置git
  • 提前注冊準備碼云gitee賬號。
  • git工具下載安裝
    sudo apt install git
    sudo apt install git-lfs
    
  • 生成/添加SSH密鑰:生成密鑰
    使用gitee賬號綁定的郵箱生成密鑰對
    ssh-keygen -t ed25519 -C "xxxxx@xxxxx.com"
    
  • 查看生成的密鑰
    cat ~/.ssh/id_ed25519.pub
    
  • 復制生成后的 ssh key,返回gitee個人主頁,通過主頁 「個人設置」->「安全設置」->「SSH 公鑰」 ,將生成的“SSH密鑰”添加到倉庫中。
  • 配置git用戶信息
    git config --global user.name "yourname"
    git config --global user.email "your-email-address"
    git config --global credential.helper store
    
準備repo
sudo curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
準備系統源碼
#特別注意:請下載OpenHarmony 3.1 Beta版本
mkdir ~/OpenHarmony_3.1_Beta
cd ~/OpenHarmony_3.1_Beta
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1-Beta --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'

注意:

  • 權限問題請參考[生成/添加SSH公鑰]。
  • 若在已安裝python3.8后,執行repo init 時,仍顯示如下錯誤:
/usr/bin/env: ‘python’: No such file or directory

執行如下命令后,進行重試:

sudo ln -s /usr/bin/python3.8 /usr/bin/python
準備設備側應用代碼

使用git 命令下載。

git clone git@gitee.com:openharmony-sig/knowledge_demo_smart_home.git --depth=1
編譯前準備
  • 代碼拷貝
mkdir ~/OpenHarmony_3.1_Beta/vendor/team_x/
主代碼拷貝:
cp -rfa  ~/knowledge_demo_smart_home/dev/team_x/smart_humidifier  ~/OpenHarmony_3.1_Beta/vendor/team_x/
iot_link三方庫拷貝:
cp -rfa  ~/knowledge_demo_smart_home/dev/third_party/iot_link ~/OpenHarmony_3.1_Beta/third_party/
common庫拷貝:
cp -rfa ~/knowledge_demo_smart_home/dev/team_x/common ~/OpenHarmony_3.1_Beta/vendor/team_x
iot_link庫拷貝:
cp -rfa ~/knowledge_demo_smart_home/dev/third_party/iot_link ~/OpenHarmony_3.1_Beta/third_party/

步驟1. 下載patch [地址]

? 點擊上述鏈接進入瀏覽器,將該網頁中內容全部復制。

? 本地創建一個名為***.patch文件,并將已經復制的內容粘貼到該文件中。

步驟2. 打上步驟1中的patch

cd ~/OpenHarmony_3.1_Beta/kernel/liteos_m
patch -p1 < ***.patch
  • device/soc/bestechnic 修改

步驟1. 下載patch

? 點擊上述鏈接進入瀏覽器,將該網頁中內容全部復制。

? 本地創建一個名為***.patch文件,并將已經復制的內容粘貼到該文件中。

步驟2. 打上步驟1中的patch

cd ~/OpenHarmony_3.1_Beta/device/soc/bestechnic
patch -p1 < ***.patch
  • third_party/mbedtls 修改

參考如下代碼段修改 platform.c 和BUILD.gn

diff --git a/library/platform.c b/library/platform.c
index c4c3fd3..214173b 100755
--- a/library/platform.c
+++ b/library/platform.c
@@ -86,9 +86,24 @@ static void platform_free_uninit( void *ptr )
 static void * (*mbedtls_calloc_func)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC;
 static void (*mbedtls_free_func)( void * ) = MBEDTLS_PLATFORM_STD_FREE;
 
+#include "los_memory.h"
+
 void * mbedtls_calloc( size_t nmemb, size_t size )
 {
-    return (*mbedtls_calloc_func)( nmemb, size );
+    //return (*mbedtls_calloc_func)( nmemb, size );
+    size_t real_size;
+    void *ptr = NULL;
+
+    if (nmemb == 0 || size == 0) {
+        return NULL;
+    }
+
+    real_size = (size_t)(nmemb * size);
+    ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, real_size);
+    if (ptr != NULL) {
+        (void)memset_s(ptr, real_size, 0, real_size);
+    }
+    return ptr;
 }
diff --git a/BUILD.gn b/BUILD.gn
index 9ecb37a..30dbb2e 100755
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -124,6 +124,7 @@ if (defined(ohos_lite)) {
         "http://kernel/liteos_m/kernel/include",
         "http://kernel/liteos_m/utils",
         "http://third_party/musl/porting/liteos_m/kernel/include/",
+        "http://kernel/liteos_m/kernel/include/",
       ]
     }
     output_name = "mbedtls"
  • third_party/lwip 修改

修改src/api/netdb.c 文件

diff --git a/src/api/netdb.c b/src/api/netdb.c
index 52a6fdf..2043636 100644
--- a/src/api/netdb.c
+++ b/src/api/netdb.c
@@ -100,7 +100,7 @@ lwip_gethostbyname(const char *name)
   err = netconn_gethostbyname(name, &addr);
   if (err != ERR_OK) {
     LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%dn", name, err));
-    h_errno = HOST_NOT_FOUND;
+    //h_errno = HOST_NOT_FOUND;
     return NULL;
   }
  • 修改iot_link中的部分文件

步驟1. third_party/iot_link/network/mqtt/paho_mqtt/port/paho_mqtt_port.c

測試發現,當fd為0的時候,在執行recv時會立馬返回-1,因此做下面規避操作。

static int __socket_connect(Network *n, const char *host, int port)
{
    ...
    int tmpfd = socket(AF_INET,SOCK_STREAM,0); // to skip fd = 0;
    fd = socket(AF_INET,SOCK_STREAM,0);
    if(fd == -1) {
        return ret;
    }
    close(tmpfd);       // to skip fd = 0;
    ...
}

系統setsockopt函數未適配,因此需要做下面的修改:

static int __socket_read(void *ctx, unsigned char *buf, int len, int timeout)
{
    int fd;
    int ret = 0;
#if 0
    struct timeval timedelay = {timeout / 1000, (timeout % 1000) * 1000};
    if(NULL== buf)
    {
        return ret;
    }
    
    fd = (int)(intptr_t)ctx;  ///< socket could be zero

    if (timedelay.tv_sec < 0 || (timedelay.tv_sec == 0 && timedelay.tv_usec <= 0))
    {
        timedelay.tv_sec = 0;
        timedelay.tv_usec = 100;
    }
    
    if(0 != setsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,&timedelay,sizeof(struct timeval)))
    {
        return ret;  //could not support the rcv timeout
    }
    int bytes = 0;
    while (bytes < len) {
        int rc = recv(fd, &buf[bytes], (size_t)(len - bytes), 0);
        printf("[%s|%s|%d]fd = %d, rc = %dn", __FILE__,__func__,__LINE__, fd, rc);
        if (rc == -1) {
            if (errno != EAGAIN && errno != EWOULDBLOCK) {
                bytes = -1;
            }
            break;
        } else if (rc == 0) {
            bytes = 0;
            break;
        } else {
            bytes += rc;
        }
    }
    return bytes;
#else
    int bytes = 0;
    fd_set fdset;

    struct timeval timedelay = {timeout / 1000, (timeout % 1000) * 1000};
    if(NULL== buf)
    {
        return ret;
    }
    
    fd = (int)(intptr_t)ctx;  ///< socket could be zero

    if (timedelay.tv_sec < 0 || (timedelay.tv_sec == 0 && timedelay.tv_usec <= 0))
    {
        timedelay.tv_sec = 0;
        timedelay.tv_usec = 100;
    }
    timedelay.tv_sec = 2;
    FD_ZERO(&fdset);
    FD_SET(fd, &fdset);

    ret = select(fd + 1, &fdset, NULL, NULL, &timedelay);
    if (ret > 0) {
        while (bytes < len) {
            int rc = recv(fd, &buf[bytes], (size_t)(len - bytes), 0);
 //         printf("[%s|%s|%d]fd = %d, rc = %d, errno=%d(%s)n", __FILE__,__func__,__LINE__, fd, rc,errno, strerror(errno));
            if (rc == -1) {
                if (errno != EAGAIN && errno != EWOULDBLOCK) {
                    bytes = -1;
                }
                break;
            } else if (rc == 0) {
                bytes = 0;
                break;
            } else {
                bytes += rc;
            }
        }
    }

    return bytes;
#endif
}

步驟2. third_party/iot_link/network/dtls/mbedtls/mbedtls_port/dtls_interface.c

系統部分mbedtls接口不一致,固需要注釋部分接口代碼:

mbedtls_ssl_context dtls_ssl_new(dtls_establish_info_s *info, char plat_type)
{
    ...
    if (info- >psk_or_cert == VERIFY_WITH_PSK)
    {
/*
        if ((ret = mbedtls_ssl_conf_psk(conf,
                                        info- >v.p.psk,
                                        info- >v.p.psk_len,
                                        info- >v.p.psk_identity,
                                        strlen((const char *)info- >v.p.psk_identity))) != 0)
        {
            MBEDTLS_LOG("mbedtls_ssl_conf_psk failed: -0x%x", -ret);
            goto exit_fail;
        }
*/
    }
    ...
}

int dtls_shakehand(mbedtls_ssl_context *ssl, const dtls_shakehand_info_s *info)
{
    ...
    if (MBEDTLS_SSL_IS_CLIENT == info- >client_or_server)
    {
        ret = mbedtls_net_connect(server_fd, info- >u.c.host, info- >u.c.port, info- >udp_or_tcp);
        if( 0 != ret)
        {
            ret = MBEDTLS_ERR_NET_CONNECT_FAILED;
            goto exit_fail;
        }
    }
    else
    {
        //server_fd = (mbedtls_net_context*)atiny_net_bind(NULL, info- >u.s.local_port, MBEDTLS_NET_PROTO_UDP);
        ///< --TODO ,not implement yet
    }
    ...
}

void dtls_init(void)
{
    (void)mbedtls_platform_set_calloc_free(calloc, free);
    (void)mbedtls_platform_set_snprintf(snprintf);
//    (void)mbedtls_platform_set_printf(printf);
}

步驟3. 修改dtls下的BUILD.gn因為弱引用導致無法鏈接相關符號

diff --git a/dev/third_party/iot_link/network/dtls/BUILD.gn b/dev/third_party/iot_link/network/dtls/BUILD.gn
index 035805d7..05188295 100755
--- a/dev/third_party/iot_link/network/dtls/BUILD.gn
+++ b/dev/third_party/iot_link/network/dtls/BUILD.gn
@@ -17,6 +17,7 @@ dtls_inc = [
     "../../link_misc",
     "http://kernel/liteos_m/components/cmsis/2.0",
     "http://third_party/mbedtls/include/",
+    "http://base/hiviewdfx/hilog_lite/interfaces/native/innerkits/",^M
 ]
 
 
@@ -41,7 +42,8 @@ dtls_cflags = [
     "-Wno-unused-parameter",
 ]
 
-static_library("dtls") {
+#static_library("dtls") {^M
+source_set("dtls") {^M
         cflags = dtls_cflags
         defines = dtls_def
         sources = dtls_src

步驟4. 修改mqtt下的BUILD.gn因為弱引用導致無法鏈接相關符號

diff --git a/dev/third_party/iot_link/network/mqtt/BUILD.gn b/dev/third_party/iot_link/network/mqtt/BUILD.gn
index 5a4a8e0d..f56f4ae6 100755
--- a/dev/third_party/iot_link/network/mqtt/BUILD.gn
+++ b/dev/third_party/iot_link/network/mqtt/BUILD.gn
@@ -16,8 +16,10 @@ mqtt_paho_inc = [
     "paho_mqtt/paho/MQTTPacket/src",
     "paho_mqtt/port",
     "../../inc",
+    "http://third_party/musl/porting/liteos_m/kernel/include/",^M
     "http://kernel/liteos_m/components/cmsis/2.0",
     "http://vendor/hisi/hi3861/hi3861/third_party/lwip_sack/include/",
+    "http://base/hiviewdfx/hilog_lite/interfaces/native/innerkits/",^M
 ]
 
 
@@ -50,7 +52,8 @@ mqtt_cflags = [
     "-Wno-unused-function",
 ]
 
-static_library("mqtt") {
+#static_library("mqtt") {^M
+source_set("mqtt") {^M
         cflags = mqtt_cflags
         defines = mqtt_paho_defs
         sources = mqtt_paho_src

步驟5. 修改時間編譯問題:

iff --git a/dev/third_party/iot_link/network/mqtt/paho_mqtt/port/paho_osdepends.h b/dev/third_party/iot_link/network/mqtt/paho_mqtt/port/paho_osdepends.h
index 2c6cab1b..38e3dce3 100755
--- a/dev/third_party/iot_link/network/mqtt/paho_mqtt/port/paho_osdepends.h
+++ b/dev/third_party/iot_link/network/mqtt/paho_mqtt/port/paho_osdepends.h
@@ -84,6 +84,7 @@
 
 #include "ohos_init.h"
 #include "cmsis_os2.h"
+#include "sys/time.h"
 #include  < mqtt_al.h >
 
 #define MQTT_TASK 1
@@ -117,6 +118,13 @@ typedef struct Thread
 int ThreadStart(Thread*, void (*fn)(void*), void* arg);
 
 
+#define timeradd(s,t,a) (void) ( (a)- >tv_sec = (s)- >tv_sec + (t)- >tv_sec, ^M
+        ((a)- >tv_usec = (s)- >tv_usec + (t)- >tv_usec) >= 1000000 && ^M
+        ((a)- >tv_usec -= 1000000, (a)- >tv_sec++) )^M
+#define timersub(s,t,a) (void) ( (a)- >tv_sec = (s)- >tv_sec - (t)- >tv_sec, ^M
+        ((a)- >tv_usec = (s)- >tv_usec - (t)- >tv_usec) < 0 && ^M
+        ((a)- >tv_usec += 1000000, (a)- >tv_sec--) )^M
+^M
 typedef struct Network
 {
     void *ctx;                      ///< if it is tls, then it is tls context, else it is socket fd
  • 配置相關的修改

步驟1. gpio hdf框架相關修改。

根據下方代碼修改drivers/adapter/platform/gpio/gpio_bes.c

diff --git a/platform/gpio/gpio_bes.c b/platform/gpio/gpio_bes.c
index ed4d18b..890d528 100755
--- a/platform/gpio/gpio_bes.c
+++ b/platform/gpio/gpio_bes.c
@@ -257,7 +257,7 @@ static int32_t GpioDriverBind(struct HdfDeviceObject *device)
     }

     gpioCntlr.device.hdfDev = device;
-    device- >service = gpioCntlr.device.service;
+    device- >service = &(gpioCntlr.device);

     return HDF_SUCCESS;
 }

步驟2 . uart相關配置,本實例使用uart1接口,相對應的GPIO為gpio20,gpio21。電機控制使用的gpio11,相關的配置如下所示,文件路徑:/home/water/OpenHarmony_3.1_Beta/device/board/fnlink/shields/v200zr-evb-t1/v200zr-evb-t1.hcs

diff --git a/shields/v200zr-evb-t1/v200zr-evb-t1.hcs b/shields/v200zr-evb-t1/v200zr-evb-t1.hcs
index 44212eb..f8d0985 100644
--- a/shields/v200zr-evb-t1/v200zr-evb-t1.hcs
+++ b/shields/v200zr-evb-t1/v200zr-evb-t1.hcs
@@ -1,6 +1,6 @@
 #include "../../hcs/v200zr.hcs"
 root {
-    /*device_info {
+    device_info {
         platform :: host {
             device_uart :: device {
                 uart2 :: deviceNode {
@@ -8,21 +8,21 @@ root {
                     priority = 40;                      
                     permission = 0644;                  
                     moduleName = "BES_UART_MODULE_HDF";   
-                    serviceName = "HDF_PLATFORM_UART_2";
+                    serviceName = "HDF_PLATFORM_UART_1";
                     deviceMatchAttr = "uart2_config";
                 }
             }
         }
-    }*/
+    }
     platform {
         gpio_config {
             match_attr = "gpio_config";
-            pin = [0, 1];
+            pin = [0, 1, 2];
             // touch_ztw523: TSP_RST - GPIO12, TSP_INT-GPIO27
             // touch_fts: TSP_RST - GPIO05, TSP_INT-GPIO27
-            realPin = [5, 27];
-            config = [5, 2];
-            pinNum = 2;
+            realPin = [5, 27, 11];
+            config = [5, 2, 2];
+            pinNum = 3;
         }
         i2c_config {
             i2c0 {
@@ -52,7 +52,7 @@ root {
                 mode = 0;
             }
         }
-        /*uart_config {
+        uart_config {
             template uart_controller {
                 match_attr = "";
                 num = 0;
@@ -65,9 +65,9 @@ root {
             }
             uart2 :: uart_controller {
                 match_attr = "uart2_config";
-                num = 2;
+                num = 1;
             }
-        }*/
+        }
     }
     display {
         panel_config {
(END)

步驟3. iic相關的配置,使i2c1通道和芯片管腳gpio6,gpio7相關的配置如下:

i2c_config {
            i2c1 {
                match_attr = "i2c1_config";
                port = 1;
                speed = 200000;
                // TSP_SCL/SDA - I2C1 = GPIO06/GPIO07
                sclPin = 6;
                sdaPin = 7;
                useDma = 0;
                useSync = 1;
                asMaster = 1;
                address_width = 8;
                mode = 0;
            }
        }
  • 將JS應用合入工程。

本節為可選章節,忽略本節內容不影響本項目的展示和運行。但若想要在本項目的基礎上進行涉及到顯示的內容修改與新規開發,則需完整的閱讀本節及鏈接內容。

1.下載并安裝[DevEco Studio]。

2.新建一個js工程。

工程名為:smart_humidifier/FA

project

3.在DevEco Studio的SDK中添加@system.communicationkit.d.ts文件。

將@system.communicationkit.d.ts文件(源文件目錄:~/knowledge_demo_smart_home/dev/interface/sdk-js/api/common/@system.communicationkit.d.ts)拷貝到DevEco Studio的SDK中(目標目錄: HarmonyOS Legacy SDK /js/3.0.0.0/api/common)。HarmonyOS Legacy SDK目錄在DevEco Studio安裝時,由用戶配置,該目錄位置可在設置(ctrl+alt+s)中查找。

setting

4.編譯hap包。

依次選擇構建 -> Build Hap(s)/APP(s) -> Build Hap(s)進行hap包編譯。

build

5.使用預覽功能得到 js 包: entry.previewintermediatesresdebugliteassetsjsdefault

image-20211229115647534

將 js 包放到文件系統里面:

default目錄中除app.js.map外的的數據全部拷貝到OpenHarmonySDK中的//vendor/team_x/smart_humidifier/fs/data/data/js目錄下:

需要注意 :FA的bundleName必須和工程代碼//vendor/team_x/smart_humidifier/demo_smart_humidifier/ability/ability_device.cpp文件里面定義的JS_BUNDLE_NAME一致。

#define JS_BUNDLE_NAME "com.example.control_panel2.hmservice"

FA中的bundleName:

image-20211229115647534

工程效果

整合并修改完成后的代碼目錄結構如下圖:

image-20211229115647534

編譯

編譯命令:

hb set  // 如果是第一次編譯,Input code path 命令行中鍵入"./" 指定OpenHarmony工程編譯根目錄后 回車,

如下圖所示,使用鍵盤上下鍵選中智能加濕器 “smart_humidifier”,(注:工程名字根據實際要編譯的工程來)如圖:

image-20211229115748113

hb build // 如果需要全量編譯,可以添加-f 選項

編譯通過,生成固件成功,如圖:

image-20211229120006333

燒錄/安裝

  • 安裝[CP2102驅動]
  • 固件編譯完成以后拷貝./out/v200zr/smart_door_bell/write_flash_gui文件夾到windows下,并點擊Wifi_download_main.exe

downlaod

  • 點擊工具上的文件夾圖標

downlaod

  • 選擇List按鈕

downlaod

  • 在顯示出來的串口列表中選擇需要燒錄的串口,并點擊開始按鈕。

downlaod

  • 在開發板上點擊reset按鍵,或者重新上電。

reset

  • 進入燒錄狀態

download end

  • 燒錄成功

download over

操作體驗

鴻蒙開發應用知識已更新[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

設備配網
  • 在設備上電前需準備好安裝了數字管家應用的HarmonyOS手機, 并在設置中開啟手機的NFC功能;
  • 寫設備NFC標簽;
  • 燒錄完成后,上電,將手機上半部靠近NFC標簽;
  • 無需任何操作手機將自動拉起數字管家應用并進入配網界面,輸入熱點密碼。

humidifier connect

設備操作

手機端開關機

審核編輯 黃宇

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 加濕器
    +關注

    關注

    3

    文章

    155

    瀏覽量

    20338
  • 鴻蒙
    +關注

    關注

    55

    文章

    1760

    瀏覽量

    42153
  • HarmonyOS
    +關注

    關注

    79

    文章

    1876

    瀏覽量

    29330
  • OpenHarmony
    +關注

    關注

    23

    文章

    3375

    瀏覽量

    15192
收藏 人收藏

    評論

    相關推薦

    OpenHarmony南向開發案例:【分布式畫板】

    使用OpenHarmony3.1-Release開發的應用。通過OpenHarmony的分布式技術,使多人能夠一起畫畫。
    的頭像 發表于 04-12 14:40 ?554次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【分布式畫板】

    OpenHarmony南向開發案例:【智能油煙機】

    基于Hi3516開發板,使用開源OpenHarmony開發的應用。
    的頭像 發表于 04-18 15:54 ?679次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【<b class='flag-5'>智能</b>油煙機】

    OpenHarmony南向開發案例:【 智能家居中控】

    今天打造的這一款全新智能家庭控制系統,凸顯應用在智能控制和用戶體驗的特點,開創國內智能家居系統體驗新局面。新的系統主要應用在鴻蒙生態。
    的頭像 發表于 04-23 15:50 ?503次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【 <b class='flag-5'>智能</b>家居中控】

    鴻蒙開發南向環境搭建教學

    南向開發環境搭建教學,更多鴻蒙開發資料可以前往高清完整版 《鴻蒙開發4.0基礎-高階文檔》找保存
    發表于 01-05 16:38

    鴻蒙不再兼容安卓,那么鴻蒙開發者是否會大增?

    。以上為略縮版圖冊,如果需要高清完整的可以在主頁4或https://qr23.cn/AKFP8k保存。 內容涵蓋:(文檔形式) OpenHarmony入門基礎 OpenHarmony核心技能 OpenHarmony高級技能
    發表于 01-31 22:17

    OpenHarmony南向能力征集令

    1、適配過程中缺少哪些接口能力或者南向能力,需要OpenHarmony去補齊的?例如內核、編譯、器件適配、單板適配等; 2、對標linux,需要OpenHarmony提供哪些能力?比如V4L2
    發表于 04-09 15:32

    OpenHarmony開發樣例】智能加濕器

    IOT云平臺指南;智能設備同數字管家應用之間的設備模型定義可以參考profile 。2.實物簡介如上圖,我們使用V200Z-R藍牙WIFI語音AIoT模組恒玄BES2600WM開發板來模擬智能
    發表于 03-24 11:28

    凌蒙派-開源鴻蒙北向App控制南向設備應用示例-RGB燈控制

    OpenHarmony標準系統,rgb三色燈APP控制,hdf?napi?UI框架,一個開源鴻蒙北向應用開發,控制南向設備應用。
    發表于 03-22 10:56

    openharmony鴻蒙有什么關系

    ,讓平板、手機、智能家居都可以通過建房子搭積木的方式來使用鴻蒙系統。 openharmony鴻蒙之間屬于相輔相成的,可以說openharmony
    的頭像 發表于 06-22 16:02 ?1.1w次閱讀

    華為開發者分論壇HarmonyOS學生公開課-OpenHarmony Codelabs開發案

    2021華為開發者分論壇HarmonyOS學生公開課-OpenHarmony Codelabs開發案
    的頭像 發表于 10-24 11:25 ?1635次閱讀
    華為<b class='flag-5'>開發</b>者分論壇HarmonyOS學生公開課-<b class='flag-5'>OpenHarmony</b> Codelabs<b class='flag-5'>開發案</b>例

    OpenHarmony Dev-Board-SIG專場:南向共建案例分享

    OpenHarmony南向共建案例分享: 審核編輯:金巧
    的頭像 發表于 12-28 14:16 ?840次閱讀
    <b class='flag-5'>OpenHarmony</b> Dev-Board-SIG專場:<b class='flag-5'>南向</b>共建案例分享

    OpenHarmony南向開發案例:【智能照相機】

    基于Hi3516開發板,使用OpenHarmony3.0-LTS開發的應用。通過獲取攝像頭數據,實現預覽拍照以及路視頻等功能。并且通過后臺AI服務識別喚醒詞來進行語音控制拍照及錄制視頻。
    的頭像 發表于 04-18 22:19 ?91次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【<b class='flag-5'>智能</b>照相機】

    OpenHarmony鴻蒙南向開發案例:【智能門鈴】

    智能門鈴通過監控來訪者信息,告訴主人門外是否有人按鈴、有陌生人靠近或者無人狀態。
    的頭像 發表于 04-19 15:35 ?142次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>鴻蒙</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【<b class='flag-5'>智能</b>門鈴】

    OpenHarmony鴻蒙南向開發案例:【智能燃氣檢測設備】

    安全廚房案例中的相關智能燃氣檢測設備,本安全廚房案例利用輕量級軟總線能力,將兩塊歐智通V200Z-R/BES2600開發板模擬的智能燃氣檢測設備和燃氣告警設備組合成。當燃氣數值告警時,無需其它操作,直接通知軟總線網絡中的通風設備
    的頭像 發表于 04-19 17:17 ?198次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>鴻蒙</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【<b class='flag-5'>智能</b>燃氣檢測設備】

    OpenHarmony鴻蒙南向開發案例:【智能貓眼(基于3516開發板)】

    基于Hi3516開發板,使用開源OpenHarmony開發的RTSP協議流媒體應用。達到將Hi3516開發板中攝像頭獲取的數據通過RTSP協議傳輸到手機并顯示 。
    的頭像 發表于 04-19 22:01 ?75次閱讀
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>鴻蒙</b><b class='flag-5'>南向</b><b class='flag-5'>開發案</b>例:【<b class='flag-5'>智能</b>貓眼(基于3516<b class='flag-5'>開發</b>板)】
    亚洲欧美日韩精品久久_久久精品AⅤ无码中文_日本中文字幕有码在线播放_亚洲视频高清不卡在线观看
    <acronym id="s8ci2"><small id="s8ci2"></small></acronym>
    <rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
    <acronym id="s8ci2"></acronym>
    <acronym id="s8ci2"><center id="s8ci2"></center></acronym>