Fix timeout and add RFM95 test

This commit is contained in:
Olivier
2016-11-24 16:55:42 +01:00
parent 45b671457d
commit 5bc5eff1f9
3 changed files with 41 additions and 21 deletions
+3 -11
View File
@@ -413,9 +413,8 @@ LOCAL bool RFM95_executeATC(const rfm95_RSSI_t currentRSSI, const rfm95_RSSI_t t
return RFM95_setTxPower(RFM95.powerLevel);;
}
LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer, const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTime) {
(void)retryWaitTime;
LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer, const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTime)
{
for (uint8_t retry = 0; retry < retries; retry++) {
RFM95_DEBUG(PSTR("RFM95:SWR:SEND TO=%d,RETRY=%d\n"), recipient, retry);
rfm95_flag_t flags = 0x00;
@@ -427,7 +426,7 @@ LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer, cons
return true;
}
const uint32_t enterMS = hwMillis();
while (hwMillis() - enterMS < RFM95_RETRY_TIMEOUT_MS) {
while (hwMillis() - enterMS < retryWaitTime) {
if (RFM95.rxBufferValid) {
const uint8_t sender = RFM95.currentPacket.header.sender;
const rfm95_sequenceNumber_t ACKsequenceNumber = RFM95.currentPacket.ACK.sequenceNumber;
@@ -478,13 +477,6 @@ LOCAL bool RFM95_waitPacketSent(void) {
LOCAL int16_t RFM95_getRSSI(void) {
return (int16_t)(RFM95.currentPacket.RSSI - RFM95_RSSI_OFFSET);
}
LOCAL int16_t RFM95_getSNR(void) {
return (int16_t)(RFM95.currentPacket.SNR / 4);
}
LOCAL int8_t RFM95_getTxPower(void) {
return RFM95.powerLevel;
}
LOCAL void RFM95_ATCmode(const bool OnOff, const int16_t targetRSSI) {
RFM95.ATCenabled = OnOff;
-10
View File
@@ -386,11 +386,6 @@ LOCAL void RFM95_interruptHandler(void);
*/
LOCAL void RFM95_clearRxBuffer(void);
/**
* @brief RFM95_getSNR
* @return SNR Signal strength of last packet
*/
LOCAL int16_t RFM95_getSNR(void);
/**
* @brief RFM95_getRSSI
* @return RSSI Signal strength of last packet
*/
@@ -403,11 +398,6 @@ LOCAL int16_t RFM95_getRSSI(void);
*/
LOCAL bool RFM95_executeATC(const rfm95_RSSI_t currentRSSI, const rfm95_RSSI_t targetRSSI);
/**
* @brief RFM95_getTxPower
* @return Current power level
*/
LOCAL int8_t RFM95_getTxPower(void);
/**
* @brief RFM95_ATCmode
* @param targetRSSI Target RSSI for transmitter (default -60)
* @param OnOff True to enable ATC