mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
move data link layer constants to constants component
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS "DataLinkManager.cpp" "DataLinkRIP.cpp" "DataLinkScheduler.cpp" "DataLinkFrames.cpp"
|
||||
PRIV_REQUIRES driver esp_event nvs_flash esp_netif rmt
|
||||
REQUIRES esp_timer
|
||||
REQUIRES esp_timer constants
|
||||
INCLUDE_DIRS "include")
|
||||
|
||||
@@ -4,40 +4,8 @@
|
||||
#include <variant>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "constants/datalink.h"
|
||||
|
||||
#define BROADCAST_ADDR 0xFF //used for discovery (finding the board's neighbours). this will mean the board ids will have 2^8-2 = 254 unique IDs that could be assigned
|
||||
#define PC_ADDR 0x0 //setting 0 to be the PC
|
||||
|
||||
#define START_OF_FRAME 0xAB //0b1010_1011 - denotes the start of frame
|
||||
|
||||
#define MAX_FRAME_SIZE 121 //Max 121B (due to rmt) - note this includes the overhead of the frame. the actual payload max depends on the frame type (eg. 121 - 9 B is the max control data length)
|
||||
|
||||
#define MAX_GENERIC_NUM_FRAG (1 << 16) // Max 2**16 Fragments can be made with a generic frame (total 2**16 *MAX_GENERIC_DATA_LEN B of data can be sent ~ 6.7 MiB)
|
||||
|
||||
#define MAX_FRAME_QUEUE_SIZE 15 //Size of the queue for the frame scheduler (per channel)
|
||||
|
||||
//Flags
|
||||
#define FLAG_FRAG 0x8 //0b1000 //this fragmented frame is part of a larger frame
|
||||
#define FLAG_DISCOVERY 0x4 //0b0100
|
||||
#define FLAG_NEIGH_TABLE 0x2 //0b0010 - used to denote the frame contains the neighbour tables (used for finding the configuration/topology of the network); similar to an ARP or MAC table
|
||||
#define FLAG_ACK 0x1 //0b0001_0000 - used for confirming receipt of different types of frames from the neighbours
|
||||
|
||||
#define GET_TYPE(x) ((x) & 0xF0)
|
||||
#define GET_FLAG(x) ((x) & 0x0F)
|
||||
#define MAKE_TYPE_FLAG(type, flag) ((uint8_t)((type & 0xF0) | (flag & 0xF)))
|
||||
#define IS_CONTROL_FRAME(x) (((x) & 0x80) != 0)
|
||||
|
||||
#define CONTROL_FRAME_OVERHEAD 9
|
||||
#define GENERIC_FRAME_OVERHEAD 14
|
||||
|
||||
#define MAX_GENERIC_DATA_LEN (MAX_FRAME_SIZE - GENERIC_FRAME_OVERHEAD)
|
||||
#define MAX_CONTROL_DATA_LEN (MAX_FRAME_SIZE - CONTROL_FRAME_OVERHEAD)
|
||||
|
||||
//Generic Frame Fragment ACK
|
||||
#define GENERIC_FRAG_ACK_DATA_SIZE 7
|
||||
#define GENERIC_FRAG_ACK_PREAMBLE 0x69
|
||||
|
||||
#define CONTROL_FRAME_TYPE 0x80 //if the frame type MSB is set to 1, use the control frame
|
||||
//Types (total 2^4 = 16 different types)
|
||||
enum class FrameType : uint8_t {
|
||||
//Control Frames
|
||||
|
||||
@@ -2,18 +2,7 @@
|
||||
#include "Frames.h"
|
||||
#include "esp_timer.h"
|
||||
#include <cstdint>
|
||||
|
||||
#define SCHEDULER_MUTEX_WAIT 10 //max time duration to wait
|
||||
#define SCHEDULER_PERIOD_MS 140
|
||||
#define RECEIVE_TASK_PERIOD_MS 2
|
||||
|
||||
#define GENERIC_FRAME_SLIDING_WINDOW_SIZE 5 //defines the maximum size of the sliding window before resending previously un-ack'd fragments
|
||||
#define SLIDING_WINDOW_MUTEX_TIMEOUT_MS 5
|
||||
#define GENERIC_FRAME_MOD_TIMEOUT 10 //be scheduled at most 9 + GENERIC_FRAME_MIN_TIMEOUT times before sending another fragment
|
||||
#define GENERIC_FRAME_MIN_TIMEOUT 10
|
||||
|
||||
#define SEND_ACK_PERIOD_MS 50
|
||||
#define SEND_ACK_MUTEX_WAIT 10
|
||||
#include "constants/datalink.h"
|
||||
|
||||
//Metadata representing the frame to be sent but is currently scheduled
|
||||
typedef struct _frame_scheduler_metadata {
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
#pragma once
|
||||
#ifdef DATA_LINK
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "constants/datalink.h"
|
||||
|
||||
#define RIP_MAX_HOPS 15 //16 or more is infinite
|
||||
#define RIP_MAX_ROUTES 10 //for the demo we will use up to 10 boards in total (9 other boards will be connected = 9 rows)
|
||||
#define RIP_INVALID_ROW 0
|
||||
#define RIP_VALID_ROW 1
|
||||
#define RIP_NEW_ROW 2
|
||||
#define RIP_BROADCAST_INTERVAL 30000 //broadcast every 30 seconds (30000ms)
|
||||
// #define RIP_BROADCAST_INTERVAL 3000 //temp broadcast every 3 seconds (3000ms)
|
||||
#define RIP_TTL_START 180 //seconds
|
||||
#define RIP_MS_TO_SEC 1000 //1000 ms to 1 sec
|
||||
#define RIP_MAX_SEM_WAIT_MS 30
|
||||
#define RIP_FLUSH_COUNT 8 //flush after 8*30 seconds = 240 seconds
|
||||
|
||||
#define RIP_DISCOVERY_MESSAGE_SIZE 1
|
||||
/**
|
||||
* @brief Routing data to a board
|
||||
* This struct will be sent to other boards
|
||||
|
||||
Reference in New Issue
Block a user