Skip to content

Commit 8baa5cd

Browse files
committed
Add exclusive NimBLE headers
1 parent 8db73d6 commit 8baa5cd

8 files changed

+1209
-0
lines changed
+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2020-2024 Ryan Powell <[email protected]> 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_ADVERTISEMENT_DATA_H_
19+
#define NIMBLE_CPP_ADVERTISEMENT_DATA_H_
20+
21+
#include "sdkconfig.h"
22+
#if (defined(CONFIG_NIMBLE_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) && !CONFIG_BT_NIMBLE_EXT_ADV)
23+
24+
#include <cstdint>
25+
#include <string>
26+
#include <vector>
27+
28+
class BLEUUID;
29+
/**
30+
* @brief Advertisement data set by the programmer to be published by the BLE server.
31+
*/
32+
class BLEAdvertisementData {
33+
// Only a subset of the possible BLE architected advertisement fields are currently exposed. Others will
34+
// be exposed on demand/request or as time permits.
35+
//
36+
public:
37+
bool addData(const uint8_t *data, size_t length);
38+
bool addData(const std::vector<uint8_t> &data);
39+
bool setAppearance(uint16_t appearance);
40+
bool setFlags(uint8_t);
41+
bool addTxPower();
42+
bool setPreferredParams(uint16_t minInterval, uint16_t maxInterval);
43+
bool addServiceUUID(const BLEUUID &serviceUUID);
44+
bool addServiceUUID(const char *serviceUUID);
45+
bool removeServiceUUID(const BLEUUID &serviceUUID);
46+
bool removeServiceUUID(const char *serviceUUID);
47+
bool removeServices();
48+
bool setManufacturerData(const uint8_t *data, size_t length);
49+
bool setManufacturerData(const std::string &data);
50+
bool setManufacturerData(const std::vector<uint8_t> &data);
51+
bool setURI(const std::string &uri);
52+
bool setName(const std::string &name, bool isComplete = true);
53+
bool setShortName(const std::string &name);
54+
bool setCompleteServices(const BLEUUID &uuid);
55+
bool setCompleteServices16(const std::vector<BLEUUID> &uuids);
56+
bool setCompleteServices32(const std::vector<BLEUUID> &uuids);
57+
bool setPartialServices(const BLEUUID &uuid);
58+
bool setPartialServices16(const std::vector<BLEUUID> &uuids);
59+
bool setPartialServices32(const std::vector<BLEUUID> &uuids);
60+
bool setServiceData(const BLEUUID &uuid, const uint8_t *data, size_t length);
61+
bool setServiceData(const BLEUUID &uuid, const std::string &data);
62+
bool setServiceData(const BLEUUID &uuid, const std::vector<uint8_t> &data);
63+
bool removeData(uint8_t type);
64+
void clearData();
65+
int getDataLocation(uint8_t type) const;
66+
67+
std::string toString() const;
68+
std::vector<uint8_t> getPayload() const;
69+
70+
private:
71+
friend class BLEAdvertising;
72+
73+
bool setServices(bool complete, uint8_t size, const std::vector<BLEUUID> &v_uuid);
74+
std::vector<uint8_t> m_payload{};
75+
}; // BLEAdvertisementData
76+
77+
#endif // CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV
78+
#endif // NIMBLE_CPP_ADVERTISEMENT_DATA_H_

0 commit comments

Comments
 (0)