Cross-layer optimization for industrial control applications using wireless sensor and actuator mesh networks