CN113824783A - Internet of things byte transparent transmission method based on H5JS local programming - Google Patents

Internet of things byte transparent transmission method based on H5JS local programming Download PDF

Info

Publication number
CN113824783A
CN113824783A CN202111098910.4A CN202111098910A CN113824783A CN 113824783 A CN113824783 A CN 113824783A CN 202111098910 A CN202111098910 A CN 202111098910A CN 113824783 A CN113824783 A CN 113824783A
Authority
CN
China
Prior art keywords
mqtt
computer
program
node module
mobile phone
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111098910.4A
Other languages
Chinese (zh)
Inventor
金琦明
金隐华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hexue Education Technology Co ltd
Original Assignee
Hangzhou Hexue Education Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hexue Education Technology Co ltd filed Critical Hangzhou Hexue Education Technology Co ltd
Priority to CN202111098910.4A priority Critical patent/CN113824783A/en
Publication of CN113824783A publication Critical patent/CN113824783A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/12Messaging; Mailboxes; Announcements
    • H04W4/14Short messaging services, e.g. short message services [SMS] or unstructured supplementary service data [USSD]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/02Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
    • H04W84/10Small scale networks; Flat hierarchical networks
    • H04W84/12WLAN [Wireless Local Area Networks]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Telephonic Communication Services (AREA)
  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses an Internet of things byte transparent transmission method based on H5JS local programming, which is used for fully exploiting the potential application characteristics of a cloud Internet of things MQTT in combination with Nodemcu and establishing a local operation mode of a mobile terminal (mobile phone or computer) Html-JS program based on full-range byte transparent transmission. The cloud Internet of things MQTT has the functions of supplementing direct WeChat and sound alarm, and provides a locally executed Internet of things Html-JS general program, so that the user programming links are greatly reduced, low-level repetition is avoided, and a programming example is provided. The mode is also particularly suitable for being combined with a singlechip, and MQTT is not needed in a local area network. And meanwhile, a mode that the Nodemcu program migrates to JS or realizes program size reduction through resetting and samples at high speed at fixed time is also provided, and data are transmitted to a mobile terminal connected with wifi in batches and in a centralized manner by combining the single chip microcomputer with the ESP-12. The simplified and complete Internet of things is from a local area network to a wide area network, and from a computer mobile phone to a single chip microcomputer to send WeChat, and the main stream technology is adopted, so that the system is very suitable for being used as a large-scale and special-type unified teaching material of the Internet of things.

Description

Internet of things byte transparent transmission method based on H5JS local programming
Technical Field
The invention belongs to the field of computer network communication control, and particularly relates to an Internet of things byte transparent transmission method based on H5JS local programming.
Background
Many single-chip programmer are unfamiliar with network programming, and it is desirable to have a simple and convenient way to integrate with the internet of things, which means that it is not easy to learn new network programming, rather than to say that network programming is more difficult or complicated. Even if one language is identified and programmed as far as possible by avoiding the backend according to the idea of the present invention, the answer is still seriously lost, and even the fundamental problem can not be found actually (the execution sequence setting of a large number of asynchronous processing programs in JS, including Promise of ES6, actually only refers to the execution sequence setting of the initiator, but not to the fact that the low-priority program can be interrupted by the high-priority program in the process of executing, the (interrupt) priority setting of the program, such as JS script language or nodemmu LUA language, the node. And such interrupt priority settings are critical in high-speed sampling, batch-and-forward data systems. It is further inconvenient that the priority of the timed asynchronous execution program in the commonly used scripting language (comprising JS, nodemmu LUA) is always lowest, which presents a difficult problem for high-speed timing sampling. Therefore, a solution is found by exploring a byte transparent transmission communication mode, locally executing an Html-JS program and combining a single chip microcomputer.
Disclosure of Invention
Based on the background technology, the invention provides an Internet of things byte transparent transmission method based on H5JS local programming.
According to the Internet of things byte transparent transmission method based on H5JS local programming, which is provided by the embodiment of the invention, the method is realized on an Internet of things structure, and an Html-JS local operation program is executed on a mobile phone or a computer, and the Internet of things byte transparent transmission method comprises the following steps:
(1) for an internet wide area network, constructing an internet of things structure, the internet of things structure comprising: the system comprises an Tencent cloud Internet of things MQTT server, a node module, a mobile phone end and/or a computer end, wherein the node module and the mobile phone and/or the computer end are connected with the MQTT server to realize bidirectional communication from the mobile phone or the computer to the node module;
(2) selecting an ESP-12 series node module, selecting Nodemcu firmware, and connecting the Nodemcu firmware with the MQTT server through an MQTT module in the Nodemcu firmware;
(3) the MQTT service at the back end of the network does not need to be programmed by a user, and the work flow of the user does not need to be adjusted and the program of the user does not need to be changed; when a new product of the Tencent cloud Internet of things MQTT is built, a default JSON data format is changed into a custom data format, a binary word throttling data transmission mode is selected through LUA language programming of a node module and JS language programming of a mobile phone or a computer end, the byte per byte in a data transmission packet is in a full range of 0-255, and network communication between the mobile phone or the computer end and the node module end through the MQTT is direct byte transmission without encoding/decoding in two directions, namely full-range byte transparent transmission for short;
(3.1) defining a control command based on full-range byte transparent transmission, wherein full-range byte file transmission from a mobile phone or a computer end to a node module end is included;
(3.2) according to the full-range byte transparent transmission, transmitting all data processing except the direct IO device driving in the node module to a mobile phone or a computer for processing through the bidirectional full-range byte transparent transmission;
(4) controlling n users at a mobile phone or computer end to control the operation authority of the m node modules by setting a rule engine of the Tencent cloud Internet of things MQTT;
(5) the computer end is provided with a browser, and the browser locally runs HTML-JS script language; the local operation HTML-JS script language of the mobile phone end converts the HTML-JS program into the operation of the mobile phone App through the HBuilderX; the connection between the mobile phone or the computer and the MQTT server is realized through JS plus a plug-in mqtt.js;
(5.1) uniformly programming programs except for presenting the personalized requirements of the user by a professional company, and designing the following general programs which can be executed independently, wherein the general programs are taken as programming demonstration:
mqtt connection. htm: generating UserName and Password according to the ProductID, the equipment name and the Hmac signature algorithm, and generating login parameters and connection detection of the Tencent cloud Internet of things MQTT equipment at a computer terminal;
mqtt communication. htm: a plurality of computers run simultaneously to test data or Chinese character mutual transmission among MQTT login equipment;
lua: the node module is connected with WIFI;
get _ mqtt.htm, get _ mqtt.lua: the computer end sets MQTT equipment login parameters of the node module through HTTP and tests whether the MQTT connection of the node module is successful or not;
init. lua: the node module automatically starts a program after being reset;
tencent mqtt. lua: the node module working program is matched with user demonstration programs mqtt _ wx.htm and mqtt _ wx.apk;
http. htm: the computer terminal automatically sends out a WeChat notification test;
simple push http. The node module automatically sends out a WeChat notification test;
providing a demonstration program for a user to realize a personalized operation display interface or a management process:
html _ wtt _ wx.htm: and (3) operating, controlling, testing and demonstrating programs of the MQTT internet of things of the Tencent cloud at the computer terminal.
mqtt _ wx.apk: and (5) operating, controlling, testing and demonstrating the program of the MQTT internet of things in the Tencent cloud at the mobile phone terminal.
Lua: a user self-defining program in the node module mainly writes a user self-defining global function usrdfn ();
(6) the initialization setting is carried out before the node module works normally, and the method comprises the following steps:
(6.1) power-on or reset, LED pilot lamp of node module slowly flashes, searches for WIFI during slowly flashing, slowly flashes and can reach a period of time, and the user uses the WIFI of computer connection node module AP this moment: a NodeMCU _6 bit random number is accessed 192.168.4.1 by a browser, wherein the searched WIFI is listed, a user selects the WIFI on the user's own capability, inputs a password and resets and restarts;
(6.2) after the node module is restarted, the LED indicator light of the node module flashes slowly for several seconds, the LED indicator light becomes bright to indicate that WIFI connection is successful, and MQTT is not connected, at the moment, the node module automatically enters a get _ mqtt.lua equipment login parameter setting program, a user computer sets back the WIFI on the node module, double-clicks the get _ mqtt.htm program in the computer, enters equipment parameters and user name/Password setting of the Tencent cloud Internet of things MQTT login, the equipment parameters ProductID, equipment name and DeviceScaret are filled item by item according to the equipment parameters ProductID, equipment name and DeviceScaret set in the Tencent cloud Internet of things MQTT, and the get _ mqtt.htm program automatically generates UserName and Passsword and tests whether MQTT connection login of the node module is successful or not; if the MQTT connection is successful, clicking for reservation, automatically writing the equipment login parameters ProductID, equipment name, UserName and Password which are successfully connected with the MQTT into an MQTT. If the situation is always unsuccessful, the user can double-click to start MQTT connection in the computer, the htm program and the get _ MQTT. htm program have the same setting interface of the logging parameters of the flight communication cloud Internet of things MQTT device, the computer browser is directly connected with the flight communication cloud Internet of things MQTT, and the connectivity of the logging parameters of the MQTT device is checked;
(6.3) once the MQTT connection login of the node module is successful, generating an mqtt.txt file, and then automatically entering a flight message mqtt.lua MQTT response program when the node module is powered on or reset and restarted, so as to realize the measurement and control work of the node module of the Internet of things, wherein an LED indicator lamp flashes slowly and then flashes and finally is not lighted, which indicates that the MQTT connection is successful;
(7) in the Tencent cloud Internet of things MQTT protocol, the MQTT is supplemented with the functions of sending WeChat and alarming, and the function of supplementing MQTT and sending WeChat specifically operates as follows: by adding a designated Topic, issuing information publish (Topic, msg) to the Topic, namely sending the information msg to a WeChat, wherein the receiving population of WeChat sending is determined by any one setting operation of the following 3 types:
(7.1) the Tencent cloud service manages a mobile phone WeChat APP of a login account, the mobile phone WeChat APP can scan codes to log in Tencent cloud service and can send WeChat, then a micro signal of the cloud service management login account is a receiver sent by the WeChat, and Topic is product ID/device name/WX 1;
(7.2) entering a work setting page of MQTT after the cloud service management account logs in, inputting a WeChat ID number or a group name of a WeChat sending and receiving person, wherein the input personal or group name is a person or group to which all WeChats in the WeChat address book of the cloud service management login account can be sent, and Topic is product ID/equipment name/WX 2;
(7.3) the cloud service management account logs in and then enters a work setting page of the MQTT, all individuals to which the WeChat can be sent in a WeChat address book of the cloud service management login account can be managed, a mobile phone WeChat APP can be used for scanning the two-dimensional code in the work setting page of the MQTT, a person passing verification is the individual to which the WeChat can be sent, and Topic is product ID/device name/WX 2;
when the MQTT sends out the WeChat receiving crowd Topic which is the product ID/the equipment name/WX 2, the crowd indicates a plurality of crowds, and the Topic can be subdivided into Topic which is the product ID/the equipment name/WX 2/a user I; topic ═ product ID/device name/WX 2/user two;
(7.4) when the mpic of the MQTT sending WeChat is product ID/device name/WXA 1, WXA2, not only sending WeChat, but also alarm, like WeChat [ voice call ] alarm call before connection.
Further, still include:
in the local area network, based on the two-way transparent transmission communication of local operation of a mobile phone or a computer Html-JS:
(8) in the local area network, the two-way transparent communication between the mobile phone or the computer and the node module adopts a UDP network protocol without a back-end service, and because the computer browser does not support UDP, a WS service is locally added to the computer to convert into UDP, and the conversion from WS service to UDP is finished by limiting an exe program which does not need to be installed;
(8.1) the mobile phone end introduces java.net in the project of H5+ APP of HBuilderx, supports for UDP are included, UDP communication is achieved through Html5+ JS programming, the HBuilderx generates a mobile phone APP program, and the WS service is not required to be converted into UDP;
(8.2) the broadcasting mode is realized by utilizing UDP, the problem that WIFI connection (DHCP) IP is not fixed is solved, the naming communication of the local area network multi-node module is realized, and the whole system is simplified to 4 programs:
WS services to udp. exe: a computer program, wherein the WebSocket protocol WS service is converted into a UDP protocol, and the computer program is started firstly and runs all the time;
name program htm: the computer browser Html5-JS locally runs and connects with the WS service program, each node module shuts off other node modules when running, only the node module with the currently set name is online, the name is input in a name program interface, and the computer can record the unique number of the node module and the input name in the local storage of the computer; WIFI and passwords can be set;
test program htm: when the computer browser Html5-JS operates locally and is connected with the WS service program, the computer can test and confirm the bidirectional data communication on each node module by naming when a plurality of node modules operate on line simultaneously, and the LED indicator light of the node modules is observed to indicate whether the state is normal or not; meanwhile, the method is also a programming demonstration program provided for a user, and a computer browser accesses WS service through a WebSocket protocol; if only one node module is needed, the naming process is not needed, and the router can be directly connected, namely the AP of the WIFI direct-connected node module of the computer;
node module, lua: the node module end is matched with a program, and the running of each HTML-JS program, including the mobile phone APP, the WIFI setting and the password, is executed by the LUA program through receiving and sending UDP data interpretation; UDP data transmission and reception of the LUA program is a net operation of a net module in the nodemcu firmware;
for the mobile phone, the naming program, htm and the test program, htm, are changed into the naming program, apk and the test program, apk, the operation mode is not changed, and the WS service is not required to be converted into the UDP.exe computer program;
(8.3) the node module alarms in real time to send the WeChat and sends the WeChat through a third party WeChat sending website, specifically, when the Nodemcu sends the HTTP GET and downloads through Nodemcu firmware, the HTTP module is selected, and the LUA program is sent by HTTP.
Further, still include:
(9) the full-range byte transparent transmission has the following uniform transceiving forms:
(9.1) JS MQTT receiving and sending at the mobile phone or the computer end:
an MQTT object, onmessageassociated, function, topic, destinationName; payloadBytes }
Transmitting an object, new path.mqtt.message (data);
destination name ═ topic
MQTT object Send (Send object) or MQTT object publishing (topic, data, 1);
(9.2) node module end LUA MQTT transceiving:
MQTT object on (message, function (MQTT object, topic, data) end)
MQTT object publish (topic, data, 1);
(9.3) sending and receiving by a JS local area network WS at a computer end:
WS object new WebSocket (WS:// 127.0.0.1: 8183')
WS object, open () { network attached notification }
WS object, function (ev) { received data, new Uint8Array (ev
Send (send data);
(9.4) UDP sending and receiving of JS local area network at the mobile phone end:
UDP Transmit-receive object new Datagramtoken (native port)
New datagrampack (send data, send data length, addr. getbyname (counterpart IP), counterpart port)
UDP Transmit-receive object send
Received packet is new datagrampack (abf, abf
UDP Transmit-receive object, receive (received data packet)
getData (); getLength (); the opposite port receives the data packet, getPort (); get address () when the other party IP receives the packet;
(9.5) node module end LUA local area network UDP transceiving:
UDP connection object on (reception, opposite side port, opposite side IP) end)
The UDP connection object send (opposite side port, opposite side IP, send data).
Further, the method also comprises a step of solving the problem that the ESP-12 node module installed Nodemcu firmware runs insufficient RAM, and the step comprises the following steps:
(10) splitting a LUA big program in a node Module into small programs to run independently one by one, recording the working state through an RTC User Memory Module or a Flash file, after automatic resetting and restarting, determining to enter a corresponding small program to run independently according to the working state recorded by the RTC User Memory Module or the Flash file, and resetting and restarting the process again after the running is finished.
Further, still include:
(11) and (3) performing high-speed sampling by using a domestic macro-crystal STC15W408AS series single chip microcomputer with high priority timed interruption, intensively transmitting the data to the node module with low priority when the sampled data are accumulated to a certain amount, and after the node module receives the data, forwarding the intensively transmitted sampled data to a computer or a mobile phone according to the local area network UDP or Internet MQTT communication mode (9).
Further, a mode can be established in which the setting of the operating parameters of the single chip microcomputer is separated from the operation, and the method is characterized by further comprising the following steps:
(12) the node module and the single chip microcomputer control system can separate the part of the wireless WIFI connected with a computer or a mobile phone from the application controlled by the specific single chip microcomputer, and can be separately carried out in secondary development and the use of an end user;
for the development process: only 1-2 HTML-JS programmers or professional companies which are familiar with the claims 2 and 3 are needed to set the relevant working parameters, so that the working parameters are set on a computer or a mobile phone to realize visual dynamic operation prompt, and the set parameter data are stored in the node module and the file of the singlechip or a Flash EPROM; a singlechip developer who is not familiar with HTML-JS programming only needs to directly develop control-oriented programming according to the node module and the file of the singlechip or the data in a Flash EPROM without concerning WIFI to connect a computer or a mobile phone to set working parameters; the node module runs an application program which can automatically select to enter a WIFI transparent transmission communication program or directly aim at control when the node module is reset according to the data state in the files of the node module and the singlechip or a Flash EPROM according to the method of claim 4;
for the end user: the computer or the mobile phone is connected with the setting before use through wireless WIFI, and the computer or the mobile phone is visually operated with dynamic prompt; when the work parameter is needed after being set, the work is started by electrifying or pressing a reset key, and the work can be selected by pressing a key and a plurality of LED indicator lamps without being related to a computer or a mobile phone; and then, the WIFI is required to be re-connected with a computer or a mobile phone for setting, and a common entering mode is adopted when a certain key is pressed, or double-click or long-press is carried out, or two keys are simultaneously pressed, or a certain key is pressed when power is on.
Further, the Nodemcu LUA program in the node module can be put into a Flash ROM to be operated by an LFS.
Further, before adding the WeChat sending function to the Tencent cloud Internet of things MQTT, the mobile phone can temporarily use a third party to send a WeChat website for standby real-time alarm, and then the user presses (8.3).
Further, the Tencent cloud Internet of things MQTT is replaced by the Internet of things MQTT of Aliyun, Huayun or OneNet.
The invention has the beneficial effects that: programming links based on MQTT and byte transparent transmission are reduced, a locally executed Html-JS general program of the Internet of things is provided, programming quantity of a user is reduced, low-level repetition is avoided, and a programming example is provided for the user. Also provides a way for MQTT to directly send out WeChat (including sound) alarm and transfer the working program of the singlechip to a mobile phone or a computer. Meanwhile, a method for realizing large and small program execution by Nodemcu through resetting is also provided, and in order to solve the problem of high-speed timing sampling, a mode of using a common typical singlechip to perform high-speed timing sampling and combining an ESP-12 module (using the Internet of things to transparently transmit) to transmit data to a computer or a mobile phone connected with wifi in batches and in a centralized manner is provided.
The internet of things not only refers to a cross-region internet, but also includes a local area network which does not relate to the internet. Because the localized operation mode of the Html-JS program at the mobile terminal based on the byte transparent transmission in the whole range is particularly suitable for being combined with a singlechip, and MQTT (especially a rule engine unfamiliar to beginners) is not needed in a local area network, a UDP (user Datagram protocol) communication mode of the local area network is provided, and the scheme comprises a matched program composition and a solution scheme for sending micro-information by the singlechip.
The simplified Internet of things is from a local area network to a wide area network, is connected to a single chip microcomputer from a computer mobile phone to send WeChat, adopts mainstream technology, has completeness, and is very suitable for being used as a large-scale and special-purpose Internet of things unified teaching material.
Drawings
Fig. 1 is a schematic view of an internet of things structure provided in this embodiment.
Detailed Description
The network technology has wide related areas and endless branches of new technologies, so that beginners or users who ask for simple and direct solution of network practical problems are confused and do not know how many front-end and back-end technologies need to learn. Aiming at basic application of the Internet of things, a whole set of solution suitable for beginners to enter is screened out from a plurality of network technologies, so that the beginners can realize personalized application of the Internet of things with an operation display interface or a management function only by learning the most basic HTML + JS programming. The invention firstly forms platform screening from hardware, not only accords with the development mainstream, fully utilizes the prior art, reduces the links that the user needs to program by himself, avoids low-level repetition, but also is simple, easy to learn, safe and reliable. It is also desirable to have low cost, small size, and low power consumption.
After selecting network technology and the configuration of software and hardware systems, professional programming is needed, various functions required by the practical system are realized by unified programming, and each functional module is typical and universal as much as possible. Only with such a system, the user can be done with half the effort.
Note that the user referred to herein is actually a technician or programming beginner, as previously stated: the users need to design and program themselves to realize a personalized operation display interface or management function (but do not want to learn programming deeply, and only want to learn as little as possible to do enough), and the method is different from the users who entrust the whole system to be developed by others in the conventional sense (the users in the conventional sense do not program themselves, certainly pay high, function adjustment and upgrade cannot be carried out at will, and the method must be limited by contract agreements in advance).
Therefore, the invention provides an internet of things byte transparent transmission method based on H5JS local programming, which is realized on an internet of things structure, wherein the internet of things structure comprises: the system comprises an Tencent cloud Internet of things MQTT server, a node module, a mobile phone end and/or a computer end; the node module and the mobile end of the mobile phone and/or the computer are connected with the MQTT server to realize bidirectional byte transparent transmission communication from the mobile phone or the computer to the node module, and refer to fig. 1.
In this example, the system architecture of the constructed internet of things is as follows: the method adopts a main stream Tencent cloud Internet of things MQTT portable network communication protocol, takes an ESP-12 module (a single chip microcomputer with WIFI) as a measurement and control node (a node module for short) of an object end of the Internet of things, and is controlled and managed by a mobile phone or a computer. The hardware architecture seems to be compact, and the practical rule is typical and is a hardware foundation which is deeply developed below.
Software system configuration: ESP-12 node module, which is equipped with Nodemcu firmware and is programmed by LUA script language.
The node modules ESP-12 and Nodemcu need to be described in more points, the ESP8266 chip 32-bit single chip microcomputer with the WIFI function is used, the ESP-12 module is only one of the most practical products in the series, the series of products are abundant, and particularly, the other Nodemcu module which is based on the ESP-12 module, is provided with an RS 232-USB interface, 5V power supply conversion and leads out all port pins is more convenient for experiments or door-to-door learning. The series can be matched with a plurality of software development systems, but from the aim of reducing the programming difficulty of users as much as possible, the invention selects Nodemcu firmware as the best scheme, the Nodemcu firmware is programmed by LUA script language (programmable by a notebook and an uploading tool), the Nodemcu firmware is provided for a plurality of commonly used electronic devices by existing ready-made supporting programs, such as a digital temperature sensor DS18B20, a temperature and humidity sensor HDT12, PWM waveform generation, a bus interface OW, a two-bus interface I2C, a three-bus interface SPI, a serial port UART, necessary FILE operation FILE, network service NET, WIFI, MQTT and the like, and a website is arranged to enable users to freely select modules for downloading (without register and login troubles), in detail, Nodemcu-build. In addition, the ESP-12 module is low in cost (less than 10 yuan), small in volume (half a stamp) and low in power consumption (3.3V80 mA). The perfect single chip microcomputer module integrating WIFI network access and measurement and control sampling is used as a node measurement and control sampling module of the Internet of things project, and great convenience is brought to users, particularly to the entrance of a beginner.
The computer system (such as Windows) is provided with a browser, and the browser can directly and locally run HTML-JS (JavaScript) scripting language, so that the HTML-JS program can be directly run without a programming development environment, namely the HTML-JS program is learned only by a notebook, and the execution result of the HTML-JS program local to the computer can be directly seen in the browser, thereby being very convenient for learning and trying. The browser is a webpage access tool, and HTML and JS are webpage files (except that conventional HTML and JS files are from a website Web server, namely, commonly-known rear-end programming, and are not directly started and operated locally. Therefore, the JS script language is very popular at present, but the aim of the invention is to learn the entrance convenience, so that only basic parts of HTML and JS are required to be enough (all extensions of jQuery, ES6 and the like are not required, and any programming environment is not required to be built). That is, the simplicity of JS learning to enter the door and the inherent superiority in the interface display are emphasized here. In addition, a key point to be emphasized is that the aforementioned HTML-JS program can be directly started and executed in a local (disk) of a mobile phone or a computer, so that the program originally serving as a node module single chip microcomputer can be moved to a computer or a mobile phone with super-high processing capability as much as possible without a Web server (a large back-end programming link is omitted), and many technical routes to be developed below are all around the key point.
Regarding local execution of the HTML-JS scripting language at the mobile phone end, a common method is to install and run through an HBuilderX-to-APP program (pure HTML + JS-to-APP is the simplest basic type in an HBuilderX project).
Because the Internet of things adopts mainstream cloud Internet of things and selects the MQTT lightweight network communication protocol of Tencent cloud Internet of things, the invention not only provides basic network communication, but also can obtain three advantages: (1) byte of each byte of the communication data packet can be in a full range of 0-255 (the capability of avoiding the transcoding of a single chip microcomputer is limited); (2) the n users at the mobile phone or the computer control the operation authority control of the m node modules, which is set and determined by a rule engine of the Tencent cloud Internet of things MQTT (management of the operation authority of the users does not need to be researched and developed and set, and operation authority identification sentences are set at places in a very troublesome way in the programming); (3) the core of the invention which is convenient for learning is that the HTML-JS script language runs locally in the computer (the JS local running is prohibited to directly access the website according to the same domain access safety rule), and the JS local running can directly access the external network MQTT server only through the plug-in MQTT.
JS (JavaScript scripting language) does not have an MQTT function, and a plug-in mqtt.js is added to realize the connection between the mobile phone or the computer and the Tencent cloud Internet of things MQTT server. The node module is provided with Nodemcu firmware, and can be connected with the Tencent cloud Internet of things MQTT server only by selecting the MQTT module. The Tencent cloud Internet of things MQTT server realizes bidirectional network communication between a mobile phone or a computer and an ESP-12 node module (namely realizing cross-router or remote control).
By the configuration of the software and hardware system of the internet of things, the invention provides an internet of things byte transparent transmission method based on H5JS local programming, which comprises the following steps:
(1) when a new (common) product of the Tencent cloud Internet of things MQTT is built, the default JSON data format is changed into the user-defined data format, and then the MQTT bidirectional data transmission binary byte stream is realized through the following programming statements, namely, byte per byte is in the range of 0-255. The LUA statement of Nodemcu MQTT of the node module is as follows:
local ubs=string.char(0,1,2,...,255);mclt:publish(topic,ubs,1,0,func)
the mqtt.js statement at the mobile phone or the computer end is as follows:
var ABbf=new ArrayBuffer(bfln)
var Ui8Ar ═ new Uint8Array (ABbf)// operate on unsigned one byte arrays
var mqttMsg=new Paho.MQTT.Message(ABbf)
mqttMsg.destinationName=topic
Send (mqttMsg) or publish (topic, ABbf,1)
Therefore, the JS language at the mobile phone or the computer end and the LUA language at the node module end are in bidirectional direct byte transmission through MQTT communication, a resource-consuming coding/decoding algorithm (such as commonly used Base64) is omitted, and the method is particularly suitable for a single chip microcomputer and is a basis of the method, and is called as follows: the byte is transmitted through the whole range, not only relieve the insufficient processing ability of the single-chip microcomputer, especially the Nodemcu firmware does not provide the bitwise logical operation instruction (JS has bitwise operator), but also facilitate the work of the node module single-chip microcomputer to transfer to the mobile phone or computer end with the ultra-strong processing ability, for example, the reading of the 18B20 temperature sensor is not decoded after being obtained at the node module end, and is directly sent to the computer end according to the original code, the JS decodes/displays after the computer end receives the reading, and the JS decodes, converts and displays the LUA language far more conveniently and quickly than the LUA language at the node module end. And any file can be transmitted, and the method is realized by the point.
(2) (3) as described above.
(3.1) defining control command sequences based on MQTT byte stream communication, the first byte being a command broad class distinction, the next several bytes being either sub-classes or parameters, such as:
ABbf [0] ═ 1 represents a remote power switch, ABbf [1] ═ 0 represents off, and ABbf [1] ═ 1 represents on;
ABbf [0] ═ 2 represents the starting reading temperature, ABbf [1] ═ n represents the temperature data sent every n seconds, and n = 0 represents the stopping sending; ABbf 2 ═ m denotes reading m 18B20 temperature sensor, m ═ 0 denotes reading all;
ABbf [0] ═ 3 indicates passing the file to the node module, the next 10 bytes ABbf [1] -ABbf [10] indicate the file name (less than 0), and all the following bytes indicate the file content.
More freely definable.
The transmission file comprises an executable file init.lua or prog.lc, so that remote file updating or node module system updating is realized, and then remote debugging of the node module is realized by combining a profile (prog.lua) statement. The operation authority control is set and determined by a rule engine of the Tencent cloud Internet of things MQTT.
(3.2) the work of the node module singlechip is transferred to a mobile phone or a computer end, which is said in (1).
(4) N users at the mobile phone or the computer control the operation authority control of the m ESP-12 node modules, which is set and determined by a rule engine of the Tencent cloud Internet of things MQTT (operation authority management which is very troublesome does not need to be set), and the rule engine of the Tencent cloud Internet of things MQTT sets closed.
(5) The computer end is provided with a browser, and the browser locally runs HTML-JS script language. And (3) locally running an HTML-JS script language at the mobile phone end, and converting the HTML-JS program into a mobile phone App to run through the HBuilderX (see: hx.dcloud.net.cn/Tutorial/project). The connection between the mobile phone or the computer and the MQTT server is realized through a JS add-in-plug mqtt.js (see: www.eclipse.org/paho/files/jsdoc/paho-mqtt.js.html).
And (5.1) in order to greatly reduce user programming, related programs forming the Internet of things are uniformly programmed by professional companies as much as possible and are designed into general programs (the general programs do not need to be changed no matter how the user programs change, and the general programs can be independently executed to complete certain typical functions). Since Html-JS is a scripting language that can be opened with a notepad, these programs are also a programming paradigm, both reducing the amount of user programming, avoiding low level repetition, and providing the user with an instance of programming. Particularly, the system comprises a setting program and a testing program of each stage of building the internet of things by a user, and the setting program and the testing program are also the basis for realizing the technical service on the internet. Otherwise, no company has the energy to deal with the problem of the feverish door to each user, and the problem must be classified and unified (to which program and what error information is executed) so that the user can express the unified basis of the problem.
The general procedure included:
mqtt connection. htm: according to the ProductID, the equipment name and the Hmac signature algorithm, UserName and Password are generated, and logging parameters of the Tencent cloud Internet of things MQTT equipment at a computer end are generated and connection detection is carried out.
mqtt communication. htm: and (4) simultaneously operating a plurality of computers and testing data or Chinese character mutual transmission among the MQTT login equipment.
Lua: and the ESP-12 node module is connected with WIFI.
get _ mqtt.htm, get _ mqtt.lua: the computer end sets MQTT equipment login parameters of the ESP-12 node module through HTTP (to solve the problem that the direct wireless communication between the computer end and the ESP-12 node module is realized by a local area network before the MQTT is communicated, and at the moment, the ESP-12 node module is a Web server), and tests whether the MQTT connection of the node module is successful or not.
init. lua: and the node module automatically starts the program after being reset.
Tencent mqtt. lua: and the node module working program is matched with user self-programming tencMqtt.
http _ wx.htm: and the computer terminal automatically sends out a WeChat notification test.
http _ wx.lua: the node module automatically sends out a WeChat notification test.
The user self-programming is needed to realize the personalized operation and control of the display interface or the measurement and control data management process, the HTML-JS script language program is operated on the local computer of the user, a programming development environment (a notepad can be edited) is not needed, and the debugging result is visual. Demonstration programs are also provided for the user to learn, adapt.
tencmqtt. htm: and (3) performing operation control testing and demonstration programs of the MQTT internet of things of the Tencent cloud at the computer terminal.
tencmqtt.apk: and (3) performing operation control testing and demonstration of the MQTT internet of things in the Tencent cloud at the mobile phone terminal.
Lua: the user-defined program in the node module mainly writes a global function usrdfn ().
The user learning emulation may begin by changing the nouns, parameters.
And a user self-programming Lua language interface is reserved for the function expansion of the node module:
when the first byte of the MQTT command sequence sent to the node module is 98, a user-defined global function usrdfn (msg) in a reset self-starting program init.
When the first byte of the MQTT command sequence sent to the node module is 99, the reset self-start program init. Lua contains the statement:
MQTT data packets received by usrdfn (msg) -msg are processed by usrdfn () user self-programming interpretation. Or
if usrdfn==nil then dofile("usrprg.lua");usrdfn(msg)else usrdfn(msg)end
Lua, without local, and with global customization function usrdfn (msg).
In addition to the custom global function name usrdfn, the node module also has several dedicated global variable names that are not accidentally reused or changed: such as: tmr0, mclt, fmqtt0, fbk0, wx.
The user-defined program of the node module is particularly suitable for a mode that the big program is directly executed in an LFS, all LUA working programs are compiled and packaged into LUA.img at the moment and are loaded into a Flash ROM (see the details: nodemcu.
It should be noted that although the init.lua may be provided with the user-defined global function usrdfn (), and called by the MQTT command sequence ABbf [0] ═ 98, it is not recommended to modify the init.lua, and even if an error occurs, the beginner may mistakenly discard the ESP-12 node module by mistake.
The user self-programming of the node modules is also provided by the exemplary program usrprg.
Before the mode adjustment of the Internet of things, establishing an Tencent cloud login account, real-name authentication and an MQTT product ID of the Internet of things, and then establishing device names one by one, wherein the specific operation is as follows: com.
The parameters such as Tencent cloud login account, Internet of things MQTT product ID, equipment name and the like are provided, the MQTT is recommended to be tested and connected on a computer, and many problems are fully understood. In another point of view, many programming links (whole back-end programming and user management are omitted) are reduced by selecting the MQTT, but the problem is transferred to the learning of the MQTT of the cloud Internet of things, especially, the rule engine which does not have the standard MQTT needs to be learned, before the node module of the Internet of things is related, the MQTT is directly connected with the Tengcong cloud Internet of things from a computer, the JS program sentences of the MQTT, the equipment connection parameters, the communication among multiple equipment, the continuous data and the Chinese characters are transmitted, and the like are fully exercised and clarified, not only are two pieces of equipment mutually communicated through the Tengcong cloud Internet of things, but also determines the operation authority control (set by Tencent cloud Internet of things (rule engine)) of n users at the mobile phone or the computer end to the m node modules, therefore, the user operation authority management does not need to be researched and developed, and the trouble that a large section of operation authority identification statement needs to be arranged everywhere in programming is avoided.
The general computer-end MQTT test program comprises the following steps:
mqtt connection. htm: generating UserName and Password according to the ProductID, the equipment name and the Hmac signature algorithm, and generating registration parameters and connection detection of the Tencent cloud Internet of things MQTT equipment. If the connection is successful, the login parameters of the equipment are saved in the local computer, and the MQTT is automatically connected next time. (note: a device name is created on the Tencent cloud Internet of things, and a user name and a Password for MQTT device login connection can be obtained through a security algorithm, and according to timeliness and randomness, an infinite number of MQTT login connections can be generated, wherein the user name and the Password can be used for the MQTT login connection of the device name, but one device name does not allow simultaneous login at multiple places, the user name and the Password can be connected through an MQTT, and an htm program is confirmed.)
The device login parameters "product id, device name, UserName, and Password" are always the same as the standard MQTT, and unlike the standard MQTT, which has only one fixed UserName and Password, the device login type MQTT not only has its own UserName and Password for each device login, but also has product id and device name as the components for connecting the MQTT server name and Topic, so the MQTT.
mqtt communication. htm: multiple computers (using different device names to log in parameters) can be connected with MQTT at the same time to test the data or Chinese characters mutual transmission among the MQTT log-in devices. In particular for checking the inter-device interworking effect of the [ rules Engine ] settings and the corresponding topic settings. Note that, for higher security, MQTT in each of the large mainstream cloud services in China is not standard MQTT, and the transmission target of the standard MQTT is directly determined by Topic at the time of transmission (there is no concept of device name login). The transmitting Topic of the MQTT in the mainstream cloud service is defined as the self Topic of the device, and the interoperability of the transmitting target is defined by the self Topic of each device through adding definition [ rule engine ], so that the transmitting target can be understood as [ device login type MQTT ]. Note that the n users at the mobile phone or the computer and the m node modules at the object side of the internet of things are all similar device names when the flight cloud internet of things MQTT establishes the device names, and the n users at the mobile phone or the computer can be named as USRn and the m node modules at the object side can be named as DVCm in terms of naming. The interoperability between USRn and DVCm is established by setting a rule engine for Topic ═ product ID/USRn and Topic ═ product ID/DVCm for each device name by logging in the "rule engine" of the Tencent cloud [ Internet of things communication ].
The user only uses the HTML-JS program to practice MQTT communication on a computer, which is very convenient and visual. By being familiar with the communication foundation of the internet of things, the experience of operation flexibility is already provided in the connection of the node modules of the internet of things at the next stage, and the test program information can be used as a reference point in the process of flexible tests when problems are encountered or on-line help expression.
Here, mqtt connection htm and mqtt communication htm are HTML-JS script languages, and users can adapt/reduce to personalized special programs of own environments after being familiar with the HTML-JS script languages.
In addition, although the program names have Chinese characters, the program file names on the network and for the HBuilderX to convert to the APP cannot use Chinese characters, so that some program file names cannot use Chinese characters. The same applies below.
(6) The initialization setting steps before the normal work of the node module of the Internet of things are as follows:
(6.1) power-on or reset for the first time, the LED indicator lamp of the node module (end user Lua is executed by init Lua control) slowly flashes at an interval of 0.5 second, and the WIFI is searched for half a minute, and at the moment, a user is connected with the WIFI of the node module AP through a computer: and the NodeMCU _ xxxxxx is accessed by a browser 192.168.4.1, wherein the searched WIFI is listed, the user selects the WIFI on the user's own capability and inputs a password, and then the node module is reset and restarted.
(6.2) after the node module is restarted, the LED indicator light slowly flashes for about 2-10 seconds for 5 times of flash (keeps a bright state) for 0.5 second, which indicates that the WIFI connection is successful (but the MQTT is not logged in), at the moment, the node module automatically enters a get _ mqtt.lua equipment login parameter setting program, the user computer returns the WIFI on the user computer, double-click starts the get _ mqtt.htm program in the computer, enters equipment parameters and user name/Password setting of the Tencent cloud Internet of things MQTT login, and automatically generates UserName and Passsword according to equipment parameters ProductID, equipment name and DeviceSceret set in the Tencent cloud Internet of things MQTT, items are filled in one by one, and the get _ mqtt.htm program automatically generates UserName and Passsword and tests whether the MQTT connection login of the node module is successful or not; if the MQTT connection is successful, clicking the reserved device, automatically writing the device login parameters ProductID, the device name, the UserName and the Password which are successfully connected with the MQTT into an MQTT. If the situation is always unsuccessful, the user can double-click and start the Mqtt connection htm program in the computer, the program and the get _ Mqtt htm program have the same setting interface of the logging parameters of the MqtT equipment of the Tencent cloud Internet of things, a computer browser is directly connected with the MqtT of the Tencent cloud Internet of things, and the connectivity of the logging parameters of the MqtT equipment is checked.
(6.3) once the node module has the mqtt.txt file and the MQTT connection login is successful, the node module automatically enters a Tencent MqtT response program whenever being powered on or reset and restarted, and monitors the measurement and control operation of the node (namely, all the nodes can be intuitively operated from a computer or a mobile phone when the network is connected).
(7) The basic functions of the internet of things have been built up so far, but an important real-time alarm function is still lacked, and it seems difficult to find a simple programming method at first glance for the following reasons:
the self-programming is closed by the system after 5 minutes when the mobile phone is in standby state after screen turning. Even if a programming development environment of a mobile phone system is specially used for manufacturing a standby alarm waiting program (including troublesome operation permission system setting), according to the current power saving strategy of a mobile phone manufacturer, when the mobile phone is in standby state after being turned off, the system can stop the operation of all user APPs except some large-brand software on a white list, such as WeChat, Paibao, Huawei service and the like.
More practically, many small and medium-sized internet of things applications still need to work for a long time when the mobile phone is in a screen off standby state, such as anti-theft alarm, fire alarm and old people fall down alarm, the frequency of alarm actually generated by the applications is extremely low, if the APP specially made on the mobile phone is not suitable for long-time background operation, power is consumed, and the APP is easily turned off unintentionally (namely, the program can still normally respond when the key cannot be guaranteed at all).
After comprehensive analysis, a proper positive solution appears: the mobile phone has the best choice for carrying the standby real-time alarm function of the mobile phone to the APP of the mobile phone installed by people, such as WeChat, Paibao and Huacheng services. The WeChat of Tengchong corporation is taken as an example, and the function of sending WeChat is added to the MQTT of Tengchong cloud Internet of things.
From the network technical architecture, the MQTT in several mainstream cloud service internet of things is not the standard MQTT, and is the MQTT with the limitation of adding a rule engine to Topic (herein, the "device login type MQTT" is detailed in the context of content, client, and/or rule), and then the function of sending the micro-communication is added in the aspect, and more than half the effort is that the internet of things MQTT device login and the ready-made account number of the micro-communication login can be used as the ready-made safety mechanism for pushing and controlling the micro-communication (otherwise, another set is the most important for the user, so that the user can simply get the information one ring after another), so that the safety authentication operation process of receiving the micro-communication pushed crowd is greatly simplified (the safety authentication process of the micro-communication pushing function in the counter micro-communication applet is very worrisome, and the pencils try to communicate for several times, but the micro-communication developer can refer to the safety authentication process of the micro-communication pushing function in the micro-communication development tool.
The specific implementation details are as follows:
in the Tencent cloud Internet of things MQTT protocol, an MQTT WeChat sending function is supplemented, and a specified Topic is added to send information publish (Topic, msg) to the Topic, namely the information msg is sent to WeChat, and a receiving crowd sent by WeChat is determined by the following 3 setting operations:
(7.1) the Tencent cloud service management login account personal mobile phone WeChat APP must be capable of scanning codes to log in Tencent cloud service and sending WeChat, so that the WeChat of the Tencent cloud service management login account personal micro signal is a receiver sent by WeChat, and Topic is product ID/device name/WX 1;
(7.2) entering a work setting page of MQTT after the Tencent cloud service management account is logged in, inputting a WeChat ID number or a group name of a WeChat sending and receiving person (the operation is similar to the setting of a rule engine), wherein the input individual or group name is an individual or group to which all WeChats in the Tencent cloud service management login account self WeChat address book can be sent, and Topic is product ID/device name/WX 2;
(7.3) entering a work setting page of the MQTT after logging in by the Tencent cloud service management account, wherein the Tencent cloud service management account manages all individuals, to which the WeChat can be sent, in the WeChat address book of the Tencent cloud service management account, the individuals can scan the two-dimensional codes in the work setting page of the MQTT by using the mobile phone WeChat APP, the person passing the verification is the individual to which the WeChat can be sent, and Topic is product ID/equipment name/WX 2. For example, the LUA program statement is mclt: publish ('product ID/device name/WX 2', 'Alarm:'. message).
When the MQTT sends out the WeChat receiving crowd Topic which is the product ID/the equipment name/WX 2, the crowd indicates a plurality of crowds, and Topic can be subdivided into Topic which is the product ID/the equipment name/WX 2/Zhang III; topic ═ product ID/device name/WX 2/liquad.
Note that: the MQTT WeChat sending function setting operation is that firstly, a mobile phone WeChat APP of a Tencent cloud service management login account must be capable of scanning codes to log in Tencent cloud and sending WeChat to a WeChat sending and receiving crowd.
Regarding the setting of the people who send and receive the WeChat, entering a Tencent cloud service management interface on a computer, a mobile phone or a mobile terminal, and setting allowed operation items of the people who send and receive the WeChat under each product ID/equipment name established by the user after logging in successfully by a management account.
(7.4) when the Topic of the MQTT sending Wechat is product ID/device name/WXA 1, WXA2, not only sending Wechat, but also alarm (long time sound reminder), like Wechat [ voice call ] alarm call before connection. This is mainly an emergency alarm such as accident, malfunction, etc.
The potential functions of the Tencent cloud MQTT and the WeChat are fully developed, so that the programming links of the user are greatly reduced.
Therefore, a simplified technical route is passed, and the existing technology and potential highlights (especially, lessons are done on the simplification of twice with half the effort, such as MQTT byte 0-255 full-range direct transparent transmission, a front-end program local operation rear-end MQTT does not need programming and only vacates a communication cloud (rule engine), a single-chip program is moved to a computer front end as much as possible and is replaced by a local JS program, and a locally executed Internet of things Html-JS general program is provided, so that the programming amount of a user is reduced, low-level repetition is avoided, a programming example is provided for the user), are actually integrated in a way of fine selection from one loop to one loop, and the wonderful originality can also be applied to a local area network.
(8) As a completeness, especially in the early internal commissioning or learning stage, the internet of things should also include a local area network mode, that is, in a building or a room, only through a local area network (unrelated to any commercial internet), a two-way transparent network communication from a mobile phone or a computer end to a node module end is realized. The method is safe (not communicated with an external network), avoids various network charges, does not relate to the cloud service MQTT, avoids the need of knowing the account of the cloud Internet of things for security authentication and setting the MQTT rule engine thoroughly, and enables the learning of the Internet of things to have a lower starting point for entry. In fact, most small internet of things projects are applied in a local area network, the application in the local area network is certainly done, the mode of the invention is not conflicted if the application is expanded to a cross-region or a remote place and then a cloud MQTT block is supplemented, and the user programming only needs to modify byte transceiving calling interfaces at two ends (all based on byte transparent transmission, see the following 9).
The mobile phone wireless direct connection is used as a control core single chip microcomputer of household appliances and instruments, and has special application fields of serving as a super display screen and controlling function keys, so that display panels or control keys of the household appliances and the instruments are greatly simplified, the production process is simplified, and the operation is perfect, convenient and visual.
UDP is a non-connection simple network protocol, and is applied to a local area network without interference and almost without packet loss, and is very suitable for a single chip microcomputer to transmit large pieces of data at a high speed (such as electrocardiogram display and 2.4G wireless FSK communication group control upper computers to manage backbone data transmission), so that a UDP network protocol is adopted for local area network communication from a mobile phone or a computer end to a node module end. As the computer browser does not support UDP, WS (WebSocket) service is added locally to the computer to convert UDP, and the computer browser directly supports WS.
The conversion from the WS service to the UDP is a computer program which runs independently, and installation and account setting registration are not needed (so that a user is facilitated, and complicated downloading, installation, NodeJS and environment configuration are omitted).
The realization method for converting WS service into UDP.exe comprises the steps of firstly installing nodejs, then operating and checking the WS service into UDP.js, and then packaging pkg of nodejs into the independently operated WS service into UDP.exe.
The key steps of converting WS service to UDP.js by NodeJS comprise: establishing UDP interception, starting WebSocket service to intercept a service request of a WS, responding and remembering a client by the WS: v/127.0.0.1: 8183 protocol from a computer browser, finding an IP and a port number 8080 of a node module corresponding to a unique number according to naming, and directly forwarding UDP; once the UDP data is received, its name and unique number can be retrieved from the local storage of the computer according to its IP, and pushed together with the received UDP data to the client's browser JS in mind using WS. Some key feature statements are as follows:
Figure BDA0003270123610000181
Figure BDA0003270123610000191
(8.2) the computer browser requests the WS service with the WSs:// 127.0.0.1:8183 protocol supported by html5-JS, and the WS service forwards UDP. UDP traffic, without a service/client partition, is sent over the opposite IP and port number. However, in the actual situation, the (DHCP) IP of the node module WIFI is not fixed, and the WS service needs to determine the IP of the other node module before communicating with the UDP. The WS service receives the UDP message and has the IP and the port number of the opposite node module, and records the record as the target IP and the port number in normal work.
In the above case of one node module, an initial naming setting procedure (corresponding to the creation setting device name of MQTT) is added for the case of multiple node modules: before each node module works normally, the node modules need to be named one by one on a computer, the unique numbers of the node modules are recorded, and then a user operates each node module according to the name.
The specific setting naming process is as follows: the other node modules are turned off, only one node module which is communicated with the UDP network by a computer browser is left after converting the WS service into the UDP, the unique number is read out and sent to the computer, and the unique number and the name input by the user are recorded in the local storage of the computer (the power-off does not disappear).
When several node modules are on-line at the same time, the computer adopts successive broadcast with unique number to determine IP of each node module, and each node module (simultaneously receiving, but only receiving the information identical to its own unique number) sends back UDP information, so that the computer can fill the existing name and unique number with current IP and port number one by one.
Note that, the port numbers of the UDP network communication are usually agreed in advance, for example, the UDP port number of the mobile terminal computer or the mobile phone is 8081, and the UDP port number of each node module is 8080.
When multiple node modules are online at the same time and it is determined that all current IP (and port number 8080) enter normal WS service to UDP, the key steps for nodjs to implement [ WS service to UDP. Establishing UDP interception, starting WebSocket service to intercept a service request of a WS, responding and remembering a client by the WS: v/127.0.0.1: 8183 protocol from a computer browser, finding an IP and a port number 8080 of a node module corresponding to a unique number according to naming, and directly forwarding UDP; once the UDP data is received, its name and unique number can be retrieved from the local storage of the computer according to its IP, and pushed together with the received UDP data to the client's browser JS in mind using WS.
According to the working principle, four programs (which can be used as external features) are actually determined:
WS services to udp. exe: the service program is started first and is always running (whether a node module is online or HTML-JS is running).
Name program htm: when the name is input in the operation interface appearing in htm, the computer can record the unique number of the node module and the input name in the local storage of the computer together (the power off does not disappear, so the operation is only performed once). The current operation serial number can also be used as a serial number and pasted on the node module at the same time (for visual distinction) (but the inside always works only according to a unique number). Also here including setting WIFI and password.
Note that: htm designates to connect in the AP mode of the node module, that is, the AP of the WIFI direct connection node module of the computer (broadcast IP of WS service to UDP is 196.168.4.255 or 196.168.4.1), and then WIFI and password of the node module are set (the node module is automatically connected to WIFI after being powered on or restarted, LED indicator lights flash slowly for about 2-10 seconds at intervals of 0.5 second until WIFI connection occurs successfully for 5 times, and the computer also returns to the original WIFI). Namely: the node module is provided with WIFI which can be set in an HTTP mode (end user. lua) in (6.1) or in a UDP mode (in short, the operation from a computer or a mobile phone is intuitive as long as the network is connected).
Test program htm: the computer can test and confirm the bidirectional data communication for each node module by naming when running, and observe whether the LED indicator lamp of the node module is in normal state or not. And is also a programming demonstration program provided to the user.
Note that: a plurality of node modules are simultaneously online and certainly in a local area network mode formed by wireless routers, all the node modules need to be connected successfully through automatic WIFI, and all the node modules are named and recorded in a computer.
For the case of only one node module, naming is not used, i.e. WS services are handled as a single node module without finding a naming record.
Htm designates connection in AP mode of node module, i.e. AP (broadcast IP of WS service to UDP is 196.168.4.255 or 196.168.4.1) of computer (WIFI connection) direct connection node module, then WS service to UDP.
Node module, lua: the unified node module end is matched with a program (just one), and the operation of each HTML-JS program, including the mobile phone APP, the WIFI and the password, is executed by the LUA program through receiving and sending UDP data interpretation.
(8.1) regarding to replace the computer operation here with the mobile phone, because the mobile phone end programming invention is to change HTML-JS program into mobile phone APP program through HBuilderx, it is more advantageous that java.net is introduced into the project of [ H5+ APP ] of HBuilderx to have support to UDP, therefore the above WS serve changes UDP.exe service program completely and the other data transparent transmission to the node module end through UDP and the naming recording process of the multi-node module (including setting WIFI and password) are all similar to keep, namely there are corresponding naming program, apk, test program, apk. The corollary programs (node modules. lua) at all node module ends are still the same (unchanged).
The HTML5plus of the specific HBuilderX has a statement related to UDP operation (the UDP operation statement at the mobile phone end is uncommon, and the main UDP transceiving statements are listed as follows for interested internet retrieval):
var DatagramPacket=plus.android.importClass("java.net.DatagramPacket");
var DatagramSocket=plus.android.importClass("java.net.DatagramSocket");
var socket ═ new DatagramSocket (8081); v/set UDP Port
var spkt=new DatagramPacket(data,data.length,address,port);
send (spkt); // UDP data packet spkt
var rpkt=new DatagramPacket(buf,buf.length);
Record (rpkt); // UDP receives the data packet rpkt.
(8.3) if the local area network router is connected with an external network, the node module can still give an alarm in real time to send a WeChat, and a WeChat website is sent by a third party, such as: shrimp thrust www.xtuis.cn, kindly xz.qqoq.net/#/index, Server sauce sc.ftqq.com. The nodemmcu sends HTTP GET to download a time selection HTTP module through nodemmcu firmware, and the LUA program sends the HTTP.
The user scans the code and registers (pays attention to or pays) on the third party sending WeChat website in advance, sets up sending WeChat address (provided after paying attention to or paying) and content input field in the user program, and stores the parameters needed by the two third party sending WeChat websites in the node module file in advance.
(9) Based on the two-way transparent transmission, one of the advantages is that the communication mode can be easily changed by knowing the transparent transmission statement, such as the MQTT upgraded from the local area network UDP to the wide area network. The uniform means that regardless of the design of the user personalized workflow, the received data always triggers a function with received data parameters to process the received data (directly sending and receiving). The UDP and MQTT bidirectional transparent transmitting and receiving statements used by the invention are summarized as follows (can be used as keywords for online retrieval):
(9.1) JS MQTT receiving and sending at the mobile phone or the computer end:
client.onMessageArrived=function(mqttMsg)
{topic=mqttMsg.destinationName;Msg=mqttMsg.payloadBytes}
mqttMsg=new Paho.MQTT.Message(Msg)
mqttMsg.destinationName=topic
send (mqttMsg) or publish (topic, Msg,1)
(9.2) node module end LUA MQTT transceiving:
on (message, function, data) receipt processing end)
mclt:publish(topic,data,1)
(9.3) sending and receiving by a JS local area network WS at a computer end:
var wsObj=new WebSocket("ws://127.0.0.1:8183")
wsObj.binaryType="arraybuffer"
wsObj.onopen=function(){document.all.dsp.innerHTML="WebSocket open"}
wsObj.onmessage=function(ev){var bf=new Uint8Array(ev.data)}
wsObj.send(data)
(9.4) UDP transceiving of JS local area network at the mobile phone end (H5+ JS UDP):
skt=new DatagramSocket(8081)
spkt=new DatagramPacket(abf,abf.length,Addr.getByName(IP),8080)
skt.send(spkt)
rpkt=new DatagramPacket(abf,abf.length)
skt.receive(rpkt)
rpkt.getData();rpkt.getLength();rpkt.getPort();rpkt.getAddress()
(9.5) node module end LUA local area network UDP transceiving:
on ("receive", function (socket, data, port, ip) received processing end)
UdpSocket:send(8081,ip,data)
All the types of the data to be transmitted and received have the type of a 0-255 full-range byte array, namely, the statement format of full-range byte transparent transmission is directly given in summary in this section.
Note that, the full-range byte array type is used as a transmission data packet, and some types are directly supported, such as UDP or MQTT of nodemmu LUA, and the array type and the character string type are simultaneously supported without description; the WS of the computer browser is set by the wsobj. Js of the computer browser is specified by data object attribute setting Msg-mqttmsg.
It should be detailed here that the java.net can be directly used by UDP introduced by the mobile phone end through the [ H5+ APP item ] of HBuilderX, except that its receiving mode is a simple blocking form (dead and so on until receiving), and the others are event trigger forms, and the receiving of the processing function is triggered only when receiving. For the blocking shape received by the Html5plus-JS UDP, a very short (blocking) receiving time (for example, 10 ms) can be set by using a skin.setsotimeout (10) but a pre-stored function is received, the user call interval (200) can be received once every 200 ms (10 ms is blocked when no data comes), and the user call interval (rpkt) function processing is executed when data is received, which is equivalent to the event triggering shape (a received event triggering function of a UDP receiving and sending object can be directly encapsulated by an object encapsulation statement), which specifically includes:
Figure BDA0003270123610000231
Figure BDA0003270123610000241
in addition, the (Java) UDP in the item H5+ APP of HBuilderX is also slightly exceptional, and the byte range of the transmission packet is 0 to 127, -1 to-128, and is unified into the full range of bytes 0 to 255, and conversion is performed:
b? b (b-256). This simple conversion is not stressful for modern cell phones.
(10) The node module ESP-12 has only 40K RAM, and a slightly larger program will be over-rebooted and no effective way to exit the executed program can be found. Therefore, a large program is divided into small programs, the working process state is recorded by resetting an RTC User Memory Module or a Flash file which is not cleared, after automatic reset and restart, init.lua enters a corresponding program according to the working process state recorded by the RTC User Memory or the Flash file, and after execution is finished (the RTC User Memory Module or the Flash file record is adjusted), the process of resetting and restarting circulation is reset again. Generally, long-acting working parameters are recorded by a Flash file, and are not lost when power is off, for example, a get _ mqtt.lua program records MQTT equipment login parameters in an mqtt.txt file, and then the node module self-starting program init.lua enters an Tencent mqtt.lua working program according to the mqtt.txt file after power is on or reset and restarted, so that the situation that the get _ mqtt.lua program occupies a memory (cannot be quitted unless reset) at the same time is avoided; the temporary working process state is recorded by the RTC Memory, if a certain abnormality is detected and a WeChat sending alarm is required (a 29K Memory is required and only a WeChat sending program can be independently operated), after automatic reset, init.lua enters the WeChat sending program (without an original working program) according to the RTC Memory, after the WeChat sending is finished, the RTC Memory state is recovered, reset and restart are carried out again, and the original working program is returned (the existence of the WeChat sending program occupying the Memory at the same time is avoided).
(11) As a technical scheme for solving the problems of high-speed timing sampling and batch centralized data transmission, the invention provides a technical scheme that a common typical single chip microcomputer (such as 3-yuan high-configuration typical domestic macro-crystal STC15W408AS series) is used for executing high-speed sampling at a high priority timing interruption, when the sampled data is accumulated to a certain quantity, the sampled data is transmitted to a node module (Nodemcu ESP-12) at a low priority in a centralized manner, and after the sampled data is received by the node module, the sampled data transmitted in a centralized manner is transmitted to a computer or a mobile phone according to the local area network UDP or Internet MQTT communication mode.
The reason why a typical one-chip microcomputer is added to realize high-speed sampling is that no (interrupt) priority setting of program execution can be found in the JS scripting language or the nodemmcu LUA scripting language (the execution sequence setting of a large number of asynchronous processing programs in the JS, including the Promise of ES6, actually refers to only the execution sequence setting of a startup program, but does not refer to a low-priority program which can be interrupted by a high-priority program during execution. In fact, the JS script language is originally proposed for the dynamic display effect of the webpage, and has no positioning for real-time operation. It is difficult to wonderful that the reception of UDP (HBuilderX H5+ JS UDP) at JS lan at (9.4) is a simple blocking form, and no simple method can be found for directly providing a uniform reception trigger function. According to the document given by JS, it is understood that the problem of blocking of the skin of the new ES6 (i.e. without setInterval or setTimeout) should be solved by the Promise and async await of the new ES6, which cannot be actually done at all. With setInterval or setTimeout, this in itself achieves the asynchronous non-blocking problem (as illustrated in FIG. 9.4, this is the case), and it is not necessary to encapsulate the Promise asynchronous non-blocking sensation (which increases the difficulty of first-learning understanding).
But the real problem is asynchronous non-blocking implemented by setInterval or setTimeout, which has the lowest priority for timing execution and cannot find a high-priority timer. Especially, a node module (nodemmu LUA) used for controlling sensor sampling cannot find a high-priority timer (which should be set in the RTC Time module most naturally according to the theory), which is a big regret, and a typical single chip microcomputer is added to realize high-speed sampling. Looking at an application example: the real-time electrocardiogram display device requires that ADC sampling is performed at the priority timing of 500 points per second, 500 points of data (each data is one byte) are transmitted together in a batch, and the transmission is naturally interrupted by ADC sampling with higher priority for many times (the ADC sampling comes once every 2 milliseconds, and 500 bytes of data packets cannot be transmitted within 2 milliseconds). The typical problem can be perfectly solved by adding a macro-crystal STC15W408AS series single chip microcomputer: by utilizing a two-stage priority interrupt mechanism of a classical traditional 51-type single chip microcomputer, a high-priority timing interrupt executes a high-speed sampling program, and the execution of the high-speed sampling by the timing interrupt is not influenced when a data transmission program is executed. In addition, the macro-crystal STC15W408AS series single-chip microcomputer can solve the problem of executing programs according to priorities, has higher sampling precision than ESP-12, provides up to 8 ADC input ports, and is low in cost and small in size. The STC15W408AS single chip microcomputer is very convenient to communicate with the ESP-12, and can be used for transmitting and receiving programs from and to the slave I2C of the STC15W408AS end by an RS serial port (three-wire), an SPI (five-wire) or an I2C (two-wire). The subject of the project is that data are forwarded to a computer or a mobile phone by an ESP-12 node module, and key data receiving and sending sentences of two network communication modes are collectively and generally listed in (9). In other words, this section also gives a typical practical example of the present invention.
(12) The node module and the single chip microcomputer control system can separate the part of the wireless WIFI connected computer or the mobile phone from the application controlled by the specific single chip microcomputer, and can be separately carried out in secondary development and the use of an end user.
For the development process: only 1-2 HTML-JS programmers or professional companies in claim 2 or 3 need to make the setting of the relevant working parameters, so that the setting of the working parameters on the computer or mobile phone can realize the visual dynamic operation prompt, and the set parameter data can be stored in the node module and the file of the single chip microcomputer or the Flash EPROM. A single chip microcomputer developer who is not familiar with HTML-JS programming only needs to directly develop the control-oriented programming according to the node module and the file of the single chip microcomputer or the data in the Flash EPROM, and does not need to care about setting working parameters of a WIFI connection computer or a mobile phone. The node module can automatically select to enter a WIFI transparent transmission communication program or directly aim at a controlled application program (completely not related to the network and the design of a working parameter interface set by a computer or a mobile phone) when the node module is reset according to the file of the node module and a singlechip or the data state in a Flash EPROM (according to the claim 4), wherein the programming of the working parameter interface set by the network communication and the computer or the mobile phone is one-time and universal as much as possible, so that only 1 to 2 persons familiar with HTML-JS programmers or professional companies do so can finish the programming, the development of the singlechip can develop a plurality of products according to different electric appliances and positioning grades, and the singlechip is respectively programmed, for example, a set of mobile phone operation interfaces with timing firepower setting is designed, and the singlechip can be also used for an electric cooker, a health preserving oven, an electromagnetic oven, an electric ceramic oven and the like, even if the products have different names and the best mobile phone operation interfaces have corresponding matching, the method is just suitable for local operation of the HTML-JS script language emphasized by the invention, can be edited by a notebook, is very convenient for changing a plurality of names, and can directly operate locally to see results).
For the end user: the computer or the mobile phone is connected with the setting before use through wireless WIFI, and the computer or the mobile phone is visually operated with dynamic prompt. When the work parameter is needed after the work parameter is set, the work is started by electrifying or pressing a reset key, and the work can be selected by pressing a key and a plurality of LED indicator lamps at the moment without any relation with a computer or a mobile phone. And then, the user needs to enter the WIFI connection computer or mobile phone again, and can enter the WIFI connection computer or mobile phone by pressing a certain key or double-clicking or long-pressing, or simultaneously pressing two keys, or pressing a certain key when the power is on.
For example, if the digital alarm clock needs to reset the date and time when the battery is replaced, and the electric cooker needs to reset the time when the time is cut off or the time is long, the time setting operation of the digital alarm clock and the time setting operation are easy to forget, because only 3-4 keys are arranged on a panel and are realized by various short-press and long-press combinations, many people are afraid of doing the digital alarm clock, especially the old people, even if the time is good, the date and time is not easy to adjust, it is not clear whether the current time is the current time or the alarm clock or the start-stop time, and a mistake is made all over! And all the operations are convenient and intuitive when the computer or the mobile phone is used, and the operations can be carried out only by modifying when the computer or the mobile phone is mistaken. Particularly, the HTML-JS language emphasized by the invention is provided with a date and time control, so that the design of a computer or mobile phone interface becomes very simple. On the other hand, when the LED lamp is used, a computer or a mobile phone does not need to be connected, only a start-stop key or a power switch is simply pressed, and the LED lamp can be seen in the working state. The intelligent household computer is also suitable for the old at home, the old can press a start-stop key or a power switch at ordinary times, and the intelligent household computer is set by a computer or a mobile phone for women when complex requirements exist. And the household appliance in the mode has low production cost, and is simple and reliable.
This section also presents a typical practical example of the present invention.
The whole text content is more, can summarize and be: by fully exploring the potential application characteristics of the cloud Internet of things MQTT and the Nodemcu, a mobile terminal (mobile phone or computer) Html-JS program localization operation mode based on the full-range byte transparent transmission as the network communication is established. In the mode, the cloud Internet of things MQTT is provided, a direct WeChat sending function is supplemented, and a locally executed Internet of things Html-JS general program is provided, so that the programming amount of a user is reduced, low-level repetition is avoided, and a programming example is provided for the user.
Because the localized operation mode of the Html-JS program at the mobile terminal based on the byte transparent transmission in the whole range is particularly suitable for being combined with a singlechip, and MQTT (especially a rule engine which is most afraid of beginners) is not needed in a local area network, a UDP communication form of the local area network in the mode and a matched program structure are provided.
Note also that the node mcus LUA general program in the node module is usually large in program amount, and can be put into a Flash ROM for LFS operation, so that not only can a large program be operated, but also less RAM is occupied (see Nodemcu.
Before adding the function of sending the WeChat to the Tencent cloud Internet of things MQTT, the mobile phone can temporarily use a third party to send the WeChat website when in standby and giving an alarm in real time, see (8.3).
In order to express intuition, the 'Tencent cloud Internet of things MQTT' is always used, and the similar mainstream Internet cloud services also comprise: arrhizus, hua are clouds, OneNet, etc., none of which is a standard MQTT, but is an MQTT (herein called device login MQTT) that defines the Topic augmentation rules engine, i.e. for MQTT, the strain flux is:
a yard login is swept to Aliyun is with paying precious APP or nailing APP, and it is the nailing crowd to receive the crowd, sends out what nail information.
Hua is cloud code scanning and is used for logging in Hua is a mobile phone browser, the receiving crowd is Hua is a mobile phone address book, and the sending crowd is Hua is cloud information.

Claims (9)

1. An Internet of things byte transparent transmission method based on H5JS local programming is realized on an Internet of things structure, and a program is locally run on an Html-JS (Java native markup language) on a mobile phone or a computer, and the Internet of things byte transparent transmission method comprises the following steps:
(1) for an internet wide area network, constructing an internet of things structure, the internet of things structure comprising: the system comprises an Tencent cloud Internet of things MQTT server, a node module, a mobile phone end and/or a computer end, wherein the node module and the mobile phone and/or the computer end are connected with the MQTT server to realize bidirectional communication from the mobile phone or the computer to the node module;
(2) selecting an ESP-12 series node module, selecting Nodemcu firmware, and connecting the Nodemcu firmware with the MQTT server through an MQTT module in the Nodemcu firmware;
(3) the MQTT service at the back end of the network does not need to be programmed by a user, and the work flow of the user does not need to be adjusted and the program of the user does not need to be changed; when a new product of the Tencent cloud Internet of things MQTT is built, a default JSON data format is changed into a custom data format, a binary word throttling data transmission mode is selected through LUA language programming of a node module and JS language programming of a mobile phone or a computer end, the byte per byte in a data transmission packet is in a full range of 0-255, and network communication between the mobile phone or the computer end and the node module end through the MQTT is direct byte transmission without encoding/decoding in two directions, namely full-range byte transparent transmission for short;
(3.1) defining a control command based on full-range byte transparent transmission, wherein full-range byte file transmission from a mobile phone or a computer end to a node module end is included;
(3.2) according to the full-range byte transparent transmission, transmitting all data processing except the direct IO device driving in the node module to a mobile phone or a computer for processing through the bidirectional full-range byte transparent transmission;
(4) controlling n users at a mobile phone or computer end to control the operation authority of the m node modules by setting a rule engine of the Tencent cloud Internet of things MQTT;
(5) the computer end is provided with a browser, and the browser locally runs HTML-JS script language; the local operation HTML-JS script language of the mobile phone end converts the HTML-JS program into the operation of the mobile phone App through the HBuilderX; the connection between the mobile phone or the computer and the MQTT server is realized through JS plus a plug-in mqtt.js;
(5.1) uniformly programming programs except for presenting the personalized requirements of the user by a professional company, and designing the following general programs which can be executed independently, wherein the general programs are taken as programming demonstration:
mqtt connection. htm: generating UserName and Password according to the ProductID, the equipment name and the Hmac signature algorithm, and generating login parameters and connection detection of the Tencent cloud Internet of things MQTT equipment at a computer terminal;
mqtt communication. htm: a plurality of computers run simultaneously to test data or Chinese character mutual transmission among MQTT login equipment;
lua: the node module is connected with WIFI;
get _ mqtt.htm, get _ mqtt.lua: the computer end sets MQTT equipment login parameters of the node module through HTTP and tests whether the MQTT connection of the node module is successful or not;
init. lua: the node module automatically starts a program after being reset;
tencent mqtt. lua: the node module working program is matched with user demonstration programs mqtt _ wx.htm and mqtt _ wx.apk;
http. htm: the computer terminal automatically sends out a WeChat notification test;
simple push http. The node module automatically sends out a WeChat notification test;
providing a demonstration program for a user to realize a personalized operation display interface or a management process:
html _ wtt _ wx.htm: and (3) operating, controlling, testing and demonstrating programs of the MQTT internet of things of the Tencent cloud at the computer terminal.
mqtt _ wx.apk: and (5) operating, controlling, testing and demonstrating the program of the MQTT internet of things in the Tencent cloud at the mobile phone terminal.
Lua: a user self-defining program in the node module mainly writes a user self-defining global function usrdfn ();
(6) the initialization setting is carried out before the node module works normally, and the method comprises the following steps:
(6.1) power-on or reset, LED pilot lamp of node module slowly flashes, searches for WIFI during slowly flashing, slowly flashes and can reach a period of time, and the user uses the WIFI of computer connection node module AP this moment:
a NodeMCU _6 bit random number is accessed 192.168.4.1 by a browser, wherein the searched WIFI is listed, a user selects the WIFI on the user's own capability, inputs a password and resets and restarts;
(6.2) after the node module is restarted, the LED indicator light of the node module flashes slowly for several seconds, the LED indicator light becomes bright to indicate that WIFI connection is successful, and MQTT is not connected, at the moment, the node module automatically enters a get _ mqtt.lua equipment login parameter setting program, a user computer sets back the WIFI on the node module, double-clicks the get _ mqtt.htm program in the computer, enters equipment parameters and user name/Password setting of the Tencent cloud Internet of things MQTT login, the equipment parameters ProductID, equipment name and DeviceScaret are filled item by item according to the equipment parameters ProductID, equipment name and DeviceScaret set in the Tencent cloud Internet of things MQTT, and the get _ mqtt.htm program automatically generates UserName and Passsword and tests whether MQTT connection login of the node module is successful or not; if the MQTT connection is successful, clicking for reservation, automatically writing the equipment login parameters ProductID, equipment name, UserName and Password which are successfully connected with the MQTT into an MQTT. If the situation is always unsuccessful, the user can double-click to start MQTT connection in the computer, the htm program and the get _ MQTT. htm program have the same setting interface of the logging parameters of the flight communication cloud Internet of things MQTT device, the computer browser is directly connected with the flight communication cloud Internet of things MQTT, and the connectivity of the logging parameters of the MQTT device is checked;
(6.3) once the MQTT connection login of the node module is successful, generating an mqtt.txt file, and then automatically entering a flight message mqtt.lua MQTT response program when the node module is powered on or reset and restarted, so as to realize the measurement and control work of the node module of the Internet of things, wherein an LED indicator lamp flashes slowly and then flashes and finally is not lighted, which indicates that the MQTT connection is successful;
(7) in the Tencent cloud Internet of things MQTT protocol, the MQTT is supplemented with the functions of sending WeChat and alarming, and the function of supplementing MQTT and sending WeChat specifically operates as follows: by adding a designated Topic, issuing information publish (Topic, msg) to the Topic, namely sending the information msg to a WeChat, wherein the receiving population of WeChat sending is determined by any one setting operation of the following 3 types:
(7.1) the Tencent cloud service manages a mobile phone WeChat APP of a login account, the mobile phone WeChat APP can scan codes to log in Tencent cloud service and can send WeChat, then a micro signal of the cloud service management login account is a receiver sent by the WeChat, and Topic is product ID/device name/WX 1;
(7.2) entering a work setting page of MQTT after the cloud service management account logs in, inputting a WeChat ID number or a group name of a WeChat sending and receiving person, wherein the input personal or group name is a person or group to which all WeChats in the WeChat address book of the cloud service management login account can be sent, and Topic is product ID/equipment name/WX 2;
(7.3) the cloud service management account logs in and then enters a work setting page of the MQTT, all individuals to which the WeChat can be sent in a WeChat address book of the cloud service management login account can be managed, a mobile phone WeChat APP can be used for scanning the two-dimensional code in the work setting page of the MQTT, a person passing verification is the individual to which the WeChat can be sent, and Topic is product ID/device name/WX 2;
when the MQTT sends out the WeChat receiving crowd Topic which is the product ID/the equipment name/WX 2, the crowd indicates a plurality of crowds, and the Topic can be subdivided into Topic which is the product ID/the equipment name/WX 2/a user I; topic ═ product ID/device name/WX 2/user two;
(7.4) when the mpic of the MQTT sending WeChat is product ID/device name/WXA 1, WXA2, not only sending WeChat, but also alarm, like WeChat [ voice call ] alarm call before connection.
2. The method of claim 1, further comprising:
in the local area network, based on the two-way transparent transmission communication of local operation of a mobile phone or a computer Html-JS:
(8) in the local area network, the two-way transparent communication between the mobile phone or the computer and the node module adopts a UDP network protocol without a back-end service, and because the computer browser does not support UDP, a WS service is locally added to the computer to convert into UDP, and the conversion from WS service to UDP is finished by limiting an exe program which does not need to be installed;
(8.1) the mobile phone end introduces java.net in the project of H5+ APP of HBuilderx, supports for UDP are included, UDP communication is achieved through Html5+ JS programming, the HBuilderx generates a mobile phone APP program, and the WS service is not required to be converted into UDP;
(8.2) the broadcasting mode is realized by utilizing UDP, the problem that WIFI connection (DHCP) IP is not fixed is solved, the naming communication of the local area network multi-node module is realized, and the whole system is simplified to 4 programs:
WS services to udp. exe: a computer program, wherein the WebSocket protocol WS service is converted into a UDP protocol, and the computer program is started firstly and runs all the time;
name program htm: the computer browser Html5-JS locally runs and connects with the WS service program, each node module shuts off other node modules when running, only the node module with the currently set name is online, the name is input in a name program interface, and the computer can record the unique number of the node module and the input name in the local storage of the computer; WIFI and passwords can be set;
test program htm: when the computer browser Html5-JS operates locally and is connected with the WS service program, the computer can test and confirm the bidirectional data communication on each node module by naming when a plurality of node modules operate on line simultaneously, and the LED indicator light of the node modules is observed to indicate whether the state is normal or not; meanwhile, the method is also a programming demonstration program provided for a user, and a computer browser accesses WS service through a WebSocket protocol; if only one node module is needed, the naming process is not needed, and the router can be directly connected, namely the AP of the WIFI direct-connected node module of the computer;
node module, lua: the node module end is matched with a program, and the running of each HTML-JS program, including the mobile phone APP, the WIFI setting and the password, is executed by the LUA program through receiving and sending UDP data interpretation; UDP data transmission and reception of the LUA program is a net operation of a net module in the nodemcu firmware;
for the mobile phone, the naming program, htm and the test program, htm, are changed into the naming program, apk and the test program, apk, the operation mode is not changed, and the WS service is not required to be converted into the UDP.exe computer program;
(8.3) the node module alarms in real time to send the WeChat and sends the WeChat through a third party WeChat sending website, specifically, when the Nodemcu sends the HTTP GET and downloads through Nodemcu firmware, the HTTP module is selected, and the LUA program is sent by HTTP.
3. The method of claim 1 or 2, further comprising:
(9) the full-range byte transparent transmission has the following uniform transceiving forms:
(9.1) JS MQTT receiving and sending at the mobile phone or the computer end:
an MQTT object, onmessageassociated, function, topic, destinationName; payloadBytes }
Transmitting an object, new path.mqtt.message (data);
destination name ═ topic
MQTT object Send (Send object) or MQTT object publishing (topic, data, 1);
(9.2) node module end LUA MQTT transceiving:
MQTT object on (message, function (MQTT object, topic, data) end)
MQTT object publish (topic, data, 1);
(9.3) sending and receiving by a JS local area network WS at a computer end:
WS object new WebSocket (WS:// 127.0.0.1: 8183')
WS object, open () { network attached notification }
WS object, function (ev) { received data, new Uint8Array (ev
Send (send data);
(9.4) UDP sending and receiving of JS local area network at the mobile phone end:
UDP Transmit-receive object new Datagramtoken (native port)
New datagrampack (send data, send data length, addr. getbyname (counterpart IP), counterpart port)
UDP Transmit-receive object send
Received packet is new datagrampack (abf, abf
UDP Transmit-receive object, receive (received data packet)
getData (); getLength (); the opposite port receives the data packet, getPort (); get address () when the other party IP receives the packet;
(9.5) node module end LUA local area network UDP transceiving:
UDP connection object on (reception, opposite side port, opposite side IP) end)
The UDP connection object send (opposite side port, opposite side IP, send data).
4. The method of claim 1, further comprising the step of resolving the problem of insufficient running memory RAM of the node ESP-12 node module nodemmcu firmware, the step comprising:
(10) splitting a LUA big program in a node Module into small programs to run independently one by one, recording the working state through an RTC User Memory Module or a Flash file, after automatic resetting and restarting, determining to enter a corresponding small program to run independently according to the working state recorded by the RTC User Memory Module or the Flash file, and resetting and restarting the process again after the running is finished.
5. The method of claim 1, 2, 3, or 4, further comprising:
(11) and (3) performing high-speed sampling by using a domestic macro-crystal STC15W408AS series single chip microcomputer with high priority timed interruption, intensively transmitting the data to the node module with low priority when the sampled data are accumulated to a certain amount, and after the node module receives the data, forwarding the intensively transmitted sampled data to a computer or a mobile phone according to the local area network UDP or Internet MQTT communication mode (9).
6. A method as claimed in claim 2, 3, 4 or 5, capable of establishing a mode in which the setup of the operating parameters of the singlechip is separated from the operation, characterized by further comprising:
(12) the node module and the single chip microcomputer control system can separate the part of the wireless WIFI connected with a computer or a mobile phone from the application controlled by the specific single chip microcomputer, and can be separately carried out in secondary development and the use of an end user;
for the development process: only 1-2 HTML-JS programmers or professional companies which are familiar with the claims 2 and 3 are needed to set the relevant working parameters, so that the working parameters are set on a computer or a mobile phone to realize visual dynamic operation prompt, and the set parameter data are stored in the node module and the file of the singlechip or a Flash EPROM; a singlechip developer who is not familiar with HTML-JS programming only needs to directly develop control-oriented programming according to the node module and the file of the singlechip or the data in a Flash EPROM without concerning WIFI to connect a computer or a mobile phone to set working parameters; the node module runs an application program which can automatically select to enter a WIFI transparent transmission communication program or directly aim at control when the node module is reset according to the data state in the files of the node module and the singlechip or a Flash EPROM according to the method of claim 4;
for the end user: the computer or the mobile phone is connected with the setting before use through wireless WIFI, and the computer or the mobile phone is visually operated with dynamic prompt; when the work parameter is needed after being set, the work is started by electrifying or pressing a reset key, and the work can be selected by pressing a key and a plurality of LED indicator lamps without being related to a computer or a mobile phone; and then, the WIFI is required to be re-connected with a computer or a mobile phone for setting, and a common entering mode is adopted when a certain key is pressed, or double-click or long-press is carried out, or two keys are simultaneously pressed, or a certain key is pressed when power is on.
7. A method according to claim 1, 2 or 3, characterized in that the LFS can be run in Flash ROM in respect of the nodemmcu LUA program in the node module.
8. The method according to claim 1, characterized in that the mobile phone is standby for real-time alarm before Tencent cloud Internet of things MQTT is added with the function of sending WeChat, and a third party sending WeChat website can be temporarily used for sending WeChat according to the standby state (8.3).
9. The method according to claim 1, wherein the Tencent cloud IOT MQTT is replaced by an IOT MQTT of the Ali cloud, Hua cloud or OneNet.
CN202111098910.4A 2021-09-18 2021-09-18 Internet of things byte transparent transmission method based on H5JS local programming Pending CN113824783A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111098910.4A CN113824783A (en) 2021-09-18 2021-09-18 Internet of things byte transparent transmission method based on H5JS local programming

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111098910.4A CN113824783A (en) 2021-09-18 2021-09-18 Internet of things byte transparent transmission method based on H5JS local programming

Publications (1)

Publication Number Publication Date
CN113824783A true CN113824783A (en) 2021-12-21

Family

ID=78914908

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111098910.4A Pending CN113824783A (en) 2021-09-18 2021-09-18 Internet of things byte transparent transmission method based on H5JS local programming

Country Status (1)

Country Link
CN (1) CN113824783A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114500036A (en) * 2022-01-24 2022-05-13 华润电力技术研究院有限公司 Method, device and medium for transmitting data
CN116431122A (en) * 2023-03-07 2023-07-14 中电金信软件有限公司 Compiling method, displaying method and device for development effect and readable storage medium
CN117499736A (en) * 2023-12-29 2024-02-02 杭州阿启视科技有限公司 Method for playing front-end camera video by web browser plug-in based on windows operating system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114500036A (en) * 2022-01-24 2022-05-13 华润电力技术研究院有限公司 Method, device and medium for transmitting data
CN116431122A (en) * 2023-03-07 2023-07-14 中电金信软件有限公司 Compiling method, displaying method and device for development effect and readable storage medium
CN116431122B (en) * 2023-03-07 2024-05-07 中电金信软件有限公司 Compiling method and device for development effect and readable storage medium
CN117499736A (en) * 2023-12-29 2024-02-02 杭州阿启视科技有限公司 Method for playing front-end camera video by web browser plug-in based on windows operating system
CN117499736B (en) * 2023-12-29 2024-04-19 杭州阿启视科技有限公司 Method for playing front-end camera video by web browser plug-in based on windows operating system

Similar Documents

Publication Publication Date Title
CN113824783A (en) Internet of things byte transparent transmission method based on H5JS local programming
Alaya et al. Toward semantic interoperability in oneM2M architecture
US6680730B1 (en) Remote control of apparatus using computer networks
US20180262391A1 (en) System and method for developing run time self-modifying interaction solution through configuration
Anwaarullah et al. RTOS based home automation system using Android
EP3011443A1 (en) Method and apparatus for code virtualization and remote process call generation
Kubitza et al. Towards a toolkit for the rapid creation of smart environments
US20180129519A1 (en) Method and system for emulating application running in secondary device on primary device
Mynzhasova et al. Drivers, standards and platforms for the IoT: Towards a digital VICINITY
CN106850418A (en) A kind of gateway of intelligent home network
Shi et al. Construction of industrial internet of things based on mqtt and opc ua protocols
Kurniawan Arduino Programming with. NET and Sketch
Chen Research on Application System of Remote-Control Computer of Android Mobile Phone
Gaglio et al. Interoperable real-time symbolic programming for smart environments
Wan et al. Lightweight and universal intelligent service platform in indoor environment
CN105550571A (en) Method for managing screen-less network lock
Yunge et al. Hybrid apps: Apps for the internet of things
Otuoze et al. Implementation of a cloud-based home automation system
Soto-Ortiz et al. Development of a DAPP (decentralized application) on Rinkeby Network for the registration of Sensors of an Internet of Things (IoT) Environment
Jensen Architectural Design and Implementation of a Visualization and Control-Interface for BabbleSim
Koirala Evaluating BLE mesh technology for lighting control
Dunkels et al. Contiki Programming Course: Hands-On Session Notes
Ruiz et al. Evaluation of cloud platforms for managing IoT devices
Xiao et al. A Weibo APP Design Based on Eclipse and Android Platforms
Rădescu et al. Intelligent Monitoring of Vital Parameters in Wireless Applications: Android Solution for Pulse and Body Temperature

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination