File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,8 @@ static void bleLoop()
150150rtos::Thread bleLoopThread;
151151
152152
153- HCICordioTransportClass::HCICordioTransportClass ()
153+ HCICordioTransportClass::HCICordioTransportClass () :
154+ _begun(false )
154155{
155156}
156157
@@ -172,6 +173,8 @@ int HCICordioTransportClass::begin()
172173
173174 CordioHCIHook::setDataReceivedHandler (HCICordioTransportClass::onDataReceived);
174175
176+ _begun = true ;
177+
175178 return 1 ;
176179}
177180
@@ -180,6 +183,8 @@ void HCICordioTransportClass::end()
180183 bleLoopThread.terminate ();
181184
182185 CordioHCIHook::getDriver ().terminate ();
186+
187+ _begun = false ;
183188}
184189
185190void HCICordioTransportClass::wait (unsigned long timeout)
@@ -208,12 +213,16 @@ int HCICordioTransportClass::read()
208213
209214size_t HCICordioTransportClass::write (const uint8_t * data, size_t length)
210215{
216+ if (!_begun) {
217+ return 0 ;
218+ }
219+
211220 uint8_t packetLength = length - 1 ;
212221 uint8_t packetType = data[0 ];
213222
214223#if CORDIO_ZERO_COPY_HCI
215224 uint8_t * packet = (uint8_t *)WsfMsgAlloc (max (packetLength, MIN_WSF_ALLOC));
216-
225+
217226 memcpy (packet, &data[1 ], packetLength);
218227
219228 return CordioHCIHook::getTransportDriver ().write (packetType, packetLength, packet);
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class HCICordioTransportClass : public HCITransportInterface {
4747 void handleRxData (uint8_t * data, uint8_t len);
4848
4949private:
50+ bool _begun;
5051 RingBufferN<256 > _rxBuf;
5152};
5253
You can’t perform that action at this time.
0 commit comments