mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Update wifi channels
This commit is contained in:
@ -5,36 +5,31 @@ import pwnagotchi.mesh.wifi as wifi
|
|||||||
MAX_EPOCH_DURATION = 1024
|
MAX_EPOCH_DURATION = 1024
|
||||||
|
|
||||||
|
|
||||||
def describe(extended=False):
|
histogram_size = wifi.NumChannels
|
||||||
if not extended:
|
|
||||||
histogram_size = wifi.NumChannels
|
|
||||||
else:
|
|
||||||
# see https://github.com/evilsocket/pwnagotchi/issues/583
|
|
||||||
histogram_size = wifi.NumChannelsExt
|
|
||||||
|
|
||||||
return histogram_size, (1,
|
shape = (1,
|
||||||
# aps per channel
|
# aps per channel
|
||||||
histogram_size +
|
histogram_size +
|
||||||
# clients per channel
|
# clients per channel
|
||||||
histogram_size +
|
histogram_size +
|
||||||
# peers per channel
|
# peers per channel
|
||||||
histogram_size +
|
histogram_size +
|
||||||
# duration
|
# duration
|
||||||
1 +
|
1 +
|
||||||
# inactive
|
# inactive
|
||||||
1 +
|
1 +
|
||||||
# active
|
# active
|
||||||
1 +
|
1 +
|
||||||
# missed
|
# missed
|
||||||
1 +
|
1 +
|
||||||
# hops
|
# hops
|
||||||
1 +
|
1 +
|
||||||
# deauths
|
# deauths
|
||||||
1 +
|
1 +
|
||||||
# assocs
|
# assocs
|
||||||
1 +
|
1 +
|
||||||
# handshakes
|
# handshakes
|
||||||
1)
|
1)
|
||||||
|
|
||||||
|
|
||||||
def featurize(state, step):
|
def featurize(state, step):
|
||||||
|
@ -35,14 +35,11 @@ class Environment(gym.Env):
|
|||||||
self._epoch_num = 0
|
self._epoch_num = 0
|
||||||
self._last_render = None
|
self._last_render = None
|
||||||
|
|
||||||
# see https://github.com/evilsocket/pwnagotchi/issues/583
|
channels = agent.supported_channels()
|
||||||
self._supported_channels = agent.supported_channels()
|
|
||||||
self._extended_spectrum = any(ch > 150 for ch in self._supported_channels)
|
|
||||||
self._histogram_size, self._observation_shape = featurizer.describe(self._extended_spectrum)
|
|
||||||
|
|
||||||
Environment.params += [
|
Environment.params += [
|
||||||
Parameter('_channel_%d' % ch, min_value=0, max_value=1, meta=ch + 1) for ch in
|
Parameter('_channel_%d' % ch, min_value=0, max_value=1, meta=ch + 1) for ch in
|
||||||
range(self._histogram_size) if ch + 1 in self._supported_channels
|
range(featurizer.histogram_size) if ch + 1 in channels
|
||||||
]
|
]
|
||||||
|
|
||||||
self.last = {
|
self.last = {
|
||||||
@ -55,7 +52,7 @@ class Environment(gym.Env):
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.action_space = spaces.MultiDiscrete([p.space_size() for p in Environment.params if p.trainable])
|
self.action_space = spaces.MultiDiscrete([p.space_size() for p in Environment.params if p.trainable])
|
||||||
self.observation_space = spaces.Box(low=0, high=1, shape=self._observation_shape, dtype=np.float32)
|
self.observation_space = spaces.Box(low=0, high=1, shape=featurizer.shape, dtype=np.float32)
|
||||||
self.reward_range = reward.range
|
self.reward_range = reward.range
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -123,7 +120,7 @@ class Environment(gym.Env):
|
|||||||
return self.last['state_v']
|
return self.last['state_v']
|
||||||
|
|
||||||
def _render_histogram(self, hist):
|
def _render_histogram(self, hist):
|
||||||
for ch in range(self._histogram_size):
|
for ch in range(featurizer.histogram_size):
|
||||||
if hist[ch]:
|
if hist[ch]:
|
||||||
logging.info(" CH %d: %s" % (ch + 1, hist[ch]))
|
logging.info(" CH %d: %s" % (ch + 1, hist[ch]))
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
NumChannels = 140
|
NumChannels = 177
|
||||||
NumChannelsExt = 165 # see https://github.com/evilsocket/pwnagotchi/issues/583
|
|
||||||
|
|
||||||
|
|
||||||
def freq_to_channel(freq):
|
def freq_to_channel(freq):
|
||||||
|
@ -130,10 +130,10 @@ def merge_config(user, default):
|
|||||||
|
|
||||||
|
|
||||||
def keys_to_str(data):
|
def keys_to_str(data):
|
||||||
if isinstance(data,list):
|
if isinstance(data, list):
|
||||||
converted_list = list()
|
converted_list = list()
|
||||||
for item in data:
|
for item in data:
|
||||||
if isinstance(item,list) or isinstance(item,dict):
|
if isinstance(item, list) or isinstance(item, dict):
|
||||||
converted_list.append(keys_to_str(item))
|
converted_list.append(keys_to_str(item))
|
||||||
else:
|
else:
|
||||||
converted_list.append(item)
|
converted_list.append(item)
|
||||||
@ -277,7 +277,8 @@ def load_config(args):
|
|||||||
elif config['ui']['display']['type'] in ('ws_154inch', 'ws154inch', 'waveshare_154inch', 'waveshare154inch'):
|
elif config['ui']['display']['type'] in ('ws_154inch', 'ws154inch', 'waveshare_154inch', 'waveshare154inch'):
|
||||||
config['ui']['display']['type'] = 'waveshare154inch'
|
config['ui']['display']['type'] = 'waveshare154inch'
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('waveshare144lcd', 'ws_144inch', 'ws144inch', 'waveshare_144inch', 'waveshare144inch'):
|
elif config['ui']['display']['type'] in (
|
||||||
|
'waveshare144lcd', 'ws_144inch', 'ws144inch', 'waveshare_144inch', 'waveshare144inch'):
|
||||||
config['ui']['display']['type'] = 'waveshare144lcd'
|
config['ui']['display']['type'] = 'waveshare144lcd'
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('ws_213d', 'ws213d', 'waveshare_213d', 'waveshare213d'):
|
elif config['ui']['display']['type'] in ('ws_213d', 'ws213d', 'waveshare_213d', 'waveshare213d'):
|
||||||
@ -285,7 +286,7 @@ def load_config(args):
|
|||||||
|
|
||||||
elif config['ui']['display']['type'] in ('ws_213bc', 'ws213bc', 'waveshare_213bc', 'waveshare213bc'):
|
elif config['ui']['display']['type'] in ('ws_213bc', 'ws213bc', 'waveshare_213bc', 'waveshare213bc'):
|
||||||
config['ui']['display']['type'] = 'waveshare213bc'
|
config['ui']['display']['type'] = 'waveshare213bc'
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('ws_213bv4', 'ws213bv4', 'waveshare_213bv4', 'waveshare213inb_v4'):
|
elif config['ui']['display']['type'] in ('ws_213bv4', 'ws213bv4', 'waveshare_213bv4', 'waveshare213inb_v4'):
|
||||||
config['ui']['display']['type'] = 'waveshare213inb_v4'
|
config['ui']['display']['type'] = 'waveshare213inb_v4'
|
||||||
|
|
||||||
@ -318,7 +319,8 @@ def total_unique_handshakes(path):
|
|||||||
|
|
||||||
def iface_channels(ifname):
|
def iface_channels(ifname):
|
||||||
channels = []
|
channels = []
|
||||||
output = subprocess.getoutput("/sbin/iwlist %s freq" % ifname)
|
phy = subprocess.getoutput("/sbin/iw %s info | grep wiphy | cut -d ' ' -f 2" % ifname)
|
||||||
|
output = subprocess.getoutput("/sbin/iw phy%s channels | grep ' MHz' | sed 's/^.*\[//g' | sed s/\].*\$//g" % phy)
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line.startswith("Channel "):
|
if line.startswith("Channel "):
|
||||||
|
Reference in New Issue
Block a user