Skip to content

Lorawan add snr and GW count in receive packet #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/LoRaWan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,22 @@ bool LoRaWanClass::transferPacketWithConfirmed(unsigned char *buffer, unsigned c
return false;
}

short LoRaWanClass::receivePacket(char *buffer, short length, short *rssi)
short LoRaWanClass::receivePacket(char *buffer, int length, short *rssi, float *snr, short *gwcnt)
{
char *ptr;
short number = 0;

ptr = strstr(_buffer, "RSSI ");
if(ptr)*rssi = atoi(ptr + 5);
else *rssi = -255;

ptr = strstr(_buffer, "SNR ");
if(ptr)*snr = atof(ptr + 4);
else *snr = -20.00;

ptr = strstr(_buffer, "Link");
if(ptr)*gwcnt = atoi(ptr + 9);
else *gwcnt = 0;

ptr = strstr(_buffer, "RX: \"");
if(ptr)
Expand Down Expand Up @@ -1042,4 +1050,4 @@ short LoRaWanClass::sendCommandAndWaitForResponse(char* command, char *response,
}


LoRaWanClass lora;
LoRaWanClass lora;
6 changes: 4 additions & 2 deletions src/LoRaWan.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,12 @@ class LoRaWanClass
* \param [in] *buffer The receive data cache
* \param [in] length The length of data cache
* \param [in] *rssi The RSSI cache
* \param [in] *snr The SNR cache
* \param [in] *gwcnt The Gateway count cache
*
* \return Return Receive data number
*/
short receivePacket(char *buffer, short length, short *rssi);
short receivePacket(char *buffer, int length, short *rssi, float *snr, short *gwcnt);

/**
* \brief Transfer the proprietary data
Expand Down Expand Up @@ -498,4 +500,4 @@ class LoRaWanClass
extern LoRaWanClass lora;


#endif
#endif