Ends an ongoing BLE scan started by :meth:`begin_scan`.

        Returns:
            a :class:`ScanResults` object containing the scan results.

def end_scan(self):
        """Ends an ongoing BLE scan started by :meth:`begin_scan`.

        Returns:
            a :class:`ScanResults` object containing the scan results.
        """
        # TODO check states before/after
        self._set_state(self._STATE_GAP_END)
        self.api.ble_cmd_gap_end_procedure()
        self._wait_for_state(self._STATE_GAP_END)

        logger.debug('scanning completed')
        return self.scan_responses