Updated the LoRa library by implementing a read(uint8_t *, size_t) function to read multiple bytes at once

This commit is contained in:
anschrammh 2025-11-05 23:55:05 +01:00
parent 8b6b906602
commit ebc1444ca4
2 changed files with 17 additions and 0 deletions

View File

@ -347,6 +347,22 @@ int LoRaClass::read()
return readRegister(REG_FIFO); return readRegister(REG_FIFO);
} }
int LoRaClass::read(uint8_t *buffer, size_t len)
{
if(!buffer) return 0;
size_t nbread = 0;
while(nbread < len && available())
{
int c = read();
if(c == -1) break;
buffer[nbread++] = c;
}
return nbread;
}
int LoRaClass::peek() int LoRaClass::peek()
{ {
if (!available()) { if (!available()) {

View File

@ -54,6 +54,7 @@ public:
// from Stream // from Stream
virtual int available(); virtual int available();
virtual int read(); virtual int read();
virtual int read(uint8_t *buffer, size_t len);
virtual int peek(); virtual int peek();
virtual void flush(); virtual void flush();