Permalink
Browse files

backoff bugfix now ^4

  • Loading branch information...
gioblu committed Dec 1, 2016
1 parent 8697169 commit 305d6c11b2e88b3bf98bf9584d204270440d9827
Showing with 5 additions and 10 deletions.
  1. +4 −7 PJON.h
  2. +1 −3 PJONDefines.h
11 PJON.h
@@ -858,20 +858,17 @@ limitations under the License. */
uint32_t back_off;
for(uint8_t i = 0; i < MAX_PACKETS; i++) {
if(packets[i].state == 0) continue;
packets_count++;
#if(ORDERED_SENDING)
if(!first_packet_to_be_sent(i)) continue;
#endif
packets_count++;
back_off = packets[i].attempts;
back_off = back_off * back_off * back_off;
bool async_ack = (packets[i].content[1] & ACK_MODE_BIT) &&
(packets[i].content[1] & SENDER_INFO_BIT);
if(async_ack && packets[i].state != TO_BE_SENT)
back_off += ASYNC_BACKOFF_OFFSET;
back_off = packets[i].attempts;
back_off = (back_off * back_off * back_off * back_off);
if((uint32_t)(micros() - packets[i].registration) > packets[i].timing + back_off)
packets[i].state = send_packet(packets[i].content, packets[i].length);
@@ -910,7 +907,7 @@ limitations under the License. */
packets[i].registration = micros();
packets[i].state = TO_BE_SENT;
}
} else packets[i].registration = micros();
}
}
return packets_count;
};
@@ -117,7 +117,7 @@ limitations under the License. */
/* CONSTRAINTS:
Max attempts before throwing CONNECTON_LOST error */
#ifndef MAX_ATTEMPTS
#define MAX_ATTEMPTS 50
#define MAX_ATTEMPTS 42
#endif
/* Max time delayed by backoff in microseconds */
@@ -167,8 +167,6 @@ limitations under the License. */
#define ADDRESSING_TIMEOUT 2900000
/* Master reception time during LIST_ID request broadcast (20 milliseconds) */
#define LIST_IDS_RECEPTION_TIME 20000
/* Asynchronous acknowledge backoff offset: */
#define ASYNC_BACKOFF_OFFSET 100000
struct PJON_Packet {
uint8_t attempts;

0 comments on commit 305d6c1

Please sign in to comment.