diff --git a/cicada/commdevices/cc1352p7.cpp b/cicada/commdevices/cc1352p7.cpp index faf875e..e4c22e8 100644 --- a/cicada/commdevices/cc1352p7.cpp +++ b/cicada/commdevices/cc1352p7.cpp @@ -176,7 +176,7 @@ void CC1352P7CommDevice::run() logStates(_sendState, _replyState); // Handle error states - if (strncmp(_lineBuffer, "ERROR", 5) == 0 ) { + if (strncmp(_lineBuffer, "ERROR", 5) == 0) { _stateBooleans |= RESET_PENDING; _connectState = generalError; _waitForReply = NULL; @@ -225,8 +225,8 @@ void CC1352P7CommDevice::run() if (strncmp(_lineBuffer, "+IPD,", 4) == 0) { _bytesToReceive = strtol(_lineBuffer + 5, NULL, 10); _stateBooleans |= DATA_PENDING; - } else if (strncmp(_lineBuffer, "CLOSED", 6) == 0 || - strncmp(_lineBuffer, "SEND FAIL", 9) == 0) { + } else if (strncmp(_lineBuffer, "CLOSED", 6) == 0 + || strncmp(_lineBuffer, "SEND FAIL", 9) == 0) { _stateBooleans &= ~IP_CONNECTED; } } diff --git a/cicada/commdevices/rakrui3.cpp b/cicada/commdevices/rakrui3.cpp index d8e64a8..429a825 100644 --- a/cicada/commdevices/rakrui3.cpp +++ b/cicada/commdevices/rakrui3.cpp @@ -22,9 +22,9 @@ */ #include "cicada/commdevices/rakrui3.h" +#include #include #include -#include using namespace Cicada; @@ -37,18 +37,16 @@ using namespace Cicada; const char* RakDevice::_okStr = "OK"; const char* RakDevice::_lineEndStr = "\r\n"; -//const char* RakDevice::_quoteEndStr = "\"\r\n"; +// const char* RakDevice::_quoteEndStr = "\"\r\n"; // LoRaWAN maximum packet payload for different data rates. Taken from table 3 at // https://lora-developers.semtech.com/documentation/tech-papers-and-guides/the-book/packet-size-considerations/ -const uint8_t RakDevice::_packetSizes[14] = - { 11, 51, 51, 115, 222, 222, 222, 222, 33, 109, 222, 222, 222, 222 }; +const uint8_t RakDevice::_packetSizes[14] + = { 11, 51, 51, 115, 222, 222, 222, 222, 33, 109, 222, 222, 222, 222 }; RakDevice::RakDevice( IBufferedSerial& serial, uint8_t* readBuffer, uint8_t* writeBuffer, Size bufferSize) : - _serial(serial), - _readBuffer(readBuffer, bufferSize), - _writeBuffer(writeBuffer, bufferSize) + _serial(serial), _readBuffer(readBuffer, bufferSize), _writeBuffer(writeBuffer, bufferSize) { resetStates(); } @@ -193,11 +191,11 @@ void RakDevice::run() #ifdef CICADA_DEBUG if (_waitForReply) printf("_sendState=%d, _replyState=%d, " - "_waitForReply=\"%s\", data: %s\n", + "_waitForReply=\"%s\", data: %s\n", _sendState, _replyState, _waitForReply, _lineBuffer); else printf("_sendState=%d, _replyState=%d, " - "_waitForReply=NULL, data: %s\n", + "_waitForReply=NULL, data: %s\n", _sendState, _replyState, _lineBuffer); #endif @@ -228,8 +226,8 @@ void RakDevice::run() break; case sendConfirm: - if (strncmp(_lineBuffer, "+EVT:SEND_CONFIRMED_FAILED", 26) == 0 || - strncmp(_lineBuffer, "AT_BUSY_ERROR", 13) == 0) { + if (strncmp(_lineBuffer, "+EVT:SEND_CONFIRMED_FAILED", 26) == 0 + || strncmp(_lineBuffer, "AT_BUSY_ERROR", 13) == 0) { _writeBuffer.rewindReadHead(_bytesToResend); _replyState = okReply; _waitForReply = NULL; @@ -245,11 +243,11 @@ void RakDevice::run() char* src = _lineBuffer + 6; int nColons = 0; if (strncmp(_lineBuffer, "+EVT:RX", 7) == 0) { - while(*src) { - if(*src++ == ':') { - if(++nColons == 5) { + while (*src) { + if (*src++ == ':') { + if (++nColons == 5) { int b; - while(sscanf(src, "%02x", &b) == 1) { + while (sscanf(src, "%02x", &b) == 1) { _readBuffer.push((uint8_t)b); src += 2; } @@ -261,7 +259,7 @@ void RakDevice::run() } // Don't go on when waiting for a reply - if (_waitForReply) // || _replyState != okReply) + if (_waitForReply) // || _replyState != okReply) return; // Don't go on if space in write buffer is low @@ -341,8 +339,7 @@ void RakDevice::run() } break; - case sendPacket: - { + case sendPacket: { _waitForReply = "+EVT:SEND_CONFIRMED_OK"; //_waitForReply = _okStr; _sendState = waitForSend; diff --git a/cicada/commdevices/rakrui3.h b/cicada/commdevices/rakrui3.h index 3465fd3..516b3b2 100644 --- a/cicada/commdevices/rakrui3.h +++ b/cicada/commdevices/rakrui3.h @@ -40,8 +40,7 @@ namespace Cicada { class RakDevice : public IStatefulDevice, public Task { public: - RakDevice( - IBufferedSerial& serial, uint8_t* readBuffer, uint8_t* writeBuffer, Size bufferSize); + RakDevice(IBufferedSerial& serial, uint8_t* readBuffer, uint8_t* writeBuffer, Size bufferSize); RakDevice(IBufferedSerial& serial, uint8_t* readBuffer, uint8_t* writeBuffer, Size readBufferSize, Size writeBufferSize); virtual ~RakDevice() {} diff --git a/examples/linux/simplesend.cpp b/examples/linux/simplesend.cpp index 67ef7ee..3aa9019 100644 --- a/examples/linux/simplesend.cpp +++ b/examples/linux/simplesend.cpp @@ -2,8 +2,8 @@ * Example code for simply sending a sequence of bytes */ -#include "cicada/platform/linux/unixserial.h" #include "cicada/commdevices/rakrui3.h" +#include "cicada/platform/linux/unixserial.h" #include "cicada/scheduler.h" #include "cicada/tick.h" #include @@ -15,9 +15,7 @@ using namespace Cicada; class SimpleSend : public Task { public: - SimpleSend(RakDevice& commDev) : - m_commDev(commDev) - {} + SimpleSend(RakDevice& commDev) : m_commDev(commDev) {} virtual void run() { @@ -31,7 +29,7 @@ class SimpleSend : public Task printf("*** Connected! ***\n"); - for (m_i=0; m_i<10; m_i++) { + for (m_i = 0; m_i < 10; m_i++) { m_commDev.write((uint8_t*)m_str, strlen(m_str)); E_REENTER_COND(m_commDev.writeBufferProcessed()); } diff --git a/test/modules/circularbuffertest.cpp b/test/modules/circularbuffertest.cpp index 82a3c88..6733459 100644 --- a/test/modules/circularbuffertest.cpp +++ b/test/modules/circularbuffertest.cpp @@ -174,7 +174,6 @@ TEST(CircularBufferTest, ReReadSameData) STRNCMP_EQUAL("567", dataOut, 4); } - TEST(CircularBufferTest, ReReadSameDataWithWrapAround) { const uint8_t MAX_BUFFER_SIZE = 10;