A method of message Remote Installation and unloading advertisement based on MQTT
Technical field
The present invention relates to internet communications, and in particular to the side of a kind of message Remote Installation based on MQTT and unloading advertisement
Method.
Background technique
Current internet communication technology needs installing terminal to network, and then goes downloading that application to be installed is needed to pacify again again
Fill terminal.The operation cost and difficulty of terminal are virtually increased in this way, if having multiple terminals, needing to network, it is more to download
It is secondary, it results in waste of resources, and unload and need into the operating platform of terminal, unloading manually again after the software of unloading is found, is made
It is huge at workload.
MQTT communications protocol be for a large amount of computing capabilitys it is limited, and work in low broadband, the long-range biography of insecure network
The agreement of sensor or communication control design, it has the property that
1) publish/subscribe massage pattern is used, one-to-many news release is provided, releases application program coupling;
2) message of load contents shielding is transmitted;
3) network connection is provided using TCP/IP;
4) there are three types of news release service quality:
" at most primary ", news release is completely dependent on bottom TCP/IP network.Information drop-out or repetition can occur.This level-one
It not can be used for following situation, environmental sensor data, losing a read record, it doesn't matter, because also having second of hair shortly after
It send.
" at least once ", it is ensured that message reaches, but message repeats to occur.
" only once ", it is ensured that message reaches primary.This rank can be used for following situation, in charge system, message
It repeats or loses to will lead to incorrect result.
Small-sized transmission, expense very little (head of regular length is 2 bytes), agreement exchange minimizes, to reduce network flow
Amount;According to the characteristic of mqtt, mqtt agreement is selected to intercut message be an ideal method.
DES (Data Encryption Standard) is grouping symmetric cryptographic algorithm.DES uses 64 groupings
Length and 56 key lengths, 64 inputs are obtained 64 output by a series of transformation by it.Decryption then uses
Identical step and identical key.The key length of DES is 64, due to the n-th * 8 (n=1,2 ... 8) be check bit,
Therefore real
The length that border participates in encryption is 56, and key space contains 2^56 key.
DES algorithm works out plaintext using multiple combination replacement algorithm and transposition algorithm, the interaction of dispersion and entanglement
At the very high ciphertext of Cipher Strength, its encryption and decryption are same algorithms.
DES algorithm is a kind of product ciphers, and the letters such as displacement, replacement, the addition of mould two are mainly used on algorithm structure
Number, is calculated and is worked by way of round function iteration.
DES algorithm also will use data replacement technique, mainly there is initial permutation IP and inverse two type of initial permutation IP^-1
Type.DES algorithm is that all formats of original plaintext and all data are all upset rearrangement using the purpose of in-place computation.And
It takes turns in encryption function, i.e., data is all upset to rearrangement, while in terms of data format, original 32 bit data format expands
It transforms into as 48 bit data formats, in order to meet requirement of the S box group to data length and data format specifications.
One group of data information is difficult the process and make for therefrom deriving that it is calculated after a series of nonlinear transformation
Nonlinear combination;But if this group of data information uses linear transformation, calculate be easy for it is more.In DES algorithm
In, the calculating process for belonging to nonlinear transformation only has S box, remaining data calculate and transformation be all belong to linear transformation, so
The key of DES algorithm security is the security intensity of S box.In addition, S box and displacement IP cooperate, very strong robust is formd
Divide attack and resist linear attacking ability, wherein resisting differential attacking ability is more stronger.
Summary of the invention
The present invention is in view of the above-mentioned problems, provide the method for a kind of the message Remote Installation based on MQTT and unloading advertisement.
The technical solution adopted by the present invention is that: a method of message Remote Installation and unloading advertisement based on MQTT, packet
Include following steps:
S1 when terminal starts, subscribes to message subject;
S2, user issue Remote Installation and unloading message, and message passes through des encryption, and the message of installation includes advertisement apk
Title and advertisement apk download address, the message of unloading only need advertisement apk title;
S3, terminal receive the Remote Installation or unloading message that user issues according to theme is subscribed to;
S4, terminal receives Remote Installation or unloading message, and carries out DES decryption;
S5, terminal obtain advertisement apk title and advertisement apk download address according to Remote Installation and unloading message, if it is
Unloading message only obtains advertisement apk title.
Further, the step S1 further include:
S11 connects MQTT:
Generate connection string: the IP address of specified Message Agent host and the port numbers of MQTT distribution;
Connection attribute is set, the interval time of mark, subscription type, transmission alive messages including client computer;Creation
MQTT client objects;
S12, subscribe to theme to agency: subscription is by MQTT object handles, including two array parameters, i.e. subscription theme
Array, service quality array.
Further, the step S2 further include:
S21 gives out information to digital signage: the api function publish directly provided using MQTT, it is desirable to provide main
The parameters such as topic, message, service quality;
S22 receives the message from agency: to make to create a readjustment processing letter using the message for receiving subscription
Number, and registered in MQTTMQTT client objects;
With M qttSimple Callback interface creation simple interface object, and realize connection Lost,
Tri- methods of delivery Complete and message Arrived;
When the connection with agency surprisingly terminates, connection Lost method is just called;If this occurs,
Then the method attempts to reconnect to agency;It, can throw exception if connection Lost method can not reconnect
The message that notice client computer reconnects failure message Arrived method notice system subscription theme arrived client;
Whether delivery Complete method indicates to send and complete;
S23 needs des encryption before news release.
Further, the step S3 further include: receive message decryption: after digital signage subscribes to message, agency's publication
The theme that digital signage is subscribed to, digital signage receive the message of publication and decryption.
Further, the step S4 further include: correlative code is encrypted and is decrypted.
Advantages of the present invention:
The mqtt agreement that the present invention uses, which is used under the environment such as weak signal, low broadband to work, also can guarantee that reception is complete, and
And message passes through des encryption, safety is guaranteed, be mqtt agreement and DES safety certification to be used in be one on digital signage
The extraordinary method of kind;Method of the invention uploads and unloading energy batch operation, if as packet name, can also cover previous text
Part.
Other than objects, features and advantages described above, there are also other objects, features and advantages by the present invention.
Below with reference to figure, the present invention is described in further detail.
Detailed description of the invention
The attached drawing constituted part of this application is used to provide further understanding of the present invention, schematic reality of the invention
It applies example and its explanation is used to explain the present invention, do not constitute improper limitations of the present invention.
Fig. 1 is the method flow diagram of the message Remote Installation of the invention based on MQTT and unloading advertisement.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
With reference to Fig. 1, the method for a kind of message Remote Installation based on MQTT as shown in Figure 1 and unloading advertisement, including with
Lower step:
S1 when terminal (digital signage) starts, subscribes to message subject;
S2, user issue Remote Installation and unloading message, and message passes through des encryption, and the message of installation includes advertisement apk
Title and advertisement apk download address, the message of unloading only need advertisement apk title;
S3, terminal receive the Remote Installation or unloading message that user issues according to theme is subscribed to;
S4, terminal receives Remote Installation or unloading message, and carries out DES decryption;
S5, terminal obtain advertisement apk title and advertisement apk download address according to Remote Installation and unloading message, if it is
Unloading message only obtains advertisement apk title.The step S1 further include:
S11 connects MQTT: generating connection string: the IP address of specified Message Agent host and the port of MQTT distribution
Number;Connection attribute is set, the interval time of mark, subscription type, transmission alive messages including client computer;Create MQTT client
Machine object;
S12, subscribe to theme to agency: subscription is by MQTT object handles, including two array parameters, i.e. subscription theme
Array, service quality array.
The step S2 further include:
S21 gives out information to digital signage: the api function publish directly provided using MQTT, it is desirable to provide main
The parameters such as topic, message, service quality;
S22 receives the message from agency: to make to create a readjustment processing letter using the message for receiving subscription
Number, and in MQTT client registers;
With MqttSimple Callback interface creation simple interface object, and realize connection Lost,
Tri- methods of delivery Complete and message Arrived;When the connection with agency surprisingly terminates, just call
Connection Lost method;If this occurs, then the method attempts to reconnect to agency;If
Connection Lost method can not reconnect, then can throw exception come notify client computer reconnect failure;
The message that message Arrived method notice system subscribes to theme arrived client;
Whether delivery Complete method indicates to send and complete;
S23 needs des encryption before news release.
The step S3 further include: receive message decryption: after digital signage subscribes to message, agency's publication digital signage is subscribed to
Theme, digital signage receives the message of publication and decryption.
The step S4 further include: correlative code is encrypted and is decrypted.
The present invention passes through MQTT agreement, PUSH message to terminal, after terminal receives message decryption, according to protocol contents
The value of action if it is installation then go on server to download according to the value of apkUrl to distinguish installation or unloading advertisement
Installation kit then goes the advertisement on discharging terminal if it is unloading according to apkName.
The method of message Remote Installation based on MQTT and unloading advertisement of the invention, when terminal (digital signage) starts,
Subscribe to message subject such as: cloudring/client/terminal/terminalId/#, wherein terminalId
For the occurrence of terminal;
User issues Remote Installation and unloading message, and message passes through des encryption, and the message of installation includes advertisement apk title
With advertisement apk download address, the message of unloading only needs advertised name;
Terminal receives the Remote Installation and unloading message of user's publication according to theme is subscribed to;
Terminal receives Remote Installation and unloading message, and carries out DES decryption;
Terminal obtains advertisement apk title and advertisement apk download address according to Remote Installation and unloading message, if it is unloading
Message only obtains advertisement apk title;
It is transmitted by then passing through mqtt agreement, can guarantee to receive in weak signal, low broadband environment, it is objective in this way
The experience at family can be more perfect.
Now many digital signage, the wifi signal of itself is not strong, if it is http agreement is walked, then suspension may occur
The case where or link it is obstructed cause message sink less than either it is imperfect, will lead to the experience effect of advertisement in this way
Difference, the mqtt agreement that the present invention uses, which is used under the environment such as weak signal, low broadband to work, also can guarantee that reception is complete, and message
By des encryption, safety is guaranteed, be mqtt agreement and DES safety certification is used on digital signage be it is a kind of very
Good method;Method of the invention uploads and unloading energy batch operation, if as packet name, can also cover previous file.
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and
Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.