Heterogeneity-aware and energy-aware scheduling and routing in wireless sensor networks