Skip to content
Open
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
2 changes: 0 additions & 2 deletions sming/sming/commandprocessing/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const String Command::operator[](unsigned int index)
Command::~Command() {
delete cmdVector;
delete cmdJsonBuffer;
delete &cmdRoot;
}

JsonObject& Command::getRoot()
Expand Down Expand Up @@ -64,7 +63,6 @@ void Command::clear()
cmdName = "";
delete cmdVector;
delete cmdJsonBuffer;
// delete cmdRoot;
cmdVector = NULL;
cmdJsonBuffer = NULL;
cmdRoot = NULL;
Expand Down
1 change: 0 additions & 1 deletion sming/sming/commandprocessing/CommandOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void CommandOutput::flush()
}
}
outputString = "";
delete &cmdRoot;
delete cmdJsonBuffer;
cmdRoot = NULL;
cmdJsonBuffer = NULL;
Expand Down
11 changes: 11 additions & 0 deletions sming/sming/core/DataSourceStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class DelegateStream : public Print, public IDataSourceStream
StreamDelegate streamDelegate = NULL;
bool finished = false;

DelegateStream(const DelegateStream&) = delete;
};

class FlashStream : public Print, public IDataSourceStream
Expand All @@ -89,6 +90,8 @@ class FlashStream : public Print, public IDataSourceStream
uint32 startAddress = 0;
uint32 currentOffset = 0;
uint32 streamSize = 0;

FlashStream(const FlashStream&) = delete;
};

class MemoryDataStream : public Print, public IDataSourceStream
Expand All @@ -113,6 +116,8 @@ class MemoryDataStream : public Print, public IDataSourceStream
char* pos;
int size;
int capacity;

MemoryDataStream(const MemoryDataStream&) = delete;
};

class FileStream : public IDataSourceStream
Expand Down Expand Up @@ -140,6 +145,8 @@ class FileStream : public IDataSourceStream
file_t handle;
int pos;
int size;

FileStream(const FileStream&) = delete;
};

enum TemplateExpandState
Expand Down Expand Up @@ -172,6 +179,8 @@ class TemplateFileStream : public FileStream
int skipBlockSize;
int varDataPos;
int varWaitSize;

TemplateFileStream(const TemplateFileStream&) = delete;
};

class JsonObjectStream : public MemoryDataStream
Expand All @@ -190,6 +199,8 @@ class JsonObjectStream : public MemoryDataStream
DynamicJsonBuffer buffer;
JsonObject &rootNode;
bool send;

JsonObjectStream(const JsonObjectStream&) = delete;
};


Expand Down
3 changes: 2 additions & 1 deletion sming/sming/network/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ bool MqttClient::publish(String topic, String message, bool retained /* = false*

#define MQTT_COMMAND_MAXSIZE 512 // needs to be relocated

bool MqttClient::publish(String topic, MemoryDataStream reqDataStream, bool retained /* = false */)
bool MqttClient::publish(String topic, MemoryDataStream& reqDataStream, bool retained /* = false */)
{
char* msgBuffer = new char[MQTT_COMMAND_MAXSIZE+1];
int msgSize = reqDataStream.readMemoryBlock(msgBuffer, MQTT_COMMAND_MAXSIZE);
msgBuffer[msgSize] = '\0';
int res = mqtt_publish(&broker, topic.c_str(), msgBuffer, retained);
delete [] msgBuffer;
return res > 0;
}

Expand Down
2 changes: 1 addition & 1 deletion sming/sming/network/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MqttClient: protected TcpClient
__forceinline TcpClientState getConnectionState() { return TcpClient::getConnectionState(); }

bool publish(String topic, String message, bool retained = false);
bool publish(String topic, MemoryDataStream reqDataStream, bool retained = false);
bool publish(String topic, MemoryDataStream& reqDataStream, bool retained = false);
bool publishWithQoS(String topic, String message, int QoS, bool retained = false);


Expand Down