Skip to content
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

Lorawan 1.0.3 5.5 End-DeviceStatus(DevStatusReq, DevStatusAns. Battery Percentage #271

Open
Cloolalang opened this issue Dec 8, 2020 · 2 comments

Comments

@Cloolalang
Copy link

Hi All, I really like this library, very well documented and easy to get going.
I was wondering if I could request a feature:

I would like to check battery and DL margin using DevStatusReq.

would it be difficult to expose this in this library as the Microchip can do it MAC SET BAT.

Cheers
P

@Cloolalang
Copy link
Author

Oh, Maybe not.

@Cloolalang Cloolalang reopened this Dec 8, 2020
@Cloolalang
Copy link
Author

Cloolalang commented Dec 8, 2020

OK I did a quick and nasty: in TheThingsNetwork.cpp file I added:

`void TheThingsNetwork::Setbattery()//patricks very crude DEvstatusReq Batter percentage function
{
readResponse(SYS_TABLE, SYS_TABLE, SYS_GET_VDD, buffer, sizeof(buffer));//fetch volts reading from VDD (I dont know where this comes from!)
int val = atoi(buffer);//convert to int
debugPrint(SENDING);
debugPrintLn();
debugPrint(val);//print to debug
debugPrintLn();
//Lorawan DevStatus sends battery level up to the netwotk as a percentage, 1-254 = 1-100% , 0 and 255 are reserved for mains power on or no battery infor available
if (val < 3200){
sendMacSet(MAC_BAT, "0");
}
else if (val > 3200 && val < 3300){
sendMacSet(MAC_BAT, "64");;
}
else if (val > 3300 && val < 3400){
sendMacSet(MAC_BAT, "128");;
}
else if (val > 3400 && val < 3500){
sendMacSet(MAC_BAT, "250");;
}
else if (val > 3500){
sendMacSet(MAC_BAT, "255");;
}

}`

@Cloolalang Cloolalang changed the title Lorawan 1.0.3 5.5 End-DeviceStatus(DevStatusReq, DevStatusAns. Please can we have this feature? Lorawan 1.0.3 5.5 End-DeviceStatus(DevStatusReq, DevStatusAns. Battery Percentage Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant