-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageChunkPacket.hpp
31 lines (24 loc) · 1.03 KB
/
ImageChunkPacket.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef __IMAGECHUNKPACKET_HPP_
#define __IMAGECHUNKPACKET_HPP_
#include <array>
#include "Position.hpp"
#include "settings.hpp"
struct ImageChunkPacket { // Image identified by <nodeID, timestamp>
uint8_t nodeID=0;
uint32_t timestamp;
Position position;
uint32_t offset;
uint32_t sizeImage;
std::array<char,IMG_CHUNK_SIZE> chunk_content;
ImageChunkPacket(uint8_t nodeID, uint32_t timestamp, uint32_t offset, uint32_t sizeImage, std::array<char,IMG_CHUNK_SIZE> chunk_content) :
nodeID(nodeID), timestamp(timestamp), position(), offset(offset), sizeImage(sizeImage), chunk_content(chunk_content) {}
ImageChunkPacket() :
nodeID(0), timestamp(0), position(), offset(0), sizeImage(0), chunk_content() {}
std::string repr() const {
const size_t len=256;
char buffer[len];
snprintf(buffer, len, "{nodeID=%d|offset=%d|timestamp=%d|Pos=(%f,%f)|sizeImage=%d}", nodeID, offset, timestamp, position.longitude, position.latitude, sizeImage);
return buffer;
}
};
#endif