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
@@ -0,0 +1,38 @@
/*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2016 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*/
#include <stdint.h>
#include <pins_arduino.h>
#define MY_DEBUG
#define MY_DEBUG_VERBOSE_SIGNING
#define MY_RADIO_RFM95
//#define MY_SIGNING_SOFT
#define MY_SIGNING_ATSHA204
#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}}
#define MY_SIGNING_REQUEST_SIGNATURES
#ifndef MY_SIGNING_SOFT_RANDOMSEED_PIN
#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
#endif
#ifndef MY_SIGNING_ATSHA204_PIN
#define MY_SIGNING_ATSHA204_PIN 17
#endif
#define MY_RFM69_ENABLE_ENCRYPTION
#include <MySensors.h>