1515 * limitations under the License.
1616 */
1717
18- #ifndef NIMBLE_CPP_STREAM_H
19- #define NIMBLE_CPP_STREAM_H
18+ #ifdef ESP_PLATFORM
19+ # ifndef NIMBLE_CPP_STREAM_H
20+ # define NIMBLE_CPP_STREAM_H
2021
21- #include " syscfg/syscfg.h"
22- #if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
22+ # include " syscfg/syscfg.h"
23+ # if CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
2324
24- # include " NimBLEUUID.h"
25- # include < freertos/FreeRTOS.h>
26- # include < freertos/ringbuf.h>
25+ # include " NimBLEUUID.h"
26+ # include < freertos/FreeRTOS.h>
27+ # include < freertos/ringbuf.h>
2728
28- # if NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
29- # include < Stream.h>
30- # else
29+ # if NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
30+ # include < Stream.h>
31+ # else
3132// Minimal Stream/Print stubs when Arduino not available
3233class Print {
3334 public:
@@ -50,7 +51,7 @@ class Stream : public Print {
5051 protected:
5152 unsigned long m_timeout{0 };
5253};
53- # endif
54+ # endif
5455
5556class NimBLEStream : public Stream {
5657 public:
@@ -104,13 +105,13 @@ class NimBLEStream : public Stream {
104105 mutable bool m_hasPeek{false };
105106};
106107
107- # if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
108- # include " NimBLECharacteristic.h"
108+ # if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
109+ # include " NimBLECharacteristic.h"
109110
110111class NimBLEStreamServer : public NimBLEStream {
111112 public:
112113 NimBLEStreamServer () : m_charCallbacks(this ) {}
113- ~NimBLEStreamServer () = default ;
114+ ~NimBLEStreamServer () = default ;
114115 // non-copyable
115116 NimBLEStreamServer (const NimBLEStreamServer&) = delete ;
116117 NimBLEStreamServer& operator =(const NimBLEStreamServer&) = delete ;
@@ -152,15 +153,15 @@ class NimBLEStreamServer : public NimBLEStream {
152153 NimBLECharacteristic* m_pChr{nullptr };
153154 int m_rc{0 };
154155};
155- # endif // BLE_ROLE_PERIPHERAL
156+ # endif // BLE_ROLE_PERIPHERAL
156157
157- # if MYNEWT_VAL(BLE_ROLE_CENTRAL)
158- # include " NimBLERemoteCharacteristic.h"
158+ # if MYNEWT_VAL(BLE_ROLE_CENTRAL)
159+ # include " NimBLERemoteCharacteristic.h"
159160
160161class NimBLEStreamClient : public NimBLEStream {
161162 public:
162- NimBLEStreamClient () = default ;
163- ~NimBLEStreamClient () = default ;
163+ NimBLEStreamClient () = default ;
164+ ~NimBLEStreamClient () = default ;
164165 // non-copyable
165166 NimBLEStreamClient (const NimBLEStreamClient&) = delete ;
166167 NimBLEStreamClient& operator =(const NimBLEStreamClient&) = delete ;
@@ -182,38 +183,38 @@ class NimBLEStreamClient : public NimBLEStream {
182183 bool m_writeWithRsp{false };
183184 NimBLERemoteCharacteristic::notify_callback m_userNotifyCallback{nullptr };
184185};
185- # endif // BLE_ROLE_CENTRAL
186-
187- #endif // CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
186+ # endif // BLE_ROLE_CENTRAL
188187
188+ # endif // CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
189189
190190// These logging macros exist to provide log output over UART so that it stream classes can
191191// be used to redirect logs without causing recursion issues.
192192static int uart_log_printfv (const char * format, va_list arg);
193193static int uart_log_printf (const char * format, ...);
194194
195- #if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 4
196- # define NIMBLE_UART_LOGD (tag, format, ...) uart_log_printf(" D %s: " format " \n " , tag, ##__VA_ARGS__)
197- #else
198- # define NIMBLE_UART_LOGD (tag, format, ...) (void )tag
199- #endif
200-
201- #if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 3
202- # define NIMBLE_UART_LOGI (tag, format, ...) uart_log_printf(" I %s: " format " \n " , tag, ##__VA_ARGS__)
203- #else
204- # define NIMBLE_UART_LOGI (tag, format, ...) (void )tag
205- #endif
206-
207- #if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 2
208- # define NIMBLE_UART_LOGW (tag, format, ...) uart_log_printf(" W %s: " format " \n " , tag, ##__VA_ARGS__)
209- #else
210- # define NIMBLE_UART_LOGW (tag, format, ...) (void )tag
211- #endif
212-
213- #if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 1
214- # define NIMBLE_UART_LOGE (tag, format, ...) uart_log_printf(" E %s: " format " \n " , tag, ##__VA_ARGS__)
215- #else
216- # define NIMBLE_UART_LOGE (tag, format, ...) (void )tag
217- #endif
218-
219- #endif // NIMBLE_CPP_STREAM_H
195+ # if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 4
196+ # define NIMBLE_UART_LOGD (tag, format, ...) uart_log_printf(" D %s: " format " \n " , tag, ##__VA_ARGS__)
197+ # else
198+ # define NIMBLE_UART_LOGD (tag, format, ...) (void )tag
199+ # endif
200+
201+ # if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 3
202+ # define NIMBLE_UART_LOGI (tag, format, ...) uart_log_printf(" I %s: " format " \n " , tag, ##__VA_ARGS__)
203+ # else
204+ # define NIMBLE_UART_LOGI (tag, format, ...) (void )tag
205+ # endif
206+
207+ # if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 2
208+ # define NIMBLE_UART_LOGW (tag, format, ...) uart_log_printf(" W %s: " format " \n " , tag, ##__VA_ARGS__)
209+ # else
210+ # define NIMBLE_UART_LOGW (tag, format, ...) (void )tag
211+ # endif
212+
213+ # if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 1
214+ # define NIMBLE_UART_LOGE (tag, format, ...) uart_log_printf(" E %s: " format " \n " , tag, ##__VA_ARGS__)
215+ # else
216+ # define NIMBLE_UART_LOGE (tag, format, ...) (void )tag
217+ # endif
218+
219+ # endif // NIMBLE_CPP_STREAM_H
220+ #endif // ESP_PLATFORM
0 commit comments