1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #ifndef NEIGHBORS_H
- #define NEIGHBORS_H
- #include <Arduino.h>
- #include <esp_now.h>
- #include <stdio.h>
- #include "configuration.h"
- /** Convert hex mac address to uint64_t
- * @param[in] hwaddr hex mac address
- * @return mac address as uint64_t
- */
- uint64_t mac2int(const uint8_t macstr[]);
- void print_id(const uint64_t id);
- typedef struct {
- uint64_t id;
- unsigned long last_hello;
- bool agreement;
- } neighbor_t;
- class Neighbor_List {
- // Maintains a list of neighbors
- private:
- neighbor_t list[MAX_NEIGHBORS];
- uint64_t my_id;
- bool network_ready = false;
-
- bool sort_neighbors(void);
-
- public:
- Neighbor_List(void);
- bool ready(void);
- void beacon(void);
- void test_sort(void);
- void print_list(void);
- void set_agreement(const uint64_t neighbor_id, const bool agreement);
- bool add_neighbor(const uint64_t neighbor_id);
- bool process_discovery(const uint8_t neighbor[19], const uint8_t *data, const size_t len);
- };
- extern Neighbor_List NList;
- #endif
|