File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
examples/Peripheral/throughput Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,12 @@ void bleuart_rx_callback(uint16_t conn_hdl)
157
157
rxStartTime = millis ();
158
158
}
159
159
160
- rxCount += bleuart.available ();
160
+ uint32_t count = bleuart.available ();
161
+
162
+ rxCount += count;
161
163
bleuart.flush (); // empty rx fifo
164
+
165
+ Serial.printf (" RX %d bytes\n " , count);
162
166
}
163
167
164
168
void bleuart_notify_callback (uint16_t conn_hdl, bool enabled)
@@ -219,12 +223,11 @@ void loop(void)
219
223
{
220
224
getUserInput ();
221
225
test_throughput ();
222
-
223
226
}
224
227
225
228
// 3 seconds has passed and there is no data received
226
229
// then reset rx count
227
- if ( (rxCount > 0 ) && (rxLastTime + 3000 < millis ()) )
230
+ if ( (rxCount > 0 ) && (rxLastTime + 1000 < millis ()) )
228
231
{
229
232
print_speed (" Received " , rxCount, rxLastTime-rxStartTime);
230
233
rxCount = 0 ;
Original file line number Diff line number Diff line change @@ -192,6 +192,24 @@ int BLEUart::read(uint8_t * buf, size_t size)
192
192
return _rx_fifo->read (buf, size);
193
193
}
194
194
195
+ uint8_t BLEUart::read8 (void )
196
+ {
197
+ uint8_t num;
198
+ return read (&num, sizeof (num)) ? num : 0 ;
199
+ }
200
+
201
+ uint16_t BLEUart::read16 (void )
202
+ {
203
+ uint16_t num;
204
+ return read ((uint8_t *) &num, sizeof (num)) ? num : 0 ;
205
+ }
206
+
207
+ uint32_t BLEUart::read32 (void )
208
+ {
209
+ uint32_t num;
210
+ return read ((uint8_t *) &num, sizeof (num)) ? num : 0 ;
211
+ }
212
+
195
213
size_t BLEUart::write (uint8_t b)
196
214
{
197
215
return this ->write (Bluefruit.connHandle (), &b, 1 );
Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ class BLEUart : public BLEService, public Stream
70
70
bool flushTXD (void );
71
71
bool flushTXD (uint16_t conn_hdl);
72
72
73
+ // Read helper
74
+ uint8_t read8 (void );
75
+ uint16_t read16 (void );
76
+ uint32_t read32 (void );
77
+
73
78
// Stream API
74
79
virtual int read ( void );
75
80
virtual int read ( uint8_t * buf, size_t size );
You can’t perform that action at this time.
0 commit comments