2021-01-01 22:23:27 +00:00
|
|
|
#ifndef BOARD_FINDER_H_
|
|
|
|
#define BOARD_FINDER_H_
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <SPI.h>
|
2021-03-12 22:21:45 +00:00
|
|
|
#include <Wire.h>
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2022-03-19 23:22:19 +00:00
|
|
|
#include <logger.h>
|
|
|
|
|
2021-01-01 22:23:27 +00:00
|
|
|
enum BoardType
|
|
|
|
{
|
2021-03-12 22:21:45 +00:00
|
|
|
eHELTEC_WIFI_LORA_32_V1,
|
|
|
|
eHELTEC_WIFI_LORA_32_V2,
|
|
|
|
eTTGO_LORA32_V1,
|
|
|
|
eTTGO_LORA32_V2,
|
|
|
|
eTTGO_T_Beam_V0_7,
|
|
|
|
eTTGO_T_Beam_V1_0,
|
|
|
|
eETH_BOARD,
|
|
|
|
eTRACKERD
|
2021-01-01 22:23:27 +00:00
|
|
|
};
|
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
class BoardConfig {
|
2021-01-01 22:23:27 +00:00
|
|
|
public:
|
2021-03-12 22:21:45 +00:00
|
|
|
explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, bool needcheckpowerchip = false, bool powercheckstatus = false);
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
String Name;
|
|
|
|
BoardType Type;
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
uint8_t OledSda;
|
|
|
|
uint8_t OledScl;
|
|
|
|
uint8_t OledAddr;
|
|
|
|
uint8_t OledReset;
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
uint8_t LoraSck;
|
|
|
|
uint8_t LoraMiso;
|
|
|
|
uint8_t LoraMosi;
|
|
|
|
uint8_t LoraCS;
|
|
|
|
uint8_t LoraReset;
|
|
|
|
uint8_t LoraIRQ;
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
bool needCheckPowerChip;
|
|
|
|
bool powerCheckStatus;
|
2021-01-01 22:23:27 +00:00
|
|
|
};
|
|
|
|
|
2021-03-12 22:21:45 +00:00
|
|
|
class BoardFinder {
|
2021-01-01 22:23:27 +00:00
|
|
|
public:
|
2021-05-25 18:10:42 +00:00
|
|
|
explicit BoardFinder(const std::list<BoardConfig const *> &boardConfigs);
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2022-03-19 23:22:19 +00:00
|
|
|
BoardConfig const *searchBoardConfig(logging::Logger &logger);
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2021-05-18 22:43:59 +00:00
|
|
|
BoardConfig const *getBoardConfig(String name);
|
2021-01-01 22:23:27 +00:00
|
|
|
|
|
|
|
private:
|
2021-05-25 18:10:42 +00:00
|
|
|
const std::list<BoardConfig const *> &_boardConfigs;
|
2021-01-01 22:23:27 +00:00
|
|
|
|
2022-03-19 23:22:19 +00:00
|
|
|
bool checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger);
|
2021-05-18 22:43:59 +00:00
|
|
|
bool checkModemConfig(BoardConfig const *boardConfig);
|
2022-03-19 23:22:19 +00:00
|
|
|
bool checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger);
|
2021-01-01 22:23:27 +00:00
|
|
|
};
|
|
|
|
|
2021-05-18 22:43:59 +00:00
|
|
|
extern BoardConfig TTGO_LORA32_V1;
|
|
|
|
extern BoardConfig TTGO_LORA32_V2;
|
|
|
|
extern BoardConfig TTGO_T_Beam_V0_7;
|
|
|
|
extern BoardConfig TTGO_T_Beam_V1_0;
|
|
|
|
extern BoardConfig ETH_BOARD;
|
|
|
|
extern BoardConfig TRACKERD;
|
|
|
|
extern BoardConfig HELTEC_WIFI_LORA_32_V1;
|
|
|
|
extern BoardConfig HELTEC_WIFI_LORA_32_V2;
|
|
|
|
|
2021-01-01 22:23:27 +00:00
|
|
|
#endif
|