rockymeza/wifi

Setting the 'cell' without Cell.all(interface)[x]

Closed this issue · 3 comments

dunca commented

This is not a bug, but I didn't know where to ask.

Is it possible to set the 'cell' without actually searching for the available APNs?

cell = Cell(ssid=APN) obviously doesn't work, so I'm looking for a solution.

Doing Cell.all(interface)[x] is fine, as long as the index of the access point doesn't change, but if does, scheme.activate() will fail.

Thanks

dunca commented

I think the following might be what I'm looking for.
"
classmethod from_string(cell_string)
Parses the output of iwlist scan for one cell and returns a Cell object for it.
"
However, when I try Cell.from_string('Cell(ssid=MyCoolApn)') I get: 'Cell' object has no attribute 'encrypted' - line 153 in scan.py. The apn is definitely encrypted though.

Hi @boobcoder,

Sorry for not responding earlier. I've been too busy lately.

You could use the where method on the Cell class for finding the specific interface that you want. Here's an example usage:

cell = Cell.where('wlan0', lambda c: c.ssid == 'MySSID')[0]
scheme = Scheme.for_cell('wlan0', 'nickname', cell)
scheme.save()
scheme.activate()

This might be what you want.

However, after the first time that you save it, you could just retrieve the saved scheme.

scheme = Scheme.find('wlan0', 'home')
scheme.activate()

I apologize if the docs weren't very obvious about this. So really, that's probably what you want.

As for from_string, it actually takes the output of the iwlist command, which you can see examples of here.

I'm going to close this for now, but feel free to reopen.