当前位置:网站首页>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
边栏推荐
- The type initializer for ‘Gdip‘ threw an exception
- Esp32 (UART receiving and sending) - receiving and sending communication of serial port (4)
- Fundamentals of machine learning theory -- some terms about machine learning
- Practice of Druid SQL and security in meituan review
- MySQL学习第五弹——事务及其操作特性详解
- listener. log
- How can programmers quickly develop high-quality code?
- 视频边框背景如何虚化,简单操作几步实现
- 7、 DOM (Part 2) - chapter after class exercises and answers
- Machine learning theory (8): model integration ensemble learning
猜你喜欢
ESP32 LVGL8. 1 - calendar (calendar 25)
mysql_linux版本的下載及安裝詳解
Practice of Druid SQL and security in meituan review
七、DOM(下) - 章节课后练习题及答案
视频边框背景如何虚化,简单操作几步实现
Query the logistics update quantity according to the express order number
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
After opening the original normal project, the dependency package displays red and does not exist.
Tangle
One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
随机推荐
From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
Excel intercept text
Sentinel规则持久化进Nacos
Treatment of incomplete display of listview height
iptables初探
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
ESP32 LVGL8. 1 - roller rolling (roller 24)
ESP32 LVGL8. 1 - bar progress bar (bar 21)
Halo open source project learning (VII): caching mechanism
Esp32 drive encoder -- siq-02fvs3 (vscade + IDF)
玻璃体中的硫酸软骨素
iptables -L执行缓慢
MySQL Téléchargement et installation de la version Linux
机器学习理论基础篇--关于机器学习的一些术语
WebView saves the last browsing location
ESP32 LVGL8. 1 - input devices (input devices 18)
深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
Nacos作为服务配置中心实战