-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathBLEEddystoneTLM.h
61 lines (55 loc) · 1.63 KB
/
BLEEddystoneTLM.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* BLEEddystoneTLM.cpp
*
* Created on: Mar 12, 2018
* Author: pcbreflux
*/
#ifndef _BLEEddystoneTLM_H_
#define _BLEEddystoneTLM_H_
#include "soc/soc_caps.h"
#if SOC_BLE_SUPPORTED
#include "BLEUUID.h"
#include <BLEAdvertisedDevice.h>
#define EDDYSTONE_TLM_FRAME_TYPE 0x20
#define ENDIAN_CHANGE_U16(x) ((((x) & 0xFF00) >> 8) + (((x) & 0xFF) << 8))
#define ENDIAN_CHANGE_U32(x) ((((x) & 0xFF000000) >> 24) + (((x) & 0x00FF0000) >> 8)) + ((((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24))
#define EDDYSTONE_TEMP_U16_TO_FLOAT(tempU16) (((int16_t)ENDIAN_CHANGE_U16(tempU16)) / 256.0f)
#define EDDYSTONE_TEMP_FLOAT_TO_U16(tempFloat) (ENDIAN_CHANGE_U16(((int)((tempFloat) * 256))))
/**
* @brief Representation of a beacon.
* See:
* * https://github.com/google/eddystone
*/
class BLEEddystoneTLM {
public:
BLEEddystoneTLM();
BLEEddystoneTLM(BLEAdvertisedDevice *advertisedDevice);
String getData();
BLEUUID getUUID();
uint8_t getVersion();
uint16_t getVolt();
float getTemp();
uint16_t getRawTemp();
uint32_t getCount();
uint32_t getTime();
String toString();
void setData(String data);
void setUUID(BLEUUID l_uuid);
void setVersion(uint8_t version);
void setVolt(uint16_t volt);
void setTemp(float temp);
void setCount(uint32_t advCount);
void setTime(uint32_t tmil);
private:
BLEUUID beaconUUID;
struct {
uint8_t frameType;
uint8_t version;
uint16_t volt;
uint16_t temp;
uint32_t advCount;
uint32_t tmil;
} __attribute__((packed)) m_eddystoneData;
}; // BLEEddystoneTLM
#endif /* SOC_BLE_SUPPORTED */
#endif /* _BLEEddystoneTLM_H_ */