# Copyright 2019 Dom Sekotill # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Interfaces control client class """ from itertools import count from typing import Iterable from . import consts from .base import BaseClient from .. import util class InterfaceClient(BaseClient): """ A client for per-interface management """ name = None async def connect(self, path: consts.Path): await super().connect(path) self.name = await self.send_command(consts.COMMAND_IFNAME, convert=str) async def scan(self) -> Iterable[dict]: """ Iteratively produces the details of all detectable IEEE 802.11 BSS (WiFi Access Points to you and me) """ async with self.attach(): await self.send_command(consts.COMMAND_SCAN) await self.event(consts.CTRL_EVENT_SCAN_RESULTS) for idx in count(): bss = await self.send_command( consts.COMMAND_BSS, str(idx), convert=util.kv2dict ) if not bss: return yield bss