src/eric7/MicroPython/Devices/RP2040Devices.py

branch
mpy_network
changeset 9782
67414f28db68
parent 9781
3112f77f722b
child 9787
163511257f24
equal deleted inserted replaced
9781:3112f77f722b 9782:67414f28db68
659 """ 659 """
660 elif self._deviceData["wifi_type"] == "pimoroni": 660 elif self._deviceData["wifi_type"] == "pimoroni":
661 # TODO: not yet implemented 661 # TODO: not yet implemented
662 pass 662 pass
663 else: 663 else:
664 return super().checkInternet() 664 return super().scanNetworks()
665 665
666 out, err = self._interface.execute(command, timeout=15000) 666 out, err = self._interface.execute(command, timeout=15000)
667 if err: 667 if err:
668 return [], err 668 return [], err
669 669
680 except KeyError: 680 except KeyError:
681 security = self.tr("unknown ({0})").format(network[4]) 681 security = self.tr("unknown ({0})").format(network[4])
682 networks.append((ssid, mac, channel, rssi, security)) 682 networks.append((ssid, mac, channel, rssi, security))
683 683
684 return networks, "" 684 return networks, ""
685
686 def deactivateInterface(self, interface):
687 """
688 Public method to deactivate a given WiFi interface of the connected device.
689
690 @param interface designation of the interface to be deactivated (one of 'AP'
691 or 'STA')
692 @type str
693 @return tuple containg a flag indicating success and an error message
694 @rtype tuple of (bool, str)
695 @exception ValueError raised to indicate a wrong value for the interface type
696 """
697 if interface not in ("STA", "AP"):
698 raise ValueError(
699 "interface must be 'AP' or 'STA', got '{0}'".format(interface)
700 )
701
702 if self._deviceData["wifi_type"] == "picow":
703 command = """
704 def deactivate():
705 import network
706 from time import sleep
707
708 wifi = network.WLAN(network.{0}_IF)
709 wifi.active(False)
710 sleep(0.1)
711 print(not wifi.active())
712
713 deactivate()
714 del deactivate
715 """.format(interface)
716 elif self._deviceData["wifi_type"] == "pimoroni":
717 # TODO: not yet implemented
718 pass
719 else:
720 return super().deactivateInterface(interface)
721
722 out, err = self._interface.execute(command, timeout=15000)
723 if err:
724 return False, err
725 else:
726 return out.decode("utf-8").strip() == "True", ""
727
728 def startAccessPoint(self):
729 """
730 Public method to start the access point interface.
731
732 @return tuple containing a flag indicating success and an error message
733 @rtype tuple of (bool, str)
734 """
735
736 def stopAccessPoint(self):
737 """
738 Public method to stop the access point interface.
739
740 @return tuple containg a flag indicating success and an error message
741 @rtype tuple of (bool, str)
742 """
743 if self._deviceData["wifi_type"] == "picow":
744 return self.deactivateInterface("AP")
745 elif self._deviceData["wifi_type"] == "pimoroni":
746 # TODO: not yet implemented
747 pass
748 else:
749 return super().stopAccessPoint()
685 750
686 ############################################################################ 751 ############################################################################
687 ## RP2 only methods below 752 ## RP2 only methods below
688 ############################################################################ 753 ############################################################################
689 754

eric ide

mercurial