场景简介
随着大量的中小商户使用移动支付进行收款的普及,中小商户面临着收款逃单漏单的困扰。云喇叭(收款音箱)作为一款实用的收款播报工具,通过收款的实时语音播报有效提升商户的收款体验,已成为各支付平台必备的商户服务智能硬件产品。本文档以云喇叭(收款音箱)应用场景为例,介绍如何通过合宙Cat.1模组Air780E 接入腾讯云物联网开发平台以实现语音播报场景物联应用。
硬件设备
需要的硬件全家福如下,合宙官方有相关的开发套餐可以直接购买体验。
1. Air780E开发板(需要一张可以上网的SIM卡)。
2. 音频扩展板。
3. 喇叭。
创建产品和设备
1. 登录腾讯云物联网开发平台控制台。
2. 点击公共实例->新建项目->保存。
3. 点击进入上一步新建的项目,点击新建产品,进入新建产品界面。
4. 点击进入上一步创建的产品界面,在第一步物模型界面,点击导入物模型,然后将以下物模型复制粘贴到文本框。
{"version": "1.0","properties": [{"id": "lac","name": "地区区域码","desc": "地区区域码","required": true,"mode": "r","define": {"type": "int","unit": "","step": "1","min": "0","max": "32","start": "0"}},{"id": "cid","name": "基站码","desc": "基站码","required": true,"mode": "r","define": {"type": "int","unit": "","step": "1","min": "0","max": "32","start": "0"}},{"id": "mnc","name": "移动网号","desc": "移动网号","required": false,"mode": "r","define": {"type": "int","unit": "","step": "1","min": "0","max": "5","start": "0"}},{"id": "mcc","name": "移动国家号码","desc": "移动国家号码","required": false,"mode": "r","define": {"type": "int","unit": "","step": "1","min": "0","max": "5","start": "0"}},{"id": "networkType","name": "网络制式","desc": "网络制式","required": false,"mode": "r","define": {"type": "enum","mapping": {"1": "GSM","2": "CDMA","3": "WCDMA","4": "TD_WCDMA","5": "LTE"}}},{"id": "keepalive","name": "心跳间隔","desc": "","mode": "rw","define": {"type": "int","min": "0","max": "10000","start": "30","step": "1","unit": ""},"required": false},{"id": "signal_level","name": "信号强度","desc": "","mode": "rw","define": {"type": "int","min": "0","max": "1000","start": "0","step": "1","unit": ""},"required": false},{"id": "battery","name": "剩余电量","desc": "","mode": "r","define": {"type": "int","min": "0","max": "100","start": "0","step": "1","unit": "%"},"required": false},{"id": "imei","name": "IMEI","desc": "","mode": "r","define": {"type": "string","min": "0","max": "40"},"required": false},{"id": "imsi","name": "IMSI","desc": "","mode": "r","define": {"type": "string","min": "0","max": "40"},"required": false},{"id": "iccid","name": "ICCID","desc": "","mode": "r","define": {"type": "string","min": "0","max": "40"},"required": false},{"id": "ota_type","name": "OTA类型","desc": "指定OTA类型,是否播报提示等\\"","mode": "rw","define": {"type": "enum","mapping": {"0": "不播报系统升级提示","1": "播报系统升级提示"}},"required": false},{"id": "battery_voltage","name": "电池电压","desc": "电池电压 单位mv","mode": "r","define": {"type": "int","min": "0","max": "1000000","start": "0","step": "1","unit": "mv"},"required": false},{"id": "charge_status","name": "充电状态","desc": "","mode": "r","define": {"type": "bool","mapping": {"0": "未充电","1": "正在充电"}},"required": false}],"events": [{"id": "payment_play_result","name": "播报结果反馈","desc": "","type": "info","params": [{"id": "idempotent","name": "幂等ID","define": {"type": "string","min": "0","max": "32"}},{"id": "recv_timestamp","name": "收到播报消息时间戳","define": {"type": "timestamp"}},{"id": "play_timestamp","name": "播报时间戳","define": {"type": "timestamp"}},{"id": "play_result","name": "播报结果","define": {"type": "enum","mapping": {"0": "播报成功","1": "播报失败"}}}],"required": false}],"actions": [{"id": "payment_play","name": "收款播报","desc": "","input": [{"id": "content","name": "播报内容","define": {"type": "string","min": "0","max": "2048"}},{"id": "money","name": "收款金额","define": {"type": "int","min": "0","max": "10000000","start": "0","step": "1","unit": ""}},{"id": "from","name": "收款来源","define": {"type": "enum","mapping": {"0": "微信","1": "支付宝","2": "云闪付"}}},{"id": "idempotent","name": "幂等ID","define": {"type": "string","min": "0","max": "32"}}],"output": [{"id": "play_rsp","name": "播报结果","define": {"type": "enum","mapping": {"0": "加入播报队列成功","1": "幂等ID重复","2": "播报队列满","3": "播报参数错误"}}}],"required": false}],"profile": {"ProductId": "xxxxx","CategoryId": "1"}}
至此,我们导入了云喇叭专用的物模型。
5. 使能动态注册功能,然后记录这里的生成的产品密钥,后期要放到设备端sdk里。关于动态注册的更多内容,请访问产品级密钥认证。
至此,控制台的操作就已全部完成。
Air780E设备端开发
1. 首先拿到合宙的Air780E二次开发的C-SDK。
2. 根据Air780E的二次开发C-SDK教程,搭建开发&编译环境,可以正常编译project目录下的项目,如果编译完成,可以在out目录下生成相应的*.binpkg文件。如果编译过程中遇到问题,可以根据C-SDK软件开发资料排查,或者联系合宙提供技术支持。
3. 联系对应腾讯云物联网开发平台的销售or产品经理,拿到适配腾讯云物联网开发平台的云喇叭sdk,导入到当前工程。
4. 修改qcloud_speaker工程中的三元组信息,填入上一步在控制台创建的产品的产品ID、产品密钥,SDK会在第一次连接腾讯云物联网开发平台的时候,通过动态注册的方式生成一个设备名为当前模组的IMEI的设备,之后会通过这个三元组信息接入腾讯云物联网开发平台。
#define YOUR_PRODUCT_ID "填入你控制台生成的产品ID"#define YOUR_DEVICE_NAME "设备名会获取当前模组的IMEI号,可以不填"#define YOUR_DEVICE_SECRET "IOT_PSK" // 无需修改#define YOUR_PRODUCT_SECRET "填入你控制台生成的产品密钥"
5. 编译qcloud_speaker工程,生成相应的qcloud_speaker.binpkg烧录文件。
text data bss dec hex filename2545256 28536 613166 3186958 30a10e build/qcloud_speaker/qcloud_speaker.elf-outfile ./out/qcloud_speaker/qcloud_speaker.binpkg[100%]: build ok!
烧录&演示
1. 下载合宙Luatools最新版本的烧录调试工具。
2. Air780E确认插好能正常上网的SIM卡,然后使用USB-C线连接PC。
3. 打开LuatTools工具,Air780E开发板按POW按键开机,正常开机后,PC端设备管理器会枚举出三个USB转串口设备,同时Luatools也可以打印模组相关日志。
4. 点击下载固件打开烧录界面,然后找到上一步生成的/out/qcloud_speaker/qcloud_speaker.binpkg文件,点击下载。
5. 先按BOOT按键,然后按RST按键,让AIr780E进入升级模式。
6. 设备进入升级模式,开始烧录固件。
7. 烧录完成后,就可以在控制台模拟下发一笔收款。
8. 第三方平台可以对接腾讯云物联网开发平台的云API来完成对接。
视频演示