How BLE knows about the peripheral disconnection when there is no data send and receive from application?
The RF link between central and peripheral is always "checked" by the devices at lower levels of the bluetooth stack because there is always a minimal data exchange (at a predefined timings) between devices also when there is no data exchange at application level (the code you directly write);
These "predefined timings" are defined by the GAP connection parameters, in which you specify: