[Huawei's cloud technology to share best practices]] [IoT voice of wisdom smoke alarm (Configuration chapter)

Abstract We simulate a smoke alarm reporting smoke concentration and temperature, concentration and temperature are when the temperature exceeds the threshold set by the application server, the application server calls the announcement Huawei cloud service to make the user's mobile phone alarm.

Scene Description

IOT solution, a typical scenario is the report data to the device platform things, things pushed to internet application server, the application server performs service processing according to the data reported.

In this example, we simulate a smoke alarm reporting smoke concentration and temperature, concentration and temperature are when the temperature exceeds the threshold set by the application server, the application server calls the announcement Huawei cloud service to make the user's mobile phone alarm.

Huawei cloud voice used in this example notification service the needs of enterprise users can authenticate opened.

This example is run DEMO machine requires a push message server receives things platforms must bind an external network IP.

Configure device management services

Create a product model in device management services and register the device.

  1. Cloud log on the official website of Huawei, access device management services .

  2. Click "immediately" enter the Device Manager console.

  3. Click the upper right corner of the page, "enter the device management service" into the console.

  4. In the "application list" page, click on the application icon to view application details.

1578536256974190.png

The re-keying, and save the application ID and key after reset.

1578536388255106.png

6. Switch on the left menu, open the "product model" page, click on the upper right corner of the page, "new product model> Local Import."

Note: The product model and equipment used herein are examples only, you can use your own product model and operate the equipment.

7. Import sample model files, "product name" Custom, such as "Smokescope". Click here to get a sample model filespacer.gif

1578536539285698.png

8. enter the "Device> Device Registration" page, click "Create", fill out the registration device parameters.spacer.gif

1578536563247088.png 

9. Fill finished, click "OK" to save the registration Please note that the successful return of "Device ID" and a "key."

Configure voice call service

Opening the voice call service, and configure the voice application service resource templates, voice alarm notification function.

  1. Cloud log on the official website of Huawei, access voice calls .

  2. 单击“进入控制台”,申请开通服务。详情请参考如何订购并开通语音通话服务?服务开通后会收到包含开发者账号和开发者密码的短信。

  3. 登录语音通话管理控制台,添加企业

  4. 添加应用,业务类型为“语音通知”,根据业务需要选择是否开通录音和是否需要接收呼叫状态和呼叫话单通知。

  5. 本示例中不开通录音且不填写呼叫状态和呼叫话单的接收地址。

  6. 添加业务申请,申请CallEnabler业务号码和来电显示号码。

  7. 添加语音模板,模板样例如下:

  • 模板名称:smoke_alarm

  • 语速控制:正常

  • 模板内容:尊敬的${TXT_12},${TXT_32}可能发生火灾,请尽快确认并处理。

  • 备注:烟雾报警器报警后自动语音通知用户火灾发生地点。

开发物联网应用

开发物联网应用,实现设备上报的烟雾浓度和温度均高于阈值时,根据设备ID查找设备安装地点和关联手机号,调用语音通话服务的接口拨打该手机进行告警。

本文中使用DEMO进行演示,您可以参考DEMO开发自己的物联网应用进行使用。

  1. 点击下载烟感应用DEMO。

  2. 准备JAVA开发环境并导入DEMO工程,操作方法可参考开发指南

  3. 修改DEMO中的常量。

  • 打开“com.utils > Constant.java”。

1578536670734108.png

  • 修改IOT_BASE_URL为物联网平台的应用接入地址,可在设备接入服务的管理控制台查看。
  • 修改IOT_APPID和IOT_SECRET为配置设备管理服务时获取的应用ID和密钥。
  • 修改IOT_CALLBACK_URL中的IP为本机的外网IP,端口保持8888不变。
  • 修改CN_BASE_URL为语音通知的应用接入地址,可在语音通话服务管理控制台的“应用管理”页面获取。
  • 修改CN_APPID为语音通知应用的APP_Key,可在语音通话服务管理控制台的“应用管理”页面获取。
  • 修改CN_USERNAME和CN_PASSWORD为开通语音通话服务时短信通知的开发者账号和密码。
  • 修改TEMPLATEID为语音通知模板ID,可在语音通话服务管理控制台的“语音模板管理”页面获取。
  • 修改BINDNUM和DSPNUM为已申请的CallEnabler业务号码和和来电显示号码,可在语音通话服务管理控制台的“业务管理”页面获取。

 

验证操作

  1. 右键单击“com.iot_voice_demo > SubscribeServiceNotification.java”,选择“Run As > Java Application”,若控制台显示订阅返回“201 created”,表示DEMO运行成功。

  2. 控制设备上报数据。

  • 您可以使用配置设备管理服务时注册的真实设备接入平台,上报“smoke”和“temperature”均大于70的数据。

  • 您也可以使用模拟器模拟设备上报“smoke”和“temperature”均大于70的数据,操作方法请参考快速体验设备接入

期望结果:

手机收到呼叫,显示号码是DEMO中设置为DSPNUM的来电显示号码,接听后可听到语音通知,例如“尊敬的张三,A市B小区C栋1101可能发生火灾,请尽快确认并处理。”

Author: Huawei's cloud-cloud enjoy expert I was spiced corned egg

Published 961 original articles · won praise 5343 · Views 710,000 +

Guess you like

Origin blog.csdn.net/devcloud/article/details/103934131