Skip to content

Commit ccea428

Browse files
committed
Refactor include directives to use different paths for arduino/idf.
* Sets macros to allow compiling when Central role is enabled and Observer disabled, or Peripheral enabled and Broadcaster disabled. * Adds a macro definition for CONFIG_NIMBLE_CPP_IDF to enable different include paths/functionality for IDF / Arduino.
1 parent e238a18 commit ccea428

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+188
-190
lines changed

src/NimBLE2904.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
* See also:
1717
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
1818
*/
19-
#include "sdkconfig.h"
20-
#if defined(CONFIG_BT_ENABLED)
21-
2219
#include "nimconfig.h"
23-
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
20+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
2421

2522
#include "NimBLE2904.h"
2623

@@ -86,5 +83,4 @@ void NimBLE2904::setUnit(uint16_t unit) {
8683
setValue((uint8_t*) &m_data, sizeof(m_data));
8784
} // setUnit
8885

89-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
90-
#endif
86+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

src/NimBLE2904.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414

1515
#ifndef MAIN_NIMBLE2904_H_
1616
#define MAIN_NIMBLE2904_H_
17-
#include "sdkconfig.h"
18-
#if defined(CONFIG_BT_ENABLED)
19-
2017
#include "nimconfig.h"
21-
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
18+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
2219

2320
#include "NimBLEDescriptor.h"
2421

@@ -82,6 +79,5 @@ class NimBLE2904: public NimBLEDescriptor {
8279
BLE2904_Data m_data;
8380
}; // BLE2904
8481

85-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
86-
#endif /* CONFIG_BT_ENABLED */
82+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
8783
#endif /* MAIN_NIMBLE2904_H_ */

src/NimBLEAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Created on: Jul 2, 2017
1212
* Author: kolban
1313
*/
14-
#include "sdkconfig.h"
14+
#include "nimconfig.h"
1515
#if defined(CONFIG_BT_ENABLED)
1616

1717
#include <algorithm>

src/NimBLEAddress.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414

1515
#ifndef COMPONENTS_NIMBLEADDRESS_H_
1616
#define COMPONENTS_NIMBLEADDRESS_H_
17-
#include "sdkconfig.h"
17+
#include "nimconfig.h"
1818
#if defined(CONFIG_BT_ENABLED)
1919

20+
#if defined(CONFIG_NIMBLE_CPP_IDF)
2021
#include "nimble/ble.h"
22+
#else
23+
#include "nimble/nimble/include/nimble/ble.h"
24+
#endif
25+
2126
/**** FIX COMPILATION ****/
2227
#undef min
2328
#undef max

src/NimBLEAdvertisedDevice.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414

1515
#ifndef COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
1616
#define COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
17-
#include "sdkconfig.h"
18-
#if defined(CONFIG_BT_ENABLED)
19-
2017
#include "nimconfig.h"
21-
#if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
18+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
2219

2320
#include "NimBLEAddress.h"
2421
#include "NimBLEScan.h"
2522
#include "NimBLEUUID.h"
2623

24+
#if defined(CONFIG_NIMBLE_CPP_IDF)
2725
#include "host/ble_hs_adv.h"
26+
#else
27+
#include "nimble/nimble/host/include/host/ble_hs_adv.h"
28+
#endif
2829

2930
#include <map>
3031
#include <vector>
@@ -171,6 +172,5 @@ class NimBLEAdvertisedDeviceCallbacks {
171172
virtual void onResult(NimBLEAdvertisedDevice* advertisedDevice) = 0;
172173
};
173174

174-
#endif // #if defined( CONFIG_BT_NIMBLE_ROLE_CENTRAL)
175-
#endif /* CONFIG_BT_ENABLED */
175+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER */
176176
#endif /* COMPONENTS_NIMBLEADVERTISEDDEVICE_H_ */

src/NimBLEAdvertising.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* Author: kolban
1414
*
1515
*/
16-
#include "sdkconfig.h"
17-
#if defined(CONFIG_BT_ENABLED)
18-
1916
#include "nimconfig.h"
20-
#if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
17+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
2118

19+
#if defined(CONFIG_NIMBLE_CPP_IDF)
2220
#include "services/gap/ble_svc_gap.h"
21+
#else
22+
#include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
23+
#endif
2324
#include "NimBLEAdvertising.h"
2425
#include "NimBLEDevice.h"
2526
#include "NimBLEServer.h"
@@ -1028,5 +1029,4 @@ std::string NimBLEAdvertisementData::getPayload() {
10281029
return m_payload;
10291030
} // getPayload
10301031

1031-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
1032-
#endif /* CONFIG_BT_ENABLED */
1032+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER */

src/NimBLEAdvertising.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414

1515
#ifndef MAIN_BLEADVERTISING_H_
1616
#define MAIN_BLEADVERTISING_H_
17-
#include "sdkconfig.h"
18-
#if defined(CONFIG_BT_ENABLED)
19-
2017
#include "nimconfig.h"
21-
#if defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
18+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
2219

20+
#if defined(CONFIG_NIMBLE_CPP_IDF)
2321
#include "host/ble_gap.h"
22+
#else
23+
#include "nimble/nimble/host/include/host/ble_gap.h"
24+
#endif
25+
2426
/**** FIX COMPILATION ****/
2527
#undef min
2628
#undef max
@@ -132,6 +134,5 @@ class NimBLEAdvertising {
132134
std::vector<uint8_t> m_uri;
133135
};
134136

135-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
136-
#endif /* CONFIG_BT_ENABLED */
137+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER */
137138
#endif /* MAIN_BLEADVERTISING_H_ */

src/NimBLEBeacon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Created on: Jan 4, 2018
1212
* Author: kolban
1313
*/
14-
#include "sdkconfig.h"
14+
#include "nimconfig.h"
1515
#if defined(CONFIG_BT_ENABLED)
1616

1717
#include <string.h>

src/NimBLECharacteristic.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
* Created on: Jun 22, 2017
1010
* Author: kolban
1111
*/
12-
#include "sdkconfig.h"
13-
#if defined(CONFIG_BT_ENABLED)
1412

1513
#include "nimconfig.h"
16-
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
14+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
1715

1816
#include "NimBLECharacteristic.h"
1917
#include "NimBLE2904.h"
@@ -641,6 +639,4 @@ void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacter
641639
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
642640
}
643641

644-
645-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
646-
#endif /* CONFIG_BT_ENABLED */
642+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

src/NimBLECharacteristic.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
#ifndef MAIN_NIMBLECHARACTERISTIC_H_
1515
#define MAIN_NIMBLECHARACTERISTIC_H_
16-
#include "sdkconfig.h"
17-
#if defined(CONFIG_BT_ENABLED)
18-
1916
#include "nimconfig.h"
20-
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
17+
#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
2118

19+
#if defined(CONFIG_NIMBLE_CPP_IDF)
2220
#include "host/ble_hs.h"
21+
#else
22+
#include "nimble/nimble/host/include/host/ble_hs.h"
23+
#endif
24+
2325
/**** FIX COMPILATION ****/
2426
#undef min
2527
#undef max
@@ -195,6 +197,5 @@ class NimBLECharacteristicCallbacks {
195197
virtual void onSubscribe(NimBLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc, uint16_t subValue);
196198
};
197199

198-
#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
199-
#endif /* CONFIG_BT_ENABLED */
200+
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
200201
#endif /*MAIN_NIMBLECHARACTERISTIC_H_*/

0 commit comments

Comments
 (0)