A Formal Approach for Scalable Applications in Dynamic and Constrained IoT Systems