当前位置:网站首页>[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
2022-07-07 23:32:00 【Little river god is tangled】
List of articles
Preface
First, let's talk about what is dynamic registration , What's its use :
1. Dynamic registration : After dynamic registration is enabled, the device does not need to burn the device certificate one by one / secret key , All devices under the same product can burn the same product key (ProductId and ProductSecret); It means that after the dynamic registration function is enabled ,STM32 When connected as a new device , There is no need to go to the cloud platform to get triples , Just modify the device name in the code to automatically create a new device on the cloud platform .
2. Benefits of dynamic registration : The advantage of using dynamic registration is , You don't need to create new devices on your own cloud platform , We are STM32 Modifying the device name in the code can create the corresponding device on the Tencent cloud IOT development platform , And connect .
One 、 Open the dynamic registration function of the product
Products after opening , You may not create a device , Just put the product ID and ProductSecret( Product key ) Just copy it .
Two 、STM32 Code changes
The modification of the project code is based on yesterday's project ( Please move to :【STM32+ESP8266 Connect Tencent cloud Internet of things development platform 2】STM32+ESP8266-01S Connect to Tencent cloud ), The source code of this time will also be open source for everyone .
1. Modify triples
I put the macro of device triplet ESP8266.h In file .
#define PRODUCT_ID " ***** " // product ID Modify it into your own product ID
#define DEVUICE_NAME "LED" // Equipment name New equipment only needs to modify this
#define DEVICE_SECRET " ******** "// Product key Change it to your own product key
#define PRODUCT_REGION "ap-guangzhou" // Geographical name
2. Modify the connection code
Previous static connection , It's a DeviceName( Equipment name )、PRODUCT_ID( product ID) and DEVICE_SECRET( Device key ) to 8266 Connect , The instructions are :
AT+TCDEVINFOSET=<tls_mode>,<product_id>,<device_name>,<device_secret>[,<product_region>]
Equipment level information , Dynamic registration belongs to product level , So we're going to use Product information setting instructions :
AT+TCPRDINFOSET=<tls_mode>,<product_ID>,<product_secret>,<device_name>,<product_region>
The last parameter can be left blank , The default is used :“ap-guangzhou”, Use after setting Dynamic registration instructions :
AT+TCDEVREG
// Set product information
case 8:
sprintf((char *)device_massage, "AT+TCPRDINFOSET=1,\"%s\",\"%s\",\"%s\"\r\n", PRODUCT_ID, DEVICE_SECRET,DEVUICE_NAME);
HAL_UART_Transmit(&huart2, device_massage, strlen((const char *)device_massage), 5000);
osDelay(500);
break;
// Dynamic registration
case 9:
case 10:
HAL_UART_Transmit(&huart2, "AT+TCDEVREG\r\n", strlen("AT+TCMQTTDISCONN\r\n"), 5000); // Dynamic registration
osDelay(2000);
break;
// Start connecting
case 11:
HAL_UART_Transmit(&huart2, "AT+TCMQTTCONN=1,5000,240,0,1\r\n", strlen("AT+TCMQTTCONN=1,5000,240,0,1\r\n"), 5000);// Start connecting
osDelay(100);
break;
You can register dynamically with other code unchanged ,
3、 ... and 、 Effect demonstration
These three blog posts will be synchronized to the official blog posts of anxinco Technology !!
Source code :https://pan.baidu.com/s/1rOEzEuz9XeIe3tAPIz1d0g Extraction code :4sg4
边栏推荐
- Cloud native is devouring everything. How should developers deal with it?
- re1攻防世界逆向
- Lm12 rolling heikin Ashi double K-line filter
- Markdown
- [compilation principle] lexical analysis design and Implementation
- Entity层、DAO层、Service层、Controller层 先后顺序
- 伸展树(一) - 图文解析与C语言实现
- Design and implementation of spark offline development framework
- LeeCode -- 6. Z 字形变换
- 三问TDM
猜你喜欢
List. How to achieve ascending and descending sort() 2020.8.6
Technology at home and abroad people "see" the future of audio and video technology
产业共融新势能,城链科技数字峰会厦门站成功举办
SAP 内存参数调优过程
SAP HR 家庭成员信息
SRM supplier cloud collaborative management platform solution for building materials industry to realize business application scalability and configuration
SAP HR 社会工作经历 0023
0-1背包问题
LDO voltage stabilizing chip - internal block diagram and selection parameters
给出一个数组,如 [7864, 284, 347, 7732, 8498],现在需要将数组中的数字拼接起来,返回「最大的可能拼出的数字」
随机推荐
Right click the idea file to create new. There is no solution to create new servlet
Summary of common methods of object class (September 14, 2020)
Entity层、DAO层、Service层、Controller层 先后顺序
Install Fedora under RedHat
LeeCode -- 6. Zigzag transformation
8.31 Tencent interview
In the field of software engineering, we have been doing scientific research for ten years!
MATLAB signal processing [Q & A essays · 2]
Matlab-SEIR传染病模型预测
KeePass realizes automatic input of web pages
Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
648. Word replacement
2021ICPC上海 H.Life is a Game Kruskal重构树
turbo intruder常用脚本
HDU 4747 mex "recommended collection"
【7.4】25. K 个一组翻转链表
生鲜行业数字化采购管理系统:助力生鲜企业解决采购难题,全程线上化采购执行
Solution: prompt "unsupported video format" when inserting avi format video into the message
Puce à tension stabilisée LDO - schéma de bloc interne et paramètres de sélection du modèle