当前位置:网站首页>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
边栏推荐
- Yyds dry goods inventory stringprep --- Internet string preparation
- ctfshow-web362(SSTI)
- Actual combat of Nacos as service configuration center
- ESP32 LVGL8. 1 - checkbox (checkbox 23)
- Loop path
- Druid SQL和Security在美团点评的实践
- 深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
- MVVM model
- 实战业务优化方案总结---主目录---持续更新
- STM32: LCD display
猜你喜欢
ctfshow-web362(SSTI)
从技术体系到商业洞察,中小研发团队架构实践之收尾篇
Tangle
机器学习理论之(8):模型集成 Ensemble Learning
CANopen STM32 transplantation
Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.
MVVM模型
How to virtualize the video frame and background is realized in a few simple steps
c#:泛型反射
os_ authent_ Prefix
随机推荐
Recyclerview control list item layout match_ Fundamental principle of parent attribute invalidation
Chondroitin sulfate in vitreous
RPM package management
Keil RVMDK compiled data type
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
Treatment of incomplete display of listview height
Get a list of recent apps
深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
Ctfshow - web362 (ssti)
From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure
机器学习实战 -朴素贝叶斯
Screenshot using projectmediamanager
PyGame tank battle
ctfshow-web361(SSTI)
Fundamentals of machine learning theory -- some terms about machine learning
The type initializer for ‘Gdip‘ threw an exception
Click the input box to pop up the keyboard layout and move up
Nacos cluster construction and MySQL persistence configuration
ESP32 LVGL8. 1 - event (event 17)
os_authent_prefix