Updated the LoRa library by implementing a read(uint8_t *, size_t) function to read multiple bytes at once
This commit is contained in:
parent
cae484fb53
commit
d3cabc4e73
@ -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()) {
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user