The Internet of Things (IoT) paradigm combines the interconnection of massive amounts of battery-constrained and low-computational-power devices with low-latency and high-reliability network requirements. Additionally, diverse end-to-end services and applications with different Quality of Service (QoS) requirements are expected to coexist in the same network infrastructure. Software-defined Networking (SDN) is a paradigm designed to solve these problems, but its implementation in wireless networks and especially in the resource-constrained IoT systems is extremely challenging and has seen very limited adoption, since it requires isolation of data and control plane information flows and a reliable and scalable control plane. In this work, Bluetooth Low Energy (BLE) mesh is introduced as an adequate technology for an all-wireless SDN-BLE implementation, which is a technology that has become the de-facto standard for IoT. The proposed SDN-BLE framework uses a routing network slice for the data plane information flow and a flooding network slice for the control plane information flow, ensuring their isolation while still being transmitted over the wireless medium. The design and implementation of all the classical SDN layers on a hybrid BLE mesh testbed is given, where the data plane is formed by the BLE nodes and the control plane can be centralized on a server or distributed over several WiFi gateways. Several controllers are described and implemented, allowing the framework to obtain end-to-end network knowledge to manage individual nodes over the air and configure their behavior to meet application requirements. An experimental characterization of the SDN-BLE framework is given, where the impact of the different parameters of the system on the network reliability, overhead, and energy consumption is studied. Additionally, the distributed versus centralized control plane operation modes are experimentally characterized, and it is shown that the distributed approach can provide the same performance as the centralized one when careful system design is performed. Finally, a proof of concept for the SDN-BLE framework is presented, where a network congestion is automatically detected and the nodes responsible of such congestion are identified and reconfigured over the air, bypassing the congested links, to resume regular network performance.