AliOS Things 3.0 Application Note: Camera Distribution Network + nails + weather notification group show

Introduction

This example has the following three functions:

  1. Webcam distribution network.
  2. Push message to the nail base.
  3. To display today's weather.


TB1wqU9iAT2gK0jSZFkXXcIQFXa-1692-944.png

Show results

Weather Display


TB1H_M7iuL2gK0jSZFmXXc7iXXa-1174-1544.pn

Distribution demo

Click to view the distribution network video .

Operating procedures

Environment Configuration

  1. AliOS Things installation environment, Reference: Alios-Things-Environment-the Setup .
  2. AliOS Things 3.0 application development environment to build, reference AliOS Things 3.0 Application Development Guide .
  3. Ready developerkit development board.
  4. Download Application development Source: developerkit_app.zip .

Use vscode open developerkit_app source.

Source Directory Structure

.
├── Config.in
├── README.md
├── aos.mk
├── gui               # gui显示,包括进度条、天气界面等
├── http              # https client应用,包括上报消息到钉钉群,获取天气数据等
├── k_app_config.h
├── main.c            # 主入口函数
└── qr_decode         # 摄像头扫码识别

Configuration

Change AOS_SDK_PATH path
  • Edit .aos:
AOS_SDK_PATH=/Users/xxw/workspace/github/AliOS-Things
DEPENDENCIES=
MD5SUM_HEADER=a1a4b53ab917fb4a6cb08289b6007fe0

Changes /Users/xxw/workspace/github/AliOS-Thingsto your AliOS-Thingssource path.

  • Edit Config.in:
......
config AOS_SDK_PATH
    string
    default "/Users/xxw/workspace/github/AliOS-Things"
......

Changes /Users/xxw/workspace/github/AliOS-Thingsto your AliOS-Thingssource path.

Change the nail group robot token

Changes http/http_request.cin DINGTALK_TOKENyour nails group token, click here for detailed instructions:

/* dingtalk token */
#define DINGTALK_TOKEN "<YOUR-DINGTALK-TOKEN>"
Changing weather api of appcode

Change http/http_request.cin WEATHER_APPCODEyour appcode, click here for detailed instructions:

/* weather api appcode */
#define WEATHER_APPCODE "<YOUR-WEATHER-APPCODE>"

Burn Run

Download and run the burn, in accordance with the distribution network presentation process interface to display the weather. Wherein the distribution network dimensional code as follows:


TB1Y2U8iAT2gK0jSZPcXXcKkpXa-260-260.png

Source explained

QR scan code portion

本demo使用developerkit开发板的摄像头,通过摄像头扫二维码获取到wifi信息,然后连接到二维码。配网二维码中的wifi信息格式为:yunqiwifi&<ssid>&<passwd>,比如wifi名称为aiot,密码为12345678,那配网二维码中的wifi信息为:yunqiwifi&aiot&12345678

当然也可以用网上的二维码生成网站自己生成二维码:https://cli.im/

GUI部分

本demo基于littlevGL绘制了简单的UI交互界面,使用了littlevGL如下组件:

其中字体图标和中文字体在Iconfont中生成,也可以到FontEditor里面编辑字体,得到的ttf文件通过littlevGL提供的Font Converter在线工具转化为C文件。

https client部分

本示例使用到了AliOS Things 3.0提供的httpc组件,httpc组件支持多种RESTful的API调用,包括GET、POST、PUT、HEAD等,也支持https安全协议。

1. 钉钉群机器人:

本示例使用到了钉钉群自定义机器人的webhook功能,当设备上线后,会主动发送消息到钉钉群中,原理就是通过https client发送POST数据到机器人webhook中,就能够在钉钉群中显示相应POST的数据,该数据也支持markdown格式。

了解钉钉群自定义机器人如何运作的可以参考:自定义机器人

2. 天气API:

This example uses the API to the cloud Ali cloud market Weather API: National Weather Forecast queries, real-time weather, 24-hour weather, scenic weather forecast 7 days / 15 days [] [support high concurrent low-latency] , you can call for free. Please purchase the application (0 yuan free to buy), then get the appropriate access appcode:

undefined

How to Obtain the CA root certificate

This example uses https which interfaces are secure encrypted interface, you need to configure CA root certificate to be able to properly access these interfaces, how to get https site ca certificates please refer to: Export website https certificate .

Reference Documents

Guess you like

Origin yq.aliyun.com/articles/720391