A recently proposed class of materials, called software-defined metamaterials, can change their electromagnetic behavior on demand, utilizing a nanonetwork embedded in their structure. The present work focuses on 2D metamaterials, known as metasurfaces, and their electromagnetically programmable counterparts, the Hyper-Surfaces. The particular focus of the study is to propose a nanonetworking protocol that can support the intended macroscopic functionality of a HyperSurface, such as sensing and reacting to impinging waves in a customizable manner. The novel protocol is derived analytically, using the Lyapunov drift minimization approach, taking into account nano-node energy, communication latency and complexity concerns. The proposed scheme is evaluated via simulations, covering both the macroscopic Hyper-Surface functionality and the microscopic, nanonetwork behavior.