Hi,
I am not an expert on the Energy module, but I think it only "measures" the energy depending on the states of the WiFi (sending, receiving etc).
You will need to implement an application or any other mechanism that will look at the Energy level of the node and decide to send or not. The example you posted does not do that. It only prints in the output the energy.
Regards,
K.