1
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); }