当前位置:网站首页>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
边栏推荐
- ESP32 LVGL8. 1 - img picture (IMG 20)
- STM32: LCD display
- 根据快递单号查询物流查询更新量
- Esp32 (UART ecoh) - serial port echo worm learning (2)
- Fundamentals of machine learning theory -- some terms about machine learning
- Methods of nested recycleview to solve sliding conflict and incomplete item display
- MVVM model
- mysql_linux版本的下载及安装详解
- Excel intercept text
- Click the input box to pop up the keyboard layout and move up
猜你喜欢

os_authent_prefix

Introduction to ROS learning notes (I)

Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha

【数学建模】—— 层次分析法(AHP)

Chondroitin sulfate in vitreous

MVVM模型

昇腾 AI 开发者创享日全国巡回首站在西安成功举行
![[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born](/img/0a/ed4eab6589e1c072edc247463e889e.png)
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born

ctfshow-web361(SSTI)

教你用简单几个步骤快速重命名文件夹名
随机推荐
[mathematical modeling] - analytic hierarchy process (AHP)
RPM package management
Introduction to ROS learning notes (I)
ESP32 LVGL8. 1 - anim animation (anim 16)
Golang 语言实现TCP UDP通信
WebView opens H5 video and displays gray background or black triangle button. Problem solved
Ctfshow - web362 (ssti)
[popular science] CRC verification (I) what is CRC verification?
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
Tencent map and high logo removal method
22 year flying Book manpower Kit
纠结
#yyds干货盘点#stringprep --- 因特网字符串预备
Druid SQL和Security在美团点评的实践
Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.
How can programmers quickly develop high-quality code?
MySQL Téléchargement et installation de la version Linux
mysql_linux版本的下载及安装详解
Sentinel规则持久化进Nacos
Go 语言 GUI 框架 fyne 中文乱码或者不显示的问题