当前位置:网站首页>[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
边栏推荐
- How to change the formula picture in the paper directly into the formula in word
- Description of longitude and latitude PLT file format
- Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
- Adrnoid Development Series (XXV): create various types of dialog boxes using alertdialog
- Installing spss25
- SAP HR 劳动合同信息 0016
- 产业共融新势能,城链科技数字峰会厦门站成功举办
- Cloud native data warehouse analyticdb MySQL user manual
- POJ2392 SpaceElevator [DP]
- 8.31 Tencent interview
猜你喜欢
随机推荐
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
V-for traversal object
B_QuRT_User_Guide(36)
Unity3d Learning Notes 6 - GPU instantiation (1)
Oracle-数据库的备份与恢复
SAP HR奖罚信息导出
leetcode-520. Detect capital letters -js
Summary of common methods of object class (September 14, 2020)
How to change the formula picture in the paper directly into the formula in word
LeeCode -- 6. Zigzag transformation
PCI-Express接口的PCB布线规则
电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级
The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
Illegal behavior analysis 1
UE4_ Ue5 panoramic camera
Fibonacci number of dynamic programming
SAP HR 劳动合同信息 0016
How to login and enable synchronization function in Google browser
HDU 4747 mex "recommended collection"
B_ QuRT_ User_ Guide(36)