Hardware Abstraction Layer, permitting any LoRa application to use any LoRa radio chip
Dependents: alarm_slave alarm_master lora_p2p lorawan1v1 ... more
radio chip selection
Radio chip driver is not included, allowing choice of radio device.
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 LR1110, then import LR1110 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.
If you're using Type1SJ select target DISCO_L072CZ_LRWAN1
and import sx126x driver into your program.
Pin assigned to arduino LoRa radio shield form-factor
- SX1272 shield.
- SX1276 shield.
- SX126x kit with color touch screen, or sx126x radio-only shield.
- Exceptions with their own pin assignments: NAMote-72 and Murata discovery board.
- TODO: pin assign XDOT.
Diff: radio_sx128x.cpp
- Revision:
- 7:ba81f66e56d1
- Parent:
- 5:ab124d3842a8
- Child:
- 8:0518c6e68b79
--- a/radio_sx128x.cpp Tue Dec 04 15:22:54 2018 -0800 +++ b/radio_sx128x.cpp Wed Dec 05 15:04:48 2018 -0800 @@ -40,6 +40,7 @@ #ifdef TARGET_FF_MORPHO DigitalOut pc3(PC_3); // debug RX indication, for nucleo boards + #define RX_INDICATION pc3 #endif /* TARGET_FF_MORPHO */ @@ -248,11 +249,11 @@ if (RadioEvents->TxDone_topHalf) { RadioEvents->TxDone_topHalf(); } + } else { +#ifdef RX_INDICATION + RX_INDICATION = 0; +#endif } -#ifdef TARGET_FF_MORPHO - else - pc3 = 0; -#endif /* TARGET_FF_MORPHO */ } void Radio::rxDone(uint8_t size, const pktStatus_t* pktStatus) @@ -276,9 +277,9 @@ if (!tx) { if (RadioEvents->RxTimeout) RadioEvents->RxTimeout(); -#ifdef TARGET_FF_MORPHO - pc3 = 0; -#endif /* TARGET_FF_MORPHO */ +#ifdef RX_INDICATION + RX_INDICATION = 0; +#endif } // else TODO tx timeout } @@ -313,6 +314,13 @@ radio.periodBase = 2; // 1ms resolution } +float Radio::GetRssiInst() +{ + uint8_t buf[2]; + radio.xfer(OPCODE_GET_RSSIINST, 0, 2, buf); + return buf[1] / -2.0; +} + int Radio::Send(uint8_t size, timestamp_t maxListenTime, timestamp_t channelFreeTime, int rssiThresh) { uint8_t buf[8]; @@ -528,23 +536,17 @@ void Radio::LoRaModemConfig(unsigned bwKHz, uint8_t sf, uint8_t cr) { - unsigned use; - if (radio.getPacketType() != PACKET_TYPE_LORA) radio.setPacketType(PACKET_TYPE_LORA); if (bwKHz > 800) { mpLORA.lora.bandwidth = LORA_BW_1600; - use = 1600; } if (bwKHz > 400) { mpLORA.lora.bandwidth = LORA_BW_800; - use = 800; } if (bwKHz > 200) { mpLORA.lora.bandwidth = LORA_BW_400; - use = 400; } else { mpLORA.lora.bandwidth = LORA_BW_200; - use = 200; } mpLORA.lora.codingRate = cr; @@ -597,6 +599,9 @@ void Radio::Rx(unsigned timeout) { +#ifdef RX_INDICATION + RX_INDICATION = 1; +#endif radio.start_rx(timeout / 1000); }