File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,8 @@ static void bleLoop()
150
150
rtos::Thread bleLoopThread;
151
151
152
152
153
- HCICordioTransportClass::HCICordioTransportClass ()
153
+ HCICordioTransportClass::HCICordioTransportClass () :
154
+ _begun(false )
154
155
{
155
156
}
156
157
@@ -172,6 +173,8 @@ int HCICordioTransportClass::begin()
172
173
173
174
CordioHCIHook::setDataReceivedHandler (HCICordioTransportClass::onDataReceived);
174
175
176
+ _begun = true ;
177
+
175
178
return 1 ;
176
179
}
177
180
@@ -180,6 +183,8 @@ void HCICordioTransportClass::end()
180
183
bleLoopThread.terminate ();
181
184
182
185
CordioHCIHook::getDriver ().terminate ();
186
+
187
+ _begun = false ;
183
188
}
184
189
185
190
void HCICordioTransportClass::wait (unsigned long timeout)
@@ -208,12 +213,16 @@ int HCICordioTransportClass::read()
208
213
209
214
size_t HCICordioTransportClass::write (const uint8_t * data, size_t length)
210
215
{
216
+ if (!_begun) {
217
+ return 0 ;
218
+ }
219
+
211
220
uint8_t packetLength = length - 1 ;
212
221
uint8_t packetType = data[0 ];
213
222
214
223
#if CORDIO_ZERO_COPY_HCI
215
224
uint8_t * packet = (uint8_t *)WsfMsgAlloc (max (packetLength, MIN_WSF_ALLOC));
216
-
225
+
217
226
memcpy (packet, &data[1 ], packetLength);
218
227
219
228
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 {
47
47
void handleRxData (uint8_t * data, uint8_t len);
48
48
49
49
private:
50
+ bool _begun;
50
51
RingBufferN<256 > _rxBuf;
51
52
};
52
53
You can’t perform that action at this time.
0 commit comments