Commit 3ed6c1cb authored by Reto Da Forno's avatar Reto Da Forno
Browse files

define removed and check for protocol ID reverted

parent db7daa83
......@@ -199,7 +199,7 @@ static void gloria_rx_callback(uint8_t* payload, uint8_t size)
break;
default:
LOG_WARNING("unknown gloria message type");
LOG_WARNING("unknown gloria packet type");
break;
}
}
......
......@@ -32,10 +32,9 @@
#define PROTOCOL_GLORIA_GLORIA_CONSTANTS_H_
#define GLORIA_PHY_MAX_PAYLOAD 255 // max length of the physical layer payload (given by the hardware)
#define GLORIA_HEADER_LENGTH_WITH_TS (GLORIA_HEADER_LENGTH + GLORIA_TIMESTAMP_LENGTH) // length of the gloria header, with timestamp
#define GLORIA_HEADER_LENGTH 4 // length of the gloria header
#define GLORIA_HEADER_LENGTH_MIN 2 // length of the gloria header without ACK mode
#define GLORIA_MAX_PAYLOAD_LENGTH (GLORIA_PHY_MAX_PAYLOAD - GLORIA_HEADER_LENGTH_WITH_TS)
#define GLORIA_HEADER_LENGTH 4 // length of the gloria header (without timestamp)
#define GLORIA_HEADER_LENGTH_MIN 2 // length of the gloria header in ACK mode (without timestamp)
#define GLORIA_MAX_PAYLOAD_LENGTH (GLORIA_PHY_MAX_PAYLOAD - GLORIA_HEADER_LENGTH - GLORIA_TIMESTAMP_LENGTH)
#define GLORIA_ACK_LENGTH 2 // length of the gloria ack message
#define GLORIA_TIMESTAMP_LENGTH 8 // length of the timestamp to send with sync floods
......
......@@ -295,10 +295,11 @@ static void gloria_radio_rx_callback(uint8_t* payload, uint16_t size, int16_t r
return;
}
// update header size
current_flood->header_size = (current_flood->ack_mode ? GLORIA_HEADER_LENGTH : GLORIA_HEADER_LENGTH_MIN) + ((gloria_header_t*)payload)->sync * GLORIA_TIMESTAMP_LENGTH;
gloria_header_t* header = (gloria_header_t*)payload;
current_flood->header_size = (current_flood->ack_mode ? GLORIA_HEADER_LENGTH : GLORIA_HEADER_LENGTH_MIN) + header->sync * GLORIA_TIMESTAMP_LENGTH;
// check packet type and apply user-defined packet filter
if (!PROTOCOL_CHECK_ID(*payload, GLORIA) ||
if ((header->protocol_id != PROTOCOL_ID_GLORIA) ||
(current_flood->filter_cb && (size > current_flood->header_size) && !current_flood->filter_cb(payload + current_flood->header_size, size - current_flood->header_size))) {
gloria_radio_continue_rx();
}
......
......@@ -111,7 +111,7 @@ typedef struct {
} gloria_flood_t;
_Static_assert(sizeof(gloria_ack_msg_t) == GLORIA_ACK_LENGTH, "gloria_ack_msg_t is not GLORIA_ACK_LENGTH bytes in size!");
_Static_assert(sizeof(gloria_header_t) == GLORIA_HEADER_LENGTH_WITH_TS, "gloria_header_t is not GLORIA_HEADER_LENGTH_WITH_TS bytes in size!");
_Static_assert(sizeof(gloria_ack_msg_t) == GLORIA_ACK_LENGTH, "invalid size of gloria_ack_msg_t");
_Static_assert(sizeof(gloria_header_t) == (GLORIA_HEADER_LENGTH + GLORIA_TIMESTAMP_LENGTH), "invalid size of gloria_header_t");
#endif /* PROTOCOL_GLORIA_GLORIA_STRUCTURES_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment