mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2025-02-08 17:55:44 +05:30
added AP support in naxalnet.py and iwd.py
This commit is contained in:
parent
af5fc0e285
commit
b2f30bad62
@ -188,7 +188,8 @@ class Device:
|
||||
def start_adhoc_open(self, name: str):
|
||||
"""
|
||||
Create ad-hoc network with name, changing mode to ad-hoc
|
||||
if it isn't already on ad-hoc
|
||||
if it isn't already on ad-hoc and power onn the device
|
||||
if it is off
|
||||
"""
|
||||
if self.get_mode() != "ad-hoc":
|
||||
self.set_mode("ad-hoc")
|
||||
@ -196,7 +197,7 @@ class Device:
|
||||
if not self.is_powered_on():
|
||||
self.power_on()
|
||||
|
||||
if self.is_adhoc_started():
|
||||
# Stop adhoc if already started
|
||||
self.stop_adhoc()
|
||||
|
||||
self._proxy.StartOpen(name)
|
||||
@ -207,6 +208,29 @@ class Device:
|
||||
self._proxy.Stop()
|
||||
self.reload()
|
||||
|
||||
def start_ap(self, ssid, passwd):
|
||||
"""
|
||||
Create ap network, changing mode to ap
|
||||
if it isn't already on ap and turning
|
||||
on the device if it is off
|
||||
"""
|
||||
if self.get_mode() != "ap":
|
||||
self.set_mode("ap")
|
||||
|
||||
if not self.is_powered_on():
|
||||
self.power_on()
|
||||
|
||||
# Stop ap if already started
|
||||
self.stop_ap()
|
||||
|
||||
self._proxy.Start(ssid, passwd)
|
||||
|
||||
def stop_ap(self):
|
||||
"""stop ap if an ap is started"""
|
||||
if self.is_ap_started():
|
||||
self._proxy.Stop()
|
||||
self.reload()
|
||||
|
||||
|
||||
class Adapter:
|
||||
"""represents an adapter as a python object"""
|
||||
@ -243,7 +267,7 @@ class Adapter:
|
||||
|
||||
def supports_mode(self, mode: str) -> bool:
|
||||
"""
|
||||
Returns True if the adapter supports the mode
|
||||
Returns True if the adapter supports the mode.
|
||||
mode can be "ad-hoc", "ap" or "station"
|
||||
"""
|
||||
return mode in self.supported_modes
|
||||
|
@ -82,10 +82,11 @@ try:
|
||||
# ie, we have more devices
|
||||
if len(ap_devices) != 0:
|
||||
print("Working on AP")
|
||||
ap_device = ap_devices.pop()
|
||||
ap_device = Device(ap_devices.pop())
|
||||
# _TODO: start ap after implementing in in iwd.py
|
||||
except DBusError as e:
|
||||
print(e)
|
||||
ap_device.start_ap(AP_SSID, AP_PASSWD)
|
||||
except DBusError as error:
|
||||
print(error)
|
||||
sys.exit("An error occured while communicating with iwd")
|
||||
|
||||
print("Bye")
|
||||
|
Loading…
x
Reference in New Issue
Block a user