Farm-Data-Relay-System/fdrs_types.h

36 lines
582 B
C
Raw Normal View History

2022-06-21 19:04:05 +00:00
#ifndef __FDRS_TYPES_H__
2022-06-21 19:12:46 +00:00
#define __FDRS_TYPES_H__
2022-06-21 19:04:05 +00:00
2022-06-22 23:06:13 +00:00
#include <stdint.h>
2022-06-23 20:31:51 +00:00
#include <string.h>
2022-06-22 23:06:13 +00:00
typedef struct __attribute__((packed)) DataReading_t {
2022-06-21 19:04:05 +00:00
float data;
uint16_t id;
uint8_t type;
2022-06-22 23:06:13 +00:00
DataReading_t(): data(0.0),id(0),type(0){
}
} DataReading_t;
2022-06-24 15:40:06 +00:00
typedef struct Peer_t{
2022-06-23 20:31:51 +00:00
uint8_t peer[6];
2022-06-24 15:40:06 +00:00
Peer_t(){
2022-06-23 20:31:51 +00:00
memset(peer,0,6);
}
void _copy(uint8_t p[6]){
memcpy(peer,p,6);
}
uint8_t *_data(void){
return peer;
}
2022-06-24 15:40:06 +00:00
bool operator==(Peer_t c){
2022-06-24 18:39:18 +00:00
return (memcmp(this->peer,c.peer,6) == 0);
2022-06-24 15:40:06 +00:00
}
}Peer_t;
2022-06-23 20:31:51 +00:00
2022-06-21 19:04:05 +00:00
#endif