update throughput for testing
This commit is contained in:
1 parent
c493154ae3
commit
4bcaf05208
3 files changed
+29
-3
No files matched your search
@@ -157,8 +157,12 @@ void bleuart_rx_callback(uint16_t conn_hdl)
|
||||
rxStartTime = millis();
|
||||
}
|
||||
|
||||
rxCount += bleuart.available();
|
||||
uint32_t count = bleuart.available();
|
||||
|
||||
rxCount += count;
|
||||
bleuart.flush(); // empty rx fifo
|
||||
|
||||
Serial.printf("RX %d bytes\n", count);
|
||||
}
|
||||
|
||||
void bleuart_notify_callback(uint16_t conn_hdl, bool enabled)
|
||||
@@ -219,12 +223,11 @@ void loop(void)
|
||||
{
|
||||
getUserInput();
|
||||
test_throughput();
|
||||
|
||||
}
|
||||
|
||||
// 3 seconds has passed and there is no data received
|
||||
// then reset rx count
|
||||
if ( (rxCount > 0) && (rxLastTime + 3000 < millis()) )
|
||||
if ( (rxCount > 0) && (rxLastTime + 1000 < millis()) )
|
||||
{
|
||||
print_speed("Received ", rxCount, rxLastTime-rxStartTime);
|
||||
rxCount = 0;
|
||||
|
||||
@@ -192,6 +192,24 @@ int BLEUart::read(uint8_t * buf, size_t size)
|
||||
return _rx_fifo->read(buf, size);
|
||||
}
|
||||
|
||||
uint8_t BLEUart::read8 (void)
|
||||
{
|
||||
uint8_t num;
|
||||
return read(&num, sizeof(num)) ? num : 0;
|
||||
}
|
||||
|
||||
uint16_t BLEUart::read16(void)
|
||||
{
|
||||
uint16_t num;
|
||||
return read((uint8_t*) &num, sizeof(num)) ? num : 0;
|
||||
}
|
||||
|
||||
uint32_t BLEUart::read32(void)
|
||||
{
|
||||
uint32_t num;
|
||||
return read((uint8_t*) &num, sizeof(num)) ? num : 0;
|
||||
}
|
||||
|
||||
size_t BLEUart::write(uint8_t b)
|
||||
{
|
||||
return this->write(Bluefruit.connHandle(), &b, 1);
|
||||
|
||||
@@ -70,6 +70,11 @@ class BLEUart : public BLEService, public Stream
|
||||
bool flushTXD (void);
|
||||
bool flushTXD (uint16_t conn_hdl);
|
||||
|
||||
// Read helper
|
||||
uint8_t read8 (void);
|
||||
uint16_t read16(void);
|
||||
uint32_t read32(void);
|
||||
|
||||
// Stream API
|
||||
virtual int read ( void );
|
||||
virtual int read ( uint8_t * buf, size_t size );
|
||||
|
||||
Reference in new issue
Block a user