Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cicada/commdevices/cc1352p7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
33 changes: 15 additions & 18 deletions cicada/commdevices/rakrui3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
*/

#include "cicada/commdevices/rakrui3.h"
#include <cinttypes>
#include <cstdio>
#include <cstring>
#include <cinttypes>

using namespace Cicada;

Expand All @@ -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();
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -341,8 +339,7 @@ void RakDevice::run()
}
break;

case sendPacket:
{
case sendPacket: {
_waitForReply = "+EVT:SEND_CONFIRMED_OK";
//_waitForReply = _okStr;
_sendState = waitForSend;
Expand Down
3 changes: 1 addition & 2 deletions cicada/commdevices/rakrui3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
8 changes: 3 additions & 5 deletions examples/linux/simplesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
Expand All @@ -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()
{
Expand All @@ -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());
}
Expand Down
1 change: 0 additions & 1 deletion test/modules/circularbuffertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ TEST(CircularBufferTest, ReReadSameData)
STRNCMP_EQUAL("567", dataOut, 4);
}


TEST(CircularBufferTest, ReReadSameDataWithWrapAround)
{
const uint8_t MAX_BUFFER_SIZE = 10;
Expand Down