Battery-related parameters are defined in the BatteryModel source code project of the NetSim source code library. 
ptrBattery is a pointer variable to the structure stru_battery that is defined in the BatteryModel.c file. To be able to use the battery variables and APIs in other source code projects such as AODV, the BatteryModel project header file will have to be included.

API: battery_get_remaining_energy(ptrBATTERY battery);
battery is a structure variable of prtBATTERY.

API Usage:
For example,
battery_get_remaining_energy(phy->battery);

API: battery_get_consumed_energy(ptrBATTERY battery, int mode);
battery is a structure variable of prtBATTERY. 
Mode is an integer variable that refers to either transmission, reception, idle, or sleep for which the energy consumption is to be retrieved. The mode can take values as shown in the following table:

Mode ValueMode TypeDescription
0RX_OFFOverall energy consumption
1RX_ON_IDLE
Idle energy consumed
2
RX_ON_BUSY
Receiving energy
3TRX_ON_BUSY
Transmission energy
4
SLEEP
 Sleep energy
For Eg: 
battery_get_consumed_energy(phy->battery,0);

In the following example, the remaining energy and consumed energy of MANET nodes are obtained from AODV source codes and printed to the simulation console at different points of simulation time:

1. Include the header files of the IEEE802.11 and Battery Model project in the AODV C file where you want to get the battery parameters. For Eg: Add the following lines to the beginning of the AODV. c file as shown below:

#include "main.h"
#include "AODV.h"
#include "List.h"

#include "../BatteryModel/BatteryModel.h"
#include "../IEEE802_11/IEEE802_11_Phy.h"




2. Use the following lines to get the battery parameters using the battery model APIs. For example, we obtain the remaining and consumed energy of MANET nodes and print them to the simulation console in the fn_NetSim_AODV_Run() function which is part of the AODV.c file as shown below:

_declspec(dllexport) int fn_NetSim_AODV_Run()
{
    set_aodv_curr();
    NETSIM_ID in = aodv_get_curr_if();
    if (!isAodvConfigured(pstruEventDetails->nDeviceId, in))
        return -1;

    PIEEE802_11_PHY_VAR phy = (PIEEE802_11_PHY_VAR)DEVICE_PHYVAR(pstruEventDetails->nDeviceId, in);
    double r_energy = battery_get_remaining_energy(phy->battery);
    double c_energy = battery_get_consumed_energy(phy->battery, 0);


    fprintf(stderr, "\nSimulation Time: %f Device ID: %d\nRemaining Energy: %f mJ\
        \nConsumed Energy: % f mJ\n",pstruEventDetails->dEventTime,
        pstruEventDetails->nDeviceId, r_energy, c_energy);


3. Right-click on the AODV project in the solution explorer and click on re-build.
4. The binaries of the AODV library will automatically get updated in the bin folder of the current workspace.
5. Open MANET module in NetSim and create a scenario with MANET nodes, and set the routing protocol to AODV.



Now upon running any MANET simulation which involves, AODV protocol, the remaining energy and consumed energy of the nodes will be printed to the simulation console periodically as shown below: