@@ -408,35 +408,41 @@ def scan_networks(self):
408
408
return APs
409
409
return None
410
410
411
- def set_ip_config (self , new_ip , new_gw , new_mask = "255.255.255.0" ):
412
- """Tells the ESP32 to set ip, gateway and network mask b"\xFF " """
411
+ def set_ip_config (self , ip_address , gateway , mask = "255.255.255.0" ):
412
+ """Tells the ESP32 to set ip, gateway and network mask b"\xFF "
413
+
414
+ :param str ip_address: IP address (as a string).
415
+ :param str gateway: Gateway (as a string).
416
+ :param str mask: Mask, defaults to 255.255.255.0 (as a string).
417
+ """
413
418
resp = self ._send_command_get_response (
414
419
_SET_IP_CONFIG ,
415
420
params = [
416
421
b"\x00 " ,
417
- self .unpretty_ip (new_ip ),
418
- self .unpretty_ip (new_gw ),
419
- self .unpretty_ip (new_mask ),
422
+ self .unpretty_ip (ip_address ),
423
+ self .unpretty_ip (gateway ),
424
+ self .unpretty_ip (mask ),
420
425
],
421
426
sent_param_len_16 = False ,
422
427
)
423
428
return resp
424
429
425
- def set_dns_config (self , dns1 , dns2 = "8.8.8.8" ):
426
- """Tells the ESP32 to set DNS, with dns2 default to google dns=8.8.8.8"""
430
+ def set_dns_config (self , dns1 , dns2 ):
431
+ """Tells the ESP32 to set DNS
432
+
433
+ :param str dns1: DNS server 1 IP as a string.
434
+ :param str dns2: DNS server 2 IP as a string.
435
+ """
427
436
resp = self ._send_command_get_response (
428
437
_SET_DNS_CONFIG , [b"\x00 " , self .unpretty_ip (dns1 ), self .unpretty_ip (dns2 )]
429
438
)
430
439
if resp [0 ][0 ] != 1 :
431
440
raise RuntimeError ("Failed to set dns with esp32" )
432
441
433
442
def set_hostname (self , hostname ):
434
- """
435
- Tells the ESP32 to set hostname
443
+ """Tells the ESP32 to set hostname for DHCP.
436
444
437
- :params str hostname: Set the host name, used by DHCP to associate a local
438
- domain name like hostname.home for example, depending
439
- on the DHCP server setup.
445
+ :param str hostname: The new host name.
440
446
"""
441
447
resp = self ._send_command_get_response (_SET_HOSTNAME , [hostname .encode ()])
442
448
if resp [0 ][0 ] != 1 :
@@ -555,8 +561,7 @@ def connect(self, secrets):
555
561
self .connect_AP (secrets ["ssid" ], secrets ["password" ])
556
562
557
563
def connect_AP (self , ssid , password , timeout_s = 10 ): # pylint: disable=invalid-name
558
- """
559
- Connect to an access point with given name and password.
564
+ """Connect to an access point with given name and password.
560
565
Will wait until specified timeout seconds and return on success
561
566
or raise an exception on failure.
562
567
@@ -589,8 +594,7 @@ def connect_AP(self, ssid, password, timeout_s=10): # pylint: disable=invalid-n
589
594
def create_AP (
590
595
self , ssid , password , channel = 1 , timeout = 10
591
596
): # pylint: disable=invalid-name
592
- """
593
- Create an access point with the given name, password, and channel.
597
+ """Create an access point with the given name, password, and channel.
594
598
Will wait until specified timeout seconds and return on success
595
599
or raise an exception on failure.
596
600
@@ -851,8 +855,7 @@ def set_esp_debug(self, enabled):
851
855
raise RuntimeError ("Failed to set debug mode" )
852
856
853
857
def set_pin_mode (self , pin , mode ):
854
- """
855
- Set the io mode for a GPIO pin.
858
+ """Set the io mode for a GPIO pin.
856
859
857
860
:param int pin: ESP32 GPIO pin to set.
858
861
:param value: direction for pin, digitalio.Direction or integer (0=input, 1=output).
@@ -868,8 +871,7 @@ def set_pin_mode(self, pin, mode):
868
871
raise RuntimeError ("Failed to set pin mode" )
869
872
870
873
def set_digital_write (self , pin , value ):
871
- """
872
- Set the digital output value of pin.
874
+ """Set the digital output value of pin.
873
875
874
876
:param int pin: ESP32 GPIO pin to write to.
875
877
:param bool value: Value for the pin.
@@ -881,8 +883,7 @@ def set_digital_write(self, pin, value):
881
883
raise RuntimeError ("Failed to write to pin" )
882
884
883
885
def set_analog_write (self , pin , analog_value ):
884
- """
885
- Set the analog output value of pin, using PWM.
886
+ """Set the analog output value of pin, using PWM.
886
887
887
888
:param int pin: ESP32 GPIO pin to write to.
888
889
:param float value: 0=off 1.0=full on
@@ -895,8 +896,7 @@ def set_analog_write(self, pin, analog_value):
895
896
raise RuntimeError ("Failed to write to pin" )
896
897
897
898
def set_digital_read (self , pin ):
898
- """
899
- Get the digital input value of pin. Returns the boolean value of the pin.
899
+ """Get the digital input value of pin. Returns the boolean value of the pin.
900
900
901
901
:param int pin: ESP32 GPIO pin to read from.
902
902
"""
@@ -914,8 +914,7 @@ def set_digital_read(self, pin):
914
914
)
915
915
916
916
def set_analog_read (self , pin , atten = ADC_ATTEN_DB_11 ):
917
- """
918
- Get the analog input value of pin. Returns an int between 0 and 65536.
917
+ """Get the analog input value of pin. Returns an int between 0 and 65536.
919
918
920
919
:param int pin: ESP32 GPIO pin to read from.
921
920
:param int atten: attenuation constant
@@ -951,6 +950,7 @@ def get_time(self):
951
950
def set_certificate (self , client_certificate ):
952
951
"""Sets client certificate. Must be called
953
952
BEFORE a network connection is established.
953
+
954
954
:param str client_certificate: User-provided .PEM certificate up to 1300 bytes.
955
955
"""
956
956
if self ._debug :
@@ -973,6 +973,7 @@ def set_certificate(self, client_certificate):
973
973
def set_private_key (self , private_key ):
974
974
"""Sets private key. Must be called
975
975
BEFORE a network connection is established.
976
+
976
977
:param str private_key: User-provided .PEM file up to 1700 bytes.
977
978
"""
978
979
if self ._debug :
0 commit comments