A dynamic programming algorithm for high-level task scheduling in energy harvesting IoT