pull/51/head
Binder Tronics 2 years ago
parent d4ce926b12
commit 74b2cd33ac

@ -59,13 +59,42 @@ extern const uint8_t prefix[5];
class FDRSBase{
public:
/**
* @brief Construct a new FDRSBase object
*
* @param gtwy_mac The network MAC
* @param reading_id The network identifier for the sensor
*/
FDRSBase(uint8_t gtwy_mac,uint8_t reading_id);
~FDRSBase();
/**
* @brief Start a paticulare sensor.
*/
void begin(void);
/**
* @brief Set the data sor the next transmission.
*
* @param data Data for the next transmission
* @param type The ID for the type of data that is being sent.
*/
void load(float data, uint8_t type);
/**
* @brief Time in seconds the sensor will delay before sending data.
*
* @note This is blocking.
*
* @param seconds Number of seconds to delay.
*/
void sleep(int seconds);
/**
* @brief Send the data out on the network.
*
*/
void send();
private:
@ -76,7 +105,17 @@ private:
uint8_t _data_count;
DataReading_t *fdrsData;
/**
* @brief Required impalamnetation of a paticulare sensors initialization.
*/
virtual void init(void) = 0;
/**
* @brief Required impalamnetation of how a sensor will send its data out on the network.
*
* @param fdrsData Pointer to the data that the sensor will be seding.
* @param _data_count The number of data packets the sensor will be sending.
*/
virtual void transmit(DataReading_t *fdrsData, uint8_t _data_count) = 0;
};
@ -84,12 +123,31 @@ private:
class FDRS_EspNow: public FDRSBase{
public:
/**
* @brief Construct a new fdrs espnow object
*
* @param gtwy_mac The network MAC.
* @param reading_id The network identifier for the sensor.
*/
FDRS_EspNow(uint8_t gtwy_mac, uint8_t reading_id);
private:
uint8_t _gatewayAddress[ESP_GATEWAY_ADDRESS_SIZE];
/**
* @brief Send data out on the ESPNOW network.
*
* @param fdrsData Pointer to the data that the sensor will be seding.
* @param _data_count The number of data packets the sensor will be sending.
*/
void transmit(DataReading_t *fdrsData, uint8_t _data_count) override;
/**
* @brief Initialize the ESPNOW network
*
*/
void init(void) override;
};
@ -97,6 +155,21 @@ private:
class FDRSLoRa: public FDRSBase{
public:
/**
* @brief Construct a new FDRSLoRa object
*
* @param gtwy_mac The network MAC.
* @param reading_id The network identifier for the sensor.
* @param miso Master in slave out pin.
* @param mosi Master out slave in pin.
* @param sck Master clock pin.
* @param ss Slave select pin
* @param rst Reset Pin
* @param dio0 LoRa data pin
* @param band LoRa frequency band
* @param sf LoRa spread factor
*/
FDRSLoRa(uint8_t gtwy_mac, uint8_t reading_id,uint8_t miso,uint8_t mosi,uint8_t sck, uint8_t ss,uint8_t rst,uint8_t dio0,uint32_t band,uint8_t sf);
private:
@ -111,8 +184,26 @@ private:
uint32_t _band;
uint8_t _sf;
/**
* @brief Construct a LoRa packet
*
* @param mac Network Mac address
* @param packet Data to create the packet with
* @param len Length of the data in bytes
*/
void buildPacket(uint8_t* mac, DataReading_t * packet, uint8_t len);
/**
* @brief Send data out on the LoRa network.
*
* @param fdrsData Pointer to the data that the sensor will be seding.
* @param _data_count The number of data packets the sensor will be sending.
*/
void transmit(DataReading_t *fdrsData, uint8_t _data_count) override;
/**
* @brief Initialize the LoRa module
*/
void init(void) override;
};

Loading…
Cancel
Save