Fahad Mirza
/
Nucleo_HXC900
A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.
Diff: LoRa/lora_driver.c
- Revision:
- 29:b48f6176c2cd
- Parent:
- 28:c777d977b252
- Child:
- 30:c58316bab0fb
--- a/LoRa/lora_driver.c Fri Nov 02 23:27:16 2018 +0000 +++ b/LoRa/lora_driver.c Fri Nov 02 23:39:52 2018 +0000 @@ -265,6 +265,26 @@ } /****************************************************************************** + * @Brief : Get battery level + * @Param : None + * @Retval : Battery level +******************************************************************************/ +static uint8_t Lora_getBatteryLevel(void) +{ + char batteryLevel_str[5]; + uint8_t batteryLevel = 0; + + eAtStatus_t status = Modem_AT_Cmd(AT_GET, AT_BAT, batteryLevel_str); + + if(status == AT_OK) + { + sscanf(batteryLevel_str, "%hhu", &batteryLevel); + } + + return batteryLevel; +} + +/****************************************************************************** * @Brief : Send uplink packet using binary payload * @Param : Pointer of sSendDataBinary_t variable * @Retval : AT_OK or other eAtStatus_t statuses @@ -444,6 +464,7 @@ SendDataBinary.DataSize = 0; // Add Firmware version SendDataBinary.Buffer[SendDataBinary.DataSize++] = FwVersion; + SendDataBinary.Buffer[SendDataBinary.DataSize++] = Lora_getBatteryLevel(); // Read sensor data and populate payload SendDataBinary.DataSize = SendDataBinary.DataSize + LoraDriverParam->SendDataHandler(\ &SendDataBinary.Buffer[SendDataBinary.DataSize],\