@@ -33,17 +33,39 @@ def __init__(self):
3333 self .FUNCTION_SUFFIX = "endfunction"
3434 self .display_arrows = False
3535
36- def start_network (self , robot_id :int ):
36+ def start_network (self , ssid : str = None , robot_id :int = None , password : str = None ):
3737 """
38- Open an access point from the XRP board to be used as a captive host. The network password is "remote.xrp"
38+ Open an access point from the XRP board to be used as a captive host. The default network information can be set in secrets.json
39+
40+ :param ssid: The ssid of the access point, defaults to value from secrets.json
41+ :type ssid: str, optional
42+ :param robot_id: Replaces "{robot_id}" in ssid, defaults to value from secrets.json
43+ :type robot_id: int, optional
44+ :param password: The password of the access point, defaults to value from secrets.json
45+ :type password: str, optional
3946 """
40- self .access_point = access_point (f"XRP_{ robot_id } " , "remote.xrp" )
47+ if ssid is None :
48+ with open ("../secrets.json" ) as secrets_file :
49+ secrets = json .load (secrets_file )
50+ ssid = secrets ["ap_ssid" ]
51+ password = secrets ["ap_password" ]
52+ if robot_id is None :
53+ robot_id = secrets ["robot_id" ]
54+ ssid .replace ("{robot_id}" , robot_id )
55+ self .access_point = access_point (ssid , password )
4156 self .ip = network .WLAN (network .AP_IF ).ifconfig ()[0 ]
4257
4358 def connect_to_network (self , ssid :str = None , password :str = None , timeout = 10 ):
4459 """
4560 Connect to a wifi network with the given ssid and password.
4661 If the connection fails, the board will disconnect from the network and return.
62+
63+ :param ssid: The ssid of the network, defaults to value from secrets.json
64+ :type ssid: str, optional
65+ :param password: The password of the network, defaults to value from secrets.json
66+ :type password: str, optional
67+ :param timeout: The amount of time to wait for the connection to succeed, defaults to 10
68+ :type timeout: int, optional
4769 """
4870 self .wlan = network .WLAN (network .STA_IF )
4971 self .wlan .active (True ) # configure board to connect to wifi
0 commit comments