These codes have been collected from another repository in order to improve its use, so that the only script that is handled as a loraría.py bookstore will be improved over time. Reference: https://github.com/lemariva/upylora
In the repository you can find:
Codes: Contains all scripts used to use the SX1276 chip
Conf_lora.py
controller.py
Controller_esp32.py
ESP32Lora.bin
SX127X.py
Lora.py
Of which in which we concentrate is that of Lora.py which has the class with its methods, facilitating the use of the chip. In this case, it has been specified that the frequency used is 915 MHz, configured in the sx127x.py file, in case a different frequency is desired, it is necessary that it be changed in the script and then return has to form the .bin or just enter the necessary scripts in the ESP.
Examples: It contains examples on how class should be used, to send and receive data, in addition to the upload of data to a web service such as Ubidots.
Mainly this file has been created to instantly specified as LORA, which will have all the necessary methods to send and receive code. The pins that are used for communication with the Lora chip are the same specified in the Heltec and TTGO documentation which make development plates with the ESP32 microcontroller by adding a SX127X chip with antenna. Then you will find how to use the bookstore with your methods:
The script contains Lora which is a class to initialize the use of the SX127X chip. It can be initialized as follows:
from lora import LoRa
lora = LoRa ()
#si se desea un filtrado de los mensajes
lora = LoRa ( header = 'header' )In addition to the reception of periodic data which is handled with the wait_msg () method, a period can be specified, so that after a message has arrived, specify how long you want to pass until you receive a new one, as follows:
#sin header
lora = LoRa ( period = 2 )
#con header
lora = LoRa ( header = 'header' , period = 2 )It is the specified method to send data, so that the first parameter is to specify that data is wanted to be sent and the second in case you want to send with a specific header.
#sin header especifico
lora . send ( 'hola' )
#con header especifico
lora . send ( 'hola' , spheader = 'headersp' )The variables of a specific header has been added in case it is necessary to send a message with a different or specific header.
Like an object of MQTT for a subscribe, we use the same concept for callbacks, so that once the object of Lora is established, it is specified that function is wanted to be executed when a message arrives:
#cb corresponde al nombre de la funcion usada como callback
#que debe tener como parametro una variable que sera el mensaje
lora . set_callback ( cb ) lora . wait_msg ()Once our callback is already specified, Wait_MSG is responsible for the incoming messages and that our callback is executed in the background. In the event that when instantizing the Lora class, a value for the period variable is specified, once a message is received, the time specified will be to pass (in seconds) so that another message is accepted.
lora . receive_msg ()Similar to wait_msg () is responsible for receiving a message at a specific time, only once and callback is executed when the message arrives.
UPYLORA by Steven Silva Is Licensed Under A Creative Commons Recognition-Compartyrigual 4.0 International License.
Created from the work at https://github.com/lemariva/upylora.