NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEEddystoneTLM.h
1/*
2 * Copyright 2020-2024 Ryan Powell <ryan@nable-embedded.io> and
3 * esp-nimble-cpp, NimBLE-Arduino contributors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NIMBLE_CPP_EDDYSTONETLM_H_
19#define NIMBLE_CPP_EDDYSTONETLM_H_
20
21#include "nimconfig.h"
22#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
23
24class NimBLEUUID;
25
26# include <string>
27
28# define EDDYSTONE_TLM_FRAME_TYPE 0x20
29
36 public:
37 struct BeaconData {
38 uint8_t frameType{EDDYSTONE_TLM_FRAME_TYPE};
39 uint8_t version{0};
40 uint16_t volt{3300};
41 uint16_t temp{23 * 256};
42 uint32_t advCount{0};
43 uint32_t tmil{0};
44 } __attribute__((packed));
45
46 const BeaconData getData();
48 uint8_t getVersion();
49 uint16_t getVolt();
50 int16_t getTemp();
51 uint32_t getCount();
52 uint32_t getTime();
53 std::string toString();
54 void setData(const uint8_t* data, uint8_t length);
55 void setData(const BeaconData& data);
56 void setUUID(const NimBLEUUID& l_uuid);
57 void setVersion(uint8_t version);
58 void setVolt(uint16_t volt);
59 void setTemp(int16_t temp);
60 void setCount(uint32_t advCount);
61 void setTime(uint32_t tmil);
62
63 private:
64 uint16_t beaconUUID{0xFEAA};
65 BeaconData m_eddystoneData;
66
67}; // NimBLEEddystoneTLM
68
69#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
70#endif // NIMBLE_CPP_EDDYSTONETLM_H_
Representation of a beacon. See:
Definition NimBLEEddystoneTLM.h:35
void setData(const uint8_t *data, uint8_t length)
Set the raw data for the beacon advertisement.
Definition NimBLEEddystoneTLM.cpp:148
void setVersion(uint8_t version)
Set the version to advertise.
Definition NimBLEEddystoneTLM.cpp:183
const BeaconData getData()
Retrieve the data that is being advertised.
Definition NimBLEEddystoneTLM.cpp:35
void setUUID(const NimBLEUUID &l_uuid)
Set the UUID to advertise.
Definition NimBLEEddystoneTLM.cpp:171
uint32_t getCount()
Get the count of advertisements sent.
Definition NimBLEEddystoneTLM.cpp:75
void setCount(uint32_t advCount)
Set the advertisement count.
Definition NimBLEEddystoneTLM.cpp:207
int16_t getTemp()
Get the temperature being advertised.
Definition NimBLEEddystoneTLM.cpp:67
std::string toString()
Get a string representation of the beacon.
Definition NimBLEEddystoneTLM.cpp:91
void setTime(uint32_t tmil)
Set the advertisement time.
Definition NimBLEEddystoneTLM.cpp:215
NimBLEUUID getUUID()
Get the UUID being advertised.
Definition NimBLEEddystoneTLM.cpp:43
uint32_t getTime()
Get the advertisement time.
Definition NimBLEEddystoneTLM.cpp:83
void setVolt(uint16_t volt)
Set the battery voltage to advertise.
Definition NimBLEEddystoneTLM.cpp:191
uint8_t getVersion()
Get the version being advertised.
Definition NimBLEEddystoneTLM.cpp:51
void setTemp(int16_t temp)
Set the temperature to advertise.
Definition NimBLEEddystoneTLM.cpp:199
uint16_t getVolt()
Get the battery voltage.
Definition NimBLEEddystoneTLM.cpp:59
A model of a BLE UUID.
Definition NimBLEUUID.h:41