Permalink
Browse files

Big packets bug fixed (#26) + Added MESSAGE_TO_LONG error

  • Loading branch information...
gioblu committed Feb 27, 2016
1 parent de10e60 commit 90b025ca3be5ff75e485d5af69b0bfb856c2bfea
Showing with 12 additions and 2 deletions.
  1. +6 −1 PJON.cpp
  2. +1 −0 PJON.h
  3. +5 −1 keywords.txt
@@ -252,6 +252,11 @@ int PJON::send_string(uint8_t id, char *string, uint8_t length) {
int PJON::send(uint8_t id, char *packet, uint8_t length, unsigned long timing) {
if(length >= PACKET_MAX_LENGTH) {
this->_error(MESSAGE_TOO_BIG, length);
return FAIL;
}
char *str = (char *) malloc(length);
if(str == NULL) {
@@ -406,7 +411,7 @@ int PJON::receive() {
return BUSY;
if(i == 1)
if(data[i] > 0 && data[i] < PACKET_MAX_LENGTH)
if(data[i] > 3 && data[i] < PACKET_MAX_LENGTH)
package_length = data[i];
else return FAIL;
1 PJON.h
@@ -128,6 +128,7 @@ advised of the possibility of such damage. */
#define CONNECTION_LOST 101
#define PACKETS_BUFFER_FULL 102
#define MEMORY_FULL 103
#define MESSAGE_TOO_BIG 104
// Maximum sending attempts before throwing CONNECTON_LOST error
#define MAX_ATTEMPTS 250
@@ -41,4 +41,8 @@ BROADCAST LITERAL1
TO_BE_SENT LITERAL1
CONNECTION_LOST LITERAL1
PACKETS_BUFFER_FULL LITERAL1
MEMORY_FULL LITERAL1
MEMORY_FULL LITERAL1
MESSAGE_TOO_BIG LITERAL1
MAX_ATTEMPTS LITERAL1
MAX_PACKETS LITERAL1
PACKET_MAX_LENGTH LITERAL1

0 comments on commit 90b025c

Please sign in to comment.