Skip to content

Commit

Permalink
header type uint16_t -> uint8_t, -46 bytes of program memory
Browse files Browse the repository at this point in the history
  • Loading branch information
gioblu committed Jun 21, 2018
1 parent 5fb715c commit 506c936
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/PJON.h
Expand Up @@ -155,12 +155,12 @@ class PJON {
char *destination,
const char *source,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
uint8_t index = 0;
if(header == PJON_FAIL) header = config;
if(header == PJON_NO_HEADER) header = config;
if(length > 255) header |= PJON_EXT_LEN_BIT;
if((config & PJON_PORT_BIT) || (requested_port != PJON_BROADCAST))
header |= PJON_PORT_BIT;
Expand Down Expand Up @@ -273,7 +273,7 @@ class PJON {
const char *packet,
uint16_t length,
uint32_t timing,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST,
uint16_t p_index = PJON_FAIL
Expand Down Expand Up @@ -354,8 +354,8 @@ class PJON {

/* Calculate packet overhead: */

uint8_t packet_overhead(uint16_t header = PJON_FAIL) const {
header = (header == PJON_FAIL) ? config : header;
uint8_t packet_overhead(uint8_t header = PJON_NO_HEADER) const {
header = (header == PJON_NO_HEADER) ? config : header;
return (
(
(header & PJON_MODE_BIT) ?
Expand Down Expand Up @@ -626,7 +626,7 @@ class PJON {
uint16_t reply(
const char *packet,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -650,7 +650,7 @@ class PJON {
uint8_t id,
const char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -664,7 +664,7 @@ class PJON {
const uint8_t *b_id,
const char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -682,7 +682,7 @@ class PJON {
const uint8_t *b_id,
const char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand Down Expand Up @@ -714,7 +714,7 @@ class PJON {
const char *string,
uint16_t length,
uint32_t timing,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -732,7 +732,7 @@ class PJON {
const char *string,
uint16_t length,
uint32_t timing,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand Down Expand Up @@ -766,7 +766,7 @@ class PJON {
uint8_t id,
char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -781,7 +781,7 @@ class PJON {
const uint8_t *b_id,
char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST
) {
Expand All @@ -800,7 +800,7 @@ class PJON {
const uint8_t *b_id,
const char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST,
uint32_t timeout = 3000000
Expand Down Expand Up @@ -846,7 +846,7 @@ class PJON {
uint8_t id,
const char *string,
uint16_t length,
uint16_t header = PJON_FAIL,
uint8_t header = PJON_NO_HEADER,
uint16_t p_id = 0,
uint16_t requested_port = PJON_BROADCAST,
uint32_t timeout = 3000000
Expand Down
3 changes: 2 additions & 1 deletion src/PJONDefines.h
Expand Up @@ -90,8 +90,9 @@ limitations under the License. */
#define PJON_FAIL 65535
#define PJON_TO_BE_SENT 74

/* No header present */
#define PJON_NO_HEADER 0B01011000
/* HEADER BITS DEFINITION: */

/* 0 - Local network
1 - Shared network */
#define PJON_MODE_BIT 0B00000001
Expand Down

0 comments on commit 506c936

Please sign in to comment.