当前位置:网站首页>Using bafayun to control the computer
Using bafayun to control the computer
2022-04-23 18:52:00 【Brick Porter】
Official website address https://cloud.bemfa.com/
The address above has a detailed description . If you have a server, you can also use various voice platforms to provide SDK To access . I have only one tmall elf myself , So the tmall elf I connected here , There is no server, so use off the shelf . It's bafayun above , Of course, there are many such platforms . I'm a random choice .
For Bafa cloud, access is very simple .
First step : Pay attention to a bafayun account
The second step : After logging in, find the console , Here's the private key . This is the verification during access .
The third step : Create a theme , Of course, it's not what you want to build , Bafayun IOT platform is connected to tmall Genie control by default , Only the following types of devices are supported : Socket 、 Light bulb: 、 Fan 、 sensor 、 Air conditioner 、 switch 、 The curtain .
Users can choose whether to access tmall elf or not , According to the subject name .
When the last three of the subject names are 001 It is a socket device when .
When the last three of the subject names are 002 Light bulb equipment .
When the last three of the subject names are 003 For fan equipment .
When the last three of the subject names are 004 It is a sensor device .
When the last three of the subject names are 005 Air conditioning equipment when .
When the last three of the subject names are 006 For switchgear .
When the last three of the subject names are 009 Curtain equipment .
When the subject name is other , The default is normal topic node , Will not sync to tmall elf app.
Step four : If it's above and equipment , Turn on the phone of tmall elf API, Search for Bafayun . Enter the previously registered account and password to associate the device to tmall elf .
Step five : Write code :
Because there is no computer , So here's a stupid way , After the tmall elf is associated with the device, the device name can be set , In this way, we name it Computer Let's say this to tmall xxx Computer , You can control the computer , It won't be too embarrassing .
The curtains I built here , So it can control the switch and opening and closing . It's no use driving , So I realized shutdown and volume control , If you use a computer Watch a movie or something , If you don't want to get out of bed in winter, you can turn it off . Of course, you can also combine multiple groups of devices and take different names to control it .
Code I use TCP The way , No encryption . The data it transmits is a string . First connect to bemfa.com port 8344.
After the connection is successful, send the command "cmd=1&uid=" + m_uid + "&topic=" + m_topic + "\r\n" Subscribe to device messages .uid Is the private key of the console ,topic Is the topic name you created ,, Of course, you can subscribe to multiple device formats here cmd=1&uid=7d54f85af42976ee3c2693e6xxxxxxxx&topic=light002,outlet001,topic003\r\n This format can be subscribed up to 8 Devices . After sending, receive the server message , return cmd=1&res=1 The subscription is successful . At this time, you can receive the message as long as you send it to the tmall elf voice control device .
Field description
cmd: For message type
cmd=1 Subscription message when , When the device sends this message type once , Then you can receive a message sent to the subject
cmd=2 When, it is a news release , Send a message to the device subscribing to the topic
cmd=3 It's a subscription message , and cmd=1 identical , And will pull a message that has been sent
cmd=7 Is to get time , Get the current Beijing time
cmd=9 For the will message , Pull a message that has been sent
uid: User private key
Available on the console
topic: User themes
You can create themes in the console , The format is English or number , Equivalent to equipment identification
msg: For the body of the message
Data that the user wants to send to a topic
Get time instruction description
type=1 Get the current date and time , for example :2021-06-11 17:20:54
type=2 Get the current time , for example :17:20:54
type=3 Get the current timestamp , for example :1623403325
Symbol description
\r\n: Replace carriage return , Every command needs to be followed by a carriage return line feed
&: For the connector , Use... Between fields '&' Isolation
Heartbeat description
Send arbitrary data For heartbeat messages , Including the above instructions is also a heartbeat , But end with carriage return and line feed .
The heartbeat message tells the server that the device is still online , can 30 Seconds to send , End with \r\n ending .
版权声明
本文为[Brick Porter]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210603257269.html
边栏推荐
- Introduction to QT programming
- Esp32 drive encoder -- siq-02fvs3 (vscade + IDF)
- Machine learning theory (8): model integration ensemble learning
- Seata处理分布式事务
- Yyds dry goods inventory stringprep --- Internet string preparation
- os_ authent_ Prefix
- 使用晨曦记账本,分析某个时间段每个账户收支结余
- [today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
- Practice of Druid SQL and security in meituan review
- QT curve / oscilloscope customplot control
猜你喜欢
Esp32 (UART event) - serial port event learning (1)
使用晨曦记账本,分析某个时间段每个账户收支结余
STM32: LCD显示
iptables -L执行缓慢
从技术体系到商业洞察,中小研发团队架构实践之收尾篇
C: generic reflection
Introduction to micro build low code zero Foundation (lesson 3)
[popular science] CRC verification (I) what is CRC verification?
12 examples to consolidate promise Foundation
CANopen STM32 transplantation
随机推荐
C: generic reflection
Coolweather is revised and connected to the wind weather interface to realize the broken line diagram of temperature
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
Dynamically add and delete layouts
STM32: LCD display
Feature selection feature_ selection--SelectKBest
微搭低代码零基础入门课(第三课)
K210 serial communication
MVVM模型
解决:cnpm : 无法加载文件 ...\cnpm.ps1,因为在此系统上禁止运行脚本
ESP32 LVGL8. 1 - event (event 17)
Ctfshow - web362 (ssti)
机器学习理论之(8):模型集成 Ensemble Learning
Introduction to QT programming
From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure
ctfshow-web362(SSTI)
ESP32 LVGL8. 1 - label (style 14)
程序员如何快速开发高质量的代码?
ctfshow-web361(SSTI)
迁移学习进阶