Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【XR806开发板试用】基于鸿蒙L0系统的智能WIFI台灯开发(简易版)

    Wireless & Analog Series
    1
    1
    1056
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gahowong LV 2 last edited by

      【XR806开发板试用】基于鸿蒙L0系统的智能WIFI台灯开发(简易版)

      一、环境搭建及固件编译

      环境搭建的过程就不说了,参考官方的教程,以下提及需要注意的几个点。
      1.在windows系统下会遇到各种各样的问题,推荐使用Linux系统环境。且为64位系统,官方推荐系统要求:Ubuntu16.04及以上64位系统版本。本人使用的环境为VM虚拟机ubuntu18.04。
      2.其次是Python版本,刚开始没注意看教程用了3.6的,推荐使用3.8版本。

      sudo apt upgrade && sudo apt install python3.8

      3.交叉编译链工具不要选择最新的,否者不成功。使用了论坛上推荐的版本。

      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
      

      二、固件编译及烧录

      同理,固件编译及烧录详细参考以下几点需要注意。
      1.首次编译工程,需要对原生库进行配置,否则无法编译通过,配置步骤如下:

      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
      

      2.编译生成的固件在device/xradio/xr806/xr_skylark/out,名称为xr_system.img。插入XR806开发板,因为开发板上用的是cp210x系列串口芯片,用lsusb命令查看时会多出一个名字带有 Silicon Labs CP210x UART Bridge的设备。然后使用ls /dev/ttyUSB*查看新增节点。

      3.烧录工具文件位于device/xradio/xr806/xr_skylark/tools下,工具名为phoenixMC,工具配置文件为settings.ini。

      4.烧录时,对路径长度有限制,使用短一点的路径能解决问题。

      5.烧录波特率3000000,烧录前注意勾选住硬件复位烧写模式。

      三、功能实现

      参考了官方的点灯教程

      创建工程

      在device/xradio/xr806/ohosdemo中新建一个文件夹,并命令为MYLED。
      在文件夹中新建文件main.c。
      在文件夹中新建文件BUILD.gn。~~~~

      user:~/workspace/Harmony/device/xradio/xr806/ohosdemo$ tree -L 2
      .
      ├── BUILD.gn
      └── MYLED
          ├── BUILD.gn
          └── main.c
      
      

      修改device/xradio/xr806/ohosdemo/LED/BUILD.gn

      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",
         ]
      }
      

      部分代码

      
      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, &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); 
              }
          }
          }
      }
      
      

      总结:

      新手上路,在学习过程中,踩了很多坑,但处理解决问题的过程把它当作学习的过程,由于开发板刚出来不久,学习的资料不是很齐全,学习起来有些困难。大多数历程还没跑起来,等有时间了再完善和丰富该项目的功能。

      1 Reply Last reply Reply Quote Share 0
      • 1 / 1
      • First post
        Last post

      Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策