mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
fix type
This commit is contained in:
parent
a0e65ffeff
commit
f06d094d53
@ -11,11 +11,11 @@ uint32_t wait_time = 0;
|
||||
|
||||
FDRSBase::FDRSBase(uint8_t gtwy_mac,uint8_t reading_id):
|
||||
_gtwy_mac(gtwy_mac),
|
||||
_espnow_size(250 / sizeof(DataReading)),
|
||||
_espnow_size(250 / sizeof(DataReading_t)),
|
||||
_reading_id(reading_id),
|
||||
_data_count(0)
|
||||
{
|
||||
fdrsData = new DataReading[_espnow_size];
|
||||
fdrsData = new DataReading_t[_espnow_size];
|
||||
}
|
||||
|
||||
FDRSBase::~FDRSBase(){
|
||||
@ -53,7 +53,7 @@ void FDRSBase::load(float data, uint8_t type) {
|
||||
if (_data_count > _espnow_size){
|
||||
send();
|
||||
}
|
||||
DataReading dr;
|
||||
DataReading_t dr;
|
||||
dr.id = _reading_id;
|
||||
dr.type = type;
|
||||
dr.data = data;
|
||||
@ -121,8 +121,8 @@ void FDRS_EspNow::init(void){
|
||||
DBG(" ESP-NOW Initialized.");
|
||||
}
|
||||
|
||||
void FDRS_EspNow::transmit(DataReading *fdrsData, uint8_t _data_count){
|
||||
esp_now_send(_gatewayAddress, (uint8_t *) fdrsData, _data_count * sizeof(DataReading));
|
||||
void FDRS_EspNow::transmit(DataReading_t *fdrsData, uint8_t _data_count){
|
||||
esp_now_send(_gatewayAddress, (uint8_t *) fdrsData, _data_count * sizeof(DataReading_t));
|
||||
delay(5);
|
||||
DBG(" ESP-NOW sent.");
|
||||
}
|
||||
@ -164,17 +164,17 @@ void FDRSLoRa::init(void){
|
||||
DBG("LoRa Initialized.");
|
||||
}
|
||||
|
||||
void FDRSLoRa::buildPacket(uint8_t* mac, DataReading * packet, uint8_t len) {
|
||||
uint8_t pkt[5 + (len * sizeof(DataReading))];
|
||||
void FDRSLoRa::buildPacket(uint8_t* mac, DataReading_t * packet, uint8_t len) {
|
||||
uint8_t pkt[5 + (len * sizeof(DataReading_t))];
|
||||
memcpy(&pkt, mac, 3); //
|
||||
memcpy(&pkt[3], &LoRaAddress, 2);
|
||||
memcpy(&pkt[5], packet, len * sizeof(DataReading));
|
||||
memcpy(&pkt[5], packet, len * sizeof(DataReading_t));
|
||||
LoRa.beginPacket();
|
||||
LoRa.write((uint8_t*)&pkt, sizeof(pkt));
|
||||
LoRa.endPacket();
|
||||
}
|
||||
|
||||
void FDRSLoRa::transmit(DataReading *fdrsData, uint8_t _data_count){
|
||||
void FDRSLoRa::transmit(DataReading_t *fdrsData, uint8_t _data_count){
|
||||
buildPacket(_gatewayAddress, fdrsData, _data_count);
|
||||
DBG(" LoRa sent.");
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ private:
|
||||
const uint16_t _espnow_size;
|
||||
uint8_t _reading_id;
|
||||
uint8_t _data_count;
|
||||
DataReading *fdrsData;
|
||||
DataReading_t *fdrsData;
|
||||
|
||||
virtual void init(void) = 0;
|
||||
virtual void transmit(DataReading *fdrsData, uint8_t _data_count) = 0;
|
||||
virtual void transmit(DataReading_t *fdrsData, uint8_t _data_count) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ public:
|
||||
private:
|
||||
|
||||
uint8_t _gatewayAddress[ESP_GATEWAY_ADDRESS_SIZE];
|
||||
void transmit(DataReading *fdrsData, uint8_t _data_count) override;
|
||||
void transmit(DataReading_t *fdrsData, uint8_t _data_count) override;
|
||||
void init(void) override;
|
||||
|
||||
};
|
||||
@ -132,8 +132,8 @@ private:
|
||||
uint32_t _band;
|
||||
uint8_t _sf;
|
||||
|
||||
void buildPacket(uint8_t* mac, DataReading * packet, uint8_t len);
|
||||
void transmit(DataReading *fdrsData, uint8_t _data_count) override;
|
||||
void buildPacket(uint8_t* mac, DataReading_t * packet, uint8_t len);
|
||||
void transmit(DataReading_t *fdrsData, uint8_t _data_count) override;
|
||||
void init(void) override;
|
||||
|
||||
};
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct __attribute__((packed)) DataReading {
|
||||
typedef struct __attribute__((packed)) DataReading_t {
|
||||
float data;
|
||||
uint16_t id;
|
||||
uint8_t type;
|
||||
} DataReading;
|
||||
} DataReading_t;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user