Building the Intelligent IoT-Edge: Balancing Security and Functionality using Deep Reinforcement Learning