lora - lora Drive module#

Adapted Air780E/Air700E Air780EP Air601 Air101/Air103 Air105 ESP32C3 ESP32S3

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Tip

This library has its own demo,click this link to view lora’s demo example

Constant#

constant

type

explanation

lora.SLEEP

number

SLEEP Mode

lora.STANDBY

number

STANDBY Mode

lora.init(ic, loraconfig,spiconfig)#

lora Initialization

Parameters

Incoming Value Type

Explanation

string

lora Model, currently supported:
llcc68
sx1268

table

lora Configuration parameters, device-specific

Return Value

None

Examples

lora.init("llcc68",
    {
        id = 0,           -- SPI id
        cs = pin.PB04,    -- SPI If there is no pin library, just fill in the GPIO number for the selected GPIO number.
        res = pin.PB00,   -- The GPIO number connected to the reset pin. If there is no pin library, just fill in the GPIO number.
        busy = pin.PB01,  -- Busy detecting the GPIO number of the foot
        dio1 = pin.PB06,  -- Data input interrupt pin
        lora_init = true  -- Whether to send an initialization command. If it is read directly after waking up, pass false
    }
)

lora.set_channel(freq)#

Set channel frequency

Parameters

Incoming Value Type

Explanation

number

Frequency

Return Value

None

Examples

lora.set_channel(433000000)

lora.set_txconfig(ic, txconfig)#

lora Configure Send Parameters

Parameters

Incoming Value Type

Explanation

string

lora Model, currently supported:
llcc68
sx1268

table

lora Send configuration parameters, device-specific

Return Value

None

Examples

lora.set_txconfig("llcc68",
    {
        mode=1,
        power=22,
        fdev=0,
        bandwidth=0,
        datarate=9,
        coderate=4,
        preambleLen=8,
        fixLen=false,
        crcOn=true,
        freqHopOn=0,
        hopPeriod=0,
        iqInverted=false,
        timeout=3000
    }
)

lora.set_rxconfig(ic, set_rxconfig)#

lora Configure Receive Parameters

Parameters

Incoming Value Type

Explanation

string

lora Model, currently supported:
llcc68
sx1268

table

lora Receive configuration parameters, which are device-specific

Return Value

None

Examples

lora.set_rxconfig("llcc68",
    {
        mode=1,
        bandwidth=0,
        datarate=9,
        coderate=4,
        bandwidthAfc=0,
        preambleLen=8,
        symbTimeout=0,
        fixLen=false,
        payloadLen=0,
        crcOn=true,
        freqHopOn=0,
        hopPeriod=0,
        iqInverted=false,
        rxContinuous=false
    }
)

lora.send(data)#

Send data

Parameters

Incoming Value Type

Explanation

string

Data written

Return Value

None

Examples

lora.send("PING")

lora.recv(timeout)#

Open data collection

Parameters

Incoming Value Type

Explanation

number

Timeout, default 1000 unit ms

Return Value

None

Examples

sys.subscribe("LORA_RX_DONE", function(data, size)
    log.info("LORA_RX_DONE: ", data, size)
    lora.send("PING")
end)
-- The old version does not have recv, which can be changed lora.recive
lora.recv(1000)

lora.mode(mode)#

Set the entry mode (sleep, normal, etc.)

Parameters

Incoming Value Type

Explanation

number

Mode Normal Mode: lora.STANDBY Sleep Mode: lora.SLEEP Default to Normal Mode

Return Value

None

Examples

lora.mode(lora.STANDBY)