fix: supporting channels greater than 140 for 5g (closes #583)
This commit is contained in:
parent
9dcc647656
commit
a8c07ba997
@ -4,31 +4,37 @@ import pwnagotchi.mesh.wifi as wifi
|
|||||||
|
|
||||||
MAX_EPOCH_DURATION = 1024
|
MAX_EPOCH_DURATION = 1024
|
||||||
|
|
||||||
histogram_size = wifi.NumChannels
|
|
||||||
|
|
||||||
shape = (1,
|
def describe(extended=False):
|
||||||
# aps per channel
|
if not extended:
|
||||||
histogram_size +
|
histogram_size = wifi.NumChannels
|
||||||
# clients per channel
|
else:
|
||||||
histogram_size +
|
# see https://github.com/evilsocket/pwnagotchi/issues/583
|
||||||
# peers per channel
|
histogram_size = wifi.NumChannelsExt
|
||||||
histogram_size +
|
|
||||||
# duration
|
return histogram_size, (1,
|
||||||
1 +
|
# aps per channel
|
||||||
# inactive
|
histogram_size +
|
||||||
1 +
|
# clients per channel
|
||||||
# active
|
histogram_size +
|
||||||
1 +
|
# peers per channel
|
||||||
# missed
|
histogram_size +
|
||||||
1 +
|
# duration
|
||||||
# hops
|
1 +
|
||||||
1 +
|
# inactive
|
||||||
# deauths
|
1 +
|
||||||
1 +
|
# active
|
||||||
# assocs
|
1 +
|
||||||
1 +
|
# missed
|
||||||
# handshakes
|
1 +
|
||||||
1)
|
# hops
|
||||||
|
1 +
|
||||||
|
# deauths
|
||||||
|
1 +
|
||||||
|
# assocs
|
||||||
|
1 +
|
||||||
|
# handshakes
|
||||||
|
1)
|
||||||
|
|
||||||
|
|
||||||
def featurize(state, step):
|
def featurize(state, step):
|
||||||
|
@ -34,10 +34,14 @@ class Environment(gym.Env):
|
|||||||
self._epoch_num = 0
|
self._epoch_num = 0
|
||||||
self._last_render = None
|
self._last_render = None
|
||||||
|
|
||||||
channels = agent.supported_channels()
|
# see https://github.com/evilsocket/pwnagotchi/issues/583
|
||||||
|
self._supported_channels = agent.supported_channels()
|
||||||
|
self._extended_spectrum = any(ch > 140 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(featurizer.histogram_size) if ch + 1 in channels
|
range(self._histogram_size) if ch + 1 in self._supported_channels
|
||||||
]
|
]
|
||||||
|
|
||||||
self.last = {
|
self.last = {
|
||||||
@ -50,7 +54,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=featurizer.shape, dtype=np.float32)
|
self.observation_space = spaces.Box(low=0, high=1, shape=self._observation_shape, dtype=np.float32)
|
||||||
self.reward_range = reward.range
|
self.reward_range = reward.range
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -118,7 +122,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(featurizer.histogram_size):
|
for ch in range(self._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,4 +1,5 @@
|
|||||||
NumChannels = 140
|
NumChannels = 140
|
||||||
|
NumChannelsExt = 165 # see https://github.com/evilsocket/pwnagotchi/issues/583
|
||||||
|
|
||||||
|
|
||||||
def freq_to_channel(freq):
|
def freq_to_channel(freq):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user