sforkowany z mirror/meshtastic-firmware
commit
598abb0d23
|
@ -1,3 +1,3 @@
|
|||
|
||||
|
||||
export VERSION=0.4.1
|
||||
export VERSION=0.4.2
|
|
@ -69,9 +69,6 @@ void MeshService::init()
|
|||
|
||||
gpsObserver.observe(&gps);
|
||||
packetReceivedObserver.observe(&router.notifyPacketReceived);
|
||||
|
||||
// No need to call this here, our periodic task will fire quite soon
|
||||
// sendOwnerPeriod();
|
||||
}
|
||||
|
||||
void MeshService::sendOurOwner(NodeNum dest, bool wantReplies)
|
||||
|
|
|
@ -83,6 +83,7 @@ void NodeDB::resetRadioConfig()
|
|||
/*
|
||||
radioConfig.preferences.screen_on_secs = 30;
|
||||
radioConfig.preferences.wait_bluetooth_secs = 30;
|
||||
radioConfig.preferences.position_broadcast_secs = 15;
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,11 @@ ErrorCode CustomRF95::send(MeshPacket *p)
|
|||
DEBUG_MSG("immediate send on mesh fr=0x%x,to=0x%x,id=%d\n (txGood=%d,rxGood=%d,rxBad=%d)\n", p->from, p->to, p->id,
|
||||
txGood(), rxGood(), rxBad());
|
||||
|
||||
waitPacketSent(); // Make sure we dont interrupt an outgoing message
|
||||
|
||||
if (!waitCAD())
|
||||
return false; // Check channel activity
|
||||
|
||||
startSend(p);
|
||||
return ERRNO_OK;
|
||||
} else {
|
||||
|
|
|
@ -6,17 +6,8 @@
|
|||
#include <RHGenericDriver.h>
|
||||
|
||||
RHGenericDriver::RHGenericDriver()
|
||||
:
|
||||
_mode(RHModeInitialising),
|
||||
_thisAddress(RH_BROADCAST_ADDRESS),
|
||||
_txHeaderTo(RH_BROADCAST_ADDRESS),
|
||||
_txHeaderFrom(RH_BROADCAST_ADDRESS),
|
||||
_txHeaderId(0),
|
||||
_txHeaderFlags(0),
|
||||
_rxBad(0),
|
||||
_rxGood(0),
|
||||
_txGood(0),
|
||||
_cad_timeout(0)
|
||||
: _mode(RHModeInitialising), _thisAddress(RH_BROADCAST_ADDRESS), _txHeaderTo(RH_BROADCAST_ADDRESS),
|
||||
_txHeaderFrom(RH_BROADCAST_ADDRESS), _txHeaderId(0), _txHeaderFlags(0), _rxBad(0), _rxGood(0), _txGood(0), _cad_timeout(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,7 +20,7 @@ bool RHGenericDriver::init()
|
|||
void RHGenericDriver::waitAvailable()
|
||||
{
|
||||
while (!available())
|
||||
YIELD;
|
||||
YIELD;
|
||||
}
|
||||
|
||||
// Blocks until a valid message is received or timeout expires
|
||||
|
@ -38,13 +29,11 @@ void RHGenericDriver::waitAvailable()
|
|||
bool RHGenericDriver::waitAvailableTimeout(uint16_t timeout)
|
||||
{
|
||||
unsigned long starttime = millis();
|
||||
while ((millis() - starttime) < timeout)
|
||||
{
|
||||
if (available())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
YIELD;
|
||||
while ((millis() - starttime) < timeout) {
|
||||
if (available()) {
|
||||
return true;
|
||||
}
|
||||
YIELD;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -52,18 +41,17 @@ bool RHGenericDriver::waitAvailableTimeout(uint16_t timeout)
|
|||
bool RHGenericDriver::waitPacketSent()
|
||||
{
|
||||
while (_mode == RHModeTx)
|
||||
YIELD; // Wait for any previous transmit to finish
|
||||
YIELD; // Wait for any previous transmit to finish
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RHGenericDriver::waitPacketSent(uint16_t timeout)
|
||||
{
|
||||
unsigned long starttime = millis();
|
||||
while ((millis() - starttime) < timeout)
|
||||
{
|
||||
while ((millis() - starttime) < timeout) {
|
||||
if (_mode != RHModeTx) // Any previous transmit finished?
|
||||
return true;
|
||||
YIELD;
|
||||
return true;
|
||||
YIELD;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -72,7 +60,7 @@ bool RHGenericDriver::waitPacketSent(uint16_t timeout)
|
|||
bool RHGenericDriver::waitCAD()
|
||||
{
|
||||
if (!_cad_timeout)
|
||||
return true;
|
||||
return true;
|
||||
|
||||
// Wait for any channel activity to finish or timeout
|
||||
// Sophisticated DCF function...
|
||||
|
@ -80,14 +68,13 @@ bool RHGenericDriver::waitCAD()
|
|||
// 100 - 1000 ms
|
||||
// 10 sec timeout
|
||||
unsigned long t = millis();
|
||||
while (isChannelActive())
|
||||
{
|
||||
if (millis() - t > _cad_timeout)
|
||||
return false;
|
||||
while (isChannelActive()) {
|
||||
if (millis() - t > _cad_timeout)
|
||||
return false;
|
||||
#if (RH_PLATFORM == RH_PLATFORM_STM32) // stdlib on STMF103 gets confused if random is redefined
|
||||
delay(_random(1, 10) * 100);
|
||||
delay(_random(1, 10) * 100);
|
||||
#else
|
||||
delay(random(1, 10) * 100); // Should these values be configurable? Macros?
|
||||
delay(random(1, 10) * 100); // Should these values be configurable? Macros?
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -156,36 +143,34 @@ int16_t RHGenericDriver::lastRssi()
|
|||
return _lastRssi;
|
||||
}
|
||||
|
||||
RHGenericDriver::RHMode RHGenericDriver::mode()
|
||||
RHGenericDriver::RHMode RHGenericDriver::mode()
|
||||
{
|
||||
return _mode;
|
||||
}
|
||||
|
||||
void RHGenericDriver::setMode(RHMode mode)
|
||||
void RHGenericDriver::setMode(RHMode mode)
|
||||
{
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
bool RHGenericDriver::sleep()
|
||||
bool RHGenericDriver::sleep()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Diagnostic help
|
||||
void RHGenericDriver::printBuffer(const char* prompt, const uint8_t* buf, uint8_t len)
|
||||
void RHGenericDriver::printBuffer(const char *prompt, const uint8_t *buf, uint8_t len)
|
||||
{
|
||||
#ifdef RH_HAVE_SERIAL
|
||||
Serial.println(prompt);
|
||||
uint8_t i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (i % 16 == 15)
|
||||
Serial.println(buf[i], HEX);
|
||||
else
|
||||
{
|
||||
Serial.print(buf[i], HEX);
|
||||
Serial.print(' ');
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i % 16 == 15)
|
||||
Serial.println(buf[i], HEX);
|
||||
else {
|
||||
Serial.print(buf[i], HEX);
|
||||
Serial.print(' ');
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
#endif
|
||||
|
@ -216,6 +201,7 @@ void RHGenericDriver::setCADTimeout(unsigned long cad_timeout)
|
|||
// get linking complaints from the default code generated for pure virtual functions
|
||||
extern "C" void __cxa_pure_virtual()
|
||||
{
|
||||
while (1);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -280,17 +280,14 @@ void RH_RF95::clearRxBuf()
|
|||
ATOMIC_BLOCK_END;
|
||||
}
|
||||
|
||||
/// Note: This routine might be called from inside the RF95 ISR
|
||||
bool RH_RF95::send(const uint8_t *data, uint8_t len)
|
||||
{
|
||||
if (len > RH_RF95_MAX_MESSAGE_LEN)
|
||||
return false;
|
||||
|
||||
waitPacketSent(); // Make sure we dont interrupt an outgoing message
|
||||
setModeIdle();
|
||||
|
||||
if (!waitCAD())
|
||||
return false; // Check channel activity
|
||||
|
||||
// Position at the beginning of the FIFO
|
||||
spiWrite(RH_RF95_REG_0D_FIFO_ADDR_PTR, 0);
|
||||
// The headers
|
||||
|
|
Ładowanie…
Reference in New Issue