当前位置:网站首页>Do your filial duty to make an old people's fall prevention alarm system for your family
Do your filial duty to make an old people's fall prevention alarm system for your family
2022-06-09 21:03:00 【51CTO】
Abstract : be based on STM32+ Hua Wei Yun IoT Design of anti falling alarm system for the elderly .
This article is shared from Huawei cloud community 《 be based on STM32+ Hua Wei Yun IOT Design of anti falling alarm system for the elderly 【 Play with Huawei cloud 】》, author : DS Little dragon brother .
1. Preface
The only child in China , And the aging population , It is gradually becoming a major social problem , The decline of physical ability in the elderly , The safety and harm caused by falling are becoming more and more prominent , The state and society pay more and more attention to the health and safety of the elderly , Develop a system that can detect whether the elderly fall down in real time , And it has important practical significance to timely inform the guardian of the fall detection and alarm system . The system includes a fall detection module 、GPS Positioning module and communication module , By detecting the daily state of the elderly , We can know the state of the elderly , If the elderly fall down , At this time, the test results will be uploaded to the cloud platform of the Internet of things through the network , Get the location of the elderly fall GPS location , And through GPRS Send SMS to the preset guardian .
2. Design requirements
(1) use STM32 Single chip as the main control chip , Cooperate with other modules to complete the function design
(2) The communication module adopts SIM800C, Support uploading collected GPS Longitude and latitude data to the cloud server , Huawei cloud IOT platform is adopted in the cloud .
(3) The elderly fall detection adopts MPU6050 Gyroscope detection , When the old man falls down , Will pass SIM800C Send text messages to emergency contacts , The buzzer on the device will sound an alarm , Pedestrians around can also help when they hear it ; And will GPS Upload data to the cloud , Show the old man's position through the map , The family knew by text message that the old man fell down , Location displayed by cloud map , You can quickly get to the old man , Or call the police for help , Report location .
(4) After the old man fell down , If you can act , No big problem , You can press the button on the device to cancel the buzzer alarm , And through SIM800C Send a text message to your family , Report peace .
3. The physical effect of the design
In order to quickly verify the feasibility of the scheme , Here, ready-made modules and DuPont lines are used to complete the expected functional design .
The following is the effect picture after the hardware is connected , The selected hardware models are listed in 4 All the chapters have been posted ; For the convenience of outdoor testing , The power supply here adopts the power bank , The battery box can also be used for power supply .



Electronic fence can be set , Prompt after the coordinates exceed .


4. Hardware selection
The main control chip adopts STM32RCT6, The communication module adopts SIM800C,GPS Collect and use ATGM336 Beidou BDS+GPS Dual mode module , The elderly fall detection module adopts MPU6050 gyroscope .
These are ready-made finished modules , They were all bought on Taobao , The models of the modules are posted below , Physical screenshot of the module , If you want to be a , You can find the same module model on Taobao .
4.1 SIM800C
SIM800C The module is an industrial grade with high performance and high cost performance GSM/GPRS modular . This module adopts SIMCOM The company's industrial grade Quad Band 850/900/ 1800/1900MHz SM800 chip , It can realize voice with low power consumption 、SMS、 Transmission of data and fax information .
Module features :

Module features :
1、 Support limit DC5V-18V Wide voltage input
2、 There is a power enable switch pin EN
3、 Support lithium battery power supply interface VBAT3.5-4.5V
4、 Mobile input card and China Unicom support Micro SIM card
5、 send 51/STM32/ARDUINO Driver routines
6、DC 5V-18V Power input , Recommended DC 9V
7、 The power start enable pin is enabled by default
8、 Power ground
9、GSM Modular TXD The pin is connected to... Of other modules RXD
10、GSM Modular RXD The pin is connected to... Of other modules TXD
11、 Data terminal ready
12、 Core audio output pin
13、 Core audio output pin
14、 Lithium battery input pin ,DC 3.5 - 4.5V
15、 Power ground
16、 Start pin and GND Short circuit can realize startup and self start
17、 Power ground
18、RTC External battery pin
19、 Kernel ring prompt pin
20、 Internal audio input pin
21、 Core audio input pin
Bold pins are generally used .
It is recommended to use V_IN Separate power supply DC5-18V Input ( Recommended 9V), perhaps VBAT Power supply lithium battery has two power supply modes, which are the most stable . If it's just a simple debugging , You can also use USB-TTL Or development board 5V Power the module directly . However, the power of general computers or development boards is limited , It could be unstable . Please choose the right power supply according to the specific situation .
summary :
The module itself supports adaptive baud rate , It can automatically calculate the corresponding baud rate according to the instructions sent in the past , In general use 115200 that will do .
Module debugging summary :
(1) Supply voltage 5V It's fine too , Using computers USB Power supply ( Plug in the computer directly USB mouth ). After normal power supply , There is a power indicator on the module .
(2)SIM800C Of TX It's connected to MCU RX foot
(3)SIM800C Of RX It's connected to MCU TX foot
(4)SIM800C Of the 11 One pin (PWK) and 12 One pin (GND) Short circuited together , Before starting up .

After the power supply is normal , There is a yellow power light in the upper right corner .
Send through serial port AT Command the past to test the effect of the module .
4.2 STM32F103C8T6 Development board

4.3 GPS modular
GPS After the module is positioned normally , On module LED The light will follow 1 Blink once per second .
In the returned field GNRMC Field .
First boot GPS modular , Positioning takes about a few minutes , After successful positioning , The second start-up positioning is very fast , Preferably outdoors , Indoor signal is poor , Longer positioning time .

4.4 MPU6050 gyroscope
The gyroscope selects the module of the punctual atom , More stable , Good quality .
4.5 Buzzer
The high level selected by the buzzer triggers .
5. Create a cloud IOT server
For the convenience of checking the position of the old man after falling , Need to pass through SIM800C The data collected by the device GPS Upload the data to the cloud platform server for storage , Even if the old man did not fall , You can also pay real-time attention to the location of the elderly , Draw trace lines on the map , It is convenient for family members to contact at any time , Understand the situation of the elderly .
The platform of the Internet of things here is the Huawei cloud Internet of things platform , Now it's free to use , After creating products and other information in the cloud , The equipment passes through MQTT The protocol is connected to the cloud platform for uploading GPS data . At present, the drag and drop trial web page development page of Huawei cloud has been taken off the shelf , At present, the corresponding upper computer should be developed , You can use the recently launched low code development platform or develop your own upper computer through the application side development interface of the cloud platform , I have developed my own upper computer here , adopt QT Prepared by the host computer APP, Support windows、Android、Linux And other platforms , Cross platform usage is more convenient .
Next, I will introduce how to log in to the official website to create products 、 equipment 、 Complete the product deployment in the cloud .
5.1 Create products
Official website address : https://www.huaweicloud.com/product/iothub.html After opening the official website, if there is no Huawei cloud account, you need to register the account first , I won't say more about these steps , The next step is to introduce how to create a product 、 equipment 、 Configuration properties 、 Complete the process of data upload and interaction .
Click to use the page for free .
Click the product option on the left , Click the create product button in the upper right corner , The parameter filling dialog box pops up .
Fill in the information according to your own equipment and save it .
Product created successfully , Click for details .

5.2 Create model file
Turn down the details page now , You can see the options for model creation .
Click the custom model option , Creating models .
The model here is the data attribute uploaded by the device .
Add service ID.
Click Create attribute , Choose here JSON Data of type , The uploaded GPS There are two data of longitude and latitude , Easy to save .
Create success .
5.3 Create device
The product is a model of a large framework , Many specific devices can be created below , At present, I have only one hardware device here , Just create a device . Devices can be created manually , It also supports automatic creation , Just like the smart device products on the market , When you get the device , Scan the QR code on the device and then call the mobile phone APP You can complete the creation of the product , The addition of devices . At present, there is only one equipment here , And demonstrate the whole process , Complete the creation of the entire device on the web page .
Link address : https://console.huaweicloud.com/iotdm/?region=cn-north-4#/dm-portal/device/all-device
Click the device option on the left , Then click the registration device in the upper right corner .
After filling in the information , Click ok .
Save device data after creation .
Create success , The device is currently inactive .
5.4 obtain MQTT Login parameters
Current products 、 After the device is created, you need to upload data through the device connection , To complete this step , You also need to know some prerequisite processes .
【A】 Huawei cloud server IP Address 、 domain name 、 Port number
【B】 Format of topic subscription 、 Format of topic Publishing
【C】MQTT Triple information of protocol login
Fully understand this 3 After that, you can write the device side code . Here's how to get this information in detail .
【1】 Huawei cloud server address information
【2】 Format of topic subscription 、 Format of topic Publishing
The format of subject subscription submission can be seen on the product details page .
The official details of the theme release are here :
https://support.huaweicloud.com/devg-iothub/iot_01_2127.html#ZH-CN_TOPIC_0240834853__zh-cn_topic_0251997880_li365284516112
The attribute format of the subject report describes the document address :
https://support.huaweicloud.com/api-iothub/iot_06_v5_3010.html
Summarize according to the information of the current equipment , The information obtained is as follows :
// Subscribe to topics : The platform sends a message to the device
$ocdevicesGPS1sysmessagesdown
// Equipment report data
$ocdevicesGPS1syspropertiesreport
// Reported attribute message ( Multiple attributes can be reported at a time , stay json Just add it to the )
{
"services" [{
"service_id"
"GPS",
"properties"{
"GPS"{
"lon"
106.53,
"lat"
29.46}}}]}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
【3】MQTT Triple information of protocol login
Huawei cloud provides MQTT A tool for generating protocol parameters , Very convenient , Fill in the parameters according to the prompt, and click one key to generate triples .
MQTT Device login key generation address : https://iot-tool.obs-website.cn-north-4.myhuaweicloud.com/

The resulting triples are as follows :
5.5 use MQTT Customer tool login test
In order to verify the configuration of the server and the theme 、 Whether these attributes OK, You can use it first MQTT The client simulates the real device login test . The following MQTT I developed the tool myself , In order to facilitate the testing of the docking Internet of things platform , Use QT Wrote such a tool software .
Name of the tool software : MQTT client _v2.5( agreement 3.1.1).exe I've uploaded it to CSDN In the resource pool of , You can go straight to CSDN You can find the download address of the software by searching in , I will also upload a copy in the attachment of the following article .
Fill in the corresponding parameters on the left side of the software according to the prompts , Click login in turn , Subscribe to topics , Just publish the theme .
When you open the web page, you can see that the device is online .
You can see the uploaded data content on the device shadow page .
Start message tracking , Can understand the process of communication .
6. STM32 Hardware device programming
In the 5 Chapter completed the construction of the Internet of things cloud platform , The next one is 6 chapter , Just write STM32 Device code .
STM32 The development environment of the device side adopts keil5 Development , The programming style adopts register style , Regardless of the use of library functions , Or registers , still HAL library , They are all the same , There's no big difference , I write STM32 The code is used to register development , The main reason is that the code of register is relatively simple , Simplification of engineering documents .
About keil5 Software download process 、 The installation process 、 The basic usage is not described in detail here , See this article accordingly friends sharing same hobby These basic operations should be learned , This is mainly project oriented , Introduce the core knowledge points .
6.1 Hardware wiring
The following are the hardware modules and STM32 Hardware connection between development boards .
SIM800C Wiring instructions
GNDGND
PA2SIM800C_RXD
PA3SIM800C_TXD
CH340 Module wiring instructions
GNDGND
RXPA9
GPS Wiring instructions (
The baud rate needs to be based on GPS Modify the module according to the actual situation )
GNDGND
VCC3
.3
V
PB11GPS_TX
Buzzer module :
High level response
BEEPPB8
On board LED The lamp
LED1PC13
Low level light
Onboard keys
KEY1PA0
Press to high level
External keys :
KEY1
PB3
Pressing is low
KEY2
PB2
Pressing is low
external LED Light module :
LED1PB4
Low level light
LED2PB5
Low level light
Hardware wiring :
1
VCC
3.3
V5V
Power input
Pick up 3
.3
V
2
GND
Ground wire
Pick up GND
3
IIC_SDA
IIC
Communication data line
PB6
4
IIC_SCL
IIC
Communication clock line
PB7
5
MPU_INT
Interrupt output pin
Unanswered
6
MPU_AD0
IIC
Slave address setting pin PA15
AD0 Pin description :ID0X68(
Suspended connection
GND)
ID0X69(
Pick up
VCC)
Be careful : When the gyroscope is initialized , It can be initialized successfully only after it is placed normally
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
This is the effect picture after the module is connected through DuPont wire :
6.2 keil Project screenshot


6.3 Schematic diagram
The following is the schematic diagram .
6.4 MQTT Protocol implementation code and MQTT Parameters
SIM800C It's not built in MQTT Protocol instructions , Only TCP Communication instructions , You need to package it yourself MQTT agreement , And then through TCP Communication related instructions complete the cloud server connection , Realize data interaction .
The following code is MQTT Definition of protocol parameters , For the convenience of modification in the program , Assign these parameters by macro definition .
// Equipment information of Huawei Internet of things server
#define
MQTT_ClientID
"GPS1_0_0_2022060716"
#define
MQTT_UserName
"GPS1"
#define
MQTT_PassWord
"27a2d2dd716fac29a0041beec1d7cf5f5b529fac65cc815c7eed9adb04d7364b"
// Topics subscribed and published
#define
SET_TOPIC
"$oc/devices/GPS1/sys/messages/down"
// subscribe
#define
POST_TOPIC
"$oc/devices/GPS1/sys/properties/report"
// Release
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Here are a few of the packages MQTT Protocol core functions :
/*
The functionality : logon server
Function return value : 0 It means success 1 It means failure
*/
u8
MQTT_Connect(
char
ClientID,
char
Username,
char
Password)
{
u8
i,
j;
int
ClientIDLen
strlen(
ClientID);
int
UsernameLen
strlen(
Username);
int
PasswordLen
strlen(
Password);
int
DataLen;
mqtt_txlen0;
// Variable header +Payload Each field contains a length identifier of two bytes
DataLen
10 (
ClientIDLen2) (
UsernameLen2) (
PasswordLen2);
// Fixed header
// Control message type
mqtt_txbuf[
mqtt_txlen]
0x10;
//MQTT Message Type CONNECT
// Residual length ( Not including fixed head )
do
{
u8
encodedByte
DataLen
128;
DataLen
DataLen
128;
// if there are more data to encode, set the top bit of this byte
if (
DataLen
0 )
encodedByte
encodedByte
128;
mqtt_txbuf[
mqtt_txlen]
encodedByte;
}
while (
DataLen
0 );
// Variable header
// The name of the agreement
mqtt_txbuf[
mqtt_txlen]
0;
// Protocol Name Length MSB
mqtt_txbuf[
mqtt_txlen]
4;
// Protocol Name Length LSB
mqtt_txbuf[
mqtt_txlen]
'M';
// ASCII Code for M
mqtt_txbuf[
mqtt_txlen]
'Q';
// ASCII Code for Q
mqtt_txbuf[
mqtt_txlen]
'T';
// ASCII Code for T
mqtt_txbuf[
mqtt_txlen]
'T';
// ASCII Code for T
// Agreement level
mqtt_txbuf[
mqtt_txlen]
4;
// MQTT Protocol version = 4 about 3.1.1 Version of the agreement , The value of the protocol level field is 4(0x04)
// Connection sign
mqtt_txbuf[
mqtt_txlen]
0xc2;
// conn flags
mqtt_txbuf[
mqtt_txlen]
0;
// Keep-alive Time Length MSB
mqtt_txbuf[
mqtt_txlen]
100;
// Keep-alive Time Length LSB 100S Heartbeat bag Time to live
mqtt_txbuf[
mqtt_txlen]
BYTE1(
ClientIDLen);
// Client ID length MSB
mqtt_txbuf[
mqtt_txlen]
BYTE0(
ClientIDLen);
// Client ID length LSB
memcpy(
mqtt_txbuf[
mqtt_txlen],
ClientID,
ClientIDLen);
mqtt_txlen
ClientIDLen;
if(
UsernameLen
0)
{
mqtt_txbuf[
mqtt_txlen]
BYTE1(
UsernameLen);
//username length MSB
mqtt_txbuf[
mqtt_txlen]
BYTE0(
UsernameLen);
//username length LSB
memcpy(
mqtt_txbuf[
mqtt_txlen],
Username,
UsernameLen);
mqtt_txlen
UsernameLen;
}
if(
PasswordLen
0)
{
mqtt_txbuf[
mqtt_txlen]
BYTE1(
PasswordLen);
//password length MSB
mqtt_txbuf[
mqtt_txlen]
BYTE0(
PasswordLen);
//password length LSB
memcpy(
mqtt_txbuf[
mqtt_txlen],
Password,
PasswordLen);
mqtt_txlen
PasswordLen;
}
memset(
mqtt_rxbuf,
0,
mqtt_rxlen);
MQTT_SendBuf(
mqtt_txbuf,
mqtt_txlen);
return
1;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
6.5 MPU6050.c Code
This is a MPU6050 The core driving code of gyroscope , It is convenient to detect the posture of the elderly , Judge whether you fall .
Because of the word limit of the article , Unable to post code , The code is sorted out and uploaded through attachments .
6.6 GPS.c Code
receive GPS The data is then parsed , Get latitude and longitude , Easy to upload to the cloud platform of the Internet of things .
#include
"gps.h"
/*
The functionality : from buf There's No cnt The position of a comma
return return value :0~254, Represents the offset of the position of the comma .
255, It means that there is no such thing as cnt Commas
*/
u8
GPS_GetCommaOffset(
char
buf,
u8
cnt)
{
char
pbuf;
while(
cnt)
{
if(
buf
'*'
buf
' '
buf
'z')
return
255;
// encounter '*' Or illegal characters , There is no such thing as cx Commas
if(
buf
',')
cnt;
buf;
}
return
bufp;
// Calculate the offset
}
/*
The functionality : obtain GPS Longitude and latitude data value
Function parameter :
double *Longitude : longitude
double *latitude : latitude
Return value : 0 Indicates that the positioning is successful ,1 Indicates that the location failed
explain : analysis $GPRMC command , Get latitude and longitude
$GNRMC,023705.000,A,2842.4164,N,11549.5713,E,1.73,91.65,150319,,,A*41
Examples of conversion formulas :
longitude : dddmm.mmmm East longitude 11408.4790 114+(08.4790/60)=114.141317
latitude : ddmm.mmmm North latitude 2236.9453 22+(36.9453/60)= 22.615755
The data returned by zhongkewei
$GNRMC,144435.000,A,2942.1201,N,10636.6466,E,1.50,64.42,190422,,,A*40
*/
u8
GPS_GPRMC_Decoding(
u8
gps_buffer,
double
Longitude,
double
latitude)
{
u8
Offset;
u32
int_data;
double
s_Longitude,
s_latitude;
char
p;
/*1. Determine whether the positioning is successful */
pstrstr((
char)
gps_buffer,
"$GNRMC");
if(
p)
return
1;
OffsetGPS_GetCommaOffset(
p,
2);
if(
Offset255)
return
2;
if((
pOffset)
'A')
return
3;
// Inaccurate positioning
/*2. Get latitude */
OffsetGPS_GetCommaOffset(
p,
3);
if(
Offset255)
return
4;
sscanf(
pOffset,
"%lf",
s_latitude);
s_latitudes_latitude100;
int_datas_latitude;
// Get the latitude integer part
s_latitudes_latitudeint_data;
// Get the decimal part of latitude
s_latitude(
s_latitude)
100;
latitudeint_data(
s_latitude60
.0);
// Get the converted value
/*3. Get longitude */
OffsetGPS_GetCommaOffset(
p,
5);
if(
Offset255)
return
5;
sscanf(
pOffset,
"%lf",
s_Longitude);
s_Longitudes_Longitude100;
int_datas_Longitude;
// Get the longitude integer part
s_Longitudes_Longitudeint_data;
// Get the longitude fraction
s_Longitudes_Longitude100;
Longitudeint_data(
s_Longitude60
.0);
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
7. Upper computer APP Development
For the convenience of viewing the map location , Trajectory and other information , Current adoption QT Write a matching host computer , Through Huawei cloud IOT Application side development interface , Get the shadow data of the device , Then call Baidu map to display the target location .
Next, we will introduce the development process of the upper computer software .
7.1 install Qt development environment
Qt It's cross platform C++ Development framework , A code can be compiled and run on different system platforms . Support Android、IOS、Windows、Linux Such as platform .
At present, the development environment I use is :QT 5.12.6 , Other versions are OK .
QT5.12.6 Download address :
https://download.qt.io/archive/qt/5.12/5.12.6/
Open the download link and select the following version to download :
Installation of network software is interrupted , Otherwise, you will be prompted to enter the account . During installation , Check one in the first check box mingw 32 The compiler can , The others are OK by default , Click next to continue the installation .
If only windows Lower development , For the simplest installation, just choose MinGW The compiler can , Other compilers do not need to check .



7.2 Application side development interface document
Help document address : https://support.huaweicloud.com/usermanual-iothub/iot_01_0045.html At present, my application is mainly used to read the data uploaded by the device GPS Data is enough , There are two ways to get data :
【1】 Read device shadow data , That is to obtain the historical data after the device is uploaded to the server ( Non real time data ) It is the last data transmitted by the equipment , Get shadow data , You don't need to worry about whether the device is online .
I'm here GPS Acquisition is the shadow device data acquired , That is to get the last data uploaded by the device .
Address : https://support.huaweicloud.com/api-iothub/iot_06_v5_0079.html
【2】( Query device properties ) Read real-time data , If the equipment needs to release the current data immediately , You can send synchronization instructions to the device , The device side needs to write code for parsing instructions , After receiving the instruction, the device responds to the data according to the format . This synchronous real-time data requires the device to remain online before it can respond to instructions . Specific usage scenarios can be designed according to your own needs .
Through the interface of querying attributes , You can actively request to obtain the detailed properties of the device .
The process is : The application layer calls this API Interface ----> Request server -----> Request client device ------> Back to the server -----> Return to the application layer .
Document address : https://support.huaweicloud.com/api-iothub/iot_06_v5_0034.html
7.3 establish IAM Account
This is an important step , When developing host computer , Some interfaces on the application side need to be called , These interfaces need to be brought with token Login key . and token The generation of the login key requires IAM Account to get .
Address : https://console.huaweicloud.com/iam/?region=cn-north-4#/iam/users
(1) Create user 
(2) Filling parameters 
(3) Finish creating 
7.4 Implementation code
The core code of the request interface is posted below .
/*
function : obtain token
*/
void
WidgetGetToken()
{
// Said to get token
function_select3;
QString
requestUrl;
QNetworkRequest
request;
// Set request address
QUrl
url;
// obtain token Request address
requestUrl
QString(
"https://iam.%1.myhuaweicloud.com/v3/auth/tokens")
.
arg(
SERVER_ID);
// self-created TCP The server , Test use
//requestUrl="http://10.0.0.6:8080";
// Set the data submission format
request.
setHeader(
QNetworkRequestContentTypeHeader,
QVariant(
"application/json;charset=UTF-8"));
// Construct request
url.
setUrl(
requestUrl);
request.
setUrl(
url);
QString
text
QString(
"{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":"
"{\"user\":{\"domain\": {"
"\"name\":\"%1\"},\"name\": \"%2\",\"password\": \"%3\"}}},"
"\"scope\":{\"project\":{\"name\":\"%4\"}}}}")
.
arg(
MAIN_USER)
.
arg(
IAM_USER)
.
arg(
IAM_PASSWORD)
.
arg(
SERVER_ID);
// Send a request
managerpost(
request,
text.
toUtf8());
}
// Get shadow device data
void
Widgeton_pushButton_addr_clicked()
{
// Indicates shadow device data acquisition
function_select0;
QString
requestUrl;
QNetworkRequest
request;
// Set request address
QUrl
url;
// obtain token Request address
requestUrl
QString(
"https://iotda.%1.myhuaweicloud.com/v5/iot/%2/devices/%3/shadow")
.
arg(
SERVER_ID)
.
arg(
PROJECT_ID)
.
arg(
Device_id);
// self-created TCP The server , Test use
//requestUrl="http://10.0.0.6:8080";
// Set the data submission format
request.
setHeader(
QNetworkRequestContentTypeHeader,
QVariant(
"application/json"));
// Set up token
request.
setRawHeader(
"X-Auth-Token",
Token);
// Construct request
url.
setUrl(
requestUrl);
request.
setUrl(
url);
// Send a request
managerget(
request);
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
Mainly posted 2 A more important function , A gain token, A query device shadow data .
8. Hua Wei Yun IOT Micro authentication (3 Wechat certification activity month )
At present, HUAWEI cloud IoT Open the 3 Wechat certification activity month , Huawei cloud micro authentication provides one-stop online learning 、 Experiments and examinations , Zero foundation can also learn cutting-edge technical knowledge , Get started and develop quickly , Gain situational skill improvement !
From now on , You can participate in the lottery by signing up , Certified free gift , A group is more valuable ! Not only will it take you to get the certificate of authority ,0 Basic introduction to Internet of things development , You can also take away the Huawei bracelet 、 Earphones and other luxury gifts !
【 Activity time 】2022 year 5 month 17 Japan -2022 year 6 month 17 Japan
Event registration : https://developer.huaweicloud.com/signup/789d09ab650a46838b6908107d3282e1
Click to follow , The first time to learn about Huawei's new cloud technology ~
边栏推荐
- 逻辑回归总结
- Heap (priority queue)
- MySQL exception: the server time zone value 'xxx' solution
- Force buckle 84- the largest rectangle in the histogram (monotone stack)
- GBase8s数据库select子句2
- 『踩坑记录』IDEA导航栏工具栏添加“后退”功能按钮
- Pan micro oa9 foreground unlimited getshell
- 源代码数据防泄露解决方案分析
- KubeVirt网络源码分析(2)
- 每日一题——leecode59( 螺旋矩阵 II)
猜你喜欢

从源码解析flutter_redux 的精准局部刷新

idea:new没有class

极大似然估计

Idea:new no class

C language to realize computer automatic shutdown program -- it can be used to spoof roommate's computer

Ceisum 3D scene demo

Using ArrayList to lose data in multithreaded scenarios

The browser cannot open Baidu, and others can be opened normally

Fanwei oa8 foreground SQL injection

03 Wireshark TCP
随机推荐
go安装图文教程
Mr. wuyaohui, the world pioneer of ordinary ternary logic mathematics, announced the scientific research achievements of all truth tables of ordinary ternary logic mathematics to the world (Wu's law)
Keyword usage of default in C #
idea:new没有class
Kubevirt network source code analysis
Gbase8s database select Clause 3
Dataframe merge
Changshu science and technology applet SQL injection
做副业赚钱,这几个热门自媒体平台收益超多
dump. Pcapng packet parsing
Initial experience of transformation of vite lerna monorepo project
快速了解服务器IO的实现
Why rewrite equals and hashcode?
Fanwei oa8 foreground SQL injection
Mysql:1062 Duplicate entry '1' for key 'PRIMARY'
Heap (priority queue)
Gbase8s database select Clause 2
Latex mathematical symbols Encyclopedia
About C unity read / write file
[cf] 797 div3 E. Price Maximization