repeat message down a chain, adding to the payload at each repeating device
radio chip selection
Radio chip driver is not included, because options are available.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.
network architecture
UNIT 0x00
transmitting only device: mandatory.UNIT 0x01
: repeating device- Uni-directional network: Each unit can only receive message from
UNIT_ID - 1
(previous unit) UINT n
receiving only deviceLAST_UNIT
: mandatory; prints payload onto UART.
configuration
Each device in the network is uniquely identified by:
UNIT_ID
: ID byte designating address of this device.UNIT_LAST
: If defined, this device prints payload onto serial port instead of re-transmitting payload.
All devices in network must be configured identically with the following:
TX_INTERVAL_US
: how often to take measurement and send toUNIT_ID+1
(time of complete cycle).MAX_TX_LENGTH
: Maximum size of payload, in bytes. Payload is sent in fragments when exceeds this value; aka size of each fragment.TXRX_PADDING_US
: Time allotted for RX-TX turnaround and CPU overheadMAX_TX_ATTEMPTS
: Count of transmit retries permittedSPREADING_FACTOR
LoRa configuration of datarateCF_MHZ
: Operating radio frequency
Duration of retry interval is auto-calculated from LoRa modem configuration (bandwidth/sf) and MAX_TX_LENGTH
.
Take care that TX_INTERVAL_US
value is appropriate relative to total retry interval (interval * MAX_TX_ATTEMPTS
)
Diff: main.cpp
- Revision:
- 3:a78a70af3403
- Parent:
- 2:534be88a25dc
- Child:
- 4:f272bf72893a
diff -r 534be88a25dc -r a78a70af3403 main.cpp --- a/main.cpp Mon Jul 16 11:20:20 2018 -0700 +++ b/main.cpp Sun Nov 25 17:13:06 2018 -0800 @@ -1,6 +1,6 @@ #include "radio.h" -#define UNIT_ID 0x03 /* 0x00: first unit */ +#define UNIT_ID 0x00 /* 0x00: first unit */ //#define UNIT_LAST // test large sample, large pkt size #define N_SMP 10 @@ -43,6 +43,7 @@ unsigned rxStartup_us = RX_STARTUP_US; RawSerial pc(USBTX, USBRX); +DigitalIn button(USER_BUTTON); #ifdef TARGET_DISCO_L072CZ_LRWAN1 AnalogIn ain(A0); @@ -672,7 +673,14 @@ Radio::LoRaPacketConfig(8, false, true, false); // preambleLen, fixLen, crcOn, invIQ Radio::SetChannel(CF_MHZ * 1000000); - Radio::set_tx_dbm(TX_DBM); + printf("user_button:%u\r\n", button.read()); + if (button.read()) { + Radio::set_tx_dbm(TX_DBM); + printf("PA to %ddBm\r\n", TX_DBM); + } else { + Radio::set_tx_dbm(PA_OFF_DBM); + printf("PA off\r\n"); + } /* max TX length + turnaround + ACK length */ retryInterval_us = Radio::lora_toa_us(MAX_TX_LENGTH) + TXRX_PADDING_US + Radio::lora_toa_us(1);