当前位置:网站首页>[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
边栏推荐
- Illegal behavior analysis 1
- Have all the fresh students of 2022 found jobs? Is it OK to be we media?
- The text editor of markdown class should add colors to fonts (including typora, CSDN, etc.)
- The 19th Zhejiang Provincial College Programming Contest 2022 f.easyfix chairman tree
- Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
- php 使用阿里云存储
- SAP HR奖罚信息导出
- 城联优品作为新力量初注入,相关上市公司股价应声上涨150%
- 漏洞复现----49、Apache Airflow 身份验证绕过 (CVE-2020-17526)
- MySQL Index Optimization Practice I
猜你喜欢

How to change the formula picture in the paper directly into the formula in word

In the field of software engineering, we have been doing scientific research for ten years!

Installing spss25
![Ros2 topic (03): the difference between ros1 and ros2 [01]](/img/20/39d47c93400050a7bc8ad7efea51b3.png)
Ros2 topic (03): the difference between ros1 and ros2 [01]

Map operation execution process

SAP HR奖罚信息导出

LeeCode -- 6. Zigzag transformation

LeeCode -- 6. Z 字形变换

New potential energy of industrial integration, Xiamen station of city chain technology digital summit successfully held

Summary of SQL single table query 2020.7.27
随机推荐
HDU 4747 Mex「建议收藏」
0-1背包问题
Matlab 信号处理【问答随笔·2】
Ros2 topic (03): the difference between ros1 and ros2 [01]
Windows set redis to start automatically
Have all the fresh students of 2022 found jobs? Is it OK to be we media?
SAP HR奖罚信息导出
统计电影票房排名前10的电影并存入还有一个文件
POJ2392 SpaceElevator [DP]
Dynamics 365 find field filtering
三问TDM
Mysql索引优化实战二
Right click the idea file to create new. There is no solution to create new servlet
How can we make money by making video clips from our media?
Cloud native is devouring everything. How should developers deal with it?
VS扩展工具笔记
Force deduction solution summary 648 word replacement
Lm12 rolling heikin Ashi double K-line filter
Coreseek: the second step is index building and testing
2022 届的应届生都找到工作了吗?做自媒体可以吗?