3131# include < type_traits>
3232# include < cstdarg>
3333
34+ # ifndef NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
35+ # if defined __has_include
36+ # if __has_include(<Arduino.h>)
37+ # define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE (1 )
38+ # else
39+ # define NIMBLE_CPP_ARDUINO_STRING_AVAILABLE (0 )
40+ # endif
41+ # endif
42+ # endif
43+
3444# if NIMBLE_CPP_ARDUINO_STRING_AVAILABLE
3545# include < Stream.h>
3646# else
@@ -100,7 +110,7 @@ class NimBLEStream : public Stream {
100110 */
101111 void setRxOverflowCallback (RxOverflowCallback cb, void * userArg = nullptr ) {
102112 m_rxOverflowCallback = cb;
103- m_rxOverflowUserArg = userArg;
113+ m_rxOverflowUserArg = userArg;
104114 }
105115
106116 operator bool () const { return ready (); }
@@ -118,17 +128,17 @@ class NimBLEStream : public Stream {
118128 static void txDrainEventCb (struct ble_npl_event * ev);
119129 static void txDrainCalloutCb (struct ble_npl_event * ev);
120130
121- ByteRingBuffer* m_txBuf{nullptr };
122- ByteRingBuffer* m_rxBuf{nullptr };
123- uint8_t m_txChunkBuf[MYNEWT_VAL (BLE_ATT_PREFERRED_MTU )];
124- uint32_t m_txBufSize{1024 };
125- uint32_t m_rxBufSize{1024 };
126- ble_npl_event m_txDrainEvent{};
127- ble_npl_callout m_txDrainCallout{};
131+ ByteRingBuffer* m_txBuf{nullptr };
132+ ByteRingBuffer* m_rxBuf{nullptr };
133+ uint8_t m_txChunkBuf[MYNEWT_VAL (BLE_ATT_PREFERRED_MTU )];
134+ uint32_t m_txBufSize{1024 };
135+ uint32_t m_rxBufSize{1024 };
136+ ble_npl_event m_txDrainEvent{};
137+ ble_npl_callout m_txDrainCallout{};
128138 RxOverflowCallback m_rxOverflowCallback{nullptr };
129- void * m_rxOverflowUserArg{nullptr };
130- bool m_coInitialized{false };
131- bool m_eventInitialized{false };
139+ void * m_rxOverflowUserArg{nullptr };
140+ bool m_coInitialized{false };
141+ bool m_eventInitialized{false };
132142};
133143
134144# if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
@@ -203,13 +213,13 @@ class NimBLEStreamClient : public NimBLEStream {
203213
204214 // Attach a discovered remote characteristic; app owns discovery/connection.
205215 // Set subscribeNotify=true to receive notifications into RX buffer.
206- bool begin (NimBLERemoteCharacteristic* pChr,
207- bool subscribeNotify = false ,
208- uint32_t txBufSize = 1024 ,
209- uint32_t rxBufSize = 1024 );
210- void end () override ;
211- void setNotifyCallback (NimBLERemoteCharacteristic::notify_callback cb) { m_userNotifyCallback = cb; }
212- bool ready () const override ;
216+ bool begin (NimBLERemoteCharacteristic* pChr,
217+ bool subscribeNotify = false ,
218+ uint32_t txBufSize = 1024 ,
219+ uint32_t rxBufSize = 1024 );
220+ void end () override ;
221+ void setNotifyCallback (NimBLERemoteCharacteristic::notify_callback cb) { m_userNotifyCallback = cb; }
222+ bool ready () const override ;
213223 virtual void flush () override ;
214224
215225 using NimBLEStream::write; // Inherit template write overloads
0 commit comments