How to check Battery power and send data for sensor nodes in OMNeT++/mixim -


i exchange data under mixim framework node host80211{ }, first needs check battery power of each node in example code:

if (node1.check_battery() >= node2.check_battery()) {     send(node1.out-->node2.in); } 

how , implement code check condition ?

thanks

as have explained in comments: can have central entity other nodes can query , make sending decision based on that. central entity can node in sensor network or class nodes can instantiate.

for example:

class batterymonitor: public csimplemodule {     public:         batterymonitor();          void report_battery(const std::string& nodeid, float batterylevel,)          double check_battery(const std::string& nodeid);       protected:         std::map<std::string, double> batterylevels; }; 

you can set self-message every 1 second sensor nodes, make sure report recent battery level .

in nodes can similar code:

    if (batterymonitor->check_battery(this->myid) >= batterymonitor->check_battery(othernodeid)) {         send(thismessage, othernode); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -