<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【XR806开发板试用】基于鸿蒙L0系统的智能WIFI台灯开发（简易版）]]></title><description><![CDATA[<h1>【XR806开发板试用】基于鸿蒙L0系统的智能WIFI台灯开发（简易版）</h1>
<h2>一、环境搭建及固件编译</h2>
<p dir="auto">环境搭建的过程就不说了，参考<a href="https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md#/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md" target="_blank" rel="noopener noreferrer nofollow ugc">官方的教程</a>,以下提及需要注意的几个点。<br />
1.在windows系统下会遇到各种各样的问题，推荐使用Linux系统环境。且为64位系统，官方推荐系统要求：Ubuntu16.04及以上64位系统版本。本人使用的环境为VM虚拟机ubuntu18.04。<br />
2.其次是Python版本，刚开始没注意看教程用了3.6的，推荐使用3.8版本。</p>
<p dir="auto"><code>sudo apt upgrade &amp;&amp; sudo apt install python3.8</code></p>
<p dir="auto">3.交叉编译链工具不要选择最新的，否者不成功。使用了<a href="https://aijishu.com/a/1060000000247851" target="_blank" rel="noopener noreferrer nofollow ugc">论坛上推荐的版本</a>。</p>
<pre><code>wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
</code></pre>
<h2>二、固件编译及烧录</h2>
<p dir="auto">同理，固件编译及烧录<a href="https://xr806.docs.aw-ol.com/" target="_blank" rel="noopener noreferrer nofollow ugc">详细参考</a>以下几点需要注意。<br />
1.首次编译工程，需要对原生库进行配置，否则无法编译通过，配置步骤如下：</p>
<pre><code>cd device/xradio/xr806/xr_skylark
cp project/demo/audio_demo/gcc/defconfig .config
make menuconfig
make build_clean
make lib -j
cd -
hb set
hb build -f
</code></pre>
<p dir="auto">2.编译生成的固件在device/xradio/xr806/xr_skylark/out，名称为xr_system.img。插入XR806开发板，因为开发板上用的是cp210x系列串口芯片，用lsusb命令查看时会多出一个名字带有 Silicon Labs CP210x UART Bridge的设备。然后使用ls /dev/ttyUSB*查看新增节点。</p>
<p dir="auto">3.烧录工具文件位于device/xradio/xr806/xr_skylark/tools下，工具名为phoenixMC，工具配置文件为settings.ini。</p>
<p dir="auto">4.烧录时，对路径长度有限制，使用短一点的路径能解决问题。</p>
<p dir="auto">5.烧录波特率3000000，烧录前注意勾选住硬件复位烧写模式。</p>
<h2>三、功能实现</h2>
<p dir="auto">参考了官方的<a href="https://xr806.docs.aw-ol.com/study/soft_led/" target="_blank" rel="noopener noreferrer nofollow ugc">点灯教程</a></p>
<h3>创建工程</h3>
<p dir="auto">在device/xradio/xr806/ohosdemo中新建一个文件夹，并命令为MYLED。<br />
在文件夹中新建文件main.c。<br />
<a href="http://xn--BUILD-4n1h00cba399pg1e84s4qsea68c.gn" target="_blank" rel="noopener noreferrer nofollow ugc">在文件夹中新建文件BUILD.gn</a>。~~~~</p>
<pre><code>user:~/workspace/Harmony/device/xradio/xr806/ohosdemo$ tree -L 2
.
├── BUILD.gn
└── MYLED
    ├── BUILD.gn
    └── main.c

</code></pre>
<p dir="auto">修改device/xradio/xr806/ohosdemo/LED/BUILD.gn</p>
<pre><code>static_library("app_led") {
...
include_dirs += [
      "//kernel/liteos_m/kernel/arch/include",
      "//base/iot_hardware/peripheral/interfaces/kits",

      ".",
      "//utils/native/lite/include",
      "//device/xradio/xr806/xr_skylark/project"
      "//foundation/communication/wifi_lite/interfaces/wifiservice",
   ]
}
</code></pre>
<h4>部分代码</h4>
<pre><code>
void wifi_connect(void)
{
    const char ssid_want_connect[] = WIFI_DEVICE_CONNECT_AP_SSID;
    const char psk[] = WIFI_DEVICE_CONNECT_AP_PSK;

    printf("\n=========== Connected！！ ===========\n");

    if (WIFI_SUCCESS != EnableWifi()) {
        printf("Error: EnableWifi fail.\n");
        return;
    }
    printf("EnableWifi Success.\n"); 
    if (WIFI_SUCCESS != ConnectTo(netId)) {
        printf("Error: ConnectTo Fail\n");
        return;
    }    

    if (WIFI_STA_ACTIVE == IsWifiActive())
         IoTGpioSetOutputVal(GPIO_ID_PA21, 1); 
}

static void gpio_output_init(void)
{
    GPIO_InitParam param;
    param.driving = GPIO_DRIVING_LEVEL_1;
    param.mode = GPIOx_Pn_F1_OUTPUT;
    param.pull = GPIO_PULL_NONE;
    HAL_GPIO_Init(GPIO_OUTPUT_PORT, GPIO_PIN_21, &amp;param);//led灯对应IO
}

static void MainThread(void *arg)
{
    while(1) {
        sprintf(buf,"XR806:%s : %d \r\n",cJSON_Version(), cnt++);
        //向服务器发送数据
       send(s,buf, sizeof(buf), 0);
       if (value == 1)
        {
            IoTGpioSetOutputVal(GPIO_ID_PA21, 1);  
        }
        else
        {
            IoTGpioSetOutputVal(GPIO_ID_PA21, 0); 
        }
    }
    }
}

</code></pre>
<h2>总结：</h2>
<p dir="auto">新手上路，在学习过程中，踩了很多坑，但处理解决问题的过程把它当作学习的过程，由于开发板刚出来不久，学习的资料不是很齐全，学习起来有些困难。大多数历程还没跑起来，等有时间了再完善和丰富该项目的功能。</p>
]]></description><link>https://bbs.aw-ol.com/topic/838/xr806开发板试用-基于鸿蒙l0系统的智能wifi台灯开发-简易版</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 15:10:50 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/838.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Dec 2021 12:49:58 GMT</pubDate><ttl>60</ttl></channel></rss>