The content of the invention
In order to solve the problems of the prior art, the invention provides a kind of usb expansion device based on Lora technologies andMethod.
The invention provides a kind of usb expansion device based on Lora technologies, including Lora transceivers and microcontroller, instituteStating microcontroller includes interrupt control unit, SPI interface and the USB interface being connected with smart machine, the Lora transceivers differenceIt is connected with the interrupt control unit, SPI interface.
Present invention also offers a kind of usb expansion method based on Lora technologies, comprise the following steps:S1, LoRa extendDevice is enumerated;
S2, smart machine are initialized to LoRa expanders;
LoRa transceivers are operated pattern switching in S3, LoRa expander;
S4, pass through LoRa expanders send data;
S5, pass through LoRa expanders receive data.
As a further improvement on the present invention, step S1 includes following sub-step:
S11, detection insertion USB device, use VBUS power supply to the device;
S12, USB device initialization;
S13, smart machine read the device descriptor and interface descriptor of USB device;
S14, judge whether USB device base class is wireless controller, be wireless controller, then carry out next step, be notWireless controller, then operated using other agreements;
S15, judge whether USB device subclass is LoRa wireless controllers, be LoRa wireless controllers, then carry out next stepSuddenly, it is not LoRa wireless controllers, then is operated using other agreements;
S16, judge whether USB device protocol type is LoRa expander agreements, be LoRa expander agreements, then under carrying outOne step, is not LoRa expander agreements, is then operated using other agreements.
As a further improvement on the present invention, step S2 includes following sub-step:
S21, enumerate success;
S22, (it is referred to hereinafter as by the end points of a configuration end points (hereinafter referred to as " terminal A ") and a reading configuration resultMake " terminal B ") obtain transceiver model and technical indicator;
S23, the role for resetting LoRa expanders;
S24, LoRa expander role are set;
S25, LoRa expander functional attributes are set;
S26, LoRa expanders are made to enter working condition;
S27, LoRa expander are initialized successfully.
As a further improvement on the present invention, step S3 includes Sleep patterns, Stdby patterns, Tx patterns and Rx patterns,Wherein, Sleep pattern switchings are Stdby patterns, and Stdby pattern switchings are Tx patterns or Rx patterns, and Tx pattern switchings areSleep patterns, Rx pattern switchings are Sleep patterns.
As a further improvement on the present invention, step S4 includes following sub-step:
S41, one write to LoRa transceivers and send the end points (hereinafter referred to as " end points C ") of data and receive data from intelligenceThe data of energy equipment;
S42, judge whether data format is correct, data format correctly then carries out next step, and data formatting error is then led toCross one read the end points of data that LoRa transceivers receive be hereinafter referred to as " end points D ") returned data format error;
S43, data are added into transmit queue;
S44, take turns to this data transmission;
S45, wait are in transmittable state;
S46, random selection channel;
S47, wait duty cycle terminate;
S48, from Sleep pattern switchings to Stdby patterns;
S49, into Tx patterns, write-in LoRa transceivers FIFO;
S410, wait are sent completely interruption;
S411, closing, which are sent, to be interrupted;
S412, opening receive timer;
S413, into park mode;
S414, by end points D return send successfully.
As a further improvement on the present invention, step S5 includes following sub-step:
S51, reception timer expiry;
S52, from Sleep pattern switchings to Stdby patterns;
S53, it is switched to Rx patterns, enables to receive and interrupt, enable and receive overtime timer;
S54, judge receive whether time-out, if not overtime, carry out next step, if it times out, close receive inIt is disconnected, into Sleep patterns, returned by end points D and receive time-out;
S55, triggering, which are received, to be interrupted;
S56, closing, which are received, to be interrupted;
S57, closing receive overtime timer;
S58, into Sleep patterns;
S59, the data received are issued by smart machine by end points D.
The beneficial effects of the invention are as follows:The existing smart machine with USB interface can be made to be transformed into LoRaWAN'sThe equipment of node, gateway or gateway server one, allows it to turn into a LoRaWAN part, realizes smart machine to itThe data acquisition or control of his LoRa nodes, or smart machine is collected or is controlled, and makes LoRa application scenarios richerIt is rich.
Embodiment
The invention will be further described for explanation and embodiment below in conjunction with the accompanying drawings.
As shown in Figures 1 to 6, a kind of usb expansion device based on Lora technologies, including Lora transceivers 100 and micro-controlDevice processed, the microcontroller includes interrupt control unit 200, SPI interface 300 and the USB interface 400 being connected with smart machine, instituteLora transceivers 100 are stated to be connected with the interrupt control unit 200, SPI interface 300 respectively.
The present invention can turn the existing smart machine with USB interface by the way of Lora video modules add USBIt is turned into the equipment of LoRaWAN node, gateway or gateway server one, it is turned into a LoRaWAN part, it is realExisting data acquisition or control of the smart machine to other LoRa nodes, or smart machine is collected or is controlled, and makes LoRa'sApplication scenarios more enrich.
Referred to as " LoRa expanders ", the smart machine for possessing USB interface referred to as " is intelligently set LoRa usb expansion equipmentIt is standby ".LoRa radio transceiver modules referred to as " LoRa transceivers 100 ".The existing smart machine for possessing USB interface refers to intelligent handMachine, PC, intelligent router, intelligent network set top box etc..
Here USB interface refers to USB A types mouthful, USB Type Bs mouthful, USB c-types mouthful, USB Micro mouth, the mini mouths of USB etc.The physical interface of all support usb protocols.
LoRa expanders are connected with smart machine by USB interface 400.
Wherein smart machine is as USB Host (usb host), and LoRa expanders are used as USB Device (USB device).Both sides are communicated by the agreement of the present invention.
The mode of operation of original LoRa transceivers is encapsulated and abstracted by LoRa expanders, it is contemplated that USB dataTransmission delay is not appropriate for allowing the registers of the direct single operation LoRa transceivers of smart machine more than Millisecond, soLoRa expanders itself realize the several types (Class A, Class B, Class C etc.) of LoRaWAN terminal devices, andThe agreement of LoRaWAN gateways.Smart machine can by role to LoRa expanders (including LoRaWAN terminal devices,LoRaWAN gateways make role by oneself, hereinafter referred " role ") select and configure, realize that smart machine accesses LoRaWAN.LoRaWAN application mode is voluntarily realized by smart machine.In view of the flexibility ratio used, LoRa expanders, which are additionally provided, to be made by oneselfThe mode of role, can use the mode of the register of batch configuration LoRa transceivers, to realize proprietary protocol and communication modes.
The hardware block diagram of LoRa expanders is shown in Fig. 1.
LoRa expanders provide 4 is used for transceiving data using the end points for interrupting transmission means, wherein:
1. a configuration end points (hereinafter referred to as " terminal A "), it is an OUT terminal point, for configure LoRaWAN role,Configuration LoRaWAN functional attributes, the register for writing LoRa transceivers in batches;
2. the end points (hereinafter referred to as " terminal B ") of a reading configuration result, it is an IN end points, for obtaining configurationAs a result the return value of the register of LoRa transceivers and is in batches read.
3. one writes the end points (hereinafter referred to as " end points C ") for sending data to LoRa transceivers, it is an OUT terminalPoint, for the data and corresponding length wishing to send to be write to the transmission buffering area of LoRa transceivers, here can be selectiveWrite-in is sent using information such as channel, data transfer rate, transmission powers.
4. an end points for reading the data that LoRa transceivers are received, it is an IN end points, for being received and dispatched from LoRaData are read in the reception buffering of device, here including receiving the length of this data frame, channel, data transfer rate, link margin,The information such as RSSI, signal to noise ratio.
Smart machine can be by reading the models of the LoRa transceivers that LoRa expanders are carried, and basic technology refers toMark.It can further be clear how to apply this LoRa expander.
When smart machine wishes that LoRa expanders are switched to other role from certain role, it can be sent by terminal AReset command, and read the successful information of reset from terminal B.
Present invention also offers a kind of usb expansion method based on Lora technologies, comprise the following steps:
S1, LoRa expander are enumerated;
S2, smart machine are initialized to LoRa expanders;
LoRa transceivers are operated pattern switching in S3, LoRa expander;
S4, pass through LoRa expanders send data;
S5, pass through LoRa expanders receive data.
Step S1 includes following sub-step:
S11, detection insertion USB device, use VBUS power supply to the device;
S12, USB device initialization;
S13, smart machine read the device descriptor and interface descriptor of USB device;
S14, judge whether USB device base class is wireless controller, be wireless controller, then carry out next step, be notWireless controller, then operated using other agreements;
S15, judge whether USB device subclass is LoRa wireless controllers, be LoRa wireless controllers, then carry out next stepSuddenly, it is not LoRa wireless controllers, then is operated using other agreements;
S16, judge whether USB device protocol type is LoRa expander agreements, be LoRa expander agreements, then under carrying outOne step, is not LoRa expander agreements, is then operated using other agreements.
Step S2 includes following sub-step:
S21, enumerate success;
S22, pass through terminal A and terminal B and obtain transceiver model and technical indicator;
S23, the role for resetting LoRa expanders;
S24, LoRa expander role are set;
S25, LoRa expander functional attributes are set;
S26, LoRa expanders are made to enter working condition;
S27, LoRa expander are initialized successfully.
Wherein the functional attributes of LoRa expanders set and included:
1. LNA gains (low-noise amplifier low-noise amplifiers) are set
2. receiving sensitivity is set.
3. set receiver whether to enable automatic replacement (to reset automatically if enabled, when receiver receives saturation or hairIt can be reset automatically during existing data packet collision)
4. whether open AFC (automatic frequency correction automatic frequencies when setting receiver to startCorrection)
5. whether open AGC (Automatic Gain Control automatic growth controls) when setting receiver to start
6. set receiver down trigger condition, it is necessary to which event captured, it is RSSI interruption or detectsHeader.
7. set receiver front end to compensate RSSI offsets.
8. it is the average value sampled by how many times to set RSSI.
9. setting opens or closes detection of preamble
10. set the header for detecting several bytes to start to produce interruption.
11. how many chip mistakes can at most be tolerated by setting the identification of one, header
12. set the calibration for whether receiving resistance-capacitance oscillator to interrupt.
13. set transceiver to export the frequency of clock.
14. whether restart receiver after being arranged on one effective data packets of reception.
15. reversely (being normally 0x55, be reversed 0xaa) whether header is set
16. the generation and detection for enabling synchronization character are set.
17. FIFO fill conditions is set.
18. the length of synchronization character is set.
19. the data of each byte of synchronization character are set.
20. the length for setting packet is fixed or variable.
21. the coded system of packet is set.
22. the calculating and detection for whether enabling CRC are set
23. whether produce interruption when being arranged on CRC check failure
Can be node address filtering and broadcast address filtering 24. whether setting received data packet by filtering.
25. it is that can start how many when to send data to set data in FIFO.
It is that triggering is interrupted when exceeding how many byte data in FIFO 26. setting FIFO interruption thresholding.
Carry out calibrating with quadrature mismatch in the same direction when temperature changes and exceedes how many 27. setting.
28. the mapping interrupted is set.
29. the length of LoRa load is set.
Step S3 includes Sleep patterns, Stdby patterns, Tx patterns and Rx patterns, wherein, Sleep pattern switchings areStdby patterns, Stdby pattern switchings are Tx patterns or Rx patterns, and Tx pattern switchings are Sleep patterns, and Rx pattern switchings areSleep patterns.Include 4 kinds of mode of operations (being shown in Table 1) after LoRa expanders are started working.
| MODE name | English abbreviation | Start the internal module of transceiver | 
| Park mode | Sleep | Nothing | 
| Standby | Stdby | Top adjuster and crystal oscillator | 
| Sending mode | Tx | Frequency synthesizer and receiver | 
| Reception pattern | Rx | Frequency synthesizer and receiver | 
The mode of operation of table 1LoRa transceivers
Step S4 includes following sub-step:
S41, end points C receive data of the data from smart machine;
S42, judge whether data format is correct, data format correctly then carries out next step, and data formatting error is then led toCross end points D returned data format errors;
S43, data are added into transmit queue;
S44, take turns to this data transmission;
S45, wait are in transmittable state;
S46, random selection channel;
S47, wait duty cycle terminate;
S48, from Sleep pattern switchings to Stdby patterns;
S49, into Tx patterns, write-in LoRa transceivers FIFO;
S410, wait are sent completely interruption;
S411, closing, which are sent, to be interrupted;
S412, opening receive timer;
S413, into park mode;
S414, by end points D return send successfully.
If smart machine will send out data to LoRaWAN, operating process is shown in Fig. 5.
Wherein transmission, which advances into Stdby patterns, includes:Loaded length is set, modulating mode is set, transmit power is set, setData transfer rate is put, encoding rate is set, header length is set, sets whether packet length fixes, sets whether enable CRC calculating, settingWhether signal reversion etc. is carried out.
Step S5 includes following sub-step:
S51, reception timer expiry;
S52, from Sleep pattern switchings to Stdby patterns;
S53, it is switched to Rx patterns, enables to receive and interrupt, enable and receive overtime timer;
S54, judge receive whether time-out, if not overtime, carry out next step, if it times out, close receive inIt is disconnected, into Sleep patterns, returned by end points D and receive time-out;
S55, triggering, which are received, to be interrupted;
S56, closing, which are received, to be interrupted;
S57, closing receive overtime timer;
S58, into Sleep patterns;
S59, the data received are issued by smart machine by end points D.
If smart machine will receive LoRaWAN and issue the data of oneself, operating process is shown in Fig. 6.
Stdby patterns include before wherein receiving:Demodulation modes are set, receives frequency is set, receiving data rate is set, setWhether reception encoding rate, setting reception bandwidth, setting enable CRC check, set whether carry out signal reversion, setting reception windowLength, setting receive whether window continuously receives.
Sending and receiving the concrete meaning (application layer protocol) of data can be decided in its sole discretion by application.
A kind of usb expansion device and method based on Lora technologies that the present invention is provided has advantages below:
1st, being combined with popular smart machine can make LoRaWAN be easier popularization.
2nd, LoRa expanders are simpler with manufacturing as its design of accessory.
3rd, LoRa expanders have obvious cost advantage compared with other LoRa equipment.
4th, LoRa expanders can allow waste and old smart machine to be turned waste into wealth, and reduce the waste of entire society and with this bandThe environmental pollution come.
5th, the speed that smart machine especially smart mobile phone soft hardware performance updates is very fast, and substantial amounts of mobile phone app is openedThe promotion of originator, can also make the application quality of this low-power consumption wide area networks of LoRaWAN get a promotion using LoRa expanders, createMore application scenarios and more possibilities.
A kind of usb expansion device and method based on Lora technologies that the present invention is provided, in the family can expand LoRaOpen up the driver that LoRa expanders are contained in device insertion intelligent network set top box, set top box, and LoRaWAN server journeysSequence, makes set top box turn into a LoRaWAN server.All LoRaWAN Control & data acquisition equipment can in familyInterconnect therewith, due to LoRa long transmission distance, garden, vehicle near family can enter this LoRaWAN.Using existingIP network, user can in real time be monitored using smart mobile phone to the data of these equipment.Same scene can be answeredFor units such as school, enterprises.
Above content is to combine specific preferred embodiment further description made for the present invention, it is impossible to assertThe specific implementation of the present invention is confined to these explanations.For general technical staff of the technical field of the invention,On the premise of not departing from present inventive concept, some simple deduction or replace can also be made, should all be considered as belonging to the present invention'sProtection domain.