Skip to content

Commit 4bcaf05

Browse files
committed
update throughput for testing
1 parent c493154 commit 4bcaf05

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/throughput/throughput.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ void bleuart_rx_callback(uint16_t conn_hdl)
157157
rxStartTime = millis();
158158
}
159159

160-
rxCount += bleuart.available();
160+
uint32_t count = bleuart.available();
161+
162+
rxCount += count;
161163
bleuart.flush(); // empty rx fifo
164+
165+
Serial.printf("RX %d bytes\n", count);
162166
}
163167

164168
void bleuart_notify_callback(uint16_t conn_hdl, bool enabled)
@@ -219,12 +223,11 @@ void loop(void)
219223
{
220224
getUserInput();
221225
test_throughput();
222-
223226
}
224227

225228
// 3 seconds has passed and there is no data received
226229
// then reset rx count
227-
if ( (rxCount > 0) && (rxLastTime + 3000 < millis()) )
230+
if ( (rxCount > 0) && (rxLastTime + 1000 < millis()) )
228231
{
229232
print_speed("Received ", rxCount, rxLastTime-rxStartTime);
230233
rxCount = 0;

libraries/Bluefruit52Lib/src/services/BLEUart.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ int BLEUart::read(uint8_t * buf, size_t size)
192192
return _rx_fifo->read(buf, size);
193193
}
194194

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+
195213
size_t BLEUart::write(uint8_t b)
196214
{
197215
return this->write(Bluefruit.connHandle(), &b, 1);

libraries/Bluefruit52Lib/src/services/BLEUart.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class BLEUart : public BLEService, public Stream
7070
bool flushTXD (void);
7171
bool flushTXD (uint16_t conn_hdl);
7272

73+
// Read helper
74+
uint8_t read8 (void);
75+
uint16_t read16(void);
76+
uint32_t read32(void);
77+
7378
// Stream API
7479
virtual int read ( void );
7580
virtual int read ( uint8_t * buf, size_t size );

0 commit comments

Comments
 (0)